Changeset View
Changeset View
Standalone View
Standalone View
autotests/coronatest.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 135 | { | |||
---|---|---|---|---|---|
137 | delete m_corona; | 137 | delete m_corona; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | void CoronaTest::restore() | 140 | void CoronaTest::restore() | ||
141 | { | 141 | { | ||
142 | m_corona->loadLayout(QStringLiteral("plasma-test-appletsrc")); | 142 | m_corona->loadLayout(QStringLiteral("plasma-test-appletsrc")); | ||
143 | QCOMPARE(m_corona->containments().count(), 3); | 143 | QCOMPARE(m_corona->containments().count(), 3); | ||
144 | 144 | | |||
145 | foreach (auto cont, m_corona->containments()) { | 145 | const auto containments = m_corona->containments(); | ||
146 | for (auto cont : containments) { | ||||
apol: maybe call it containments? naming variables with a typename is bad (we even are using auto to… | |||||
Please always annotate auto with e.g. asterisk or ampersand depending on type broulik: Please always annotate `auto` with e.g. asterisk or ampersand depending on type | |||||
146 | switch (cont->id()) { | 147 | switch (cont->id()) { | ||
147 | case 1: | 148 | case 1: | ||
148 | QCOMPARE(cont->applets().count(), 2); | 149 | QCOMPARE(cont->applets().count(), 2); | ||
149 | break; | 150 | break; | ||
150 | default: | 151 | default: | ||
151 | QCOMPARE(cont->applets().count(), 0); | 152 | QCOMPARE(cont->applets().count(), 0); | ||
152 | break; | 153 | break; | ||
153 | } | 154 | } | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
203 | //can't be programmatically unlocked | 204 | //can't be programmatically unlocked | ||
204 | void CoronaTest::immutability() | 205 | void CoronaTest::immutability() | ||
205 | { | 206 | { | ||
206 | //immutability | 207 | //immutability | ||
207 | QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable); | 208 | QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable); | ||
208 | m_corona->setImmutability(Plasma::Types::UserImmutable); | 209 | m_corona->setImmutability(Plasma::Types::UserImmutable); | ||
209 | QCOMPARE(m_corona->immutability(), Plasma::Types::UserImmutable); | 210 | QCOMPARE(m_corona->immutability(), Plasma::Types::UserImmutable); | ||
210 | 211 | | |||
211 | foreach (Plasma::Containment *cont, m_corona->containments()) { | 212 | auto containments = m_corona->containments(); | ||
213 | for (Plasma::Containment *cont : qAsConst(containments)) { | ||||
broulik: why not make the container `const`? | |||||
mlaurent: Because this variable is use in code see line 228 | |||||
212 | QCOMPARE(cont->immutability(), Plasma::Types::UserImmutable); | 214 | QCOMPARE(cont->immutability(), Plasma::Types::UserImmutable); | ||
213 | foreach (Plasma::Applet *app, cont->applets()) { | 215 | const auto lstApplets = cont->applets(); | ||
216 | for (Plasma::Applet *app : lstApplets) { | ||||
214 | QCOMPARE(app->immutability(), Plasma::Types::UserImmutable); | 217 | QCOMPARE(app->immutability(), Plasma::Types::UserImmutable); | ||
215 | } | 218 | } | ||
216 | } | 219 | } | ||
217 | 220 | | |||
218 | m_corona->setImmutability(Plasma::Types::Mutable); | 221 | m_corona->setImmutability(Plasma::Types::Mutable); | ||
219 | QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable); | 222 | QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable); | ||
220 | 223 | | |||
221 | foreach (Plasma::Containment *cont, m_corona->containments()) { | 224 | containments = m_corona->containments(); | ||
225 | for (Plasma::Containment *cont : qAsConst(containments)) { | ||||
222 | QCOMPARE(cont->immutability(), Plasma::Types::Mutable); | 226 | QCOMPARE(cont->immutability(), Plasma::Types::Mutable); | ||
223 | foreach (Plasma::Applet *app, cont->applets()) { | 227 | const auto lstApplets = cont->applets(); | ||
228 | for (Plasma::Applet *app : lstApplets) { | ||||
224 | QCOMPARE(app->immutability(), Plasma::Types::Mutable); | 229 | QCOMPARE(app->immutability(), Plasma::Types::Mutable); | ||
225 | } | 230 | } | ||
226 | } | 231 | } | ||
227 | 232 | | |||
228 | m_corona->setImmutability(Plasma::Types::SystemImmutable); | 233 | m_corona->setImmutability(Plasma::Types::SystemImmutable); | ||
229 | QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable); | 234 | QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable); | ||
230 | 235 | | |||
231 | foreach (Plasma::Containment *cont, m_corona->containments()) { | 236 | containments = m_corona->containments(); | ||
237 | for (Plasma::Containment *cont : qAsConst(containments)) { | ||||
232 | QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable); | 238 | QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable); | ||
233 | foreach (Plasma::Applet *app, cont->applets()) { | 239 | const auto lstApplets = cont->applets(); | ||
240 | for (Plasma::Applet *app : lstApplets) { | ||||
234 | QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable); | 241 | QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable); | ||
235 | } | 242 | } | ||
236 | } | 243 | } | ||
237 | 244 | | |||
238 | //can't unlock systemimmutable | 245 | //can't unlock systemimmutable | ||
239 | m_corona->setImmutability(Plasma::Types::Mutable); | 246 | m_corona->setImmutability(Plasma::Types::Mutable); | ||
240 | QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable); | 247 | QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable); | ||
241 | 248 | | |||
242 | foreach (Plasma::Containment *cont, m_corona->containments()) { | 249 | containments = m_corona->containments(); | ||
250 | for (Plasma::Containment *cont : qAsConst(containments)) { | ||||
243 | QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable); | 251 | QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable); | ||
244 | foreach (Plasma::Applet *app, cont->applets()) { | 252 | const auto lstApplets = cont->applets(); | ||
253 | for (Plasma::Applet *app : lstApplets) { | ||||
245 | QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable); | 254 | QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable); | ||
246 | } | 255 | } | ||
247 | } | 256 | } | ||
248 | } | 257 | } | ||
249 | 258 | | |||
250 | QTEST_MAIN(CoronaTest) | 259 | QTEST_MAIN(CoronaTest) | ||
251 | 260 | |
maybe call it containments? naming variables with a typename is bad (we even are using auto to not mention it's a list!)