blob: eb2b59dc307ef639d93cc5cf01145282345097dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "test-resource.h"
TestResource::TestResource()
{
}
TestResource::~TestResource()
{
}
void TestResource::init()
{
resource = new Resource(MediaClass, RP_FLAGS_AUDIO|RP_FLAGS_VIDEO, this);
resourceLibrary = new MockResourceLibrary(resource, false, false);
QVERIFY(resource != NULL);
QVERIFY(resource->resourceClass == MediaClass);
QVERIFY(resource->flags == (RP_FLAGS_AUDIO|RP_FLAGS_VIDEO));
qDebug("INIT!");
}
void TestResource::testInitializeSucceeds()
{
bool initializeSucceeded = resource->initialize(resourceLibrary);
QVERIFY(resource->resourceLibrary == resourceLibrary);
QVERIFY(initializeSucceeded);
}
void TestResource::testInitializeFails()
{
MockResourceLibrary *mockResourceLibrary =
static_cast<MockResourceLibrary *>(resourceLibrary);
mockResourceLibrary->makeInitializeFail();
bool initializeSucceeded = resource->initialize(resourceLibrary);
QEXPECT_FAIL("", "Expecting resourceLibrary->initialize() to fail", Continue);
QVERIFY(initializeSucceeded);
}
void TestResource::testConnectToServerSucceeds()
{
bool initializeSucceeded = resource->initialize(resourceLibrary);
QVERIFY(resource->resourceLibrary == resourceLibrary);
QVERIFY(initializeSucceeded);
bool connectToServerSucceeded = resource->connectToServer();
QVERIFY(connectToServerSucceeded);
}
void TestResource::testConnectToServerFails()
{
MockResourceLibrary *mockResourceLibrary =
static_cast<MockResourceLibrary *>(resourceLibrary);
bool initializeSucceeded = resource->initialize(resourceLibrary);
QVERIFY(resource->resourceLibrary == resourceLibrary);
QVERIFY(initializeSucceeded);
mockResourceLibrary->makeServerConnectFail();
bool connectToServerSucceeded = resource->connectToServer();
QEXPECT_FAIL("", "Expecting resourceLibrary->connectToServer() to fail", Continue);
QVERIFY(connectToServerSucceeded);
}
QTEST_MAIN(TestResource)
|