Skip to content

Commit b75face

Browse files
strongly-typedsalkinium
authored andcommitted
[tests] Rename FakeCanDriver to CanDriver
and move it to modm_test::platform namespace
1 parent 61dec0a commit b75face

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

test/modm/communication/xpcc/backend/can/can_connector_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CanConnectorTest::createMessage(modm::can::Message& message,
6969
void
7070
CanConnectorTest::setUp()
7171
{
72-
this->driver = new FakeCanDriver();
72+
this->driver = new modm_test::platform::CanDriver();
7373
this->connector = new TestingCanConnector(this->driver);
7474
}
7575

test/modm/communication/xpcc/backend/can/can_connector_test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CanConnectorTest : public unittest::TestSuite
6161

6262
private:
6363
TestingCanConnector *connector;
64-
FakeCanDriver *driver;
64+
modm_test::platform::CanDriver *driver;
6565

6666
xpcc::Header xpccHeader;
6767
uint32_t normalIdentifier;

test/modm/communication/xpcc/backend/can/fake_can_driver.cpp renamed to test/modm/communication/xpcc/backend/can/can_driver.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2009-2010, Fabian Greif
33
* Copyright (c) 2012-2014, Niklas Hauser
4-
* Copyright (c) 2015, Sascha Schade
4+
* Copyright (c) 2015-2020, Sascha Schade
55
*
66
* This file is part of the modm project.
77
*
@@ -11,21 +11,21 @@
1111
*/
1212
// ----------------------------------------------------------------------------
1313

14-
#include "fake_can_driver.hpp"
14+
#include "can_driver.hpp"
1515

16-
FakeCanDriver::FakeCanDriver() :
16+
modm_test::platform::CanDriver::CanDriver() :
1717
sendSlots(0)
1818
{
1919
}
2020

2121
bool
22-
FakeCanDriver::isMessageAvailable()
22+
modm_test::platform::CanDriver::isMessageAvailable()
2323
{
2424
return (not receiveList.isEmpty());
2525
}
2626

2727
bool
28-
FakeCanDriver::getMessage(modm::can::Message& message)
28+
modm_test::platform::CanDriver::getMessage(modm::can::Message& message)
2929
{
3030
if (isMessageAvailable())
3131
{
@@ -40,13 +40,13 @@ FakeCanDriver::getMessage(modm::can::Message& message)
4040
}
4141

4242
bool
43-
FakeCanDriver::isReadyToSend()
43+
modm_test::platform::CanDriver::isReadyToSend()
4444
{
4545
return (this->sendSlots > 0);
4646
}
4747

4848
bool
49-
FakeCanDriver::sendMessage(const modm::can::Message& message)
49+
modm_test::platform::CanDriver::sendMessage(const modm::can::Message& message)
5050
{
5151
if (this->isReadyToSend())
5252
{
@@ -60,19 +60,19 @@ FakeCanDriver::sendMessage(const modm::can::Message& message)
6060
}
6161

6262
uint8_t
63-
FakeCanDriver::getReceiveErrorCounter()
63+
modm_test::platform::CanDriver::getReceiveErrorCounter()
6464
{
6565
return 0;
6666
}
6767

6868
uint8_t
69-
FakeCanDriver::getTransmitErrorCounter()
69+
modm_test::platform::CanDriver::getTransmitErrorCounter()
7070
{
7171
return 0;
7272
}
7373

7474
modm::Can::BusState
75-
FakeCanDriver::getBusState()
75+
modm_test::platform::CanDriver::getBusState()
7676
{
7777
return modm::Can::BusState::Connected;
7878
}

test/modm/communication/xpcc/backend/can/fake_can_driver.hpp renamed to test/modm/communication/xpcc/backend/can/can_driver.hpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2009-2010, Martin Rosekeit
33
* Copyright (c) 2009-2011, Fabian Greif
44
* Copyright (c) 2012-2014, Niklas Hauser
5+
* Copyright (c) 2020, Sascha Schade
56
*
67
* This file is part of the modm project.
78
*
@@ -11,17 +12,27 @@
1112
*/
1213
// ----------------------------------------------------------------------------
1314

14-
#ifndef FAKE_CAN_DRIVER_HPP
15-
#define FAKE_CAN_DRIVER_HPP
15+
#ifndef MODM_TEST_MOCK_CAN_DRIVER_HPP
16+
#define MODM_TEST_MOCK_CAN_DRIVER_HPP
1617

17-
#include <modm/container/linked_list.hpp>
1818
#include <modm/architecture/interface/can.hpp>
19+
#include <modm/container/linked_list.hpp>
20+
21+
namespace modm_test
22+
{
23+
24+
namespace platform
25+
{
1926

20-
/// @ingroup modm_test_test_communication
21-
class FakeCanDriver : public modm::Can
27+
/**
28+
* Mock CAN peripheral interface for unittests.
29+
*
30+
* @ingroup modm_test_mock_can
31+
*/
32+
class CanDriver : public modm::Can
2233
{
2334
public:
24-
FakeCanDriver();
35+
CanDriver();
2536

2637
bool
2738
isMessageAvailable();
@@ -55,4 +66,8 @@ class FakeCanDriver : public modm::Can
5566
uint8_t sendSlots;
5667
};
5768

58-
#endif // FAKE_CAN_DRIVER_HPP
69+
} // namespace platform
70+
71+
} // namespace modm_test
72+
73+
#endif // MODM_TEST_MOCK_CAN_DRIVER_HPP

test/modm/communication/xpcc/backend/can/testing_can_connector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "testing_can_connector.hpp"
1616

17-
TestingCanConnector::TestingCanConnector(FakeCanDriver *driver) :
18-
xpcc::CanConnector<FakeCanDriver>(driver)
17+
TestingCanConnector::TestingCanConnector(modm_test::platform::CanDriver *driver) :
18+
xpcc::CanConnector<modm_test::platform::CanDriver>(driver)
1919
{
2020
}

test/modm/communication/xpcc/backend/can/testing_can_connector.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
#include <modm/communication/xpcc/backend/can/connector.hpp>
1919

20-
#include "fake_can_driver.hpp"
20+
#include "can_driver.hpp"
2121

2222
/// @ingroup modm_test_test_communication
23-
class TestingCanConnector : public xpcc::CanConnector<FakeCanDriver>
23+
class TestingCanConnector : public xpcc::CanConnector<modm_test::platform::CanDriver>
2424
{
2525
public:
26-
TestingCanConnector(FakeCanDriver *driver);
26+
TestingCanConnector(modm_test::platform::CanDriver *driver);
2727

2828
// expose the internal variable for testing
29-
using xpcc::CanConnector<FakeCanDriver>::messageCounter;
29+
using xpcc::CanConnector<modm_test::platform::CanDriver>::messageCounter;
3030
};
3131

3232
#endif // TESTING_CAN_CONNECTOR_HPP

0 commit comments

Comments
 (0)