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:
authorMikhail Gorbushin <m.gorbushin@corp.mail.ru>2019-04-04 18:59:45 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2019-05-06 14:05:29 +0300
commite41d1b6b9840dd4f587c528a1d0be13718b48788 (patch)
tree018b4e4fb4243daee9e57afee32ab37ba0108394 /routing
parentf01df8f5cd4c374b2b0c9bb885cf6f45a65f3122 (diff)
Stage 3. Generator tests.
Diffstat (limited to 'routing')
-rw-r--r--routing/routing_integration_tests/routing_test_tools.cpp2
-rw-r--r--routing/routing_tests/applying_traffic_test.cpp2
-rw-r--r--routing/routing_tests/cumulative_restriction_test.cpp2
-rw-r--r--routing/routing_tests/index_graph_test.cpp3
-rw-r--r--routing/routing_tests/index_graph_tools.cpp61
-rw-r--r--routing/routing_tests/index_graph_tools.hpp62
-rw-r--r--routing/routing_tests/restriction_test.cpp2
-rw-r--r--routing/routing_tests/road_access_test.cpp3
8 files changed, 55 insertions, 82 deletions
diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp
index 8f879c9842..8bfb5d482b 100644
--- a/routing/routing_integration_tests/routing_test_tools.cpp
+++ b/routing/routing_integration_tests/routing_test_tools.cpp
@@ -1,6 +1,6 @@
#include "routing/routing_integration_tests/routing_test_tools.hpp"
-#include "routing/routing_tests/index_graph_tools.hpp"
+#include "routing_common/index_graph_tools.hpp"
#include "testing/testing.hpp"
diff --git a/routing/routing_tests/applying_traffic_test.cpp b/routing/routing_tests/applying_traffic_test.cpp
index a6029203dc..eee5ae6afc 100644
--- a/routing/routing_tests/applying_traffic_test.cpp
+++ b/routing/routing_tests/applying_traffic_test.cpp
@@ -6,7 +6,7 @@
#include "routing/index_graph_starter.hpp"
#include "routing/routing_session.hpp"
-#include "routing/routing_tests/index_graph_tools.hpp"
+#include "routing_common/index_graph_tools.hpp"
#include "traffic/traffic_info.hpp"
diff --git a/routing/routing_tests/cumulative_restriction_test.cpp b/routing/routing_tests/cumulative_restriction_test.cpp
index 4706b37a9b..b8e843fd5c 100644
--- a/routing/routing_tests/cumulative_restriction_test.cpp
+++ b/routing/routing_tests/cumulative_restriction_test.cpp
@@ -1,5 +1,7 @@
#include "testing/testing.hpp"
+#include "generator/generator_tests/routing_tools.hpp"
+
#include "routing/routing_tests/index_graph_tools.hpp"
#include "routing/fake_ending.hpp"
diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp
index b2c6b102a4..95935e145a 100644
--- a/routing/routing_tests/index_graph_test.cpp
+++ b/routing/routing_tests/index_graph_test.cpp
@@ -12,9 +12,8 @@
#include "routing/routing_helpers.hpp"
#include "routing/vehicle_mask.hpp"
-#include "routing/routing_tests/index_graph_tools.hpp"
-
#include "routing_common/car_model.hpp"
+#include "routing_common/index_graph_tools.hpp"
#include "geometry/mercator.hpp"
#include "geometry/point2d.hpp"
diff --git a/routing/routing_tests/index_graph_tools.cpp b/routing/routing_tests/index_graph_tools.cpp
index 95faf43111..63d0c1f513 100644
--- a/routing/routing_tests/index_graph_tools.cpp
+++ b/routing/routing_tests/index_graph_tools.cpp
@@ -1,4 +1,4 @@
-#include "routing/routing_tests/index_graph_tools.hpp"
+#include "routing_common/index_graph_tools.hpp"
#include "testing/testing.hpp"
@@ -73,32 +73,6 @@ void RestrictionTest::SetStarter(FakeEnding const & start, FakeEnding const & fi
m_starter = MakeStarter(start, finish, *m_graph);
}
-// TestGeometryLoader ------------------------------------------------------------------------------
-void TestGeometryLoader::Load(uint32_t featureId, RoadGeometry & road)
-{
- auto it = m_roads.find(featureId);
- if (it == m_roads.cend())
- return;
-
- road = it->second;
-}
-
-void TestGeometryLoader::AddRoad(uint32_t featureId, bool oneWay, float speed,
- RoadGeometry::Points const & points)
-{
- auto it = m_roads.find(featureId);
- CHECK(it == m_roads.end(), ("Already contains feature", featureId));
- m_roads[featureId] = RoadGeometry(oneWay, speed, speed, points);
- m_roads[featureId].SetPassThroughAllowedForTests(true);
-}
-
-void TestGeometryLoader::SetPassThroughAllowed(uint32_t featureId, bool passThroughAllowed)
-{
- auto it = m_roads.find(featureId);
- CHECK(it != m_roads.end(), ("No feature", featureId));
- m_roads[featureId].SetPassThroughAllowedForTests(passThroughAllowed);
-}
-
// ZeroGeometryLoader ------------------------------------------------------------------------------
void ZeroGeometryLoader::Load(uint32_t /* featureId */, routing::RoadGeometry & road)
{
@@ -223,7 +197,7 @@ bool TestIndexGraphTopology::FindPath(Vertex start, Vertex finish, double & path
AlgorithmForWorldGraph algorithm;
- WorldGraphForAStar graphForAStar(*worldGraph);
+ routing_test::WorldGraphForAStar graphForAStar(*worldGraph);
AlgorithmForWorldGraph::ParamsForTests params(graphForAStar, startSegment, finishSegment,
nullptr /* prevRoute */,
@@ -353,6 +327,15 @@ unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(unique_ptr<TestGeometryLoade
estimator);
}
+unique_ptr<IndexGraph> BuildIndexGraph(unique_ptr<TestGeometryLoader> geometryLoader,
+ shared_ptr<EdgeEstimator> estimator,
+ vector<Joint> const & joints)
+{
+ auto graph = make_unique<IndexGraph>(make_shared<Geometry>(move(geometryLoader)), estimator);
+ graph->Import(joints);
+ return graph;
+}
+
unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(unique_ptr<ZeroGeometryLoader> geometryLoader,
shared_ptr<EdgeEstimator> estimator,
vector<Joint> const & joints)
@@ -388,28 +371,6 @@ unique_ptr<TransitWorldGraph> BuildWorldGraph(unique_ptr<TestGeometryLoader> geo
move(transitLoader), estimator);
}
-Joint MakeJoint(vector<RoadPoint> const & points)
-{
- Joint joint;
- for (auto const & point : points)
- joint.AddPoint(point);
-
- return joint;
-}
-
-shared_ptr<EdgeEstimator> CreateEstimatorForCar(traffic::TrafficCache const & trafficCache)
-{
- auto numMwmIds = make_shared<NumMwmIds>();
- auto stash = make_shared<TrafficStash>(trafficCache, numMwmIds);
- return CreateEstimatorForCar(stash);
-}
-
-shared_ptr<EdgeEstimator> CreateEstimatorForCar(shared_ptr<TrafficStash> trafficStash)
-{
- auto const carModel = CarModelFactory({}).GetVehicleModel();
- return EdgeEstimator::Create(VehicleType::Car, *carModel, trafficStash);
-}
-
AlgorithmForWorldGraph::Result CalculateRoute(IndexGraphStarter & starter, vector<Segment> & roadPoints,
double & timeSec)
{
diff --git a/routing/routing_tests/index_graph_tools.hpp b/routing/routing_tests/index_graph_tools.hpp
index 11bd41331c..f903fa1618 100644
--- a/routing/routing_tests/index_graph_tools.hpp
+++ b/routing/routing_tests/index_graph_tools.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "generator/generator_tests/routing_tools.hpp"
+
#include "routing/edge_estimator.hpp"
#include "routing/fake_ending.hpp"
#include "routing/index_graph.hpp"
@@ -43,6 +45,36 @@ using namespace routing;
// It just a noticeable value to detect the source of such id while debuging unit tests.
NumMwmId constexpr kTestNumMwmId = 777;
+class WorldGraphForAStar : public AStarGraph<Segment, SegmentEdge, RouteWeight>
+{
+public:
+ using Vertex = AStarGraph::Vertex;
+ using Edge = AStarGraph::Edge;
+ using Weight = AStarGraph::Weight;
+
+ explicit WorldGraphForAStar(WorldGraph & graph) : m_graph(graph) {}
+
+ Weight HeuristicCostEstimate(Vertex const & from, Vertex const & to) override
+ {
+ return m_graph.HeuristicCostEstimate(from, to);
+ }
+
+ void GetOutgoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
+ {
+ m_graph.GetOutgoingEdgesList(v, edges);
+ }
+
+ void GetIngoingEdgesList(Vertex const & v, std::vector<Edge> & edges) override
+ {
+ m_graph.GetIngoingEdgesList(v, edges);
+ }
+
+ ~WorldGraphForAStar() override = default;
+
+private:
+ WorldGraph & m_graph;
+};
+
struct RestrictionTest
{
RestrictionTest() { classificator::Load(); }
@@ -57,23 +89,6 @@ struct RestrictionTest
std::unique_ptr<IndexGraphStarter> m_starter;
};
-class TestGeometryLoader final : public routing::GeometryLoader
-{
-public:
- // GeometryLoader overrides:
- ~TestGeometryLoader() override = default;
-
- void Load(uint32_t featureId, routing::RoadGeometry & road) override;
-
- void AddRoad(uint32_t featureId, bool oneWay, float speed,
- routing::RoadGeometry::Points const & points);
-
- void SetPassThroughAllowed(uint32_t featureId, bool passThroughAllowed);
-
-private:
- std::unordered_map<uint32_t, routing::RoadGeometry> m_roads;
-};
-
class ZeroGeometryLoader final : public routing::GeometryLoader
{
public:
@@ -218,20 +233,13 @@ private:
std::vector<EdgeRequest> m_edgeRequests;
};
-unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(std::unique_ptr<TestGeometryLoader> loader,
+std::unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(std::unique_ptr<TestGeometryLoader> loader,
std::shared_ptr<EdgeEstimator> estimator,
std::vector<Joint> const & joints);
-unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(std::unique_ptr<ZeroGeometryLoader> loader,
+std::unique_ptr<SingleVehicleWorldGraph> BuildWorldGraph(std::unique_ptr<ZeroGeometryLoader> loader,
std::shared_ptr<EdgeEstimator> estimator,
std::vector<Joint> const & joints);
-routing::Joint MakeJoint(std::vector<routing::RoadPoint> const & points);
-
-shared_ptr<routing::EdgeEstimator> CreateEstimatorForCar(
- traffic::TrafficCache const & trafficCache);
-shared_ptr<routing::EdgeEstimator> CreateEstimatorForCar(
- std::shared_ptr<TrafficStash> trafficStash);
-
AStarAlgorithm<Segment, SegmentEdge, RouteWeight>::Result CalculateRoute(
IndexGraphStarter & starter, std::vector<Segment> & roadPoints, double & timeSec);
@@ -255,7 +263,7 @@ void TestRestrictions(std::vector<m2::PointD> const & expectedRouteGeom,
// take arbitrary values.
void TestTopologyGraph(TestIndexGraphTopology const & graph, TestIndexGraphTopology::Vertex from,
TestIndexGraphTopology::Vertex to, bool expectedPathFound,
- double const expectedWeight,
+ double expectedWeight,
std::vector<TestIndexGraphTopology::Edge> const & expectedEdges);
// Creates FakeEnding projected to |Segment(kTestNumMwmId, featureId, segmentIdx, true /* forward
diff --git a/routing/routing_tests/restriction_test.cpp b/routing/routing_tests/restriction_test.cpp
index 598a1234e2..dcfd573072 100644
--- a/routing/routing_tests/restriction_test.cpp
+++ b/routing/routing_tests/restriction_test.cpp
@@ -1,5 +1,7 @@
#include "testing/testing.hpp"
+#include "generator/generator_tests/routing_tools.hpp"
+
#include "routing/routing_tests/index_graph_tools.hpp"
#include "routing/fake_ending.hpp"
diff --git a/routing/routing_tests/road_access_test.cpp b/routing/routing_tests/road_access_test.cpp
index 15ab54cafa..edcabd7fb4 100644
--- a/routing/routing_tests/road_access_test.cpp
+++ b/routing/routing_tests/road_access_test.cpp
@@ -2,7 +2,8 @@
#include "routing/road_access.hpp"
#include "routing/road_access_serialization.hpp"
-#include "routing/routing_tests/index_graph_tools.hpp"
+
+#include "routing_common/index_graph_tools.hpp"
#include "coding/reader.hpp"
#include "coding/writer.hpp"