summaryrefslogtreecommitdiffstats
path: root/tests/resourceconfigtest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-06 09:58:34 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-06 09:58:34 +0200
commitabc90b737074d93f73490a77e1eb1e1666dac375 (patch)
tree2c79c2996401e7732d94ba3d0b623c8290484f9f /tests/resourceconfigtest.cpp
parenta9f3692a0bceb796d10952307f87fdb77abadbf7 (diff)
downloadsink-abc90b737074d93f73490a77e1eb1e1666dac375.tar.gz
sink-abc90b737074d93f73490a77e1eb1e1666dac375.zip
Test the resource status
Diffstat (limited to 'tests/resourceconfigtest.cpp')
-rw-r--r--tests/resourceconfigtest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/resourceconfigtest.cpp b/tests/resourceconfigtest.cpp
index bebff50..42f8b70 100644
--- a/tests/resourceconfigtest.cpp
+++ b/tests/resourceconfigtest.cpp
@@ -8,6 +8,8 @@
8#include "modelresult.h" 8#include "modelresult.h"
9#include "resultprovider.h" 9#include "resultprovider.h"
10#include "facadefactory.h" 10#include "facadefactory.h"
11#include "test.h"
12#include "testutils.h"
11 13
12/** 14/**
13 * Test of the resource configuration. 15 * Test of the resource configuration.
@@ -19,6 +21,7 @@ private slots:
19 21
20 void initTestCase() 22 void initTestCase()
21 { 23 {
24 Sink::Test::initTest();
22 Sink::FacadeFactory::instance().resetFactory(); 25 Sink::FacadeFactory::instance().resetFactory();
23 ResourceConfig::clear(); 26 ResourceConfig::clear();
24 Sink::Log::setDebugOutputLevel(Sink::Log::Trace); 27 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
@@ -72,6 +75,34 @@ private slots:
72 Sink::Store::remove(res).exec().waitForFinished(); 75 Sink::Store::remove(res).exec().waitForFinished();
73 } 76 }
74 77
78 void testLoadResourceStatus()
79 {
80 ResourceConfig::clear();
81 Sink::FacadeFactory::instance().registerStaticFacades();
82
83 Sink::ApplicationDomain::SinkResource res("", "dummyresource.identifier1", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create());
84 res.setProperty("identifier", "dummyresource.identifier1");
85 res.setProperty("type", "org.kde.dummy");
86 res.setProperty("capabilities", QVariant::fromValue(QByteArrayList() << "foo"));
87
88 Sink::Store::create(res).exec().waitForFinished();
89 {
90 Sink::Query query;
91 query.liveQuery = true;
92 query.request<Sink::ApplicationDomain::SinkResource::Status>();
93 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(Sink::Query::CapabilityFilter("foo"));
94 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
95 auto resource = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkResource::Ptr>();
96 QCOMPARE(resource->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus));
97
98 //Synchronize to connect
99 VERIFYEXEC(Sink::Store::synchronize(query));
100 QTRY_COMPARE(model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkResource::Ptr>()->getStatus(), static_cast<int>(Sink::ApplicationDomain::ConnectedStatus));
101 }
102
103 VERIFYEXEC(Sink::Store::remove(res));
104 }
105
75}; 106};
76 107
77QTEST_MAIN(ResourceConfigTest) 108QTEST_MAIN(ResourceConfigTest)