diff options
-rw-r--r-- | common/resourcefacade.cpp | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/clientapitest.cpp | 28 | ||||
-rw-r--r-- | tests/resourceconfigtest.cpp | 78 |
4 files changed, 80 insertions, 29 deletions
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index 96e2ac3..526ce6d 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -119,7 +119,7 @@ static bool matchesFilter(const QHash<QByteArray, Sink::Query::Comparator> &filt | |||
119 | if (filterProperty == "type") { | 119 | if (filterProperty == "type") { |
120 | continue; | 120 | continue; |
121 | } | 121 | } |
122 | if (filter.value(filterProperty).matches(properties.value(filterProperty))) { | 122 | if (!filter.value(filterProperty).matches(properties.value(filterProperty))) { |
123 | return false; | 123 | return false; |
124 | } | 124 | } |
125 | } | 125 | } |
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b97596a..c9f7591 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -40,6 +40,7 @@ manual_tests ( | |||
40 | 40 | ||
41 | auto_tests ( | 41 | auto_tests ( |
42 | clientapitest | 42 | clientapitest |
43 | resourceconfigtest | ||
43 | storagetest | 44 | storagetest |
44 | dummyresourcetest | 45 | dummyresourcetest |
45 | domainadaptortest | 46 | domainadaptortest |
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 96982ca..7f9f422 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -119,34 +119,6 @@ private slots: | |||
119 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 119 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
120 | } | 120 | } |
121 | 121 | ||
122 | // TODO: This test doesn't belong to this testsuite | ||
123 | void resourceManagement() | ||
124 | { | ||
125 | ResourceConfig::clear(); | ||
126 | Sink::FacadeFactory::instance().registerStaticFacades(); | ||
127 | |||
128 | Sink::ApplicationDomain::SinkResource res("", "dummyresource.identifier1", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
129 | res.setProperty("identifier", "dummyresource.identifier1"); | ||
130 | res.setProperty("type", "dummyresource"); | ||
131 | |||
132 | Sink::Store::create(res).exec().waitForFinished(); | ||
133 | { | ||
134 | Sink::Query query; | ||
135 | query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource")); | ||
136 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); | ||
137 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | ||
138 | } | ||
139 | |||
140 | Sink::Store::remove(res).exec().waitForFinished(); | ||
141 | { | ||
142 | Sink::Query query; | ||
143 | query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource")); | ||
144 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); | ||
145 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
146 | QCOMPARE(model->rowCount(QModelIndex()), 0); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | void testModelSingle() | 122 | void testModelSingle() |
151 | { | 123 | { |
152 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); | 124 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
diff --git a/tests/resourceconfigtest.cpp b/tests/resourceconfigtest.cpp new file mode 100644 index 0000000..bebff50 --- /dev/null +++ b/tests/resourceconfigtest.cpp | |||
@@ -0,0 +1,78 @@ | |||
1 | #include <QtTest> | ||
2 | #include <QDebug> | ||
3 | #include <functional> | ||
4 | |||
5 | #include "store.h" | ||
6 | #include "facade.h" | ||
7 | #include "resourceconfig.h" | ||
8 | #include "modelresult.h" | ||
9 | #include "resultprovider.h" | ||
10 | #include "facadefactory.h" | ||
11 | |||
12 | /** | ||
13 | * Test of the resource configuration. | ||
14 | */ | ||
15 | class ResourceConfigTest : public QObject | ||
16 | { | ||
17 | Q_OBJECT | ||
18 | private slots: | ||
19 | |||
20 | void initTestCase() | ||
21 | { | ||
22 | Sink::FacadeFactory::instance().resetFactory(); | ||
23 | ResourceConfig::clear(); | ||
24 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | ||
25 | } | ||
26 | |||
27 | void resourceManagement() | ||
28 | { | ||
29 | ResourceConfig::clear(); | ||
30 | Sink::FacadeFactory::instance().registerStaticFacades(); | ||
31 | |||
32 | Sink::ApplicationDomain::SinkResource res("", "dummyresource.identifier1", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
33 | res.setProperty("identifier", "dummyresource.identifier1"); | ||
34 | res.setProperty("type", "dummyresource"); | ||
35 | |||
36 | Sink::Store::create(res).exec().waitForFinished(); | ||
37 | { | ||
38 | Sink::Query query; | ||
39 | query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource")); | ||
40 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); | ||
41 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | ||
42 | } | ||
43 | |||
44 | Sink::Store::remove(res).exec().waitForFinished(); | ||
45 | { | ||
46 | Sink::Query query; | ||
47 | query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource")); | ||
48 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); | ||
49 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
50 | QCOMPARE(model->rowCount(QModelIndex()), 0); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void testLoadResourceByCapabiity() | ||
55 | { | ||
56 | ResourceConfig::clear(); | ||
57 | Sink::FacadeFactory::instance().registerStaticFacades(); | ||
58 | |||
59 | Sink::ApplicationDomain::SinkResource res("", "dummyresource.identifier1", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
60 | res.setProperty("identifier", "dummyresource.identifier1"); | ||
61 | res.setProperty("type", "dummyresource"); | ||
62 | res.setProperty("capabilities", QVariant::fromValue(QByteArrayList() << "foo")); | ||
63 | |||
64 | Sink::Store::create(res).exec().waitForFinished(); | ||
65 | { | ||
66 | Sink::Query query; | ||
67 | query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource")); | ||
68 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(Sink::Query::CapabilityFilter("foo")); | ||
69 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | ||
70 | } | ||
71 | |||
72 | Sink::Store::remove(res).exec().waitForFinished(); | ||
73 | } | ||
74 | |||
75 | }; | ||
76 | |||
77 | QTEST_MAIN(ResourceConfigTest) | ||
78 | #include "resourceconfigtest.moc" | ||