Changeset View
Changeset View
Standalone View
Standalone View
autotests/kconfigloadertest.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
49 | delete configFile; | 49 | delete configFile; | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | void ConfigLoaderTest::boolDefaultValue() | 52 | void ConfigLoaderTest::boolDefaultValue() | ||
53 | { | 53 | { | ||
54 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); | 54 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); | ||
55 | 55 | | |||
56 | QVERIFY(typeItem->isEqual(true)); | 56 | QVERIFY(typeItem->isEqual(true)); | ||
57 | QCOMPARE(typeItem->loadedValue(), true); | ||||
57 | } | 58 | } | ||
58 | 59 | | |||
59 | void ConfigLoaderTest::colorDefaultValue() | 60 | void ConfigLoaderTest::colorDefaultValue() | ||
60 | { | 61 | { | ||
61 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); | 62 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); | ||
62 | 63 | | |||
63 | QVERIFY(typeItem->isEqual(QColor("#00FF00"))); | 64 | QVERIFY(typeItem->isEqual(QColor("#00FF00"))); | ||
65 | QCOMPARE(typeItem->loadedValue(), QVariant::fromValue<QColor>(QColor("#00FF00"))); | ||||
64 | } | 66 | } | ||
65 | 67 | | |||
66 | void ConfigLoaderTest::dateTimeDefaultValue() | 68 | void ConfigLoaderTest::dateTimeDefaultValue() | ||
67 | { | 69 | { | ||
68 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); | 70 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); | ||
69 | 71 | | |||
70 | QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); | 72 | QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); | ||
73 | QCOMPARE(typeItem->loadedValue(), QDateTime::fromString("Thu Sep 09 2010")); | ||||
71 | } | 74 | } | ||
72 | 75 | | |||
73 | void ConfigLoaderTest::enumDefaultValue() | 76 | void ConfigLoaderTest::enumDefaultValue() | ||
74 | { | 77 | { | ||
75 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); | 78 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); | ||
76 | 79 | | |||
77 | QVERIFY(typeItem->isEqual(3)); | 80 | QVERIFY(typeItem->isEqual(3)); | ||
81 | QCOMPARE(typeItem->loadedValue(), 3); | ||||
78 | } | 82 | } | ||
79 | 83 | | |||
80 | void ConfigLoaderTest::fontDefaultValue() | 84 | void ConfigLoaderTest::fontDefaultValue() | ||
81 | { | 85 | { | ||
82 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); | 86 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); | ||
83 | 87 | | |||
84 | QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); | 88 | QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); | ||
89 | QCOMPARE(typeItem->loadedValue(), QFont("DejaVu Sans")); | ||||
85 | } | 90 | } | ||
86 | 91 | | |||
87 | void ConfigLoaderTest::intDefaultValue() | 92 | void ConfigLoaderTest::intDefaultValue() | ||
88 | { | 93 | { | ||
89 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); | 94 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); | ||
90 | 95 | | |||
91 | QVERIFY(typeItem->isEqual(27)); | 96 | QVERIFY(typeItem->isEqual(27)); | ||
97 | QCOMPARE(typeItem->loadedValue(), 27); | ||||
92 | } | 98 | } | ||
93 | 99 | | |||
94 | void ConfigLoaderTest::passwordDefaultValue() | 100 | void ConfigLoaderTest::passwordDefaultValue() | ||
95 | { | 101 | { | ||
96 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); | 102 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); | ||
97 | 103 | | |||
98 | QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); | 104 | QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); | ||
105 | QCOMPARE(typeItem->loadedValue(), QString::fromLatin1("h4x.")); | ||||
99 | } | 106 | } | ||
100 | 107 | | |||
101 | void ConfigLoaderTest::pathDefaultValue() | 108 | void ConfigLoaderTest::pathDefaultValue() | ||
102 | { | 109 | { | ||
103 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); | 110 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); | ||
104 | 111 | | |||
105 | QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); | 112 | QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); | ||
113 | QCOMPARE(typeItem->loadedValue(), QString::fromLatin1("/dev/null")); | ||||
106 | } | 114 | } | ||
107 | 115 | | |||
108 | void ConfigLoaderTest::stringDefaultValue() | 116 | void ConfigLoaderTest::stringDefaultValue() | ||
109 | { | 117 | { | ||
110 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); | 118 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); | ||
111 | 119 | | |||
112 | QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); | 120 | QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); | ||
121 | QCOMPARE(typeItem->loadedValue(), QString::fromLatin1("TestString")); | ||||
113 | } | 122 | } | ||
114 | 123 | | |||
115 | void ConfigLoaderTest::stringListDefaultValue() | 124 | void ConfigLoaderTest::stringListDefaultValue() | ||
116 | { | 125 | { | ||
117 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); | 126 | GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); | ||
118 | 127 | | |||
119 | // Create a string list with the expected values. | 128 | // Create a string list with the expected values. | ||
120 | QStringList expected; | 129 | QStringList expected; | ||
121 | expected.append(QStringLiteral("One")); | 130 | expected.append(QStringLiteral("One")); | ||
122 | expected.append(QStringLiteral("Two")); | 131 | expected.append(QStringLiteral("Two")); | ||
123 | expected.append(QStringLiteral("Three")); | 132 | expected.append(QStringLiteral("Three")); | ||
124 | expected.append(QStringLiteral("Four")); | 133 | expected.append(QStringLiteral("Four")); | ||
125 | expected.append(QStringLiteral("Five")); | 134 | expected.append(QStringLiteral("Five")); | ||
126 | 135 | | |||
127 | QVERIFY(typeItem->isEqual(expected)); | 136 | QVERIFY(typeItem->isEqual(expected)); | ||
137 | QCOMPARE(typeItem->loadedValue(), QVariant::fromValue<QStringList>(expected)); | ||||
128 | } | 138 | } | ||
129 | 139 | | |||
130 | void ConfigLoaderTest::uintDefaultValue() | 140 | void ConfigLoaderTest::uintDefaultValue() | ||
131 | { | 141 | { | ||
132 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); | 142 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); | ||
133 | 143 | | |||
134 | QVERIFY(typeItem->isEqual(7U)); | 144 | QVERIFY(typeItem->isEqual(7U)); | ||
145 | QCOMPARE(typeItem->loadedValue(), 7U); | ||||
135 | } | 146 | } | ||
136 | 147 | | |||
137 | void ConfigLoaderTest::urlDefaultValue() | 148 | void ConfigLoaderTest::urlDefaultValue() | ||
138 | { | 149 | { | ||
139 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); | 150 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); | ||
140 | 151 | | |||
141 | QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); | 152 | QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); | ||
153 | QCOMPARE(typeItem->loadedValue(), QUrl("http://kde.org")); | ||||
142 | } | 154 | } | ||
143 | 155 | | |||
144 | void ConfigLoaderTest::doubleDefaultValue() | 156 | void ConfigLoaderTest::doubleDefaultValue() | ||
145 | { | 157 | { | ||
146 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); | 158 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); | ||
147 | 159 | | |||
148 | QVERIFY(typeItem->isEqual(13.37)); | 160 | QVERIFY(typeItem->isEqual(13.37)); | ||
161 | QCOMPARE(typeItem->loadedValue(), 13.37); | ||||
149 | } | 162 | } | ||
150 | 163 | | |||
151 | void ConfigLoaderTest::intListDefaultValue() | 164 | void ConfigLoaderTest::intListDefaultValue() | ||
152 | { | 165 | { | ||
153 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); | 166 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); | ||
154 | 167 | | |||
155 | // Create a int list with the expected values. | 168 | // Create a int list with the expected values. | ||
156 | QList<int> expected; | 169 | QList<int> expected; | ||
157 | expected.append(1); | 170 | expected.append(1); | ||
158 | expected.append(1); | 171 | expected.append(1); | ||
159 | expected.append(2); | 172 | expected.append(2); | ||
160 | expected.append(3); | 173 | expected.append(3); | ||
161 | expected.append(5); | 174 | expected.append(5); | ||
162 | expected.append(8); | 175 | expected.append(8); | ||
163 | 176 | | |||
164 | QVERIFY(typeItem->isEqual(QVariant::fromValue(expected))); | 177 | QVERIFY(typeItem->isEqual(QVariant::fromValue(expected))); | ||
178 | QCOMPARE(typeItem->loadedValue().value<QList<int>>(), expected); | ||||
165 | } | 179 | } | ||
166 | 180 | | |||
167 | void ConfigLoaderTest::longLongDefaultValue() | 181 | void ConfigLoaderTest::longLongDefaultValue() | ||
168 | { | 182 | { | ||
169 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); | 183 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); | ||
170 | 184 | | |||
171 | QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); | 185 | QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); | ||
186 | QCOMPARE(typeItem->loadedValue(), Q_INT64_C(-9211372036854775808)); | ||||
172 | } | 187 | } | ||
173 | 188 | | |||
174 | void ConfigLoaderTest::pointDefaultValue() | 189 | void ConfigLoaderTest::pointDefaultValue() | ||
175 | { | 190 | { | ||
176 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); | 191 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); | ||
177 | 192 | | |||
178 | QVERIFY(typeItem->isEqual(QPoint(185, 857))); | 193 | QVERIFY(typeItem->isEqual(QPoint(185, 857))); | ||
194 | QCOMPARE(typeItem->loadedValue(), QPoint(185, 857)); | ||||
179 | } | 195 | } | ||
180 | 196 | | |||
181 | void ConfigLoaderTest::rectDefaultValue() | 197 | void ConfigLoaderTest::rectDefaultValue() | ||
182 | { | 198 | { | ||
183 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); | 199 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); | ||
184 | 200 | | |||
185 | // Create a new QRect with the expected value. | 201 | // Create a new QRect with the expected value. | ||
186 | QRect expected; | 202 | QRect expected; | ||
187 | expected.setCoords(3, 7, 951, 358); | 203 | expected.setCoords(3, 7, 951, 358); | ||
188 | 204 | | |||
189 | QVERIFY(typeItem->isEqual(expected)); | 205 | QVERIFY(typeItem->isEqual(expected)); | ||
206 | QCOMPARE(typeItem->loadedValue(), expected); | ||||
190 | } | 207 | } | ||
191 | 208 | | |||
192 | void ConfigLoaderTest::sizeDefaultValue() | 209 | void ConfigLoaderTest::sizeDefaultValue() | ||
193 | { | 210 | { | ||
194 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); | 211 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); | ||
195 | 212 | | |||
196 | QVERIFY(typeItem->isEqual(QSize(640, 480))); | 213 | QVERIFY(typeItem->isEqual(QSize(640, 480))); | ||
214 | QCOMPARE(typeItem->loadedValue(), QSize(640, 480)); | ||||
197 | } | 215 | } | ||
198 | 216 | | |||
199 | void ConfigLoaderTest::ulongLongDefaultValue() | 217 | void ConfigLoaderTest::ulongLongDefaultValue() | ||
200 | { | 218 | { | ||
201 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); | 219 | GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); | ||
202 | 220 | | |||
203 | QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); | 221 | QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); | ||
222 | QCOMPARE(typeItem->loadedValue(), Q_UINT64_C(9223372036854775806)); | ||||
204 | } | 223 | } | ||
205 | 224 | | |||
206 | QTEST_MAIN(ConfigLoaderTest) | 225 | QTEST_MAIN(ConfigLoaderTest) | ||
207 | 226 | |