summaryrefslogtreecommitdiff
path: root/tests/test-resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-resource.cpp')
-rw-r--r--tests/test-resource.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test-resource.cpp b/tests/test-resource.cpp
new file mode 100644
index 0000000..aae4dd5
--- /dev/null
+++ b/tests/test-resource.cpp
@@ -0,0 +1,44 @@
+#include "test-resource.h"
+TestResource::TestResource()
+{
+}
+
+TestResource::~TestResource()
+{
+}
+
+void TestResource::initTestCase()
+{
+ resource = new Resource(MediaClass, RP_FLAGS_AUDIO|RP_FLAGS_VIDEO, this);
+ resourceLibrary = new MockResourceLibrary(resource, false);
+}
+
+void TestResource::testConstructor()
+{
+ QVERIFY(resource != NULL);
+ QVERIFY(resource->resourceClass == MediaClass);
+ QVERIFY(resource->flags == (RP_FLAGS_AUDIO|RP_FLAGS_VIDEO));
+}
+
+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);
+ delete resource;
+}
+
+QTEST_MAIN(TestResource)