#include <PacketStub.h> [code]
Inherits Protocols::Generics::PacketBase.
Inheritance diagram for Protocols::Generics::Testing::PacketStub:


R1 A simple concrete Packet class is useful for unit tests.
U1.1 A concrete Packet object is needed to test the functionality implemented in the abstract base class.
U1.2 A concrete Packet object is needed as part of the controlled environment when unit testing another class.
Implements a very simple concrete packet. Header, payload and trailer are interpreted simply as raw byte buffers (QByteArray). You can use an object of this class for unit tests where a pointer/reference to Packet is required. If you use PacketStub together with PacketDriver you will have more control on the state and behavior of the PacketStub object.
In the ctor there is a special option (the last argument checkReadBytes), which controls the behavior of readHeader(), readPayload() and readTrailer(). Take a look at PacketStub::PacketStub() for more info.
Definition at line 53 of file PacketStub.h.
Public Member Functions | |
| PacketStub (const QByteArray &header=QByteArray(), const QByteArray &payload=QByteArray(), bool checkReadBytes=false) | |
| Constructs a PacketStub object. | |
| QString | name () const |
| Returns the name of the PacketBase type the dynamic object belongs to. | |
| QString | protocol () const |
| Returns the name of the protocol this PacketBase belongs to. | |
| auto_ptr< DataBase > | copy () const |
| Virtual copy constructor. | |
| bool | readHeader (const QByteArray &) |
| bool | readPayload (const QByteArray &) |
| QByteArray | writeHeader () const |
| QByteArray | writePayload () const |
| QByteArray | header () const |
| QByteArray | payload () const |
| QByteArray | rawPacket () const |
| Returns rawHeader() + rawPayload(). | |
Protected Member Functions | |
| Q_DECLARE_SHARED_DATA (Data) | |
Classes | |
| class | Data |
|
||||||||||||||||
|
Constructs a PacketStub object. The last argument checkReadBytes controls the behavior of readHeader() and readPayload(). If checkReadBytes is true, then the raw byte passed as arguments to readHeader() and readPayload() will be compared with header and payload respectively and the result of the comparison will be returned (i.e. true if equal, false if different). The write functions writeHeader() and writePayload() will return respectively the values of header and payload. Definition at line 39 of file PacketStub.cpp. |
|
|
Virtual copy constructor.
Implements Protocols::Generics::PacketBase. Definition at line 60 of file PacketStub.cpp. |
|
|
Definition at line 91 of file PacketStub.h. |
|
|
Returns the name of the PacketBase type the dynamic object belongs to.
Implements Protocols::Generics::PacketBase. Definition at line 50 of file PacketStub.cpp. |
|
|
Definition at line 94 of file PacketStub.h. |
|
|
Returns the name of the protocol this PacketBase belongs to.
Implements Protocols::Generics::PacketBase. Definition at line 55 of file PacketStub.cpp. |
|
|
|
|
|
Returns rawHeader() + rawPayload().
Reimplemented from Protocols::Generics::PacketBase. Definition at line 97 of file PacketStub.h. |
|
|
If checkReadBytes was set to true in the ctor, then the function returns true only if rawHeader is equal header(). If checkReadBytes was set to false, then header() will be set to rawHeader and true will be returned. Implements Protocols::Generics::PacketBase. Definition at line 70 of file PacketStub.cpp. |
|
|
If checkReadBytes was set to true in the ctor, then the function returns true only if rawPayload is equal payload(). If checkReadBytes was set to false, then payload() will be set to rawPayload and true will be returned. Implements Protocols::Generics::PacketBase. Definition at line 85 of file PacketStub.cpp. |
|
|
Implements Protocols::Generics::PacketBase. Definition at line 94 of file PacketStub.cpp. |
|
|
Implements Protocols::Generics::PacketBase. Definition at line 100 of file PacketStub.cpp. |