From 1e51b62c882b5fc1554efb46cb41c3d54157626c Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sat, 6 Jun 2015 12:30:49 +0200 Subject: NOISSUE Comment and bugfix the Resource system --- tests/CMakeLists.txt | 1 + tests/tst_Resource.cpp | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2cf9e7cb..6e66c834 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,6 +29,7 @@ add_unit_test(modutils tst_modutils.cpp) add_unit_test(inifile tst_inifile.cpp) add_unit_test(UpdateChecker tst_UpdateChecker.cpp) add_unit_test(DownloadTask tst_DownloadTask.cpp) +add_unit_test(Resource tst_Resource.cpp) # Tests END # diff --git a/tests/tst_Resource.cpp b/tests/tst_Resource.cpp index ba6f0509..54d029d5 100644 --- a/tests/tst_Resource.cpp +++ b/tests/tst_Resource.cpp @@ -43,8 +43,8 @@ public: class ResourceTest : public QObject { Q_OBJECT -private -slots: + private + slots: void initTestCase() { Resource::registerHandler("dummy"); @@ -75,10 +75,9 @@ slots: void test_DontRequestPlaceholder() { - auto resource = Resource::create("dummy:asdf") + // since dummy:asdf immediently gives a value we should not get the placeholder + Resource::create("dummy:asdf", Resource::create("dummy:fdsa")) ->then([](const QString &key) { QCOMPARE(key, QStringLiteral("asdf")); }); - // the following call should not notify the observer. if it does the above QCOMPARE would fail. - resource->placeholder(Resource::create("dummy:fdsa")); } void test_MergedResources() @@ -94,6 +93,23 @@ slots: QVERIFY(r2 != r3); QVERIFY(r4 != r3); } + + void test_MergedResourceWithPlaceholder() + { + auto p1 = Resource::create("dummy:placeA"); + auto p2 = Resource::create("dummy:placeB"); + + auto r1 = Resource::create("dummy:asdf"); + auto r2 = Resource::create("dummy:asdf", p1); + auto r3 = Resource::create("dummy:asdf", p2); + auto r4 = Resource::create("dummy:asdf", p1); + + QCOMPARE(r2, r4); + QVERIFY(r1 != r2); + QVERIFY(r1 != r3); + QVERIFY(r1 != r4); + QVERIFY(r2 != r3); + } }; QTEST_GUILESS_MAIN(ResourceTest) -- cgit v1.2.3