diff --git a/search/search_integration_tests/helpers.hpp b/search/search_integration_tests/helpers.hpp index 0d3a9dcb37..2ab3e1f413 100644 --- a/search/search_integration_tests/helpers.hpp +++ b/search/search_integration_tests/helpers.hpp @@ -37,8 +37,17 @@ public: SearchTest(); ~SearchTest(); + // Registers country in internal records. Note that physical country + // file may be absent. void RegisterCountry(string const & name, m2::RectD const & rect); + // 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(string const & name, feature::DataHeader::MapType type, TBuildFn && fn) { @@ -50,9 +59,17 @@ public: tests_support::TestMwmBuilder builder(file, type); fn(builder); } + auto result = m_engine.RegisterMap(file); - ASSERT_EQUAL(result.second, MwmSet::RegResult::Success, ()); - return result.first; + CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ()); + + auto const & id = result.first; + if (type == feature::DataHeader::country) + { + if (auto info = id.GetInfo()) + RegisterCountry(name, info->m_limitRect); + } + return id; } inline void SetViewport(m2::RectD const & viewport) { m_viewport = viewport; } diff --git a/search/search_integration_tests/search_query_v2_test.cpp b/search/search_integration_tests/search_query_v2_test.cpp index 0b35f25dca..1fbd71c49c 100644 --- a/search/search_integration_tests/search_query_v2_test.cpp +++ b/search/search_integration_tests/search_query_v2_test.cpp @@ -103,10 +103,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, Smoke) builder.Add(lantern2); }); - RegisterCountry(countryName, m2::RectD(m2::PointD(-1.0, -1.0), m2::PointD(10.1, 10.1))); - SetViewport(m2::RectD(m2::PointD(-1.0, -1.0), m2::PointD(1.0, 1.0))); - { TRules rules = {ExactMatch(wonderlandId, busStop)}; TEST(ResultsMatch("Bus stop", rules), ()); @@ -182,7 +179,6 @@ UNIT_CLASS_TEST(SearchQueryV2Test, SearchInWorld) builder.Add(wonderland); builder.Add(losAlamos); }); - RegisterCountry(countryName, m2::RectD(m2::PointD(-1.0, -1.0), m2::PointD(1.0, 1.0))); SetViewport(m2::RectD(m2::PointD(-1.0, -1.0), m2::PointD(-0.5, -0.5))); @@ -219,10 +215,8 @@ UNIT_CLASS_TEST(SearchQueryV2Test, SearchByName) builder.Add(hydePark); builder.Add(cafe); }); - RegisterCountry(countryName, m2::RectD(m2::PointD(0, 0), m2::PointD(2, 2))); SetViewport(m2::RectD(m2::PointD(-1.0, -1.0), m2::PointD(-0.9, -0.9))); - { TRules rules = {ExactMatch(wonderlandId, hydePark)}; TEST(ResultsMatch("hyde park", rules), ()); @@ -251,7 +245,7 @@ UNIT_CLASS_TEST(SearchQueryV2Test, DisableSuggests) builder.Add(london1); builder.Add(london2); }); - RegisterCountry("Wonderland", m2::RectD(m2::PointD(-2, -2), m2::PointD(2, 2))); + SetViewport(m2::RectD(m2::PointD(0.5, 0.5), m2::PointD(1.5, 1.5))); { SearchParams params; @@ -288,12 +282,11 @@ UNIT_CLASS_TEST(SearchQueryV2Test, TestRankingInfo) { builder.Add(sanFrancisco); }); - auto wonderlandId = BuildMwm(countryName, feature::DataHeader::country, [&](TestMwmBuilder & builder) + auto wonderlandId = BuildMwm(countryName, feature::DataHeader::country, [&](TestMwmBuilder & builder) { builder.Add(goldenGateStreet); builder.Add(goldenGateBridge); }); - RegisterCountry("Wonderland", m2::RectD(m2::PointD(-2, -2), m2::PointD(2, 2))); SetViewport(m2::RectD(m2::PointD(-0.5, -0.5), m2::PointD(0.5, 0.5))); {