Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::TcpIfTest Class Reference
Inheritance diagram for openlcb::TcpIfTest:
openlcb::MultiTcpIfTest openlcb::TcpNodeTest

Protected Member Functions

void wait ()
 
void capture_next_packet ()
 Instructs the mock device to save the next sent packet.
 
void ignore_all_packets ()
 Instructs the mock device to ignore all sent packets.
 
void capture_all_packets ()
 Instructs the mock device to ignore all sent packets.
 
template<typename... Args>
void generate_input_message (Args &&... args)
 Creates a GenMessage, renders it to binary format, and injects it as if it came as an input from the network.
 
template<typename... Args>
void generate_output_message (Args &&... args)
 Creates a GenMessage and sends it out via the IfTcp.
 
template<typename... Args>
void generate_output_message (IfTcp *iface, Args &&... args)
 Creates a GenMessage and sends it out via the IfTcp.
 
template<class NodeType = DefaultNode>
Nodecreate_new_node (std::unique_ptr< NodeType > *p, NodeID node_id, IfTcp *iface=nullptr)
 Helper function to create a new virtual node.
 
BarrierNotifiableget_notifiable ()
 
void wait_for_notification ()
 

Protected Attributes

SyncNotifiable n_
 
BarrierNotifiable bn_
 
HubFlow device_ {&g_service}
 
::testing::StrictMock< MockHubPortlistenPort_
 
string lastPacket_
 Stores the data from capture_next_packet.
 
vector< string > allPackets_
 Stores data from capture all packets.
 
IfTcp ifTcp_ {GW_NODE_ID, &device_, local_node_count}
 

Static Protected Attributes

static int local_node_count = 9
 
static constexpr NodeID TEST_NODE_ID = 0x101212231225ULL
 
static constexpr NodeID REMOTE_NODE_ID = 0x050902030405ULL
 
static constexpr NodeID INPUT_GW_NODE_ID = 0x101112131415ULL
 
static constexpr NodeID GW_NODE_ID = 0x101112131415ULL
 

Detailed Description

Definition at line 40 of file if_tcp_test_helper.hxx.

Constructor & Destructor Documentation

◆ TcpIfTest()

openlcb::TcpIfTest::TcpIfTest ( )
inlineprotected

Definition at line 45 of file if_tcp_test_helper.hxx.

◆ ~TcpIfTest()

openlcb::TcpIfTest::~TcpIfTest ( )
inlineprotected

Definition at line 50 of file if_tcp_test_helper.hxx.

Member Function Documentation

◆ capture_all_packets()

void openlcb::TcpIfTest::capture_all_packets ( )
inlineprotected

Instructs the mock device to ignore all sent packets.

Definition at line 75 of file if_tcp_test_helper.hxx.

◆ capture_next_packet()

void openlcb::TcpIfTest::capture_next_packet ( )
inlineprotected

Instructs the mock device to save the next sent packet.

Definition at line 62 of file if_tcp_test_helper.hxx.

◆ create_new_node()

template<class NodeType = DefaultNode>
Node * openlcb::TcpIfTest::create_new_node ( std::unique_ptr< NodeType > *  p,
NodeID  node_id,
IfTcp iface = nullptr 
)
inlineprotected

Helper function to create a new virtual node.

Parameters
pis the pointer where the node objects' ownership will be transferred.
node_idis the id of the new node.
ifacethe TCP interface to which to bind the node. nullptr = the default interface of the test.
Returns
the new node pointer.

Definition at line 143 of file if_tcp_test_helper.hxx.

◆ generate_input_message()

template<typename... Args>
void openlcb::TcpIfTest::generate_input_message ( Args &&...  args)
inlineprotected

Creates a GenMessage, renders it to binary format, and injects it as if it came as an input from the network.

Parameters
argssame arguments as GenMessage::reset(). Example reset(Defs::MTI_EVENT_REPORT, TEST_NODE_ID, eventid_to_buffer(UINT64_C(0x0102030405060708)));

Definition at line 87 of file if_tcp_test_helper.hxx.

◆ generate_output_message() [1/2]

