|
Open Model Railroad Network (OpenMRN)
|
Test fixture base class for tests that need a CAN-based interface(but not necessary specific to OpenLCB). More...
#include <async_if_test_helper.hxx>
Static Public Member Functions | |
| static void | SetUpTestCase () |
| Initializes test case with CAN0. | |
| static void | TearDownTestCase () |
| De-Initializes test case with CAN0. | |
Protected Member Functions | |
| void | wait () |
| Delays the current thread until we are certain that all asynchrnous processing has completed. | |
| void | twait () |
| Delays the current thread until all asynchronous processing and all pending timers have completed. | |
| void | expect_any_packet () |
| Ignores all produced packets. | |
| void | print_all_packets () |
| Prints all packets sent to the canbus until the end of the current test function. | |
| void | send_packet (const string &gc_packet) |
| Injects a packet to the interface. | |
| void | clear_expect (bool strict=false) |
| Clears all existing expectations on the CAN-bus packets. | |
| void | send_packet_and_flush_expect (const string &pkt) |
| Sends a packet to the canbus, waits for the executor to clear, and then verifies all previous expectations. | |
Protected Attributes | |
| NiceMock< MockSend > | canBus_ |
| Helper object for setting expectations on the packets sent on the bus. | |
| std::unique_ptr< HubPort > | printer_ |
| Object for debug-printing every packet (if requested). | |
Test fixture base class for tests that need a CAN-based interface(but not necessary specific to OpenLCB).
The direct use of this class is useful only when other CAN-based protocol flows need to be tested. The OpenLCB test fixtures are inheriting from this class.
Definition at line 86 of file async_if_test_helper.hxx.
|
inlineprotected |
Definition at line 105 of file async_if_test_helper.hxx.
|
inlineprotected |
Definition at line 110 of file async_if_test_helper.hxx.
|
inlineprotected |
Clears all existing expectations on the CAN-bus packets.
Usually means that all previously expressed expectations must have been met by this point.
| strict | if true, does not allow any unknown/unexpected/spurious packets to have arrived; i.e., fails the test if there was a packet coming with no expectation. |
Definition at line 226 of file async_if_test_helper.hxx.
|
inlineprotected |
Ignores all produced packets.
Tihs can be used in tests where the expectations are tested in a higher level than monitoring the CANbus traffic.
Definition at line 180 of file async_if_test_helper.hxx.
|
inlineprotected |
Prints all packets sent to the canbus until the end of the current test function.
Definition at line 190 of file async_if_test_helper.hxx.
|
inlineprotected |
Injects a packet to the interface.
This acts as if a different node on the CANbus had sent that packet.
Example: send_packet(":X195B4001N05010101FFFF0000;");
| gc_packet | the packet in GridConnect format, including the leading : and trailing ; |
Definition at line 209 of file async_if_test_helper.hxx.
|
inlineprotected |
Sends a packet to the canbus, waits for the executor to clear, and then verifies all previous expectations.
| pkt | gridconnnect-formatted packet to send. |
Definition at line 258 of file async_if_test_helper.hxx.
|
inlinestatic |
Initializes test case with CAN0.
Note: if a child test implements SetUpTestCase themself, they must ensure to call this function.
Definition at line 91 of file async_if_test_helper.hxx.
|
inlinestatic |
De-Initializes test case with CAN0.
Note: if a child test implements TearDownTestCase themself, they must ensure to call this function.
Definition at line 99 of file async_if_test_helper.hxx.
|
inlineprotected |
Delays the current thread until all asynchronous processing and all pending timers have completed.
Definition at line 128 of file async_if_test_helper.hxx.
|
inlineprotected |
Delays the current thread until we are certain that all asynchrnous processing has completed.
Definition at line 121 of file async_if_test_helper.hxx.
|
protected |
Helper object for setting expectations on the packets sent on the bus.
Definition at line 266 of file async_if_test_helper.hxx.
|
protected |
Object for debug-printing every packet (if requested).
Definition at line 268 of file async_if_test_helper.hxx.