Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/quick_tiling_test.cpp
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Line(s) | 232 | { | |||
---|---|---|---|---|---|
253 | QVERIFY(geometryChangedSpy.isValid()); | 253 | QVERIFY(geometryChangedSpy.isValid()); | ||
254 | QSignalSpy maximizeChangedSpy1(c, SIGNAL(clientMaximizedStateChanged(KWin::AbstractClient*,MaximizeMode))); | 254 | QSignalSpy maximizeChangedSpy1(c, SIGNAL(clientMaximizedStateChanged(KWin::AbstractClient*,MaximizeMode))); | ||
255 | QVERIFY(maximizeChangedSpy1.isValid()); | 255 | QVERIFY(maximizeChangedSpy1.isValid()); | ||
256 | QSignalSpy maximizeChangedSpy2(c, SIGNAL(clientMaximizedStateChanged(KWin::AbstractClient*,bool,bool))); | 256 | QSignalSpy maximizeChangedSpy2(c, SIGNAL(clientMaximizedStateChanged(KWin::AbstractClient*,bool,bool))); | ||
257 | QVERIFY(maximizeChangedSpy2.isValid()); | 257 | QVERIFY(maximizeChangedSpy2.isValid()); | ||
258 | 258 | | |||
259 | c->setQuickTileMode(QuickTileFlag::Maximize, true); | 259 | c->setQuickTileMode(QuickTileFlag::Maximize, true); | ||
260 | QCOMPARE(quickTileChangedSpy.count(), 1); | 260 | QCOMPARE(quickTileChangedSpy.count(), 1); | ||
261 | QCOMPARE(maximizeChangedSpy1.count(), 1); | 261 | | ||
262 | QCOMPARE(maximizeChangedSpy1.first().first().value<KWin::AbstractClient*>(), c); | | |||
263 | QCOMPARE(maximizeChangedSpy1.first().last().value<KWin::MaximizeMode>(), MaximizeFull); | | |||
264 | QCOMPARE(maximizeChangedSpy2.count(), 1); | | |||
265 | QCOMPARE(maximizeChangedSpy2.first().first().value<KWin::AbstractClient*>(), c); | | |||
266 | QCOMPARE(maximizeChangedSpy2.first().at(1).toBool(), true); | | |||
267 | QCOMPARE(maximizeChangedSpy2.first().at(2).toBool(), true); | | |||
268 | // at this point the geometry did not yet change | 262 | // at this point the geometry did not yet change | ||
269 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 263 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
270 | // but quick tile mode already changed | 264 | // but quick tile mode already changed | ||
271 | QCOMPARE(c->quickTileMode(), QuickTileFlag::Maximize); | 265 | QCOMPARE(c->quickTileMode(), QuickTileFlag::Maximize); | ||
272 | QCOMPARE(c->maximizeMode(), MaximizeFull); | | |||
273 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | 266 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | ||
274 | 267 | | |||
275 | // but we got requested a new geometry | 268 | // but we got requested a new geometry | ||
276 | QVERIFY(sizeChangeSpy.wait()); | 269 | QVERIFY(sizeChangeSpy.wait()); | ||
277 | QCOMPARE(sizeChangeSpy.count(), 1); | 270 | QCOMPARE(sizeChangeSpy.count(), 1); | ||
278 | QCOMPARE(sizeChangeSpy.first().first().toSize(), QSize(1280, 1024)); | 271 | QCOMPARE(sizeChangeSpy.first().first().toSize(), QSize(1280, 1024)); | ||
279 | 272 | | |||
280 | // attach a new image | 273 | // attach a new image | ||
281 | Test::render(surface.data(), QSize(1280, 1024), Qt::red); | 274 | Test::render(surface.data(), QSize(1280, 1024), Qt::red); | ||
282 | m_connection->flush(); | 275 | m_connection->flush(); | ||
283 | 276 | | |||
284 | QVERIFY(geometryChangedSpy.wait()); | 277 | QVERIFY(geometryChangedSpy.wait()); | ||
285 | QCOMPARE(geometryChangedSpy.count(), 2); | 278 | QCOMPARE(geometryChangedSpy.count(), 2); | ||
286 | QCOMPARE(c->geometry(), QRect(0, 0, 1280, 1024)); | 279 | QCOMPARE(c->geometry(), QRect(0, 0, 1280, 1024)); | ||
287 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | 280 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | ||
288 | 281 | | |||
282 | // client is now set to maximised | ||||
283 | QCOMPARE(maximizeChangedSpy1.count(), 1); | ||||
284 | QCOMPARE(maximizeChangedSpy1.first().first().value<KWin::AbstractClient*>(), c); | ||||
285 | QCOMPARE(maximizeChangedSpy1.first().last().value<KWin::MaximizeMode>(), MaximizeFull); | ||||
286 | QCOMPARE(maximizeChangedSpy2.count(), 1); | ||||
287 | QCOMPARE(maximizeChangedSpy2.first().first().value<KWin::AbstractClient*>(), c); | ||||
288 | QCOMPARE(maximizeChangedSpy2.first().at(1).toBool(), true); | ||||
289 | QCOMPARE(maximizeChangedSpy2.first().at(2).toBool(), true); | ||||
290 | QCOMPARE(c->maximizeMode(), MaximizeFull); | ||||
291 | | ||||
289 | // go back to quick tile none | 292 | // go back to quick tile none | ||
zzag: Maybe this is slightly off-topic, but... could we clear the spies here? | |||||
could be done. I hardly clear, though. I find it gives some value in the test to see how often the signals are emitted. Especially when having multiple. I found bugs through that. graesslin: could be done. I hardly clear, though. I find it gives some value in the test to see how often… | |||||
There's definitely value in checking there are no spurious emits - but you can do that with clears or not. I tend to in any tests I write, but I wouldn't rewrite anything, especially when the count only goes to 2. davidedmundson: There's definitely value in checking there are no spurious emits - but you can do that with… | |||||
290 | QFETCH(QuickTileMode, mode); | 293 | QFETCH(QuickTileMode, mode); | ||
291 | c->setQuickTileMode(mode, true); | 294 | c->setQuickTileMode(mode, true); | ||
292 | QCOMPARE(quickTileChangedSpy.count(), 2); | | |||
zzag: Could it stay here? | |||||
davidedmundson: It could. Done | |||||
293 | QCOMPARE(maximizeChangedSpy1.count(), 2); | | |||
294 | QCOMPARE(maximizeChangedSpy1.last().first().value<KWin::AbstractClient*>(), c); | | |||
295 | QCOMPARE(maximizeChangedSpy1.last().last().value<KWin::MaximizeMode>(), MaximizeRestore); | | |||
296 | QCOMPARE(maximizeChangedSpy2.count(), 2); | | |||
297 | QCOMPARE(maximizeChangedSpy2.last().first().value<KWin::AbstractClient*>(), c); | | |||
298 | QCOMPARE(maximizeChangedSpy2.last().at(1).toBool(), false); | | |||
299 | QCOMPARE(maximizeChangedSpy2.last().at(2).toBool(), false); | | |||
300 | QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None)); | 295 | QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None)); | ||
301 | QCOMPARE(c->maximizeMode(), MaximizeRestore); | | |||
302 | // geometry not yet changed | 296 | // geometry not yet changed | ||
303 | QCOMPARE(c->geometry(), QRect(0, 0, 1280, 1024)); | 297 | QCOMPARE(c->geometry(), QRect(0, 0, 1280, 1024)); | ||
304 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | 298 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | ||
305 | // we got requested a new geometry | 299 | // we got requested a new geometry | ||
306 | QVERIFY(sizeChangeSpy.wait()); | 300 | QVERIFY(sizeChangeSpy.wait()); | ||
307 | QCOMPARE(sizeChangeSpy.count(), 2); | 301 | QCOMPARE(sizeChangeSpy.count(), 2); | ||
308 | QCOMPARE(sizeChangeSpy.last().first().toSize(), QSize(100, 50)); | 302 | QCOMPARE(sizeChangeSpy.last().first().toSize(), QSize(100, 50)); | ||
309 | 303 | | |||
310 | // render again | 304 | // render again | ||
311 | Test::render(surface.data(), QSize(100, 50), Qt::yellow); | 305 | Test::render(surface.data(), QSize(100, 50), Qt::yellow); | ||
312 | m_connection->flush(); | 306 | m_connection->flush(); | ||
313 | 307 | | |||
314 | QVERIFY(geometryChangedSpy.wait()); | 308 | QVERIFY(geometryChangedSpy.wait()); | ||
315 | QCOMPARE(geometryChangedSpy.count(), 4); | 309 | QCOMPARE(geometryChangedSpy.count(), 4); | ||
316 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | 310 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); | ||
317 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | 311 | QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); | ||
312 | QCOMPARE(quickTileChangedSpy.count(), 2); | ||||
313 | QCOMPARE(maximizeChangedSpy1.count(), 2); | ||||
314 | QCOMPARE(maximizeChangedSpy1.last().first().value<KWin::AbstractClient*>(), c); | ||||
315 | QCOMPARE(maximizeChangedSpy1.last().last().value<KWin::MaximizeMode>(), MaximizeRestore); | ||||
316 | QCOMPARE(maximizeChangedSpy2.count(), 2); | ||||
317 | QCOMPARE(maximizeChangedSpy2.last().first().value<KWin::AbstractClient*>(), c); | ||||
318 | QCOMPARE(maximizeChangedSpy2.last().at(1).toBool(), false); | ||||
319 | QCOMPARE(maximizeChangedSpy2.last().at(2).toBool(), false); | ||||
318 | } | 320 | } | ||
319 | 321 | | |||
320 | void QuickTilingTest::testQuickTilingKeyboardMove_data() | 322 | void QuickTilingTest::testQuickTilingKeyboardMove_data() | ||
321 | { | 323 | { | ||
322 | QTest::addColumn<QPoint>("targetPos"); | 324 | QTest::addColumn<QPoint>("targetPos"); | ||
323 | QTest::addColumn<QuickTileMode>("expectedMode"); | 325 | QTest::addColumn<QuickTileMode>("expectedMode"); | ||
324 | 326 | | |||
325 | QTest::newRow("topRight") << QPoint(2559, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Right); | 327 | QTest::newRow("topRight") << QPoint(2559, 24) << QuickTileMode(QuickTileFlag::Top | QuickTileFlag::Right); | ||
▲ Show 20 Lines • Show All 579 Lines • Show Last 20 Lines |
Maybe this is slightly off-topic, but... could we clear the spies here?