From 7ee466f634e4e06da99232ca5fc8a5b44b728b38 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 13 May 2015 16:48:16 +0300 Subject: [PATCH] [routing] Online osrm router integration tests --- integration_tests/integration_tests.pro | 1 + integration_tests/online_cross_tests.cpp | 13 +++++++++++++ integration_tests/osrm_test_tools.cpp | 16 ++++++++++++++++ integration_tests/osrm_test_tools.hpp | 4 ++++ 4 files changed, 34 insertions(+) create mode 100644 integration_tests/online_cross_tests.cpp diff --git a/integration_tests/integration_tests.pro b/integration_tests/integration_tests.pro index 9d49a291c6..9def50e800 100644 --- a/integration_tests/integration_tests.pro +++ b/integration_tests/integration_tests.pro @@ -24,6 +24,7 @@ win32* : LIBS *= -lShell32 SOURCES += \ ../testing/testingmain.cpp \ + online_cross_tests.cpp \ osrm_route_test.cpp \ osrm_turn_test.cpp \ osrm_test_tools.cpp \ diff --git a/integration_tests/online_cross_tests.cpp b/integration_tests/online_cross_tests.cpp new file mode 100644 index 0000000000..158d963d5f --- /dev/null +++ b/integration_tests/online_cross_tests.cpp @@ -0,0 +1,13 @@ +#include "testing/testing.hpp" + +#include "integration_tests/osrm_test_tools.hpp" + +namespace +{ +UNIT_TEST(OnlineRussiaNorthToSouthTest) +{ + shared_ptr routerComponents = integration::GetAllMaps(); + TestOnlineCrosses({34.45, 61.76}, {38.94, 45.07}, + {"Russia_Central", "Russia_Southern", "Russia_Northwestern"}, routerComponents); +} +} // namespace diff --git a/integration_tests/osrm_test_tools.cpp b/integration_tests/osrm_test_tools.cpp index 4afd863800..4791aab6a8 100644 --- a/integration_tests/osrm_test_tools.cpp +++ b/integration_tests/osrm_test_tools.cpp @@ -6,6 +6,7 @@ #include "geometry/distance_on_sphere.hpp" +#include "routing/online_cross_fetcher.hpp" #include "routing/route.hpp" #include "map/feature_vec_model.hpp" @@ -97,6 +98,7 @@ namespace integration m_searchEngine(CreateSearchEngine(m_featuresFetcher)), m_osrmRouter(CreateOsrmRouter(m_featuresFetcher, m_searchEngine)) {} OsrmRouter * GetOsrmRouter() const { return m_osrmRouter.get(); } + search::Engine * GetSearchEngine() const { return m_searchEngine.get(); } private: shared_ptr m_featuresFetcher; @@ -248,4 +250,18 @@ namespace integration } return TestTurn(); } + + void TestOnlineCrosses(m2::PointD const & startPoint, m2::PointD const & finalPoint, + vector const & expected, + shared_ptr & routerComponents) + { + routing::OnlineCrossFetcher fetcher(OSRM_ONLINE_SERVER_URL, startPoint, finalPoint); + vector const & points = fetcher.GetMwmPoints(); + TEST_EQUAL(points.size(), expected.size(), ()); + for (m2::PointD const & point : points) + { + string const mwmName = routerComponents->GetSearchEngine()->GetCountryFile(point); + TEST(find(expected.begin(), expected.end(), mwmName) != expected.end(), ()); + } + } } diff --git a/integration_tests/osrm_test_tools.hpp b/integration_tests/osrm_test_tools.hpp index 7502dc06ca..2688bda46a 100644 --- a/integration_tests/osrm_test_tools.hpp +++ b/integration_tests/osrm_test_tools.hpp @@ -37,6 +37,10 @@ namespace integration { class OsrmRouterComponents; + void TestOnlineCrosses(m2::PointD const & startPoint, m2::PointD const & finalPoint, + vector const & expected, + shared_ptr & routerComponents); + shared_ptr GetAllMaps(); shared_ptr LoadMaps(vector const & mapNames); RouteResultT CalculateRoute(shared_ptr routerComponents,