| 234 | } |
| 235 | |
| 236 | UNIT_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. |
nothing calls this directly
no test coverage detected