Browse Source

Replace C++ RUN_TEST define with gbQuietMode

pull/1979/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
76103eeb7f
  1. 1
      CMakeLists.txt
  2. 14
      Source/DiabloUI/dialogs.cpp
  3. 1
      Source/diablo.cpp
  4. 4
      Source/diablo.h
  5. 3
      test/main.cpp

1
CMakeLists.txt

@ -542,7 +542,6 @@ if(RUN_TESTS)
include(GoogleTest)
find_package(GTest REQUIRED)
target_include_directories(devilutionx-tests PRIVATE ${GTEST_INCLUDE_DIRS})
add_definitions(-DRUN_TESTS)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(devilutionx-tests PRIVATE -fprofile-arcs -ftest-coverage)
endif()

14
Source/DiabloUI/dialogs.cpp

@ -266,15 +266,13 @@ void UiOkDialog(const char *text, const char *caption, bool error, const std::ve
if (SDL_ShowCursor(SDL_ENABLE) <= -1) {
Log("{}", SDL_GetError());
}
#ifndef RUN_TESTS
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) {
Log("{}", SDL_GetError());
#else
{
#endif
Log("{}", text);
Log("{}", caption);
if (!gbQuietMode) {
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) {
Log("{}", SDL_GetError());
}
}
Log("{}", text);
Log("{}", caption);
return;
}

1
Source/diablo.cpp

@ -109,6 +109,7 @@ bool forceDiablo;
bool gbNestArt;
bool gbBard;
bool gbBarbarian;
bool gbQuietMode = false;
int sgnTimeoutCurs;
clicktype sgbMouseDown;
int color_cycle_timer;

4
Source/diablo.h

@ -44,6 +44,10 @@ extern int PauseMode;
extern bool gbNestArt;
extern bool gbBard;
extern bool gbBarbarian;
/**
* @brief Don't show Messageboxes or other user-interaction. Needed for UnitTests.
*/
extern bool gbQuietMode;
extern clicktype sgbMouseDown;
extern uint16_t gnTickDelay;
extern char gszProductName[64];

3
test/main.cpp

@ -1,7 +1,10 @@
#include <gtest/gtest.h>
#include "diablo.h"
int main(int argc, char **argv)
{
devilution::gbQuietMode = true;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

Loading…
Cancel
Save