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

Function UNIT_CLASS_TEST

libs/routing/routing_tests/routing_session_test.cpp:236–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteBuilding)
237{
238 // Multithreading synchronization note. |counter| and |session| are constructed on the main thread,
239 // then used on gui thread and then if timeout in timedSignal.WaitUntil() is not reached,
240 // |counter| is used again.
241 TimedSignal timedSignal;
242 size_t counter = 0;
243
244 GetPlatform().RunTask(Platform::Thread::Gui, [&timedSignal, &counter, this]()
245 {
246 InitRoutingSession();
247 Route masterRoute("dummy", kTestRoute.begin(), kTestRoute.end(), 0 /* route id */);
248
249 unique_ptr<DummyRouter> router = make_unique<DummyRouter>(masterRoute, RouterResultCode::NoError, counter);
250 m_session->SetRouter(std::move(router), nullptr);
251 m_session->SetRoutingCallbacks([&timedSignal](Route const &, RouterResultCode)
252 {
253 LOG(LINFO, ("Ready"));
254 timedSignal.Signal();
255 }, nullptr /* rebuildReadyCallback */, nullptr /* needMoreMapsCallback */, nullptr /* removeRouteCallback */);
256 m_session->BuildRoute(Checkpoints(kTestRoute.front(), kTestRoute.back()), RouterDelegate::kNoTimeout);
257 });
258
259 // Manual check of the routeBuilding mutex to avoid spurious results.
260 TEST(timedSignal.WaitUntil(steady_clock::now() + kRouteBuildingMaxDuration), ("Route was not built."));
261 TEST_EQUAL(counter, 1, ());
262}
263
264// Test on route rebuilding when current position moving from the route. Each next position
265// is farther from the route then previous one.

Callers

nothing calls this directly

Calls 15

InitRoutingSessionFunction · 0.85
TESTFunction · 0.85
FillSubroutesInfoFunction · 0.85
KmphToMpsFunction · 0.85
TestMovingByUpdatingLatFunction · 0.85
TestLeavingRouteFunction · 0.85
RunTaskMethod · 0.80
SetRoutingCallbacksMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
WaitUntilMethod · 0.80
IsFollowingMethod · 0.80

Tested by

no test coverage detected