diff --git a/.travis.yml b/.travis.yml index 3d43440b..a5a0309f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,6 +71,7 @@ script: - make all - ./tests - ./api-tests + - ./gui_tests after_success: - cd $TRAVIS_BUILD_DIR diff --git a/CMakeLists.txt b/CMakeLists.txt index d3457f63..732e6230 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,8 +163,6 @@ set(CEF_PRECOMPILED_BINARIES_DIR "${SOURCE_DIR}/Release") ############################## set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/app/loot_settings.cpp" - "${CMAKE_SOURCE_DIR}/src/backend/app/loot_state.cpp" "${CMAKE_BINARY_DIR}/generated/loot_version.cpp" "${CMAKE_SOURCE_DIR}/src/backend/error_categories.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.cpp" @@ -191,8 +189,6 @@ set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/version.cpp") set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.h" - "${CMAKE_SOURCE_DIR}/src/backend/app/loot_settings.h" - "${CMAKE_SOURCE_DIR}/src/backend/app/loot_state.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_grammar.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.h" @@ -236,6 +232,8 @@ set (LOOT_GUI_SRC "${CMAKE_SOURCE_DIR}/src/gui/main.cpp" "${CMAKE_SOURCE_DIR}/src/gui/loot_app.cpp" "${CMAKE_SOURCE_DIR}/src/gui/loot_scheme_handler_factory.cpp" "${CMAKE_SOURCE_DIR}/src/gui/query_handler.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp" "${CMAKE_SOURCE_DIR}/src/resource.rc") set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/editor_message.h" @@ -274,6 +272,8 @@ set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/editor_message.h" "${CMAKE_SOURCE_DIR}/src/gui/query/sort_plugins_query.h" "${CMAKE_SOURCE_DIR}/src/gui/query/update_masterlist_query.h" "${CMAKE_SOURCE_DIR}/src/gui/query_handler.h" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h" "${CMAKE_SOURCE_DIR}/src/gui/resource.h" "${CMAKE_SOURCE_DIR}/src/gui/yaml_simple_message_helpers.h") @@ -302,12 +302,7 @@ set (LOOT_API_HEADERS "${CMAKE_SOURCE_DIR}/include/loot/api.h" set (LOOT_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/tests/backend/main.cpp") -set (LOOT_TESTS_HEADERS # Testing this here rather than as part of the API tests - # because it tests internal code and requires internal - # linking. - "${CMAKE_SOURCE_DIR}/src/tests/backend/app/loot_paths_test.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/app/loot_settings_test.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/app/loot_state_test.h" +set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/backend/app/loot_paths_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_cache_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_settings_test.h" @@ -342,17 +337,28 @@ set(LOOT_API_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/api/api_game_operatio "${CMAKE_SOURCE_DIR}/src/tests/api/is_compatible_test.h" "${CMAKE_SOURCE_DIR}/src/tests/common_game_test_fixture.h") +set(LOOT_GUI_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp" + "${CMAKE_SOURCE_DIR}/src/tests/gui/main.cpp") + +set (LOOT_GUI_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h" + "${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_settings_test.h" + "${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_state_test.h") + source_group("Header Files\\backend" FILES ${LOOT_HEADERS}) source_group("Header Files\\gui" FILES ${LOOT_GUI_HEADERS}) source_group("Header Files\\api" FILES ${LOOT_API_HEADERS}) source_group("Header Files\\tests" FILES ${LOOT_TESTS_HEADERS}) source_group("Header Files\\tests" FILES ${LOOT_API_TESTS_HEADERS}) +source_group("Header Files\\tests" FILES ${LOOT_GUI_TESTS_HEADERS}) source_group("Source Files\\backend" FILES ${LOOT_SRC}) source_group("Source Files\\gui" FILES ${LOOT_GUI_SRC}) source_group("Source Files\\api" FILES ${LOOT_API_SRC}) source_group("Source Files\\tests" FILES ${LOOT_TESTS_SRC}) source_group("Source Files\\tests" FILES ${LOOT_API_TESTS_SRC}) +source_group("Header Files\\tests" FILES ${LOOT_GUI_TESTS_SRC}) # Include source and library directories. include_directories ("${CMAKE_SOURCE_DIR}/src" @@ -446,6 +452,10 @@ add_executable (LOOT ${LOOT_GUI_SRC} ${LOOT_GUI_HEADERS}) add_dependencies (LOOT cef loot_common) target_link_libraries(LOOT ${CEF_LIBRARIES} loot_common ${LOOT_GUI_LIBS}) +# Build application tests. +add_executable (gui_tests ${LOOT_GUI_TESTS_SRC} ${LOOT_GUI_TESTS_HEADERS}) +add_dependencies (gui_tests loot_common GTest testing-metadata testing-plugins) +target_link_libraries(gui_tests loot_common ${GTEST_LIBRARIES}) ############################## # Set Target-Specific Flags @@ -465,6 +475,7 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Windows") set_target_properties (loot_common PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} LOOT_STATIC") set_target_properties (tests PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} LOOT_STATIC") set_target_properties (LOOT PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} LOOT_STATIC") + set_target_properties (gui_tests PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} LOOT_STATIC") IF (BUILD_SHARED_LIBS) set_target_properties (loot_api PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} LOOT_EXPORT") ELSE () diff --git a/appveyor.yml b/appveyor.yml index 725dffca..f715907e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,6 +66,10 @@ test_script: - cd %APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION% - tests.exe --gtest_output=xml:tests.xml - api-tests.exe --gtest_output=xml:api-tests.xml + - ps: | + if ($env:PLATFORM -eq 'Win32') { + ./gui_tests.exe --gtest_output=xml:gui_tests.xml + } after_test: - cd %APPVEYOR_BUILD_FOLDER% @@ -162,3 +166,7 @@ on_success: on_finish: - ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\tests.xml") - ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\api-tests.xml") + - ps: | + if ($env:PLATFORM -eq 'Win32') { + (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\gui_tests.xml") + } diff --git a/scripts/git/pre-commit b/scripts/git/pre-commit index d8ac8ed2..7d85521a 100755 --- a/scripts/git/pre-commit +++ b/scripts/git/pre-commit @@ -5,7 +5,7 @@ # commit if more than one line in it has changed, otherwise discard any changes # to it. -xgettext --keyword="translate:1,1t" --keyword="translate:1,2,3t" --keyword="translateFormatted:1" --add-location=full --from-code=utf-8 --package-name=LOOT --package-version=0.10.3 --copyright-holder="WrinklyNinja" --msgid-bugs-address="https://github.com/loot/loot/issues" -o resources/l10n/template.pot src/gui/html/js/*.* src/gui/*.cpp src/gui/query/*.h src/backend/*/*.* src/backend/*.* +xgettext --keyword="translate:1,1t" --keyword="translate:1,2,3t" --keyword="translateFormatted:1" --add-location=full --from-code=utf-8 --package-name=LOOT --package-version=0.10.3 --copyright-holder="WrinklyNinja" --msgid-bugs-address="https://github.com/loot/loot/issues" -o resources/l10n/template.pot src/gui/html/js/*.* src/gui/*.cpp src/gui/query/*.h src/gui/*/*.cpp src/backend/*/*.* src/backend/*.* sed -i 's|charset=CHARSET|charset=UTF-8|' resources/l10n/template.pot diff --git a/src/gui/loot_app.h b/src/gui/loot_app.h index 056068a6..5c66c15f 100644 --- a/src/gui/loot_app.h +++ b/src/gui/loot_app.h @@ -29,7 +29,7 @@ #include #include -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" namespace loot { class LootApp : public CefApp, diff --git a/src/gui/loot_handler.h b/src/gui/loot_handler.h index 5ee750fc..397d9697 100644 --- a/src/gui/loot_handler.h +++ b/src/gui/loot_handler.h @@ -30,7 +30,7 @@ #include #include -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" namespace loot { class LootHandler : public CefClient, diff --git a/src/gui/query/cancel_sort_query.h b/src/gui/query/cancel_sort_query.h index ce5926f2..01443cd7 100644 --- a/src/gui/query/cancel_sort_query.h +++ b/src/gui/query/cancel_sort_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_CANCEL_SORT_QUERY #define LOOT_GUI_QUERY_CANCEL_SORT_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/json.h" #include "gui/query/metadata_query.h" diff --git a/src/gui/query/close_settings_query.h b/src/gui/query/close_settings_query.h index f6738d79..876cff7c 100644 --- a/src/gui/query/close_settings_query.h +++ b/src/gui/query/close_settings_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_CLOSE_SETTINGS_QUERY #define LOOT_GUI_QUERY_CLOSE_SETTINGS_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/get_installed_games_query.h" namespace loot { diff --git a/src/gui/query/discard_unapplied_changes_query.h b/src/gui/query/discard_unapplied_changes_query.h index 94ae7106..dc21e846 100644 --- a/src/gui/query/discard_unapplied_changes_query.h +++ b/src/gui/query/discard_unapplied_changes_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_DISCARD_UNAPPLIED_CHANGES_QUERY #define LOOT_GUI_QUERY_DISCARD_UNAPPLIED_CHANGES_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/query.h" namespace loot { diff --git a/src/gui/query/editor_closed_query.h b/src/gui/query/editor_closed_query.h index 4f22cdb6..582ca348 100644 --- a/src/gui/query/editor_closed_query.h +++ b/src/gui/query/editor_closed_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_EDITOR_CLOSED_QUERY #define LOOT_GUI_QUERY_EDITOR_CLOSED_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/metadata_query.h" namespace loot { diff --git a/src/gui/query/editor_opened_query.h b/src/gui/query/editor_opened_query.h index d2fd4037..bb7ee1c7 100644 --- a/src/gui/query/editor_opened_query.h +++ b/src/gui/query/editor_opened_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_EDITOR_OPENED_QUERY #define LOOT_GUI_QUERY_EDITOR_OPENED_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/query.h" namespace loot { diff --git a/src/gui/query/get_init_errors_query.h b/src/gui/query/get_init_errors_query.h index 1ea0b48c..74d9fe01 100644 --- a/src/gui/query/get_init_errors_query.h +++ b/src/gui/query/get_init_errors_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_GET_INIT_ERRORS_QUERY #define LOOT_GUI_QUERY_GET_INIT_ERRORS_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/json.h" #include "gui/query/query.h" diff --git a/src/gui/query/get_installed_games_query.h b/src/gui/query/get_installed_games_query.h index 7d8b18d3..4123cbfb 100644 --- a/src/gui/query/get_installed_games_query.h +++ b/src/gui/query/get_installed_games_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_GET_INSTALLED_GAMES_QUERY #define LOOT_GUI_QUERY_GET_INSTALLED_GAMES_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/json.h" #include "gui/query/query.h" diff --git a/src/gui/query/get_settings_query.h b/src/gui/query/get_settings_query.h index ceab2db5..3bfe60b7 100644 --- a/src/gui/query/get_settings_query.h +++ b/src/gui/query/get_settings_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_GET_SETTINGS_QUERY #define LOOT_GUI_QUERY_GET_SETTINGS_QUERY -#include "backend/app/loot_settings.h" +#include "gui/state/loot_settings.h" #include "gui/query/json.h" #include "gui/query/query.h" diff --git a/src/gui/query/redate_plugins_query.h b/src/gui/query/redate_plugins_query.h index 5afe886f..731356e6 100644 --- a/src/gui/query/redate_plugins_query.h +++ b/src/gui/query/redate_plugins_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_REDATE_PLUGINS_QUERY #define LOOT_GUI_QUERY_REDATE_PLUGINS_QUERY -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/query.h" namespace loot { diff --git a/src/gui/query/save_filter_state_query.h b/src/gui/query/save_filter_state_query.h index fb2f8b20..6cd344c4 100644 --- a/src/gui/query/save_filter_state_query.h +++ b/src/gui/query/save_filter_state_query.h @@ -27,7 +27,7 @@ along with LOOT. If not, see #include -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/query.h" namespace loot { diff --git a/src/gui/query/sort_plugins_query.h b/src/gui/query/sort_plugins_query.h index 9e569404..828e03be 100644 --- a/src/gui/query/sort_plugins_query.h +++ b/src/gui/query/sort_plugins_query.h @@ -27,7 +27,7 @@ along with LOOT. If not, see #include -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "gui/query/json.h" #include "backend/plugin/plugin_sorter.h" #include "loot/exception/cyclic_interaction_error.h" diff --git a/src/gui/query_handler.h b/src/gui/query_handler.h index 7d17b2ea..215122ec 100644 --- a/src/gui/query_handler.h +++ b/src/gui/query_handler.h @@ -28,7 +28,7 @@ #include #include -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include "backend/plugin/plugin.h" #include "backend/metadata/plugin_metadata.h" #include "gui/editor_message.h" diff --git a/src/backend/app/loot_settings.cpp b/src/gui/state/loot_settings.cpp similarity index 99% rename from src/backend/app/loot_settings.cpp rename to src/gui/state/loot_settings.cpp index ad69dd71..76051a2d 100644 --- a/src/backend/app/loot_settings.cpp +++ b/src/gui/state/loot_settings.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/app/loot_settings.h" +#include "gui/state/loot_settings.h" #include diff --git a/src/backend/app/loot_settings.h b/src/gui/state/loot_settings.h similarity index 100% rename from src/backend/app/loot_settings.h rename to src/gui/state/loot_settings.h diff --git a/src/backend/app/loot_state.cpp b/src/gui/state/loot_state.cpp similarity index 99% rename from src/backend/app/loot_state.cpp rename to src/gui/state/loot_state.cpp index 9537d283..ceb27320 100644 --- a/src/backend/app/loot_state.cpp +++ b/src/gui/state/loot_state.cpp @@ -22,7 +22,7 @@ . */ -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include #include diff --git a/src/backend/app/loot_state.h b/src/gui/state/loot_state.h similarity index 98% rename from src/backend/app/loot_state.h rename to src/gui/state/loot_state.h index d8bbe3ba..e5504a87 100644 --- a/src/backend/app/loot_state.h +++ b/src/gui/state/loot_state.h @@ -25,7 +25,7 @@ #ifndef LOOT_BACKEND_APP_LOOT_STATE #define LOOT_BACKEND_APP_LOOT_STATE -#include "backend/app/loot_settings.h" +#include "gui/state/loot_settings.h" #include "backend/game/game.h" namespace loot { diff --git a/src/tests/backend/main.cpp b/src/tests/backend/main.cpp index 9c3bc35f..24f00445 100644 --- a/src/tests/backend/main.cpp +++ b/src/tests/backend/main.cpp @@ -25,8 +25,6 @@ #include #include "tests/backend/app/loot_paths_test.h" -#include "tests/backend/app/loot_settings_test.h" -#include "tests/backend/app/loot_state_test.h" #include "tests/backend/game/game_test.h" #include "tests/backend/game/game_cache_test.h" #include "tests/backend/game/game_settings_test.h" diff --git a/src/tests/gui/main.cpp b/src/tests/gui/main.cpp new file mode 100644 index 00000000..fd3221a2 --- /dev/null +++ b/src/tests/gui/main.cpp @@ -0,0 +1,40 @@ +/* LOOT + + A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and + Fallout: New Vegas. + + Copyright (C) 2014-2016 WrinklyNinja + + This file is part of LOOT. + + LOOT is free software: you can redistribute + it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + LOOT is distributed in the hope that it will + be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LOOT. If not, see + . + */ + +#include + +#include "tests/gui/state/loot_settings_test.h" +#include "tests/gui/state/loot_state_test.h" + +int main(int argc, char **argv) { + //Set the locale to get encoding conversions working correctly. + std::locale::global(boost::locale::generator().generate("")); + boost::filesystem::path::imbue(std::locale()); + + //Disable logging or else stdout will get overrun. + boost::log::core::get()->set_logging_enabled(false); + + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/tests/backend/app/loot_settings_test.h b/src/tests/gui/state/loot_settings_test.h similarity index 99% rename from src/tests/backend/app/loot_settings_test.h rename to src/tests/gui/state/loot_settings_test.h index 42fce1c2..4588baf3 100644 --- a/src/tests/backend/app/loot_settings_test.h +++ b/src/tests/gui/state/loot_settings_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_LOOT_SETTINGS_TEST #define LOOT_TESTS_BACKEND_LOOT_SETTINGS_TEST -#include "backend/app/loot_settings.h" +#include "gui/state/loot_settings.h" #include diff --git a/src/tests/backend/app/loot_state_test.h b/src/tests/gui/state/loot_state_test.h similarity index 98% rename from src/tests/backend/app/loot_state_test.h rename to src/tests/gui/state/loot_state_test.h index 87f53c6e..f216d19f 100644 --- a/src/tests/backend/app/loot_state_test.h +++ b/src/tests/gui/state/loot_state_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_LOOT_STATE_TEST #define LOOT_TESTS_BACKEND_LOOT_STATE_TEST -#include "backend/app/loot_state.h" +#include "gui/state/loot_state.h" #include