diff --git a/search/search_engine.hpp b/search/search_engine.hpp index 9a970bf9ab..745194ae1e 100644 --- a/search/search_engine.hpp +++ b/search/search_engine.hpp @@ -103,6 +103,7 @@ public: // Posts request to support old format to the queue. void SetSupportOldFormat(bool support); + // Sets default locale on all query processors. void SetLocale(string const & locale); // Posts request to clear caches to the queue. diff --git a/search/search_quality/features_collector_tool/features_collector_tool.cpp b/search/search_quality/features_collector_tool/features_collector_tool.cpp index fb0c396047..46134236fd 100644 --- a/search/search_quality/features_collector_tool/features_collector_tool.cpp +++ b/search/search_quality/features_collector_tool/features_collector_tool.cpp @@ -57,7 +57,7 @@ void GetContents(istream & is, string & contents) bool Matches(Context & context, Sample::Result const & golden, search::Result const & actual) { - static double const kEps = 2 * 1e-5; + static double constexpr kEps = 2e-5; if (actual.GetResultType() != Result::RESULT_FEATURE) return false; @@ -67,16 +67,16 @@ bool Matches(Context & context, Sample::Result const & golden, search::Result co string name; if (!ft.GetName(FeatureType::DEFAULT_LANG, name)) name.clear(); - string const houseNumber = ft.GetHouseNumber(); + auto const houseNumber = ft.GetHouseNumber(); auto const center = feature::GetCenter(ft); return golden.m_name == strings::MakeUniString(name) && golden.m_houseNumber == houseNumber && my::AlmostEqualAbs(golden.m_pos, center, kEps); } -void SetRelevances(Context & context, vector const & golden, - vector const & actual, - vector & relevances) +void SetRelevanceValues(Context & context, vector const & golden, + vector const & actual, + vector & relevances) { auto const n = golden.size(); auto const m = actual.size(); @@ -97,6 +97,7 @@ void SetRelevances(Context & context, vector const & golden, { matched[j] = true; relevances[j] = g.m_relevance; + break; } } } @@ -162,15 +163,22 @@ int main(int argc, char * argv[]) auto const & sample = samples[i]; engine.SetLocale(sample.m_locale); - string query = strings::ToUtf8(sample.m_query); - TestSearchRequest request(engine, query, sample.m_locale, Mode::Everywhere, sample.m_viewport, - sample.m_pos); + + auto latLon = MercatorBounds::ToLatLon(sample.m_pos); + + search::SearchParams params; + params.m_query = strings::ToUtf8(sample.m_query); + params.m_inputLocale = sample.m_locale; + params.SetMode(Mode::Everywhere); + params.SetPosition(latLon.lat, latLon.lon); + params.SetSuggestsEnabled(false); + TestSearchRequest request(engine, params, sample.m_viewport); request.Wait(); auto const & results = request.Results(); vector relevances; - SetRelevances(context, sample.m_results, results, relevances); + SetRelevanceValues(context, sample.m_results, results, relevances); ASSERT_EQUAL(results.size(), relevances.size(), ()); for (size_t j = 0; j < results.size(); ++j) diff --git a/search/search_tests_support/test_search_request.cpp b/search/search_tests_support/test_search_request.cpp index 725533cd94..58bb686c77 100644 --- a/search/search_tests_support/test_search_request.cpp +++ b/search/search_tests_support/test_search_request.cpp @@ -22,21 +22,6 @@ TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, string const & q engine.Search(params, viewport); } -TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, string const & query, - string const & locale, Mode mode, m2::RectD const & viewport, - m2::PointD const & position) -{ - auto latLon = MercatorBounds::ToLatLon(position); - - SearchParams params; - params.m_query = query; - params.m_inputLocale = locale; - params.SetMode(mode); - params.SetPosition(latLon.lat, latLon.lon); - SetUpCallbacks(params); - engine.Search(params, viewport); -} - TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, SearchParams params, m2::RectD const & viewport) { diff --git a/search/search_tests_support/test_search_request.hpp b/search/search_tests_support/test_search_request.hpp index ac3168874e..35c1031ebb 100644 --- a/search/search_tests_support/test_search_request.hpp +++ b/search/search_tests_support/test_search_request.hpp @@ -26,8 +26,6 @@ class TestSearchRequest public: TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale, Mode mode, m2::RectD const & viewport); - TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale, - Mode mode, m2::RectD const & viewport, m2::PointD const & position); TestSearchRequest(TestSearchEngine & engine, SearchParams params, m2::RectD const & viewport); void Wait();