Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'search/search_integration_tests/search_edited_features_test.cpp')
-rw-r--r--search/search_integration_tests/search_edited_features_test.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/search/search_integration_tests/search_edited_features_test.cpp b/search/search_integration_tests/search_edited_features_test.cpp
index bd3ed5c7f0..003ecb2c08 100644
--- a/search/search_integration_tests/search_edited_features_test.cpp
+++ b/search/search_integration_tests/search_edited_features_test.cpp
@@ -59,4 +59,69 @@ UNIT_CLASS_TEST(SearchEditedFeaturesTest, Smoke)
TEST(ResultsMatch("wifi bar quahog", rules), ());
}
}
+
+UNIT_CLASS_TEST(SearchEditedFeaturesTest, SearchInViewport)
+{
+ TestCity city(m2::PointD(0, 0), "Canterlot", "default", 100 /* rank */);
+ TestPOI bakery0(m2::PointD(0, 0), "Bakery 0", "default");
+ TestPOI cornerPost(m2::PointD(100, 100), "Corner Post", "default");
+ auto & editor = osm::Editor::Instance();
+
+ BuildWorld([&](TestMwmBuilder & builder) { builder.Add(city); });
+
+ auto const countryId = BuildCountry("Equestria", [&](TestMwmBuilder & builder) {
+ builder.Add(bakery0);
+ builder.Add(cornerPost);
+ });
+
+ auto const tmp1 = TestPOI::AddWithEditor(editor, countryId, "bakery1", {1.0, 1.0});
+ TestPOI const & bakery1 = tmp1.first;
+ FeatureID const & id1 = tmp1.second;
+ auto const tmp2 = TestPOI::AddWithEditor(editor, countryId, "bakery2", {2.0, 2.0});
+ TestPOI const & bakery2 = tmp2.first;
+ FeatureID const & id2 = tmp2.second;
+ auto const tmp3 = TestPOI::AddWithEditor(editor, countryId, "bakery3", {3.0, 3.0});
+ TestPOI const & bakery3 = tmp3.first;
+ FeatureID const & id3 = tmp3.second;
+ UNUSED_VALUE(id2);
+
+ SetViewport(m2::RectD(-1.0, -1.0, 4.0, 4.0));
+ {
+ TRules const rules = {ExactMatch(countryId, bakery0), ExactMatch(countryId, bakery1),
+ ExactMatch(countryId, bakery2), ExactMatch(countryId, bakery3)};
+
+ TEST(ResultsMatch("bakery", Mode::Viewport, rules), ());
+ }
+
+ SetViewport(m2::RectD(-2.0, -2.0, -1.0, -1.0));
+ {
+ TRules const rules = {};
+
+ TEST(ResultsMatch("bakery", Mode::Viewport, rules), ());
+ }
+
+ SetViewport(m2::RectD(-1.0, -1.0, 1.5, 1.5));
+ {
+ TRules const rules = {ExactMatch(countryId, bakery0), ExactMatch(countryId, bakery1)};
+
+ TEST(ResultsMatch("bakery", Mode::Viewport, rules), ());
+ }
+
+ SetViewport(m2::RectD(1.5, 1.5, 4.0, 4.0));
+ {
+ TRules const rules = {ExactMatch(countryId, bakery2), ExactMatch(countryId, bakery3)};
+
+ TEST(ResultsMatch("bakery", Mode::Viewport, rules), ());
+ }
+
+ editor.DeleteFeature(id1);
+ editor.DeleteFeature(id3);
+
+ SetViewport(m2::RectD(-1.0, -1.0, 4.0, 4.0));
+ {
+ TRules const rules = {ExactMatch(countryId, bakery0), ExactMatch(countryId, bakery2)};
+
+ TEST(ResultsMatch("bakery", Mode::Viewport, rules), ());
+ }
+}
} // namespace