diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-10 10:03:12 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-10 10:03:12 +0200 |
commit | ef91fc2c1fef8ed409aa60429afb4867d0dec568 (patch) | |
tree | 1edf39bc30f5d622ab76d8158b253fe1ef83c15d /tests/resourceconfigtest.cpp | |
parent | 4999ec5da028e3b11d9c7b7bc0fe25acdf0a8ddd (diff) | |
download | sink-ef91fc2c1fef8ed409aa60429afb4867d0dec568.tar.gz sink-ef91fc2c1fef8ed409aa60429afb4867d0dec568.zip |
Fixed resource property filtering
Diffstat (limited to 'tests/resourceconfigtest.cpp')
-rw-r--r-- | tests/resourceconfigtest.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
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" | ||