Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/xdgshellclient_test.cpp
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Line(s) | 295 | { | |||
---|---|---|---|---|---|
303 | // create the Transient window | 303 | // create the Transient window | ||
304 | XdgPositioner positioner(QSize(50, 40), QRect(0, 0, 5, 10)); | 304 | XdgPositioner positioner(QSize(50, 40), QRect(0, 0, 5, 10)); | ||
305 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | 305 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||
306 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 306 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
307 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | 307 | QScopedPointer<Surface> transientSurface(Test::createSurface()); | ||
308 | QScopedPointer<XdgShellPopup> transientShellSurface(Test::createXdgShellStablePopup(transientSurface.data(), shellSurface.data(), positioner)); | 308 | QScopedPointer<XdgShellPopup> transientShellSurface(Test::createXdgShellStablePopup(transientSurface.data(), shellSurface.data(), positioner)); | ||
309 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), positioner.initialSize(), Qt::blue); | 309 | auto transient = Test::renderAndWaitForShown(transientSurface.data(), positioner.initialSize(), Qt::blue); | ||
310 | QVERIFY(transient); | 310 | QVERIFY(transient); | ||
311 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 311 | QCOMPARE(transient->frameGeometry(), QRect(c->frameGeometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
312 | 312 | | |||
313 | // unmap the transient | 313 | // unmap the transient | ||
314 | QSignalSpy windowHiddenSpy(transient, &XdgShellClient::windowHidden); | 314 | QSignalSpy windowHiddenSpy(transient, &XdgShellClient::windowHidden); | ||
315 | QVERIFY(windowHiddenSpy.isValid()); | 315 | QVERIFY(windowHiddenSpy.isValid()); | ||
316 | transientSurface->attachBuffer(Buffer::Ptr()); | 316 | transientSurface->attachBuffer(Buffer::Ptr()); | ||
317 | transientSurface->commit(Surface::CommitFlag::None); | 317 | transientSurface->commit(Surface::CommitFlag::None); | ||
318 | QVERIFY(windowHiddenSpy.wait()); | 318 | QVERIFY(windowHiddenSpy.wait()); | ||
319 | 319 | | |||
320 | // now move the parent surface | 320 | // now move the parent surface | ||
321 | c->setGeometry(c->geometry().translated(5, 10)); | 321 | c->setFrameGeometry(c->frameGeometry().translated(5, 10)); | ||
322 | 322 | | |||
323 | // now map the transient again | 323 | // now map the transient again | ||
324 | QSignalSpy windowShownSpy(transient, &XdgShellClient::windowShown); | 324 | QSignalSpy windowShownSpy(transient, &XdgShellClient::windowShown); | ||
325 | QVERIFY(windowShownSpy.isValid()); | 325 | QVERIFY(windowShownSpy.isValid()); | ||
326 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | 326 | Test::render(transientSurface.data(), QSize(50, 40), Qt::blue); | ||
327 | QVERIFY(windowShownSpy.wait()); | 327 | QVERIFY(windowShownSpy.wait()); | ||
328 | QCOMPARE(transient->geometry(), QRect(c->geometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | 328 | QCOMPARE(transient->frameGeometry(), QRect(c->frameGeometry().topLeft() + QPoint(5, 10), QSize(50, 40))); | ||
329 | } | 329 | } | ||
330 | 330 | | |||
331 | void TestXdgShellClient::testWindowOutputs_data() | 331 | void TestXdgShellClient::testWindowOutputs_data() | ||
332 | { | 332 | { | ||
333 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 333 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
334 | 334 | | |||
335 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 335 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
336 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 336 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
337 | } | 337 | } | ||
338 | 338 | | |||
339 | void TestXdgShellClient::testWindowOutputs() | 339 | void TestXdgShellClient::testWindowOutputs() | ||
340 | { | 340 | { | ||
341 | QScopedPointer<Surface> surface(Test::createSurface()); | 341 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
342 | QFETCH(Test::XdgShellSurfaceType, type); | 342 | QFETCH(Test::XdgShellSurfaceType, type); | ||
343 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | 343 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface(type, surface.data())); | ||
344 | auto size = QSize(200,200); | 344 | auto size = QSize(200,200); | ||
345 | 345 | | |||
346 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | 346 | QSignalSpy outputEnteredSpy(surface.data(), &Surface::outputEntered); | ||
347 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | 347 | QSignalSpy outputLeftSpy(surface.data(), &Surface::outputLeft); | ||
348 | 348 | | |||
349 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | 349 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); | ||
350 | //move to be in the first screen | 350 | //move to be in the first screen | ||
351 | c->setGeometry(QRect(QPoint(100,100), size)); | 351 | c->setFrameGeometry(QRect(QPoint(100,100), size)); | ||
352 | //we don't don't know where the compositor first placed this window, | 352 | //we don't don't know where the compositor first placed this window, | ||
353 | //this might fire, it might not | 353 | //this might fire, it might not | ||
354 | outputEnteredSpy.wait(5); | 354 | outputEnteredSpy.wait(5); | ||
355 | outputEnteredSpy.clear(); | 355 | outputEnteredSpy.clear(); | ||
356 | 356 | | |||
357 | QCOMPARE(surface->outputs().count(), 1); | 357 | QCOMPARE(surface->outputs().count(), 1); | ||
358 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0,0)); | 358 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0,0)); | ||
359 | 359 | | |||
360 | //move to overlapping both first and second screen | 360 | //move to overlapping both first and second screen | ||
361 | c->setGeometry(QRect(QPoint(1250,100), size)); | 361 | c->setFrameGeometry(QRect(QPoint(1250,100), size)); | ||
362 | QVERIFY(outputEnteredSpy.wait()); | 362 | QVERIFY(outputEnteredSpy.wait()); | ||
363 | QCOMPARE(outputEnteredSpy.count(), 1); | 363 | QCOMPARE(outputEnteredSpy.count(), 1); | ||
364 | QCOMPARE(outputLeftSpy.count(), 0); | 364 | QCOMPARE(outputLeftSpy.count(), 0); | ||
365 | QCOMPARE(surface->outputs().count(), 2); | 365 | QCOMPARE(surface->outputs().count(), 2); | ||
366 | QVERIFY(surface->outputs()[0] != surface->outputs()[1]); | 366 | QVERIFY(surface->outputs()[0] != surface->outputs()[1]); | ||
367 | 367 | | |||
368 | //move entirely into second screen | 368 | //move entirely into second screen | ||
369 | c->setGeometry(QRect(QPoint(1400,100), size)); | 369 | c->setFrameGeometry(QRect(QPoint(1400,100), size)); | ||
370 | QVERIFY(outputLeftSpy.wait()); | 370 | QVERIFY(outputLeftSpy.wait()); | ||
371 | QCOMPARE(outputEnteredSpy.count(), 1); | 371 | QCOMPARE(outputEnteredSpy.count(), 1); | ||
372 | QCOMPARE(outputLeftSpy.count(), 1); | 372 | QCOMPARE(outputLeftSpy.count(), 1); | ||
373 | QCOMPARE(surface->outputs().count(), 1); | 373 | QCOMPARE(surface->outputs().count(), 1); | ||
374 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | 374 | QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | void TestXdgShellClient::testMinimizeActiveWindow_data() | 377 | void TestXdgShellClient::testMinimizeActiveWindow_data() | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 430 | { | |||
446 | 446 | | |||
447 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 447 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
448 | QVERIFY(c); | 448 | QVERIFY(c); | ||
449 | QVERIFY(c->isActive()); | 449 | QVERIFY(c->isActive()); | ||
450 | QCOMPARE(c->layer(), NormalLayer); | 450 | QCOMPARE(c->layer(), NormalLayer); | ||
451 | QVERIFY(!c->isFullScreen()); | 451 | QVERIFY(!c->isFullScreen()); | ||
452 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 452 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
453 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 453 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
454 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | 454 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->frameGeometry().size()); | ||
455 | QSignalSpy fullscreenChangedSpy(c, &XdgShellClient::fullScreenChanged); | 455 | QSignalSpy fullscreenChangedSpy(c, &XdgShellClient::fullScreenChanged); | ||
456 | QVERIFY(fullscreenChangedSpy.isValid()); | 456 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
457 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | 457 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
458 | QVERIFY(geometryChangedSpy.isValid()); | 458 | QVERIFY(geometryChangedSpy.isValid()); | ||
459 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | 459 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), &XdgShellSurface::sizeChanged); | ||
460 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 460 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
461 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 461 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
462 | QVERIFY(configureRequestedSpy.isValid()); | 462 | QVERIFY(configureRequestedSpy.isValid()); | ||
Show All 9 Lines | |||||
472 | QVERIFY(geometryChangedSpy.isEmpty()); | 472 | QVERIFY(geometryChangedSpy.isEmpty()); | ||
473 | 473 | | |||
474 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 474 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
475 | Test::render(surface.data(), sizeChangeRequestedSpy.first().first().toSize(), Qt::red); | 475 | Test::render(surface.data(), sizeChangeRequestedSpy.first().first().toSize(), Qt::red); | ||
476 | QVERIFY(geometryChangedSpy.wait()); | 476 | QVERIFY(geometryChangedSpy.wait()); | ||
477 | QCOMPARE(geometryChangedSpy.count(), 1); | 477 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
478 | QVERIFY(c->isFullScreen()); | 478 | QVERIFY(c->isFullScreen()); | ||
479 | QVERIFY(!c->isDecorated()); | 479 | QVERIFY(!c->isDecorated()); | ||
480 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.first().first().toSize())); | 480 | QCOMPARE(c->frameGeometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.first().first().toSize())); | ||
481 | QCOMPARE(c->layer(), ActiveLayer); | 481 | QCOMPARE(c->layer(), ActiveLayer); | ||
482 | 482 | | |||
483 | // swap back to normal | 483 | // swap back to normal | ||
484 | shellSurface->setFullscreen(false); | 484 | shellSurface->setFullscreen(false); | ||
485 | QVERIFY(fullscreenChangedSpy.wait()); | 485 | QVERIFY(fullscreenChangedSpy.wait()); | ||
486 | QVERIFY(sizeChangeRequestedSpy.wait()); | 486 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
487 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | 487 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | ||
488 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | 488 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 504 | { | |||
545 | for (const auto &it: configureRequestedSpy) { | 545 | for (const auto &it: configureRequestedSpy) { | ||
546 | xdgShellSurface->ackConfigure(it[2].toUInt()); | 546 | xdgShellSurface->ackConfigure(it[2].toUInt()); | ||
547 | } | 547 | } | ||
548 | 548 | | |||
549 | Test::render(surface.data(), QSize(100, 50), Qt::red); | 549 | Test::render(surface.data(), QSize(100, 50), Qt::red); | ||
550 | QVERIFY(geometryChangedSpy.wait()); | 550 | QVERIFY(geometryChangedSpy.wait()); | ||
551 | QCOMPARE(geometryChangedSpy.count(), 1); | 551 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
552 | QVERIFY(!c->isFullScreen()); | 552 | QVERIFY(!c->isFullScreen()); | ||
553 | QCOMPARE(c->geometry().size(), QSize(100, 50)); | 553 | QCOMPARE(c->frameGeometry().size(), QSize(100, 50)); | ||
554 | } | 554 | } | ||
555 | 555 | | |||
556 | void TestXdgShellClient::testUserCanSetFullscreen_data() | 556 | void TestXdgShellClient::testUserCanSetFullscreen_data() | ||
557 | { | 557 | { | ||
558 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | 558 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
559 | 559 | | |||
560 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | 560 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
561 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | 561 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 651 | { | |||
703 | QVERIFY(c->isFullScreen()); | 703 | QVERIFY(c->isFullScreen()); | ||
704 | 704 | | |||
705 | // render at the new size | 705 | // render at the new size | ||
706 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 706 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
707 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | 707 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | ||
708 | 708 | | |||
709 | QVERIFY(c->isFullScreen()); | 709 | QVERIFY(c->isFullScreen()); | ||
710 | QVERIFY(!c->isDecorated()); | 710 | QVERIFY(!c->isDecorated()); | ||
711 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.last().first().toSize())); | 711 | QCOMPARE(c->frameGeometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.last().first().toSize())); | ||
712 | sizeChangeRequestedSpy.clear(); | 712 | sizeChangeRequestedSpy.clear(); | ||
713 | 713 | | |||
714 | // swap back to normal | 714 | // swap back to normal | ||
715 | shellSurface->setFullscreen(false); | 715 | shellSurface->setFullscreen(false); | ||
716 | shellSurface->setMaximized(false); | 716 | shellSurface->setMaximized(false); | ||
717 | QVERIFY(fullscreenChangedSpy.wait()); | 717 | QVERIFY(fullscreenChangedSpy.wait()); | ||
718 | if (decoMode == ServerSideDecoration::Mode::Server) { | 718 | if (decoMode == ServerSideDecoration::Mode::Server) { | ||
719 | QVERIFY(sizeChangeRequestedSpy.wait()); | 719 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
▲ Show 20 Lines • Show All 562 Lines • ▼ Show 20 Line(s) | 1274 | { | |||
1282 | 1282 | | |||
1283 | // Create a 160x140 window in with a margin of 10(left), 20(top), 30(right), 40(bottom). Giving a total buffer size 200, 100 | 1283 | // Create a 160x140 window in with a margin of 10(left), 20(top), 30(right), 40(bottom). Giving a total buffer size 200, 100 | ||
1284 | shellSurface->setWindowGeometry(QRect(10, 20, 160, 40)); | 1284 | shellSurface->setWindowGeometry(QRect(10, 20, 160, 40)); | ||
1285 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | 1285 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | ||
1286 | configureRequestedSpy.wait(); //window activated after being shown | 1286 | configureRequestedSpy.wait(); //window activated after being shown | ||
1287 | 1287 | | |||
1288 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | 1288 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | ||
1289 | // resize to 300,200 in kwin terms | 1289 | // resize to 300,200 in kwin terms | ||
1290 | c->setGeometry(QRect(100, 100, 300, 200)); | 1290 | c->setFrameGeometry(QRect(100, 100, 300, 200)); | ||
1291 | QVERIFY(configureRequestedSpy.wait()); | 1291 | QVERIFY(configureRequestedSpy.wait()); | ||
1292 | // requested geometry should not include the margins we had above | 1292 | // requested geometry should not include the margins we had above | ||
1293 | const QSize requestedSize = configureRequestedSpy.last()[0].value<QSize>(); | 1293 | const QSize requestedSize = configureRequestedSpy.last()[0].value<QSize>(); | ||
1294 | QCOMPARE(requestedSize, QSize(300, 200) - QSize(10 + 30, 20 + 40)); | 1294 | QCOMPARE(requestedSize, QSize(300, 200) - QSize(10 + 30, 20 + 40)); | ||
1295 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toUInt()); | 1295 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toUInt()); | ||
1296 | Test::render(surface.data(), requestedSize + QSize(10 + 30, 20 + 40), Qt::blue); | 1296 | Test::render(surface.data(), requestedSize + QSize(10 + 30, 20 + 40), Qt::blue); | ||
1297 | geometryChangedSpy.wait(); | 1297 | geometryChangedSpy.wait(); | ||
1298 | 1298 | | |||
1299 | // kwin's concept of geometry should remain the same | 1299 | // kwin's concept of geometry should remain the same | ||
1300 | QCOMPARE(c->geometry(), QRect(100, 100, 300, 200)); | 1300 | QCOMPARE(c->frameGeometry(), QRect(100, 100, 300, 200)); | ||
1301 | 1301 | | |||
1302 | c->setFullScreen(true); | 1302 | c->setFullScreen(true); | ||
1303 | configureRequestedSpy.wait(); | 1303 | configureRequestedSpy.wait(); | ||
1304 | // when full screen, the window geometry (i.e without margins) should fill the screen | 1304 | // when full screen, the window geometry (i.e without margins) should fill the screen | ||
1305 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | 1305 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | ||
1306 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | 1306 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | ||
1307 | } | 1307 | } | ||
1308 | 1308 | | |||
1309 | WAYLANDTEST_MAIN(TestXdgShellClient) | 1309 | WAYLANDTEST_MAIN(TestXdgShellClient) | ||
1310 | #include "xdgshellclient_test.moc" | 1310 | #include "xdgshellclient_test.moc" |