diff options
author | Wolf Bergenheim <ext-wolf.2.bergenheim@nokia.com> | 2010-01-21 13:23:03 +0200 |
---|---|---|
committer | Wolf Bergenheim <ext-wolf.2.bergenheim@nokia.com> | 2010-01-21 13:23:03 +0200 |
commit | cfb16c2a93650ac2e0c9677bce11ed101aceffb0 (patch) | |
tree | 1f958fa95d966e7d6bdbfd8237cc08d13ced56c3 /tests | |
parent | def881f37f26d6f3b9bf1a9c077dae4916717157 (diff) |
Chaged Resource::Type from QString to an enumerated type
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-resource.cpp | 35 | ||||
-rw-r--r-- | tests/test-resource.h | 5 |
2 files changed, 25 insertions, 15 deletions
diff --git a/tests/test-resource.cpp b/tests/test-resource.cpp index bc72957..95f1809 100644 --- a/tests/test-resource.cpp +++ b/tests/test-resource.cpp @@ -1,5 +1,7 @@ #include "test-resource.h" +using namespace ResourcePolicy; + TestResource::TestResource() { } @@ -20,24 +22,27 @@ void TestResource::cleanup() void TestResource::testType_data() { - QTest::addColumn<QString>("type"); - QTest::addColumn<QString>("expected"); - - QTest::newRow("AudioPlayback") << "AudioPlayback" << "AudioPlayback"; - QTest::newRow("VideoPlayback") << "VideoPlayback" << "VideoPlayback"; - QTest::newRow("AudioRecording") << "AudioRecording" << "AudioRecording"; - QTest::newRow("VideoRecording") << "VideoRecording" << "VideoRecording"; - QTest::newRow("Invalid") << "Invalid" << "Invalid"; - QTest::newRow("Empty") << "" << ""; - QTest::newRow("Null") << QString() << QString(); + QTest::addColumn<ResourceType>("type"); + QTest::addColumn<ResourceType>("expected"); + + QTest::newRow("AudioPlayback") << AudioPlaybackResource << AudioPlaybackResource; + QTest::newRow("VideoPlayback") << VideoPlaybackResource << VideoPlaybackResource; + QTest::newRow("AudioRecorder") << AudioRecorderResource << AudioRecorderResource; + QTest::newRow("VideoRecorder") << VideoRecorderResource << VideoRecorderResource; + QTest::newRow("Invalid") << InvalidResource << InvalidResource; } + void TestResource::testType() { - QFETCH(QString, type); - QFETCH(QString, expected); - resource->setType(type); - QString result = resource->type(); - + QFETCH(ResourceType, type); + QFETCH(ResourceType, expected); + bool setWasSuccessfull = resource->setType(type); + ResourceType result = resource->type(); + + if(expected == InvalidResource) { + QEXPECT_FAIL("", "Expecting to fail since type == InvalidResource", Continue); + } + QVERIFY(setWasSuccessfull); QCOMPARE(result, expected); } diff --git a/tests/test-resource.h b/tests/test-resource.h index e55e2af..a5f617f 100644 --- a/tests/test-resource.h +++ b/tests/test-resource.h @@ -2,8 +2,13 @@ #define TEST_RESOURCE_H #include <QtTest/QTest> +#include <QMetaType> #include "resource.h" +Q_DECLARE_METATYPE(ResourcePolicy::ResourceType) + +using namespace ResourcePolicy; + class TestResource: public QObject { Q_OBJECT |