10#include "akapplication.h"
11#include "private/instance_p.h"
17#define AKTEST_MAIN(TestObject) \
18 int main(int argc, char **argv) \
20 qputenv("XDG_DATA_HOME", ".local-unit-test/share"); \
21 qputenv("XDG_CONFIG_HOME", ".config-unit-test"); \
22 AkCoreApplication app(argc, argv); \
23 KCrash::setDrKonqiEnabled(false); \
24 app.parseCommandLine(); \
26 return QTest::qExec(&tc, argc, argv); \
29#define AKTEST_FAKESERVER_MAIN(TestObject) \
30 int main(int argc, char **argv) \
32 AkCoreApplication app(argc, argv); \
33 KCrash::setDrKonqiEnabled(false); \
34 app.addCommandLineOptions(QCommandLineOption(QStringLiteral("no-cleanup"), QStringLiteral("Don't clean up the temporary runtime environment"))); \
35 app.parseCommandLine(); \
37 return QTest::qExec(&tc, argc, argv); \
40#define AKCOMPARE(actual, expected) \
42 if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
46#define AKVERIFY(statement) \
48 if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
52inline void akTestSetInstanceIdentifier(
const QString &instanceId)
54 Akonadi::Instance::setIdentifier(instanceId);
57#include "private/protocol_p.h"
62char *
toString(
const Akonadi::Protocol::ItemChangeNotificationPtr &msg)
64 return qstrdup(qPrintable(Akonadi::Protocol::debugString(msg)));
72 NtfOperation = (1 << 1),
73 NtfSession = (1 << 2),
74 NtfEntities = (1 << 3),
75 NtfResource = (1 << 5),
76 NtfCollection = (1 << 6),
77 NtfDestResource = (1 << 7),
78 NtfDestCollection = (1 << 8),
79 NtfAddedFlags = (1 << 9),
80 NtfRemovedFlags = (1 << 10),
81 NtfAddedTags = (1 << 11),
82 NtfRemovedTags = (1 << 12),
84 NtfFlags = NtfAddedFlags | NtfRemovedTags,
85 NtfTags = NtfAddedTags | NtfRemovedTags,
86 NtfAll = NtfType | NtfOperation | NtfSession | NtfEntities | NtfResource | NtfCollection | NtfDestResource | NtfDestCollection | NtfFlags | NtfTags
90bool compareNotifications(
const Akonadi::Protocol::ItemChangeNotificationPtr &actual,
91 const Akonadi::Protocol::ItemChangeNotificationPtr &expected,
92 const NtfFields fields = NtfAll)
94 if (fields & NtfOperation) {
95 AKCOMPARE(actual->operation(), expected->operation());
97 if (fields & NtfSession) {
98 AKCOMPARE(actual->sessionId(), expected->sessionId());
100 if (fields & NtfEntities) {
101 AKCOMPARE(actual->items(), expected->items());
103 if (fields & NtfResource) {
104 AKCOMPARE(actual->resource(), expected->resource());
106 if (fields & NtfCollection) {
107 AKCOMPARE(actual->parentCollection(), expected->parentCollection());
109 if (fields & NtfDestResource) {
110 AKCOMPARE(actual->destinationResource(), expected->destinationResource());
112 if (fields & NtfDestCollection) {
113 AKCOMPARE(actual->parentDestCollection(), expected->parentDestCollection());
115 if (fields & NtfAddedFlags) {
116 AKCOMPARE(actual->addedFlags(), expected->addedFlags());
118 if (fields & NtfRemovedFlags) {
119 AKCOMPARE(actual->removedFlags(), expected->removedFlags());
121 if (fields & NtfAddedTags) {
122 AKCOMPARE(actual->addedTags(), expected->addedTags());
124 if (fields & NtfRemovedTags) {
125 AKCOMPARE(actual->removedTags(), expected->removedTags());
char * toString(QSizePolicy sp)