MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_CLASS_TEST

Function UNIT_CLASS_TEST

libs/map/map_tests/search_api_tests.cpp:75–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73};
74
75UNIT_CLASS_TEST(SearchAPITest, MultipleViewportsRequests)
76{
77 TestCafe cafe1(m2::PointD(0, 0), "cafe 1", "en");
78 TestCafe cafe2(m2::PointD(0.5, 0.5), "cafe 2", "en");
79 TestCafe cafe3(m2::PointD(10, 10), "cafe 3", "en");
80 TestCafe cafe4(m2::PointD(10.5, 10.5), "cafe 4", "en");
81
82 auto const id = BuildCountry("Wonderland", [&](TestMwmBuilder & builder)
83 {
84 builder.Add(cafe1);
85 builder.Add(cafe2);
86 builder.Add(cafe3);
87 builder.Add(cafe4);
88 });
89
90 atomic<int> stage{0};
91
92 promise<void> promise0;
93 auto future0 = promise0.get_future();
94
95 promise<void> promise1;
96 auto future1 = promise1.get_future();
97
98 ViewportSearchParams params;
99 params.m_query = "cafe ";
100 params.m_inputLocale = "en";
101
102 params.m_onCompleted = [&](Results const & results)
103 {
104 TEST(!results.IsEndedCancelled(), ());
105
106 if (!results.IsEndMarker())
107 return;
108
109 if (stage == 0)
110 {
111 Rules const rules = {ExactMatch(id, cafe1), ExactMatch(id, cafe2)};
112 TEST(MatchResults(m_dataSource, rules, results), ());
113
114 promise0.set_value();
115 }
116 else
117 {
118 TEST_EQUAL(stage, 1, ());
119 Rules const rules = {ExactMatch(id, cafe3), ExactMatch(id, cafe4)};
120 TEST(MatchResults(m_dataSource, rules, results), ());
121
122 promise1.set_value();
123 }
124 };
125
126 m_api.OnViewportChanged(m2::RectD(-1, -1, 1, 1));
127 m_api.SearchInViewport(params);
128 future0.wait();
129
130 ++stage;
131 m_api.OnViewportChanged(m2::RectD(9, 9, 11, 11));
132 future1.wait();

Callers

nothing calls this directly

Calls 15

TESTFunction · 0.85
ExactMatchFunction · 0.85
MatchResultsFunction · 0.85
SetDefaultStrFunction · 0.85
IsEndedCancelledMethod · 0.80
IsEndMarkerMethod · 0.80
SearchInViewportMethod · 0.80
waitMethod · 0.80
SearchEverywhereMethod · 0.80
SearchInBookmarksMethod · 0.80
OnBookmarksAttachedMethod · 0.80
OnBookmarksDetachedMethod · 0.80

Tested by

no test coverage detected