diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-12-01 13:41:57 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-12-03 11:54:57 +0300 |
commit | c5c9eb5c06984fafaac9dc58828b6427ad0500d3 (patch) | |
tree | 187d024b5a29644caf22ed1a74198a026e9eae5e /routing/routing_integration_tests | |
parent | 47ded79083994e11c2a606f8bd188ef72ec9d35b (diff) |
Review fixes.
Diffstat (limited to 'routing/routing_integration_tests')
-rw-r--r-- | routing/routing_integration_tests/routing_test_tools.cpp | 9 | ||||
-rw-r--r-- | routing/routing_integration_tests/routing_test_tools.hpp | 210 |
2 files changed, 117 insertions, 102 deletions
diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index 36d79aad3d..edc3fecbd2 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -76,14 +76,15 @@ namespace integration } unique_ptr<CarRouter> CreateCarRouter(Index & index, - storage::CountryInfoGetter const & infoGetter) + storage::CountryInfoGetter const & infoGetter, + TrafficInfoGetterTest const & trafficGetter) { auto const countryFileGetter = [&infoGetter](m2::PointD const & pt) { return infoGetter.GetRegionCountryId(pt); }; auto carRouter = make_unique<CarRouter>( - index, countryFileGetter, SingleMwmRouter::CreateCarRouter(index, nullptr)); + index, countryFileGetter, SingleMwmRouter::CreateCarRouter(index, trafficGetter)); return carRouter; } @@ -106,12 +107,14 @@ namespace integration public: OsrmRouterComponents(vector<LocalCountryFile> const & localFiles) : IRouterComponents(localFiles) - , m_carRouter(CreateCarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter)) + , m_carRouter(CreateCarRouter(m_featuresFetcher->GetIndex(), *m_infoGetter, m_trafficGetter)) { } IRouter * GetRouter() const override { return m_carRouter.get(); } + private: + TrafficInfoGetterTest m_trafficGetter; unique_ptr<CarRouter> m_carRouter; }; diff --git a/routing/routing_integration_tests/routing_test_tools.hpp b/routing/routing_integration_tests/routing_test_tools.hpp index cefa6b314b..40b8ad132a 100644 --- a/routing/routing_integration_tests/routing_test_tools.hpp +++ b/routing/routing_integration_tests/routing_test_tools.hpp @@ -6,6 +6,8 @@ #include "map/feature_vec_model.hpp" +#include "traffic/traffic_info.hpp" + #include "platform/local_country_file.hpp" #include "std/set.hpp" @@ -50,107 +52,117 @@ shared_ptr<model::FeaturesFetcher> CreateFeaturesFetcher(vector<LocalCountryFile unique_ptr<storage::CountryInfoGetter> CreateCountryInfoGetter(); - class IRouterComponents +class IRouterComponents +{ +public: + IRouterComponents(vector<LocalCountryFile> const & localFiles) + : m_featuresFetcher(CreateFeaturesFetcher(localFiles)) + , m_infoGetter(CreateCountryInfoGetter()) + { + } + + virtual ~IRouterComponents() = default; + + virtual IRouter * GetRouter() const = 0; + + storage::CountryInfoGetter const & GetCountryInfoGetter() const noexcept + { + return *m_infoGetter; + } + + protected: + shared_ptr<model::FeaturesFetcher> m_featuresFetcher; + unique_ptr<storage::CountryInfoGetter> m_infoGetter; +}; + +class TrafficInfoGetterTest : public traffic::TrafficInfoGetter +{ +public: + // TrafficInfoGetter overrides: + shared_ptr<traffic::TrafficInfo> GetTrafficInfo(MwmSet::MwmId const & mwmId) const override { - public: - IRouterComponents(vector<LocalCountryFile> const & localFiles) - : m_featuresFetcher(CreateFeaturesFetcher(localFiles)) - , m_infoGetter(CreateCountryInfoGetter()) - { - } - - virtual ~IRouterComponents() = default; - - virtual IRouter * GetRouter() const = 0; - - storage::CountryInfoGetter const & GetCountryInfoGetter() const noexcept - { - return *m_infoGetter; - } - - protected: - shared_ptr<model::FeaturesFetcher> m_featuresFetcher; - unique_ptr<storage::CountryInfoGetter> m_infoGetter; - }; - - void TestOnlineCrosses(ms::LatLon const & startPoint, ms::LatLon const & finalPoint, - vector<string> const & expected, IRouterComponents & routerComponents); - void TestOnlineFetcher(ms::LatLon const & startPoint, ms::LatLon const & finalPoint, - vector<string> const & expected, IRouterComponents & routerComponents); - - /// Gets OSRM router components - IRouterComponents & GetOsrmComponents(); - shared_ptr<IRouterComponents> GetOsrmComponents(vector<platform::LocalCountryFile> const & localFiles); - - /// Gets pedestrian router components - IRouterComponents & GetPedestrianComponents(); - shared_ptr<IRouterComponents> GetPedestrianComponents(vector<platform::LocalCountryFile> const & localFiles); - - /// Gets bicycle router components. - IRouterComponents & GetBicycleComponents(); - shared_ptr<IRouterComponents> GetBicycleComponents( - vector<platform::LocalCountryFile> const & localFiles); - - TRouteResult CalculateRoute(IRouterComponents const & routerComponents, - m2::PointD const & startPoint, m2::PointD const & startDirection, - m2::PointD const & finalPoint); - - void TestTurnCount(Route const & route, uint32_t expectedTurnCount); - - /// Testing route length. - /// It is used for checking if routes have expected(sample) length. - /// A created route will pass the test iff - /// expectedRouteMeters - expectedRouteMeters * relativeError <= route->GetDistance() - /// && expectedRouteMeters + expectedRouteMeters * relativeError >= route->GetDistance() - void TestRouteLength(Route const & route, double expectedRouteMeters, - double relativeError = 0.01); - void TestRouteTime(Route const & route, double expectedRouteSeconds, + return shared_ptr<traffic::TrafficInfo>(); + } +}; + +void TestOnlineCrosses(ms::LatLon const & startPoint, ms::LatLon const & finalPoint, + vector<string> const & expected, IRouterComponents & routerComponents); +void TestOnlineFetcher(ms::LatLon const & startPoint, ms::LatLon const & finalPoint, + vector<string> const & expected, IRouterComponents & routerComponents); + +/// Gets OSRM router components +IRouterComponents & GetOsrmComponents(); +shared_ptr<IRouterComponents> GetOsrmComponents(vector<platform::LocalCountryFile> const & localFiles); + +/// Gets pedestrian router components +IRouterComponents & GetPedestrianComponents(); +shared_ptr<IRouterComponents> GetPedestrianComponents(vector<platform::LocalCountryFile> const & localFiles); + +/// Gets bicycle router components. +IRouterComponents & GetBicycleComponents(); +shared_ptr<IRouterComponents> GetBicycleComponents( + vector<platform::LocalCountryFile> const & localFiles); + +TRouteResult CalculateRoute(IRouterComponents const & routerComponents, + m2::PointD const & startPoint, m2::PointD const & startDirection, + m2::PointD const & finalPoint); + +void TestTurnCount(Route const & route, uint32_t expectedTurnCount); + +/// Testing route length. +/// It is used for checking if routes have expected(sample) length. +/// A created route will pass the test iff +/// expectedRouteMeters - expectedRouteMeters * relativeError <= route->GetDistance() +/// && expectedRouteMeters + expectedRouteMeters * relativeError >= route->GetDistance() +void TestRouteLength(Route const & route, double expectedRouteMeters, double relativeError = 0.01); +void TestRouteTime(Route const & route, double expectedRouteSeconds, + double relativeError = 0.01); - void CalculateRouteAndTestRouteLength(IRouterComponents const & routerComponents, - m2::PointD const & startPoint, - m2::PointD const & startDirection, - m2::PointD const & finalPoint, double expectedRouteMeters, - double relativeError = 0.07); +void CalculateRouteAndTestRouteLength(IRouterComponents const & routerComponents, + m2::PointD const & startPoint, + m2::PointD const & startDirection, + m2::PointD const & finalPoint, double expectedRouteMeters, + double relativeError = 0.07); - class TestTurn +class TestTurn +{ + friend TestTurn GetNthTurn(Route const & route, uint32_t turnNumber); + + m2::PointD const m_point; + TurnDirection const m_direction; + uint32_t const m_roundAboutExitNum; + bool const m_isValid; + + TestTurn() + : m_point({0., 0.}), + m_direction(TurnDirection::NoTurn), + m_roundAboutExitNum(0), + m_isValid(false) + { + } + TestTurn(m2::PointD const & pnt, TurnDirection direction, uint32_t roundAboutExitNum) + : m_point(pnt), + m_direction(direction), + m_roundAboutExitNum(roundAboutExitNum), + m_isValid(true) { - friend TestTurn GetNthTurn(Route const & route, uint32_t turnNumber); - - m2::PointD const m_point; - TurnDirection const m_direction; - uint32_t const m_roundAboutExitNum; - bool const m_isValid; - - TestTurn() - : m_point({0., 0.}), - m_direction(TurnDirection::NoTurn), - m_roundAboutExitNum(0), - m_isValid(false) - { - } - TestTurn(m2::PointD const & pnt, TurnDirection direction, uint32_t roundAboutExitNum) - : m_point(pnt), - m_direction(direction), - m_roundAboutExitNum(roundAboutExitNum), - m_isValid(true) - { - } - - public: - const TestTurn & TestValid() const; - const TestTurn & TestNotValid() const; - const TestTurn & TestPoint(m2::PointD const & expectedPoint, double inaccuracyMeters = 3.) const; - const TestTurn & TestDirection(TurnDirection expectedDirection) const; - const TestTurn & TestOneOfDirections(set<TurnDirection> const & expectedDirections) const; - const TestTurn & TestRoundAboutExitNum(uint32_t expectedRoundAboutExitNum) const; - }; - - /// Extracting appropriate TestTurn if any. If not TestTurn::isValid() returns false. - /// inaccuracy is set in meters. - TestTurn GetNthTurn(Route const & route, uint32_t turnNumber); - - void TestCurrentStreetName(routing::Route const & route, string const & expectedStreetName); - - void TestNextStreetName(routing::Route const & route, string const & expectedStreetName); -} + } + +public: + const TestTurn & TestValid() const; + const TestTurn & TestNotValid() const; + const TestTurn & TestPoint(m2::PointD const & expectedPoint, double inaccuracyMeters = 3.) const; + const TestTurn & TestDirection(TurnDirection expectedDirection) const; + const TestTurn & TestOneOfDirections(set<TurnDirection> const & expectedDirections) const; + const TestTurn & TestRoundAboutExitNum(uint32_t expectedRoundAboutExitNum) const; +}; + +/// Extracting appropriate TestTurn if any. If not TestTurn::isValid() returns false. +/// inaccuracy is set in meters. +TestTurn GetNthTurn(Route const & route, uint32_t turnNumber); + +void TestCurrentStreetName(routing::Route const & route, string const & expectedStreetName); + +void TestNextStreetName(routing::Route const & route, string const & expectedStreetName); +} // namespace integration |