diff --git a/indexer/indexer_tests_support/CMakeLists.txt b/indexer/indexer_tests_support/CMakeLists.txt index 753ccca7f6..099d504c9a 100644 --- a/indexer/indexer_tests_support/CMakeLists.txt +++ b/indexer/indexer_tests_support/CMakeLists.txt @@ -4,6 +4,10 @@ set( SRC helpers.cpp helpers.hpp + test_with_classificator.cpp + test_with_classificator.hpp + test_with_custom_mwms.cpp + test_with_custom_mwms.hpp ) add_library(${PROJECT_NAME} ${SRC}) diff --git a/indexer/indexer_tests_support/indexer_tests_support.pro b/indexer/indexer_tests_support/indexer_tests_support.pro index 9f7d6ee79e..08b2d52d08 100644 --- a/indexer/indexer_tests_support/indexer_tests_support.pro +++ b/indexer/indexer_tests_support/indexer_tests_support.pro @@ -8,6 +8,10 @@ include($$ROOT_DIR/common.pri) SOURCES += \ helpers.cpp \ + test_with_classificator.cpp \ + test_with_custom_mwms.cpp \ HEADERS += \ helpers.hpp \ + test_with_classificator.hpp \ + test_with_custom_mwms.hpp \ diff --git a/search/search_tests_support/test_with_classificator.cpp b/indexer/indexer_tests_support/test_with_classificator.cpp similarity index 73% rename from search/search_tests_support/test_with_classificator.cpp rename to indexer/indexer_tests_support/test_with_classificator.cpp index 819a198e6b..eede0bb51b 100644 --- a/search/search_tests_support/test_with_classificator.cpp +++ b/indexer/indexer_tests_support/test_with_classificator.cpp @@ -1,10 +1,10 @@ -#include "search/search_tests_support/test_with_classificator.hpp" +#include "indexer/indexer_tests_support/test_with_classificator.hpp" #include "indexer/classificator_loader.hpp" #include "indexer/map_style.hpp" #include "indexer/map_style_reader.hpp" -namespace search +namespace indexer { namespace tests_support { @@ -14,4 +14,4 @@ TestWithClassificator::TestWithClassificator() classificator::Load(); } } // namespace tests_support -} // namespace search +} // namespace indexer diff --git a/search/search_tests_support/test_with_classificator.hpp b/indexer/indexer_tests_support/test_with_classificator.hpp similarity index 81% rename from search/search_tests_support/test_with_classificator.hpp rename to indexer/indexer_tests_support/test_with_classificator.hpp index eaf3f12ee7..7d6805f75d 100644 --- a/search/search_tests_support/test_with_classificator.hpp +++ b/indexer/indexer_tests_support/test_with_classificator.hpp @@ -1,6 +1,6 @@ #pragma once -namespace search +namespace indexer { namespace tests_support { @@ -11,4 +11,4 @@ public: virtual ~TestWithClassificator() = default; }; } // namespace tests_support -} // namespace search +} // namespace indexer diff --git a/search/search_tests_support/test_with_custom_mwms.cpp b/indexer/indexer_tests_support/test_with_custom_mwms.cpp similarity index 59% rename from search/search_tests_support/test_with_custom_mwms.cpp rename to indexer/indexer_tests_support/test_with_custom_mwms.cpp index 32bf5f6f15..488ab5b5e0 100644 --- a/search/search_tests_support/test_with_custom_mwms.cpp +++ b/indexer/indexer_tests_support/test_with_custom_mwms.cpp @@ -1,20 +1,13 @@ -#include "search/search_tests_support/test_with_custom_mwms.hpp" - -#include "search/editor_delegate.hpp" +#include "indexer/indexer_tests_support/test_with_custom_mwms.hpp" #include "platform/local_country_file_utils.hpp" #include "base/stl_add.hpp" -namespace search +namespace indexer { namespace tests_support { -TestWithCustomMwms::TestWithCustomMwms() -{ - indexer::tests_support::SetUpEditorForTesting(my::make_unique(m_index)); -} - TestWithCustomMwms::~TestWithCustomMwms() { for (auto const & file : m_files) @@ -28,4 +21,4 @@ void TestWithCustomMwms::Cleanup(platform::LocalCountryFile const & file) file.DeleteFromDisk(MapOptions::Map); } } // namespace tests_support -} // namespace search +} // namespace indexer diff --git a/indexer/indexer_tests_support/test_with_custom_mwms.hpp b/indexer/indexer_tests_support/test_with_custom_mwms.hpp new file mode 100644 index 0000000000..2babdb12ad --- /dev/null +++ b/indexer/indexer_tests_support/test_with_custom_mwms.hpp @@ -0,0 +1,92 @@ +#pragma once + +#include "indexer/indexer_tests_support/test_with_classificator.hpp" +#include "indexer/indexer_tests_support/helpers.hpp" + +#include "generator/generator_tests_support/test_mwm_builder.hpp" + +#include "indexer/data_header.hpp" +#include "indexer/feature.hpp" +#include "indexer/index.hpp" +#include "indexer/mwm_set.hpp" + +#include "platform/country_file.hpp" +#include "platform/local_country_file.hpp" +#include "platform/platform.hpp" + +#include "base/assert.hpp" + +#include +#include +#include + +namespace indexer +{ +namespace tests_support +{ +class TestWithCustomMwms : public TestWithClassificator +{ +public: + ~TestWithCustomMwms() override; + + // Creates a physical country file on a disk, which will be removed + // at the end of the test. |fn| is a delegate that accepts a single + // argument - TestMwmBuilder and adds all necessary features to the + // country file. + // + // *NOTE* when |type| is feature::DataHeader::country, the country + // with |name| will be automatically registered. + template + MwmSet::MwmId BuildMwm(std::string const & name, feature::DataHeader::MapType type, BuildFn && fn) + { + m_files.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), 0 /* version */); + auto & file = m_files.back(); + Cleanup(file); + + { + generator::tests_support::TestMwmBuilder builder(file, type); + fn(builder); + } + + auto result = m_index.RegisterMap(file); + CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); + + auto const id = result.first; + auto const info = id.GetInfo(); + CHECK(info.get(), ()); + OnMwmBuilt(*info); + return id; + } + + template + MwmSet::MwmId BuildWorld(BuildFn && fn) + { + return BuildMwm("testWorld", feature::DataHeader::world, std::forward(fn)); + } + + template + MwmSet::MwmId BuildCountry(std::string const & name, BuildFn && fn) + { + return BuildMwm(name, feature::DataHeader::country, std::forward(fn)); + } + + template + void EditFeature(FeatureID const & id, EditorFn && fn) + { + Index::FeaturesLoaderGuard loader(m_index, id.m_mwmId); + FeatureType ft; + CHECK(loader.GetFeatureByIndex(id.m_index, ft), ()); + indexer::tests_support::EditFeature(ft, forward(fn)); + } + +protected: + static void Cleanup(platform::LocalCountryFile const & file); + + virtual void OnMwmBuilt(MwmInfo const & /* info */) {} + + Index m_index; + std::vector m_files; +}; +} // namespace tests_support +} // namespace indexer + diff --git a/partners_api/partners_api.pro b/partners_api/partners_api.pro index 092bb05506..8f083b8515 100644 --- a/partners_api/partners_api.pro +++ b/partners_api/partners_api.pro @@ -33,7 +33,7 @@ HEADERS += \ ads_engine.hpp \ banner.hpp \ booking_api.hpp \ - booking_availability_params.hpp + booking_availability_params.hpp \ cian_api.hpp \ facebook_ads.hpp \ google_ads.hpp \ diff --git a/search/search_integration_tests/CMakeLists.txt b/search/search_integration_tests/CMakeLists.txt index af4feff138..4e089a4277 100644 --- a/search/search_integration_tests/CMakeLists.txt +++ b/search/search_integration_tests/CMakeLists.txt @@ -19,9 +19,9 @@ omim_add_test(${PROJECT_NAME} ${SRC}) omim_link_libraries( ${PROJECT_NAME} - generator_tests_support search_tests_support indexer_tests_support + generator_tests_support generator routing routing_common diff --git a/search/search_integration_tests/generate_tests.cpp b/search/search_integration_tests/generate_tests.cpp index f73906b024..e42aaef26d 100644 --- a/search/search_integration_tests/generate_tests.cpp +++ b/search/search_integration_tests/generate_tests.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "search/search_tests_support/test_with_classificator.hpp" +#include "indexer/indexer_tests_support/test_with_classificator.hpp" #include "generator/generator_tests_support/test_mwm_builder.hpp" @@ -21,13 +21,11 @@ #include using namespace generator::tests_support; -using namespace search::tests_support; -using namespace search; using namespace std; namespace { -class GenerateTest : public TestWithClassificator +class GenerateTest : public indexer::tests_support::TestWithClassificator { public: void MakeFeature(TestMwmBuilder & builder, pair const & tag, diff --git a/search/search_integration_tests/helpers.hpp b/search/search_integration_tests/helpers.hpp index 47d930067b..b2456918cd 100644 --- a/search/search_integration_tests/helpers.hpp +++ b/search/search_integration_tests/helpers.hpp @@ -5,10 +5,10 @@ #include "search/search_tests_support/test_search_request.hpp" #include "search/search_tests_support/test_with_custom_mwms.hpp" -#include "generator/generator_tests_support/test_feature.hpp" - #include "indexer/indexer_tests_support/helpers.hpp" +#include "generator/generator_tests_support/test_feature.hpp" + #include "geometry/rect2d.hpp" #include diff --git a/search/search_integration_tests/ranker_test.cpp b/search/search_integration_tests/ranker_test.cpp index b554c815aa..48a7a7a73f 100644 --- a/search/search_integration_tests/ranker_test.cpp +++ b/search/search_integration_tests/ranker_test.cpp @@ -4,6 +4,7 @@ #include "search/search_tests_support/test_results_matching.hpp" #include "generator/generator_tests_support/test_feature.hpp" +#include "generator/generator_tests_support/test_mwm_builder.hpp" using namespace generator::tests_support; using namespace search::tests_support; diff --git a/search/search_integration_tests/search_edited_features_test.cpp b/search/search_integration_tests/search_edited_features_test.cpp index 003ecb2c08..6b7722a995 100644 --- a/search/search_integration_tests/search_edited_features_test.cpp +++ b/search/search_integration_tests/search_edited_features_test.cpp @@ -1,10 +1,11 @@ #include "testing/testing.hpp" -#include "generator/generator_tests_support/test_feature.hpp" - #include "search/search_integration_tests/helpers.hpp" + #include "search/search_tests_support/test_results_matching.hpp" +#include "generator/generator_tests_support/test_feature.hpp" + #include "indexer/editable_map_object.hpp" #include "geometry/point2d.hpp" diff --git a/search/search_integration_tests/search_integration_tests.pro b/search/search_integration_tests/search_integration_tests.pro index 426a91c1f2..25ddf43000 100644 --- a/search/search_integration_tests/search_integration_tests.pro +++ b/search/search_integration_tests/search_integration_tests.pro @@ -7,7 +7,7 @@ TEMPLATE = app ROOT_DIR = ../.. -DEPENDENCIES = generator_tests_support search_tests_support indexer_tests_support generator \ +DEPENDENCIES = search_tests_support indexer_tests_support generator_tests_support generator \ routing routing_common search storage stats_client indexer platform editor mwm_diff \ bsdiff geometry coding base tess2 protobuf jansson succinct pugixml opening_hours icu diff --git a/search/search_tests/CMakeLists.txt b/search/search_tests/CMakeLists.txt index 3d0ad38ba9..efd8f6fa93 100644 --- a/search/search_tests/CMakeLists.txt +++ b/search/search_tests/CMakeLists.txt @@ -28,6 +28,8 @@ omim_add_test(${PROJECT_NAME} ${SRC}) omim_link_libraries( ${PROJECT_NAME} search_tests_support + indexer_tests_support + generator_tests_support search indexer editor diff --git a/search/search_tests/locality_finder_test.cpp b/search/search_tests/locality_finder_test.cpp index fb3052d17b..12bdbdf178 100644 --- a/search/search_tests/locality_finder_test.cpp +++ b/search/search_tests/locality_finder_test.cpp @@ -1,6 +1,6 @@ #include "testing/testing.hpp" -#include "search/search_tests_support/test_with_classificator.hpp" +#include "indexer/indexer_tests_support/test_with_classificator.hpp" #include "indexer/data_header.hpp" #include "indexer/index.hpp" @@ -18,7 +18,7 @@ namespace { -class LocalityFinderTest : public search::tests_support::TestWithClassificator +class LocalityFinderTest : public indexer::tests_support::TestWithClassificator { platform::LocalCountryFile m_worldFile; diff --git a/search/search_tests/search_tests.pro b/search/search_tests/search_tests.pro index be2c938c63..9e9745a08b 100644 --- a/search/search_tests/search_tests.pro +++ b/search/search_tests/search_tests.pro @@ -6,7 +6,8 @@ CONFIG -= app_bundle TEMPLATE = app ROOT_DIR = ../.. -DEPENDENCIES = search_tests_support search indexer platform editor geometry coding icu base protobuf jansson succinct pugixml stats_client +DEPENDENCIES = search_tests_support indexer_tests_support generator_tests_support \ + search indexer platform editor geometry coding icu base protobuf jansson succinct pugixml stats_client include($$ROOT_DIR/common.pri) diff --git a/search/search_tests_support/CMakeLists.txt b/search/search_tests_support/CMakeLists.txt index c78ef9d224..7cf983b7d9 100644 --- a/search/search_tests_support/CMakeLists.txt +++ b/search/search_tests_support/CMakeLists.txt @@ -8,9 +8,6 @@ set( test_search_engine.hpp test_search_request.cpp test_search_request.hpp - test_with_classificator.cpp - test_with_classificator.hpp - test_with_custom_mwms.cpp test_with_custom_mwms.hpp ) diff --git a/search/search_tests_support/search_tests_support.pro b/search/search_tests_support/search_tests_support.pro index 444aa57ab0..95d75ee92c 100644 --- a/search/search_tests_support/search_tests_support.pro +++ b/search/search_tests_support/search_tests_support.pro @@ -10,12 +10,9 @@ SOURCES += \ test_results_matching.cpp \ test_search_engine.cpp \ test_search_request.cpp \ - test_with_classificator.cpp \ - test_with_custom_mwms.cpp \ HEADERS += \ test_results_matching.hpp \ test_search_engine.hpp \ test_search_request.hpp \ - test_with_classificator.hpp \ test_with_custom_mwms.hpp \ diff --git a/search/search_tests_support/test_with_custom_mwms.hpp b/search/search_tests_support/test_with_custom_mwms.hpp index fe5f967e95..b80e5516f1 100644 --- a/search/search_tests_support/test_with_custom_mwms.hpp +++ b/search/search_tests_support/test_with_custom_mwms.hpp @@ -1,93 +1,22 @@ -#pragma once +#include "indexer/indexer_tests_support/test_with_custom_mwms.hpp" -#include "search/search_tests_support/test_with_classificator.hpp" +#include "search/editor_delegate.hpp" -#include "generator/generator_tests_support/test_mwm_builder.hpp" - -#include "indexer/indexer_tests_support/helpers.hpp" - -#include "indexer/data_header.hpp" -#include "indexer/feature.hpp" -#include "indexer/index.hpp" -#include "indexer/mwm_set.hpp" - -#include "platform/country_file.hpp" -#include "platform/local_country_file.hpp" -#include "platform/platform.hpp" - -#include "base/assert.hpp" - -#include -#include -#include +#include "base/stl_add.hpp" namespace search { namespace tests_support { -class TestWithCustomMwms : public TestWithClassificator +class TestWithCustomMwms : public indexer::tests_support::TestWithCustomMwms { public: - TestWithCustomMwms(); - ~TestWithCustomMwms() override; - - // Creates a physical country file on a disk, which will be removed - // at the end of the test. |fn| is a delegate that accepts a single - // argument - TestMwmBuilder and adds all necessary features to the - // country file. - // - // *NOTE* when |type| is feature::DataHeader::country, the country - // with |name| will be automatically registered. - template - MwmSet::MwmId BuildMwm(std::string const & name, feature::DataHeader::MapType type, BuildFn && fn) + TestWithCustomMwms() { - m_files.emplace_back(GetPlatform().WritableDir(), platform::CountryFile(name), 0 /* version */); - auto & file = m_files.back(); - Cleanup(file); - - { - generator::tests_support::TestMwmBuilder builder(file, type); - fn(builder); - } - - auto result = m_index.RegisterMap(file); - CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); - - auto const id = result.first; - auto const info = id.GetInfo(); - CHECK(info.get(), ()); - OnMwmBuilt(*info); - return id; + indexer::tests_support::SetUpEditorForTesting(my::make_unique(m_index)); } - template - MwmSet::MwmId BuildWorld(BuildFn && fn) - { - return BuildMwm("testWorld", feature::DataHeader::world, std::forward(fn)); - } - - template - MwmSet::MwmId BuildCountry(std::string const & name, BuildFn && fn) - { - return BuildMwm(name, feature::DataHeader::country, std::forward(fn)); - } - - template - void EditFeature(FeatureID const & id, EditorFn && fn) - { - Index::FeaturesLoaderGuard loader(m_index, id.m_mwmId); - FeatureType ft; - CHECK(loader.GetFeatureByIndex(id.m_index, ft), ()); - indexer::tests_support::EditFeature(ft, forward(fn)); - } - -protected: - static void Cleanup(platform::LocalCountryFile const & file); - - virtual void OnMwmBuilt(MwmInfo const & /* info */) {} - - Index m_index; - std::vector m_files; + ~TestWithCustomMwms() override = default; }; } // namespace tests_support } // namespace search