template<typename... Args>
void openlcb::TcpIfTest::generate_output_message ( Args &&...  args)
inlineprotected

Creates a GenMessage and sends it out via the IfTcp.

Parameters
argssame arguments as GenMessage::reset(). Example reset(Defs::MTI_EVENT_REPORT, TEST_NODE_ID, eventid_to_buffer(UINT64_C(0x0102030405060708)));

Definition at line 102 of file if_tcp_test_helper.hxx.

◆ generate_output_message() [2/2]

template<typename... Args>
void openlcb::TcpIfTest::generate_output_message ( IfTcp iface,
Args &&...  args 
)
inlineprotected

Creates a GenMessage and sends it out via the IfTcp.

Parameters
argssame arguments as GenMessage::reset(). Example reset(Defs::MTI_EVENT_REPORT, TEST_NODE_ID, eventid_to_buffer(UINT64_C(0x0102030405060708)));

Definition at line 112 of file if_tcp_test_helper.hxx.

◆ get_notifiable()

BarrierNotifiable * openlcb::TcpIfTest::get_notifiable ( )
inlineprotected

Definition at line 159 of file if_tcp_test_helper.hxx.

◆ ignore_all_packets()

void openlcb::TcpIfTest::ignore_all_packets ( )
inlineprotected

Instructs the mock device to ignore all sent packets.

Definition at line 69 of file if_tcp_test_helper.hxx.

◆ wait()

void openlcb::TcpIfTest::wait ( )
inlineprotected

Definition at line 56 of file if_tcp_test_helper.hxx.

◆ wait_for_notification()

void openlcb::TcpIfTest::wait_for_notification ( )
inlineprotected

Definition at line 165 of file if_tcp_test_helper.hxx.

Member Data Documentation

◆ allPackets_

vector<string> openlcb::TcpIfTest::allPackets_
protected

Stores data from capture all packets.

Definition at line 177 of file if_tcp_test_helper.hxx.

◆ bn_

BarrierNotifiable openlcb::TcpIfTest::bn_
protected

Definition at line 171 of file if_tcp_test_helper.hxx.

◆ device_

HubFlow openlcb::TcpIfTest::device_ {&g_service}
protected

Definition at line 172 of file if_tcp_test_helper.hxx.

◆ GW_NODE_ID

constexpr NodeID openlcb::TcpIfTest::GW_NODE_ID = 0x101112131415ULL
staticconstexprprotected

Definition at line 182 of file if_tcp_test_helper.hxx.

◆ ifTcp_

IfTcp openlcb::TcpIfTest::ifTcp_ {GW_NODE_ID, &device_, local_node_count}
protected

Definition at line 184 of file if_tcp_test_helper.hxx.

◆ INPUT_GW_NODE_ID

constexpr NodeID openlcb::TcpIfTest::INPUT_GW_NODE_ID = 0x101112131415ULL
staticconstexprprotected

Definition at line 181 of file if_tcp_test_helper.hxx.

◆ lastPacket_

string openlcb::TcpIfTest::lastPacket_
protected

Stores the data from capture_next_packet.

Definition at line 175 of file if_tcp_test_helper.hxx.

◆ listenPort_

::testing::StrictMock<MockHubPort> openlcb::TcpIfTest::listenPort_
protected

Definition at line 173 of file if_tcp_test_helper.hxx.

◆ local_node_count

int openlcb::TcpIfTest::local_node_count = 9
staticprotected

Definition at line 43 of file if_tcp_test_helper.hxx.

◆ n_

SyncNotifiable openlcb::TcpIfTest::n_
protected

Definition at line 170 of file if_tcp_test_helper.hxx.

◆ REMOTE_NODE_ID

constexpr NodeID openlcb::TcpIfTest::REMOTE_NODE_ID = 0x050902030405ULL
staticconstexprprotected

Definition at line 180 of file if_tcp_test_helper.hxx.

◆ TEST_NODE_ID

constexpr NodeID openlcb::TcpIfTest::TEST_NODE_ID = 0x101212231225ULL
staticconstexprprotected

Definition at line 179 of file if_tcp_test_helper.hxx.


The documentation for this class was generated from the following file: