Changeset View
Changeset View
Standalone View
Standalone View
tests/units/testlib/gentodotest.cpp
Show All 20 Lines | 1 | /* This file is part of Zanshin | |||
---|---|---|---|---|---|
21 | USA. | 21 | USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include "testlib/gentodo.h" | 24 | #include "testlib/gentodo.h" | ||
25 | 25 | | |||
26 | #include <KCalCore/Todo> | 26 | #include <KCalCore/Todo> | ||
27 | 27 | | |||
28 | #include <testlib/qtest_zanshin.h> | 28 | #include <testlib/qtest_zanshin.h> | ||
29 | #include <akonadi/akonadiserializer.h> | ||||
29 | 30 | | |||
30 | using namespace Testlib; | 31 | using namespace Testlib; | ||
32 | using Akonadi::Serializer; | ||||
31 | 33 | | |||
32 | class GenTodoTest : public QObject | 34 | class GenTodoTest : public QObject | ||
33 | { | 35 | { | ||
34 | Q_OBJECT | 36 | Q_OBJECT | ||
35 | private slots: | 37 | private slots: | ||
36 | void shouldImplicitlyConvertBackToItem() | 38 | void shouldImplicitlyConvertBackToItem() | ||
37 | { | 39 | { | ||
38 | // GIVEN | 40 | // GIVEN | ||
Show All 29 Lines | |||||
68 | 70 | | |||
69 | void shouldAllowToSetContexts() | 71 | void shouldAllowToSetContexts() | ||
70 | { | 72 | { | ||
71 | // GIVEN | 73 | // GIVEN | ||
72 | Akonadi::Item item = GenTodo().withContexts({"42", "43", "44"}); | 74 | Akonadi::Item item = GenTodo().withContexts({"42", "43", "44"}); | ||
73 | 75 | | |||
74 | // THEN | 76 | // THEN | ||
75 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | 77 | auto todo = item.payload<KCalCore::Todo::Ptr>(); | ||
76 | QStringList contextUids = todo->customProperty("Zanshin", "ContextList").split(','); | 78 | QStringList contextUids = todo->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyContextList()).split(','); | ||
77 | QCOMPARE(contextUids.size(), 3); | 79 | QCOMPARE(contextUids.size(), 3); | ||
78 | QCOMPARE(contextUids.at(0), "42"); | 80 | QCOMPARE(contextUids.at(0), "42"); | ||
79 | QCOMPARE(contextUids.at(1), "43"); | 81 | QCOMPARE(contextUids.at(1), "43"); | ||
80 | QCOMPARE(contextUids.at(2), "44"); | 82 | QCOMPARE(contextUids.at(2), "44"); | ||
81 | } | 83 | } | ||
82 | 84 | | |||
83 | void shouldAllowToSetProjectType() | 85 | void shouldAllowToSetProjectType() | ||
84 | { | 86 | { | ||
85 | // GIVEN | 87 | // GIVEN | ||
86 | Akonadi::Item item = GenTodo().asProject(); | 88 | Akonadi::Item item = GenTodo().asProject(); | ||
87 | 89 | | |||
88 | // THEN | 90 | // THEN | ||
89 | QVERIFY(!item.payload<KCalCore::Todo::Ptr>()->customProperty("Zanshin", "Project").isEmpty()); | 91 | QVERIFY(!item.payload<KCalCore::Todo::Ptr>()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); | ||
90 | 92 | | |||
91 | // WHEN | 93 | // WHEN | ||
92 | item = GenTodo(item).asProject(false); | 94 | item = GenTodo(item).asProject(false); | ||
93 | 95 | | |||
94 | // THEN | 96 | // THEN | ||
95 | QVERIFY(item.payload<KCalCore::Todo::Ptr>()->customProperty("Zanshin", "Project").isEmpty()); | 97 | QVERIFY(item.payload<KCalCore::Todo::Ptr>()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsProject()).isEmpty()); | ||
96 | } | 98 | } | ||
97 | 99 | | |||
98 | void shouldAllowToSetContextType() | 100 | void shouldAllowToSetContextType() | ||
99 | { | 101 | { | ||
100 | // GIVEN | 102 | // GIVEN | ||
101 | Akonadi::Item item = GenTodo().asContext(); | 103 | Akonadi::Item item = GenTodo().asContext(); | ||
102 | 104 | | |||
103 | // THEN | 105 | // THEN | ||
104 | QVERIFY(!item.payload<KCalCore::Todo::Ptr>()->customProperty("Zanshin", "Context").isEmpty()); | 106 | QVERIFY(!item.payload<KCalCore::Todo::Ptr>()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty()); | ||
105 | 107 | | |||
106 | // WHEN | 108 | // WHEN | ||
107 | item = GenTodo(item).asContext(false); | 109 | item = GenTodo(item).asContext(false); | ||
108 | 110 | | |||
109 | // THEN | 111 | // THEN | ||
110 | QVERIFY(item.payload<KCalCore::Todo::Ptr>()->customProperty("Zanshin", "Context").isEmpty()); | 112 | QVERIFY(item.payload<KCalCore::Todo::Ptr>()->customProperty(Serializer::customPropertyAppName(), Serializer::customPropertyIsContext()).isEmpty()); | ||
111 | } | 113 | } | ||
112 | 114 | | |||
113 | void shouldAllowToSetUid() | 115 | void shouldAllowToSetUid() | ||
114 | { | 116 | { | ||
115 | // GIVEN | 117 | // GIVEN | ||
116 | Akonadi::Item item = GenTodo().withUid(QStringLiteral("42")); | 118 | Akonadi::Item item = GenTodo().withUid(QStringLiteral("42")); | ||
117 | 119 | | |||
118 | // THEN | 120 | // THEN | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |