Inheritance diagram for Protocols::BitTorrent::Transfers::Testing::PacketSessionTest:


PacketSession is an aggregate that combines a number of components without implementing new functionality itself. We use a combination of mocks and stubs to perform the tests. We mock the required interface SessionStatus and we stub the Transport interface because we do not care in with exactly what sequence of read, peek and write operations are called. Instead we are only interested in the state of the read and write buffers after packets have been read or written.
Most of the functionality of PacketSession has already been tested by the tests of GenericSession. Now we only need to once again test functionality that is spread over more than one of the components we are integrating.
Here we have the packet reading/writing funtionality that is spread this way. We want to make sure that PacketSession does read and write the type of packets (BitTorrent packets and not Gnutella packets) that it is supposed to. We run just a few test to make sure that the simple cases of reading/writing one and two packets with/without buffering work and we assume that the more complex will work too.
We also want to verify that the correct DataQueue is aggregated - FifoQueue in our case, so buffered packets should be written in the order in which they were buffered.
The TransportStatus notifications connected() and disconnected() and handled solely by GenericSession, so there are no potential integration problems.
Definition at line 62 of file PacketSessionTest.cpp.
Public Member Functions | |
| PacketSessionTest () | |
| Default constructor. | |
| void | setUp () |
| void | tearDown () |
| void | stateOpenedSession () |
| Drive session to the state OpenedSession. | |
| void | testReadNothing () |
| When not bytes are buffered in Transport, nothing can be read. | |
| void | testReadOnePacket () |
| When exactly one packet is buffered in Transport, it should be read. | |
| void | testReadTwoPackets () |
| When exactly two packets are buffered in Transport, both should be read. | |
| void | testReadOnePacketAndHalfPacketStillBuffered () |
| When one and a half packet are buffered in Transport, only one is read. | |
| void | testSendPacketWritesPacketDirectly () |
| Sending a packet results in writing it directly to Transport. | |
| void | testSendTwoPacketsBuffersThem () |
| When no bytes can be written to Transport, the packets will be buffered. | |
| void | testSendTwoPacketsBuffersThemThenWritesThem () |
| Buffered packets will be written when Transport's write buffer is free. | |
Private Member Functions | |
| PacketSessionTest (const PacketSessionTest &) | |
| PacketSessionTest & | operator= (const PacketSessionTest &) |
| CPPUNIT_TEST_SUITE (PacketSessionTest) | |
| CPPUNIT_TEST (testReadNothing) | |
| CPPUNIT_TEST (testReadOnePacket) | |
| CPPUNIT_TEST (testReadTwoPackets) | |
| CPPUNIT_TEST (testReadOnePacketAndHalfPacketStillBuffered) | |
| CPPUNIT_TEST (testSendPacketWritesPacketDirectly) | |
| CPPUNIT_TEST (testSendTwoPacketsBuffersThem) | |
| CPPUNIT_TEST (testSendTwoPacketsBuffersThemThenWritesThem) | |
| CPPUNIT_TEST_SUITE_END () | |
Private Attributes | |
| TransportStub * | transport |
| auto_ptr< SessionStatusMock > | status |
| auto_ptr< PacketSession > | sessionReal |
| auto_ptr< PacketSessionDriver > | session |
| const Packet | packet1 |
| const Packet | packet2 |
| const QByteArray | halfPacketBytes |
|
|
|
|
|
Default constructor.
Definition at line 88 of file PacketSessionTest.cpp. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 94 of file PacketSessionTest.cpp. |
|
|
Drive session to the state OpenedSession.
Definition at line 112 of file PacketSessionTest.cpp. |
|
|
Definition at line 103 of file PacketSessionTest.cpp. |
|
|
When not bytes are buffered in Transport, nothing can be read.
Definition at line 119 of file PacketSessionTest.cpp. |
|
|
When exactly one packet is buffered in Transport, it should be read.
Definition at line 128 of file PacketSessionTest.cpp. |
|
|
When one and a half packet are buffered in Transport, only one is read.
Definition at line 161 of file PacketSessionTest.cpp. |
|
|
When exactly two packets are buffered in Transport, both should be read.
Definition at line 144 of file PacketSessionTest.cpp. |
|
|
Sending a packet results in writing it directly to Transport.
Definition at line 176 of file PacketSessionTest.cpp. |
|
|
When no bytes can be written to Transport, the packets will be buffered.
Definition at line 191 of file PacketSessionTest.cpp. |
|
|
Buffered packets will be written when Transport's write buffer is free.
Definition at line 210 of file PacketSessionTest.cpp. |
|
|
Definition at line 84 of file PacketSessionTest.cpp. |
|
|
Definition at line 82 of file PacketSessionTest.cpp. |
|
|
Definition at line 83 of file PacketSessionTest.cpp. |
|
|
Definition at line 80 of file PacketSessionTest.cpp. |
|
|
Definition at line 79 of file PacketSessionTest.cpp. |
|
|
Definition at line 78 of file PacketSessionTest.cpp. |
|
|
Definition at line 77 of file PacketSessionTest.cpp. |