summaryrefslogtreecommitdiffstats
path: root/common/test.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
commit3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch)
treeaf5582170ed6164fffc9365f34b17bf449c0db40 /common/test.cpp
parentf9379318d801df204cc50385c5eca1f28e91755e (diff)
parentce2fd2666f084eebe443598f6f3740a02913091e (diff)
downloadsink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz
sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'common/test.cpp')
-rw-r--r--common/test.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/common/test.cpp b/common/test.cpp
index 59ad9ec..5b4c899 100644
--- a/common/test.cpp
+++ b/common/test.cpp
@@ -27,11 +27,17 @@
27#include "facadefactory.h" 27#include "facadefactory.h"
28#include "query.h" 28#include "query.h"
29#include "resourceconfig.h" 29#include "resourceconfig.h"
30#include "definitions.h"
31
32SINK_DEBUG_AREA("test")
30 33
31using namespace Sink; 34using namespace Sink;
32 35
33void Sink::Test::initTest() 36void Sink::Test::initTest()
34{ 37{
38 auto logIniFile = Sink::configLocation() + "/log.ini";
39 auto areaAutocompletionFile = Sink::dataLocation() + "/debugAreas.ini";
40
35 setTestModeEnabled(true); 41 setTestModeEnabled(true);
36 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); 42 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
37 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively(); 43 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).removeRecursively();
@@ -45,6 +51,31 @@ void Sink::Test::initTest()
45 QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).removeRecursively(); 51 QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)).removeRecursively();
46 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); 52 // qDebug() << "Removing " << QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
47 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively(); 53 QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).removeRecursively();
54 Log::setPrimaryComponent("test");
55
56 //We copy those files so we can control debug output from outside the test with sinksh
57 {
58 QFile file(logIniFile);
59 if (!file.open(QIODevice::ReadOnly)) {
60 qWarning() << "Failed to open the file: " << logIniFile;
61 }
62 QDir dir;
63 dir.mkpath(Sink::configLocation());
64 if (!file.copy(Sink::configLocation() + "/log.ini")) {
65 qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini";
66 }
67 }
68 {
69 QFile file(areaAutocompletionFile);
70 if (!file.open(QIODevice::ReadOnly)) {
71 qWarning() << "Failed to open the file: " << logIniFile;
72 }
73 QDir dir;
74 dir.mkpath(Sink::dataLocation());
75 if (!file.copy(Sink::dataLocation() + "/debugAreas.ini")) {
76 qWarning() << "Failed to move the file: " << Sink::configLocation() + "/log.ini";
77 }
78 }
48} 79}
49 80
50void Sink::Test::setTestModeEnabled(bool enabled) 81void Sink::Test::setTestModeEnabled(bool enabled)
@@ -102,7 +133,7 @@ public:
102 { 133 {
103 auto resultProvider = new Sink::ResultProvider<typename T::Ptr>(); 134 auto resultProvider = new Sink::ResultProvider<typename T::Ptr>();
104 resultProvider->onDone([resultProvider]() { 135 resultProvider->onDone([resultProvider]() {
105 Trace() << "Result provider is done"; 136 SinkTrace() << "Result provider is done";
106 delete resultProvider; 137 delete resultProvider;
107 }); 138 });
108 // We have to do it this way, otherwise we're not setting the fetcher right 139 // We have to do it this way, otherwise we're not setting the fetcher right
@@ -110,11 +141,11 @@ public:
110 141
111 resultProvider->setFetcher([query, resultProvider, this](const typename T::Ptr &parent) { 142 resultProvider->setFetcher([query, resultProvider, this](const typename T::Ptr &parent) {
112 if (parent) { 143 if (parent) {
113 Trace() << "Running the fetcher " << parent->identifier(); 144 SinkTrace() << "Running the fetcher " << parent->identifier();
114 } else { 145 } else {
115 Trace() << "Running the fetcher."; 146 SinkTrace() << "Running the fetcher.";
116 } 147 }
117 Trace() << "-------------------------."; 148 SinkTrace() << "-------------------------.";
118 for (const auto &res : mTestAccount->entities<T>()) { 149 for (const auto &res : mTestAccount->entities<T>()) {
119 qDebug() << "Parent filter " << query.propertyFilter.value("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); 150 qDebug() << "Parent filter " << query.propertyFilter.value("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray();
120 auto parentProperty = res->getProperty("parent").toByteArray(); 151 auto parentProperty = res->getProperty("parent").toByteArray();