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