Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OpenSCENARIO1_Engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Bauer
OpenSCENARIO1_Engine
Commits
e806e4cf
Commit
e806e4cf
authored
2 years ago
by
Baljeet Singh
Browse files
Options
Downloads
Patches
Plain Diff
add waypoints to test
parent
9186c56f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/AssignRouteActionTest.cpp
+75
-9
75 additions, 9 deletions
test/AssignRouteActionTest.cpp
with
75 additions
and
9 deletions
test/AssignRouteActionTest.cpp
+
75
−
9
View file @
e806e4cf
...
...
@@ -13,9 +13,9 @@
#include
"builders/ActionBuilder.h"
#include
"builders/PositionBuilder.h"
#include
<openScenarioLib/generated/v1_1/impl/OpenScenarioWriterFactoryImplV1_1.h>
#include
<MantleAPI/Common/vector.h>
#include
<gtest/gtest.h>
#include
<openScenarioLib/generated/v1_1/impl/OpenScenarioWriterFactoryImplV1_1.h>
namespace
OPENSCENARIO
{
...
...
@@ -27,23 +27,89 @@ class AssignRouteActionTestFixture : public OpenScenarioEngineLibraryTestBase
void
SetUp
()
override
{
OpenScenarioEngineLibraryTestBase
::
SetUp
();
}
};
MATCHER_P
(
IsControlStrategySame
,
control_strategies
,
"Waypoints do not match"
)
{
bool
are_waypoints_equal
=
false
;
for
(
size_t
i
=
0
;
i
<
control_strategies
.
size
();
++
i
)
{
auto
follow_route_control_strategy
=
std
::
dynamic_pointer_cast
<
mantle_api
::
FollowRouteControlStrategy
>
(
control_strategies
.
at
(
i
));
auto
arg_ptr
=
std
::
dynamic_pointer_cast
<
mantle_api
::
FollowRouteControlStrategy
>
(
arg
.
at
(
i
));
if
(
follow_route_control_strategy
!=
nullptr
&&
arg_ptr
!=
nullptr
)
{
for
(
size_t
j
=
0
;
j
<
follow_route_control_strategy
->
waypoints
.
size
();
++
j
)
{
are_waypoints_equal
=
(
arg_ptr
->
waypoints
.
at
(
j
).
x
==
follow_route_control_strategy
->
waypoints
.
at
(
j
).
x
&&
arg_ptr
->
waypoints
.
at
(
j
).
y
==
follow_route_control_strategy
->
waypoints
.
at
(
j
).
y
&&
arg_ptr
->
waypoints
.
at
(
j
).
z
==
follow_route_control_strategy
->
waypoints
.
at
(
j
).
z
);
if
(
are_waypoints_equal
==
true
)
{
continue
;
}
else
{
return
false
;
}
}
}
else
{
return
false
;
}
}
return
true
;
}
TEST_F
(
AssignRouteActionTestFixture
,
GivenAssignRouteAction_WhenStartAction_ThenControlStrategySetAndNoExceptionInStep
)
{
using
namespace
OPENSCENARIO
::
TESTING
;
NET_ASAM_OPENSCENARIO
::
v1_1
::
OpenScenarioWriterFactoryImpl
open_scenario_writer_factory_impl
;
auto
fake_assign_route_action
=
FakeAssignRouteActionBuilder
{}
.
WithRoute
(
open_scenario_writer_factory_impl
.
CreateRouteWriter
())
.
Build
();
using
namespace
OPENSCENARIO
::
TESTING
;
auto
fake_assign_route_action
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
AssignRouteActionImpl
>
();
auto
route
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
RouteImpl
>
();
auto
way_point_one
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
WaypointImpl
>
();
auto
way_point_two
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
WaypointImpl
>
();
auto
position_one
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
PositionImpl
>
();
auto
position_two
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
PositionImpl
>
();
auto
world_position_one
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
WorldPositionImpl
>
();
auto
world_position_two
=
std
::
make_shared
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
WorldPositionImpl
>
();
world_position_one
->
SetX
(
1.0
);
world_position_one
->
SetY
(
0.0
);
world_position_one
->
SetZ
(
0.0
);
world_position_two
->
SetX
(
42.0
);
world_position_two
->
SetY
(
0.0
);
world_position_two
->
SetZ
(
10.0
);
position_one
->
SetWorldPosition
(
world_position_one
);
position_two
->
SetWorldPosition
(
world_position_two
);
way_point_one
->
SetPosition
(
position_one
);
way_point_two
->
SetPosition
(
position_two
);
std
::
vector
<
std
::
shared_ptr
<
NET_ASAM_OPENSCENARIO
::
v1_1
::
IWaypointWriter
>>
route_way_points
=
{
way_point_one
,
way_point_two
};
route
->
SetWaypoints
(
route_way_points
);
fake_assign_route_action
->
SetRoute
(
route
);
OPENSCENARIO
::
AssignRouteAction
assign_route_action
{
fake_assign_route_action
,
env_
,
std
::
vector
<
std
::
string
>
{
"Ego"
}};
OPENSCENARIO
::
AssignRouteAction
assign_route_action
{
fake_assign_route_action
,
env_
,
std
::
vector
<
std
::
string
>
{
"Ego"
}};
std
::
vector
<
std
::
shared_ptr
<
mantle_api
::
ControlStrategy
>>
control_strategies
{};
auto
route_control_strategy
=
std
::
make_unique
<
mantle_api
::
FollowRouteControlStrategy
>
();
route_control_strategy
->
waypoints
.
push_back
(
mantle_api
::
Vec3
<
units
::
length
::
meter_t
>
{
1
_m
,
0
_m
,
0
_m
});
route_control_strategy
->
waypoints
.
push_back
(
mantle_api
::
Vec3
<
units
::
length
::
meter_t
>
{
42
_m
,
0
_m
,
10
_m
});
control_strategies
.
push_back
(
std
::
move
(
route_control_strategy
));
EXPECT_CALL
(
*
env_
,
UpdateControlStrategies
(
testing
::
_
,
testing
::
_
))
EXPECT_CALL
(
*
env_
,
UpdateControlStrategies
(
testing
::
_
,
IsControlStrategySame
(
control_strategies
)))
.
WillOnce
(
testing
::
SaveArg
<
1
>
(
&
control_strategies
));
assign_route_action
.
Start
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment