Protocols::Generics::Testing::GenericSessionTest Class Reference

Inherits TestFixture.

Inheritance diagram for Protocols::Generics::Testing::GenericSessionTest:

Inheritance graph
[legend]
Collaboration diagram for Protocols::Generics::Testing::GenericSessionTest:

Collaboration graph
[legend]
List of all members.

Detailed Description

Tests for the packet class PacketBuffer.

Todo:
test close() while inside the read notification

test abort() while inside the read notification

Definition at line 61 of file GenericSessionTest.cpp.

Public Member Functions

 GenericSessionTest ()
void setUp ()
void tearDown ()
void testOpenSessionStartsReading ()
 After the session is opened it will start reading data from Transport.
void stateSessionOpened ()
void refSentDataSerializedDirectly (const Data &data)
 No Data is buffered and the current one can be written directly.
void testSentDataSerializedDirectly ()
void refSentDataCannotBeSerializedMustBeQueued (const Data &data)
void testSentDataCannotBeSerializedMustBeQueued ()
void refSentDataIsBufferedDirectly (const Data &data)
 There already Data objects in the queue so we just enqueue data.
void testSentDataIsBufferedDirectly ()
void testSentTwoDatasThatGetQueued ()
void refWriteQueuedDatasOnReadyWrite (const QList< Data > &datas)
void testWriteQueuedDataOnReadyWrite ()
void testWriteTwoQueuedDatasOnReadyWrite ()
void testWriteQueuedDataOnReadyWriteFails ()
void testWriteTwoQueuedDatasOnReadyWriteSecondFails ()
void refReadDatasOnReadyRead (const QList< Data > &datas)
void testCannotReadPacketOnReadyRead ()
void testReadTwoPacketsOnReadyRead ()
void refCloseSessionDisconnectsTransportImmediately ()
 No Data objects are queued, so the transport can be disconnected.
void refCloseSessionDoesNotDisconnectTransportWhenQueueIsNotEmpty ()
void refTransportDisconnectedClosesTheSessionCompletely ()
void refTransportReadyWriteDisconnectsTransportWhenEmptyQueueAndClosing ()
void testCloseSessionDisconnectsTransportOnlyIfNothingToWrite ()
 If no more data is queued for writing, the Transport is disconnected.
void testCloseSessionDisconnectsTransportOnlyAfterQueueGetsEmpty ()
 After queued data is written, the Transport will be disconnected.
void testAbortSessionAbortsTransportAndClosesSession ()
void testCloseSessionFromSessionDataReceivedNotificationDisconnectDeferred ()
 Close session from withing the sessionReceivedData() notification.
void testAbortSessionFromSessionDataReceivedNotification ()

Private Member Functions

 CPPUNIT_TEST_SUITE (GenericSessionTest)
 CPPUNIT_TEST (testOpenSessionStartsReading)
 CPPUNIT_TEST (testSentDataSerializedDirectly)
 CPPUNIT_TEST (testSentDataCannotBeSerializedMustBeQueued)
 CPPUNIT_TEST (testSentDataIsBufferedDirectly)
 CPPUNIT_TEST (testSentTwoDatasThatGetQueued)
 CPPUNIT_TEST (testWriteQueuedDataOnReadyWrite)
 CPPUNIT_TEST (testWriteTwoQueuedDatasOnReadyWrite)
 CPPUNIT_TEST (testWriteQueuedDataOnReadyWriteFails)
 CPPUNIT_TEST (testWriteTwoQueuedDatasOnReadyWriteSecondFails)
 CPPUNIT_TEST (testCannotReadPacketOnReadyRead)
 CPPUNIT_TEST (testReadTwoPacketsOnReadyRead)
 CPPUNIT_TEST (testCloseSessionDisconnectsTransportOnlyIfNothingToWrite)
 CPPUNIT_TEST (testCloseSessionDisconnectsTransportOnlyAfterQueueGetsEmpty)
 CPPUNIT_TEST (testAbortSessionAbortsTransportAndClosesSession)
 CPPUNIT_TEST (testCloseSessionFromSessionDataReceivedNotificationDisconnectDeferred)
 CPPUNIT_TEST (testAbortSessionFromSessionDataReceivedNotification)
 CPPUNIT_TEST_SUITE_END ()

Private Attributes

auto_ptr< TransportMock > transport
auto_ptr< DataSerializerMock > serializer
auto_ptr< SessionStatusMock > status
auto_ptr< DataQueueMock > queue
auto_ptr< GenericSessionsessionReal
auto_ptr< GenericSessionDriver > session
const Data data1
const Data data2


Constructor & Destructor Documentation

Protocols::Generics::Testing::GenericSessionTest::GenericSessionTest  )  [inline]
 

Definition at line 93 of file GenericSessionTest.cpp.


Member Function Documentation

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testAbortSessionFromSessionDataReceivedNotification   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testCloseSessionFromSessionDataReceivedNotificationDisconnectDeferred   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testAbortSessionAbortsTransportAndClosesSession   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testCloseSessionDisconnectsTransportOnlyAfterQueueGetsEmpty   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testCloseSessionDisconnectsTransportOnlyIfNothingToWrite   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testReadTwoPacketsOnReadyRead   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testCannotReadPacketOnReadyRead   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testWriteTwoQueuedDatasOnReadyWriteSecondFails   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testWriteQueuedDataOnReadyWriteFails   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testWriteTwoQueuedDatasOnReadyWrite   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testWriteQueuedDataOnReadyWrite   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testSentTwoDatasThatGetQueued   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testSentDataIsBufferedDirectly   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testSentDataCannotBeSerializedMustBeQueued   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testSentDataSerializedDirectly   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST testOpenSessionStartsReading   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST_SUITE GenericSessionTest   )  [private]
 

Protocols::Generics::Testing::GenericSessionTest::CPPUNIT_TEST_SUITE_END  )  [private]
 

void Protocols::Generics::Testing::GenericSessionTest::refCloseSessionDisconnectsTransportImmediately  )  [inline]
 

No Data objects are queued, so the transport can be disconnected.

Definition at line 312 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refCloseSessionDoesNotDisconnectTransportWhenQueueIsNotEmpty  )  [inline]
 

Definition at line 324 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refReadDatasOnReadyRead const QList< Data > &  datas  )  [inline]
 

Definition at line 277 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refSentDataCannotBeSerializedMustBeQueued const Data data  )  [inline]
 

No Data objects are buffered but data cannot be written so it is has to be buffered.

Definition at line 169 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refSentDataIsBufferedDirectly const Data data  )  [inline]
 

There already Data objects in the queue so we just enqueue data.

If it were possible to write anything to transport then the queue would have been empty. Since this is not the case, we need not to try to write data but we simply add it to the queue.

Definition at line 195 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refSentDataSerializedDirectly const Data data  )  [inline]
 

No Data is buffered and the current one can be written directly.

Definition at line 147 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refTransportDisconnectedClosesTheSessionCompletely  )  [inline]
 

Definition at line 334 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refTransportReadyWriteDisconnectsTransportWhenEmptyQueueAndClosing  )  [inline]
 

Definition at line 342 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::refWriteQueuedDatasOnReadyWrite const QList< Data > &  datas  )  [inline]
 

Definition at line 220 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::setUp  )  [inline]
 

Definition at line 100 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::stateSessionOpened  )  [inline]
 

Definition at line 141 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::tearDown  )  [inline]
 

Definition at line 113 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testAbortSessionAbortsTransportAndClosesSession  )  [inline]
 

Definition at line 371 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testAbortSessionFromSessionDataReceivedNotification  )  [inline]
 

Definition at line 415 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testCannotReadPacketOnReadyRead  )  [inline]
 

Definition at line 299 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testCloseSessionDisconnectsTransportOnlyAfterQueueGetsEmpty  )  [inline]
 

After queued data is written, the Transport will be disconnected.

Definition at line 363 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testCloseSessionDisconnectsTransportOnlyIfNothingToWrite  )  [inline]
 

If no more data is queued for writing, the Transport is disconnected.

Definition at line 355 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testCloseSessionFromSessionDataReceivedNotificationDisconnectDeferred  )  [inline]
 

Close session from withing the sessionReceivedData() notification.

Disconnecting transport is deferred because queue is not empty. session enters the closing state and should continue to read Data objects via serializer.

Definition at line 393 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testOpenSessionStartsReading  )  [inline]
 

After the session is opened it will start reading data from Transport.

Note:
We do not need further tests where readPacket() succeeds because the implementation of connected() would call readyRead() which tests more cases.
Todo:
Should we require Transport to always signal readyRead() after connection is established?

Definition at line 131 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testReadTwoPacketsOnReadyRead  )  [inline]
 

Definition at line 305 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testSentDataCannotBeSerializedMustBeQueued  )  [inline]
 

Definition at line 183 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testSentDataIsBufferedDirectly  )  [inline]
 

Definition at line 207 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testSentDataSerializedDirectly  )  [inline]
 

Definition at line 159 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testSentTwoDatasThatGetQueued  )  [inline]
 

Definition at line 213 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testWriteQueuedDataOnReadyWrite  )  [inline]
 

Definition at line 253 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testWriteQueuedDataOnReadyWriteFails  )  [inline]
 

Definition at line 265 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testWriteTwoQueuedDatasOnReadyWrite  )  [inline]
 

Definition at line 259 of file GenericSessionTest.cpp.

void Protocols::Generics::Testing::GenericSessionTest::testWriteTwoQueuedDatasOnReadyWriteSecondFails  )  [inline]
 

Definition at line 271 of file GenericSessionTest.cpp.


Member Data Documentation

const Data Protocols::Generics::Testing::GenericSessionTest::data1 [private]
 

Definition at line 89 of file GenericSessionTest.cpp.

const Data Protocols::Generics::Testing::GenericSessionTest::data2 [private]
 

Definition at line 90 of file GenericSessionTest.cpp.

auto_ptr<DataQueueMock> Protocols::Generics::Testing::GenericSessionTest::queue [private]
 

Definition at line 85 of file GenericSessionTest.cpp.

auto_ptr<DataSerializerMock> Protocols::Generics::Testing::GenericSessionTest::serializer [private]
 

Definition at line 83 of file GenericSessionTest.cpp.

auto_ptr<GenericSessionDriver> Protocols::Generics::Testing::GenericSessionTest::session [private]
 

Definition at line 87 of file GenericSessionTest.cpp.

auto_ptr<GenericSession> Protocols::Generics::Testing::GenericSessionTest::sessionReal [private]
 

Definition at line 86 of file GenericSessionTest.cpp.

auto_ptr<SessionStatusMock> Protocols::Generics::Testing::GenericSessionTest::status [private]
 

Definition at line 84 of file GenericSessionTest.cpp.

auto_ptr<TransportMock> Protocols::Generics::Testing::GenericSessionTest::transport [private]
 

Definition at line 82 of file GenericSessionTest.cpp.


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