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:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2020-01-20 17:17:42 +0300
committergmoryes <gmoryes@gmail.com>2020-01-21 13:02:02 +0300
commitff2c6e480887db5f7dbe7ab5b52a732f581ff147 (patch)
tree56a74029089b9305217d102eedf35932cbb2302f /routing
parentbba3e1c2494353521fabccc4cb890db5b6ecf36e (diff)
[routing] Testing case when rebuild route returns an error.
Diffstat (limited to 'routing')
-rw-r--r--routing/routing_callbacks.hpp28
-rw-r--r--routing/routing_session.cpp14
-rw-r--r--routing/routing_session.hpp4
-rw-r--r--routing/routing_tests/routing_session_test.cpp15
4 files changed, 30 insertions, 31 deletions
diff --git a/routing/routing_callbacks.hpp b/routing/routing_callbacks.hpp
index 516b29f0e0..b97c9e1d87 100644
--- a/routing/routing_callbacks.hpp
+++ b/routing/routing_callbacks.hpp
@@ -45,7 +45,7 @@ enum class SessionState
NoValidRoute, // No valid route: no route after application launching or the route was removed.
RouteBuilding, // We requested a route and wait when it will be built. User may be following
// the previous route.
- RouteBuildingError, // The route was not built because of an error.
+ RouteBuildingError, // @TODO The state should be removed. The route was not built because of an error.
RouteNotStarted, // Route is built but the user isn't on it.
OnRoute, // User follows the route.
RouteNeedRebuild, // User left the route.
@@ -56,18 +56,20 @@ enum class SessionState
};
/*
- * NoValidRoute -> RouteBuilding // start route building
- * RouteBuilding -> RouteBuildingError // route was built with an error
- * RouteBuilding -> RouteNotStarted // route is built in case of building a new route
- * RouteRebuilding -> RouteBuildingError // waiting for route in case of rebuilding
- * RouteRebuilding -> RouteNotStarted // route is built in case of rebuilding
- * RouteNotStarted -> OnRoute // user started following the route
- * RouteNotStarted -> RouteNeedRebuild // user doesn't like the route.
- * OnRoute -> RouteNeedRebuild // user moves away from route - need to rebuild
- * OnRoute -> RouteNoFollowing // following mode was disabled. Router doesn't track position
- * OnRoute -> RouteFinished // user reached the end of route
- * OnRoute -> RouteBuilding // while moving along a route user makes a new route
- * RouteNeedRebuild -> RouteRebuilding // start rebuild route
+ * NoValidRoute -> RouteBuilding // start route building
+ * RouteBuilding -> RouteBuildingError // route was built with an error
+ * RouteBuilding -> RouteNotStarted // route is built in case of building a new route
+ * RouteRebuilding -> RouteBuildingError // waiting for route in case of rebuilding
+ * RouteRebuilding -> RouteNotStarted // route is built in case of rebuilding
+ * RouteNotStarted -> OnRoute // user started following the route
+ * RouteNotStarted -> RouteNeedRebuild // user doesn't like the route.
+ * OnRoute -> RouteNeedRebuild // user moves away from route - need to rebuild
+ * RouteNeedRebuild -> RouteRebuilding // the route is in process of rebuilding or
+ * // while rebuilding an error happens
+ * RouteRebuilding -> OnRoute // following along route after rebuilding
+ * OnRoute -> RouteNoFollowing // following mode was disabled. Router doesn't track position
+ * OnRoute -> RouteFinished // user reached the end of route
+ * OnRoute -> RouteBuilding // while moving along a route user makes a new route
*/
using CheckpointCallback = std::function<void(size_t passedCheckpointIdx)>;
diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp
index 41ae8b66d4..98e97af5ab 100644
--- a/routing/routing_session.cpp
+++ b/routing/routing_session.cpp
@@ -137,11 +137,9 @@ void RoutingSession::DoReadyCallback::operator()(shared_ptr<Route> route, Router
m_callback(*m_rs.m_route, e);
}
-void RoutingSession::RemoveRoute(bool changeStateToNoValidRoute)
+void RoutingSession::RemoveRoute()
{
CHECK_THREAD_CHECKER(m_threadChecker, ());
- if (changeStateToNoValidRoute)
- SetState(SessionState::NoValidRoute);
m_lastDistance = 0.0;
m_moveAwayCounter = 0;
@@ -258,7 +256,8 @@ void RoutingSession::Reset()
CHECK_THREAD_CHECKER(m_threadChecker, ());
ASSERT(m_router != nullptr, ());
- RemoveRoute(true /* changeStateToNoValidRoute */);
+ RemoveRoute();
+ SetState(SessionState::NoValidRoute);
m_router->ClearState();
m_passedDistanceOnRouteMeters = 0.0;
@@ -288,8 +287,8 @@ SessionState RoutingSession::OnLocationPositionChanged(GpsInfo const & info)
return m_state;
}
- CHECK(m_route, ());
- CHECK(m_route->IsValid(), ());
+ CHECK(m_route, (m_state));
+ CHECK(m_route->IsValid(), (m_state));
m_turnNotificationsMgr.SetSpeedMetersPerSecond(info.m_speedMpS);
@@ -502,8 +501,7 @@ void RoutingSession::AssignRoute(shared_ptr<Route> route, RouterResultCode e)
return;
}
- // Note. RemoveRoute() should not change state to NoValidRoute in this case.
- RemoveRoute(false /* changeStateToNoValidRoute */);
+ RemoveRoute();
SetState(SessionState::RouteNotStarted);
m_lastCompletionPercent = 0;
m_checkpoints.SetPointFrom(route->GetPoly().Front());
diff --git a/routing/routing_session.hpp b/routing/routing_session.hpp
index 862c903139..7d86336813 100644
--- a/routing/routing_session.hpp
+++ b/routing/routing_session.hpp
@@ -181,8 +181,8 @@ private:
};
void AssignRoute(std::shared_ptr<Route> route, RouterResultCode e);
- /// RemoveRoute() removes m_route and resets route attributes (m_state, m_lastDistance, m_moveAwayCounter).
- void RemoveRoute(bool changeStateToNoValidRoute);
+ /// RemoveRoute() removes m_route and resets route attributes (m_lastDistance, m_moveAwayCounter).
+ void RemoveRoute();
void RebuildRouteOnTrafficUpdate();
double GetCompletionPercent() const;
diff --git a/routing/routing_tests/routing_session_test.cpp b/routing/routing_tests/routing_session_test.cpp
index 9c3d5c0277..2c3d52911b 100644
--- a/routing/routing_tests/routing_session_test.cpp
+++ b/routing/routing_tests/routing_session_test.cpp
@@ -580,7 +580,7 @@ UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteRebuildingError)
TestMovingByUpdatingLat(sessionStateTest, latitudes, info, *m_session);
}
- // Leaving the route until switching to |SessionState::RouteNeedRebuild| state.
+ // Test 1. Leaving the route and returning to the route when state is |SessionState::RouteNeedRebuil|.
TestLeavingRoute(*m_session, info);
// Continue moving along the route.
@@ -591,18 +591,16 @@ UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteRebuildingError)
TestMovingByUpdatingLat(sessionStateTest, latitudes, info, *m_session);
}
- // Leaving the route until switching to |SessionState::RouteRebuilding| state.
+ // Test 2. Leaving the route until, can not rebuilding it, and going along an old route.
+ // It happens we the route is left and it's impossible to build a new route.
+ // In this case the navigation is continued based on the former route.
TestLeavingRoute(*m_session, info);
{
SessionStateTest sessionStateTest(
- {SessionState::RouteNeedRebuild, SessionState::RouteRebuilding,
- SessionState::RouteNotStarted
- },
- *m_session);
+ {SessionState::RouteNeedRebuild, SessionState::RouteRebuilding}, *m_session);
TimedSignal signal;
GetPlatform().RunTask(Platform::Thread::Gui, [this, &signal]() {
m_session->SetState(SessionState::RouteRebuilding);
- m_session->SetState(SessionState::RouteNotStarted);
signal.Signal();
});
TEST(signal.WaitUntil(steady_clock::now() + kRouteBuildingMaxDuration),
@@ -611,7 +609,8 @@ UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestRouteRebuildingError)
// Continue moving along the route again.
{
- SessionStateTest sessionStateTest({SessionState::RouteNotStarted, SessionState::OnRoute},
+ // Test on state is not changed.
+ SessionStateTest sessionStateTest({SessionState::RouteRebuilding, SessionState::OnRoute},
*m_session);
vector<double> const latitudes = {0.003, 0.0035, 0.004};
TestMovingByUpdatingLat(sessionStateTest, latitudes, info, *m_session);