27 #include "ns3/boolean.h"
28 #include "ns3/simulator.h"
29 #include "ns3/scheduler.h"
30 #include "ns3/vector.h"
31 #include "ns3/mobility-model.h"
32 #include "ns3/waypoint-mobility-model.h"
33 #include "ns3/mobility-helper.h"
46 void TestXPosition (
double expectedXPos);
48 virtual void DoRun (
void);
54 WaypointLazyNotifyFalse::WaypointLazyNotifyFalse ()
55 :
TestCase (
"Test behavior when LazyNotify is false"),
60 WaypointLazyNotifyFalse::~WaypointLazyNotifyFalse ()
65 WaypointLazyNotifyFalse::TestXPosition (
double expectedXPos)
68 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.
x, expectedXPos, 0.001,
"Position not equal", __FILE__, __LINE__);
75 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (m_courseChanges * 10.0, Simulator::Now ().GetSeconds (), 0.001,
"Course change not notified correctly", __FILE__, __LINE__);
82 m_node = CreateObject<Node> ();
83 m_mob = CreateObject<WaypointMobilityModel> ();
87 m_mob->AddWaypoint (wpt);
89 m_mob->AddWaypoint (wpt2);
91 m_mob->AddWaypoint (wpt3);
93 Simulator::Schedule (
Seconds (5.0), &WaypointLazyNotifyFalse::TestXPosition,
this, 5);
95 Simulator::Destroy ();
105 void TestXPosition (
double expectedXPos);
107 virtual void DoRun (
void);
112 WaypointLazyNotifyTrue::WaypointLazyNotifyTrue ()
113 :
TestCase (
"Test behavior when LazyNotify is true")
117 WaypointLazyNotifyTrue::~WaypointLazyNotifyTrue ()
122 WaypointLazyNotifyTrue::TestXPosition (
double expectedXPos)
125 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.
x, expectedXPos, 0.001,
"Position not equal", __FILE__, __LINE__);
133 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (15, Simulator::Now ().GetSeconds (), 0.001,
"Course change not notified correctly", __FILE__, __LINE__);
139 m_node = CreateObject<Node> ();
140 m_mob = CreateObject<WaypointMobilityModel> ();
144 m_mob->AddWaypoint (wpt);
146 m_mob->AddWaypoint (wpt2);
148 m_mob->AddWaypoint (wpt3);
150 Simulator::Schedule (
Seconds (15.0), &WaypointLazyNotifyTrue::TestXPosition,
this, 15);
152 Simulator::Destroy ();
164 virtual void DoRun (
void);
172 WaypointInitialPositionIsWaypoint::WaypointInitialPositionIsWaypoint ()
173 :
TestCase (
"Test behavior of Waypoint InitialPositionIsWaypoint")
177 WaypointInitialPositionIsWaypoint::~WaypointInitialPositionIsWaypoint ()
185 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.
x, expectedXPos, 0.001,
"Position not equal", __FILE__, __LINE__);
191 NS_TEST_EXPECT_MSG_EQ (model->
WaypointsLeft (), num,
"Unexpected number of waypoints left");
200 m_mob1 = CreateObject<WaypointMobilityModel> ();
204 Simulator::Schedule (
Seconds (1.0), &WaypointInitialPositionIsWaypoint::TestNumWaypoints,
this, m_mob1, 0);
206 Simulator::Schedule (
Seconds (15.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob1, 10.0);
210 m_mob2 = CreateObject<WaypointMobilityModel> ();
219 Simulator::Schedule (
Seconds (3.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob2, 10.0);
220 Simulator::Schedule (
Seconds (3.0), &WaypointInitialPositionIsWaypoint::TestNumWaypoints,
this, m_mob2, 1);
224 Simulator::Schedule (
Seconds (8.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob2, 18.0);
225 Simulator::Schedule (
Seconds (8.0), &WaypointInitialPositionIsWaypoint::TestNumWaypoints,
this, m_mob2, 0);
229 m_mob3 = CreateObject<WaypointMobilityModel> ();
233 Simulator::Schedule (
Seconds (1.0), &WaypointInitialPositionIsWaypoint::TestNumWaypoints,
this, m_mob3, 0);
235 Simulator::Schedule (
Seconds (15.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob3, 10.0);
239 m_mob4 = CreateObject<WaypointMobilityModel> ();
250 Simulator::Schedule (
Seconds (3.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob4, 10.0);
251 Simulator::Schedule (
Seconds (3.0), &WaypointInitialPositionIsWaypoint::TestNumWaypoints,
this, m_mob4, 1);
253 Simulator::Schedule (
Seconds (6.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob4, 16.0);
255 Simulator::Schedule (
Seconds (15.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob4, 20.0);
259 m_mob5 = CreateObject<WaypointMobilityModel> ();
273 Simulator::Schedule (
Seconds (3.0), &WaypointInitialPositionIsWaypoint::TestXPosition,
this, m_mob5, 10.0);
276 Simulator::Destroy ();
287 virtual void DoRun (
void);
290 WaypointMobilityModelViaHelper::WaypointMobilityModelViaHelper ()
291 :
TestCase (
"Test behavior using MobilityHelper and PositionAllocator")
295 WaypointMobilityModelViaHelper::~WaypointMobilityModelViaHelper ()
303 NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.
x, expectedXPos, 0.001,
"Position not equal", __FILE__, __LINE__);
314 positionAlloc->
Add (
Vector (0.0, 0.0, 0.0));
331 Simulator::Schedule (
Seconds (3), &WaypointMobilityModelViaHelper::TestXPosition,
this, mob, 20);
333 Simulator::Schedule (
Seconds (7.5), &WaypointMobilityModelViaHelper::TestXPosition,
this, mob, 15);
342 positionAlloc2->
Add (
Vector (0.0, 0.0, 0.0));
351 Simulator::Schedule (
Seconds (3), &WaypointMobilityModelViaHelper::TestXPosition,
this, mob2, 12);
354 Simulator::Destroy ();
363 MobilityTestSuite::MobilityTestSuite ()
smart pointer class similar to boost::intrusive_ptr
void AddWaypoint(const Waypoint &waypoint)
Vector GetPosition(void) const
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
virtual void DoRun(void)
Implementation to actually run this test case.
void AggregateObject(Ptr< Object > other)
virtual void DoRun(void)
Implementation to actually run this test case.
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
void SetPosition(const Vector &position)
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Waypoint-based mobility model.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Ptr< T > GetObject(void) const
uint32_t WaypointsLeft(void) const