diff --git a/generator/generator_tests_support/test_feature.cpp b/generator/generator_tests_support/test_feature.cpp index 54c89fa575..c8e3ada85d 100644 --- a/generator/generator_tests_support/test_feature.cpp +++ b/generator/generator_tests_support/test_feature.cpp @@ -167,7 +167,7 @@ void TestPOI::Serialize(FeatureBuilder1 & fb) const auto const & classificator = classif(); for (auto const & path : m_types) - fb.SetType(classificator.GetTypeByPath(path)); + fb.AddType(classificator.GetTypeByPath(path)); if (!m_houseNumber.empty()) fb.AddHouseNumber(m_houseNumber); diff --git a/generator/generator_tests_support/test_mwm_builder.cpp b/generator/generator_tests_support/test_mwm_builder.cpp index 19ce627f6a..e54af7225b 100644 --- a/generator/generator_tests_support/test_mwm_builder.cpp +++ b/generator/generator_tests_support/test_mwm_builder.cpp @@ -48,12 +48,20 @@ bool TestMwmBuilder::Add(FeatureBuilder1 & fb) { CHECK(m_collector, ("It's not possible to add features after call to Finish().")); - if (fb.PreSerialize() && fb.RemoveInvalidTypes()) + if (!fb.PreSerialize()) { - (*m_collector)(fb); - return true; + LOG(LWARNING, ("Can't pre-serialize feature.")); + return false; } - return false; + + if (!fb.RemoveInvalidTypes()) + { + LOG(LWARNING, ("No types.")); + return false; + } + + (*m_collector)(fb); + return true; } void TestMwmBuilder::Finish() diff --git a/search/search_integration_tests/helpers.cpp b/search/search_integration_tests/helpers.cpp index d12126777f..24f321d9af 100644 --- a/search/search_integration_tests/helpers.cpp +++ b/search/search_integration_tests/helpers.cpp @@ -3,12 +3,23 @@ #include "search/processor_factory.hpp" #include "search/search_tests_support/test_search_request.hpp" +#include "indexer/classificator_loader.hpp" +#include "indexer/map_style.hpp" +#include "indexer/map_style_reader.hpp" #include "indexer/scales.hpp" #include "platform/platform.hpp" namespace search { +// TestWithClassificator --------------------------------------------------------------------------- +TestWithClassificator::TestWithClassificator() +{ + GetStyleReader().SetCurrentStyle(MapStyleMerged); + classificator::Load(); +} + +// SearchTest -------------------------------------------------------------------------------------- SearchTest::SearchTest() : m_platform(GetPlatform()) , m_scopedLog(LDEBUG) diff --git a/search/search_integration_tests/helpers.hpp b/search/search_integration_tests/helpers.hpp index c2d128d3e1..7c2ab7c51b 100644 --- a/search/search_integration_tests/helpers.hpp +++ b/search/search_integration_tests/helpers.hpp @@ -8,7 +8,6 @@ #include "storage/country_decl.hpp" #include "storage/country_info_getter.hpp" -#include "indexer/classificator_loader.hpp" #include "indexer/mwm_set.hpp" #include "geometry/rect2d.hpp" @@ -29,7 +28,7 @@ namespace search class TestWithClassificator { public: - TestWithClassificator() { classificator::Load(); } + TestWithClassificator(); }; class SearchTest : public TestWithClassificator diff --git a/search/search_integration_tests/search_query_v2_test.cpp b/search/search_integration_tests/search_query_v2_test.cpp index de0d37d159..679d3e81a4 100644 --- a/search/search_integration_tests/search_query_v2_test.cpp +++ b/search/search_integration_tests/search_query_v2_test.cpp @@ -477,15 +477,23 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestCategories) TestPOI busStop(m2::PointD(0.00005, 0.0005), "ATM Bus Stop", "en"); busStop.SetTypes({{"highway", "bus_stop"}}); + TestPOI cafe(m2::PointD(0.0001, 0.0001), "Cafe", "en"); + cafe.SetTypes({{"amenity", "cafe"}, {"internet_access", "wlan"}}); + + TestPOI toi(m2::PointD(0.0001, 0.0001), "", "en"); + toi.SetTypes({{"amenity", "toilets"}}); + BuildWorld([&](TestMwmBuilder & builder) { builder.Add(sanFrancisco); }); auto wonderlandId = BuildCountry(countryName, [&](TestMwmBuilder & builder) { + builder.Add(busStop); + builder.Add(cafe); builder.Add(named); builder.Add(noname); - builder.Add(busStop); + builder.Add(toi); }); SetViewport(m2::RectD(m2::PointD(-0.5, -0.5), m2::PointD(0.5, 0.5))); @@ -535,6 +543,9 @@ UNIT_CLASS_TEST(ProcessorV2Test, TestCategories) // Tests that inexistent hashtagged categories do not crash. TEST(ResultsMatch("#void-", TRules{}), ()); + + TEST(ResultsMatch("wifi", {ExactMatch(wonderlandId, cafe)}), ()); + TEST(ResultsMatch("toilet", {ExactMatch(wonderlandId, toi)}), ()); } } // namespace } // namespace search