Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show First 20 Lines • Show All 399 Lines • ▼ Show 20 Line(s) | |||||
400 | 400 | | |||
401 | void TestShellClient::testFullscreen() | 401 | void TestShellClient::testFullscreen() | ||
402 | { | 402 | { | ||
403 | // this test verifies that a window can be properly fullscreened | 403 | // this test verifies that a window can be properly fullscreened | ||
404 | QScopedPointer<Surface> surface(Test::createSurface()); | 404 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
405 | QFETCH(Test::ShellSurfaceType, type); | 405 | QFETCH(Test::ShellSurfaceType, type); | ||
406 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 406 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||
407 | 407 | | |||
408 | ShellSurface* wlShellSurface = nullptr; | ||||
409 | XdgShellSurface *xdgShellSurface = nullptr; | ||||
410 | // fullscreen the window | ||||
411 | switch (type) { | ||||
412 | case Test::ShellSurfaceType::WlShell: | ||||
413 | wlShellSurface = qobject_cast<ShellSurface*>(shellSurface.data()); | ||||
414 | break; | ||||
415 | case Test::ShellSurfaceType::XdgShellV5: | ||||
416 | case Test::ShellSurfaceType::XdgShellV6: | ||||
417 | xdgShellSurface = qobject_cast<XdgShellSurface*>(shellSurface.data()); | ||||
418 | break; | ||||
419 | default: | ||||
420 | Q_UNREACHABLE(); | ||||
421 | break; | ||||
422 | } | ||||
423 | QVERIFY(wlShellSurface || xdgShellSurface); | ||||
424 | QVERIFY(!(wlShellSurface && xdgShellSurface)); | ||||
425 | | ||||
408 | // create deco | 426 | // create deco | ||
409 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 427 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
410 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 428 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
411 | QVERIFY(decoSpy.isValid()); | 429 | QVERIFY(decoSpy.isValid()); | ||
412 | QVERIFY(decoSpy.wait()); | 430 | QVERIFY(decoSpy.wait()); | ||
413 | QFETCH(ServerSideDecoration::Mode, decoMode); | 431 | QFETCH(ServerSideDecoration::Mode, decoMode); | ||
414 | deco->requestMode(decoMode); | 432 | deco->requestMode(decoMode); | ||
415 | QVERIFY(decoSpy.wait()); | 433 | QVERIFY(decoSpy.wait()); | ||
416 | QCOMPARE(deco->mode(), decoMode); | 434 | QCOMPARE(deco->mode(), decoMode); | ||
417 | 435 | | |||
418 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 436 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
419 | QVERIFY(c); | 437 | QVERIFY(c); | ||
420 | QVERIFY(c->isActive()); | 438 | QVERIFY(c->isActive()); | ||
421 | QCOMPARE(c->layer(), NormalLayer); | 439 | QCOMPARE(c->layer(), NormalLayer); | ||
422 | QVERIFY(!c->isFullScreen()); | 440 | QVERIFY(!c->isFullScreen()); | ||
423 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 441 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
424 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 442 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
425 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | 443 | QCOMPARE(c->sizeForClientSize(c->clientSize()), c->geometry().size()); | ||
426 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 444 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | ||
427 | QVERIFY(fullscreenChangedSpy.isValid()); | 445 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
428 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 446 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | ||
429 | QVERIFY(geometryChangedSpy.isValid()); | 447 | QVERIFY(geometryChangedSpy.isValid()); | ||
430 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | 448 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | ||
431 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 449 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
450 | QSignalSpy configureRequestedSpy(shellSurface.data(), SIGNAL(configureRequested(QSize, KWayland::Client::XdgShellSurface::States, quint32))); | ||||
451 | if (xdgShellSurface) { | ||||
452 | QVERIFY(configureRequestedSpy.isValid()); | ||||
453 | } | ||||
432 | 454 | | |||
433 | // fullscreen the window | 455 | if (wlShellSurface) { | ||
434 | switch (type) { | 456 | wlShellSurface->setFullscreen(); | ||
435 | case Test::ShellSurfaceType::WlShell: | 457 | } | ||
436 | qobject_cast<ShellSurface*>(shellSurface.data())->setFullscreen(); | 458 | if (xdgShellSurface) { | ||
437 | break; | 459 | xdgShellSurface->setFullscreen(true); | ||
438 | case Test::ShellSurfaceType::XdgShellV5: | | |||
439 | case Test::ShellSurfaceType::XdgShellV6: | | |||
440 | qobject_cast<XdgShellSurface*>(shellSurface.data())->setFullscreen(true); | | |||
441 | break; | | |||
442 | default: | | |||
443 | Q_UNREACHABLE(); | | |||
444 | break; | | |||
445 | } | 460 | } | ||
461 | | ||||
446 | QVERIFY(fullscreenChangedSpy.wait()); | 462 | QVERIFY(fullscreenChangedSpy.wait()); | ||
447 | QVERIFY(sizeChangeRequestedSpy.wait()); | 463 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
448 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | 464 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | ||
449 | QCOMPARE(sizeChangeRequestedSpy.first().first().toSize(), QSize(screens()->size(0))); | 465 | QCOMPARE(sizeChangeRequestedSpy.first().first().toSize(), QSize(screens()->size(0))); | ||
450 | // TODO: should switch to fullscreen once it's updated | 466 | // TODO: should switch to fullscreen once it's updated | ||
451 | QVERIFY(c->isFullScreen()); | 467 | QVERIFY(c->isFullScreen()); | ||
452 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 468 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
453 | QVERIFY(geometryChangedSpy.isEmpty()); | 469 | QVERIFY(geometryChangedSpy.isEmpty()); | ||
454 | 470 | | |||
455 | // render at the new size | 471 | if (xdgShellSurface) { | ||
472 | for (const auto &it: configureRequestedSpy) { | ||||
473 | xdgShellSurface->ackConfigure(it[2].toInt()); | ||||
474 | } | ||||
475 | } | ||||
476 | | ||||
456 | Test::render(surface.data(), sizeChangeRequestedSpy.first().first().toSize(), Qt::red); | 477 | Test::render(surface.data(), sizeChangeRequestedSpy.first().first().toSize(), Qt::red); | ||
457 | QVERIFY(geometryChangedSpy.wait()); | 478 | QVERIFY(geometryChangedSpy.wait()); | ||
458 | QCOMPARE(geometryChangedSpy.count(), 1); | 479 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
459 | QVERIFY(c->isFullScreen()); | 480 | QVERIFY(c->isFullScreen()); | ||
460 | QVERIFY(!c->isDecorated()); | 481 | QVERIFY(!c->isDecorated()); | ||
461 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.first().first().toSize())); | 482 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.first().first().toSize())); | ||
462 | QCOMPARE(c->layer(), ActiveLayer); | 483 | QCOMPARE(c->layer(), ActiveLayer); | ||
463 | 484 | | |||
464 | // swap back to normal | 485 | // swap back to normal | ||
465 | switch (type) { | 486 | if (wlShellSurface) { | ||
466 | case Test::ShellSurfaceType::WlShell: | 487 | wlShellSurface->setToplevel(); | ||
467 | qobject_cast<ShellSurface*>(shellSurface.data())->setToplevel(); | 488 | } | ||
468 | break; | 489 | if (xdgShellSurface) { | ||
469 | case Test::ShellSurfaceType::XdgShellV5: | 490 | xdgShellSurface->setFullscreen(false); | ||
470 | case Test::ShellSurfaceType::XdgShellV6: | | |||
471 | qobject_cast<XdgShellSurface*>(shellSurface.data())->setFullscreen(false); | | |||
472 | break; | | |||
473 | default: | | |||
474 | Q_UNREACHABLE(); | | |||
475 | break; | | |||
476 | } | 491 | } | ||
477 | QVERIFY(fullscreenChangedSpy.wait()); | 492 | QVERIFY(fullscreenChangedSpy.wait()); | ||
478 | QVERIFY(sizeChangeRequestedSpy.wait()); | 493 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
479 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | 494 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | ||
480 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | 495 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(100, 50)); | ||
481 | // TODO: should switch to fullscreen once it's updated | 496 | // TODO: should switch to fullscreen once it's updated | ||
482 | QVERIFY(!c->isFullScreen()); | 497 | QVERIFY(!c->isFullScreen()); | ||
483 | QCOMPARE(c->layer(), NormalLayer); | 498 | QCOMPARE(c->layer(), NormalLayer); | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
597 | 612 | | |||
598 | void TestShellClient::testMaximizedToFullscreen() | 613 | void TestShellClient::testMaximizedToFullscreen() | ||
599 | { | 614 | { | ||
600 | // this test verifies that a window can be properly fullscreened after maximizing | 615 | // this test verifies that a window can be properly fullscreened after maximizing | ||
601 | QScopedPointer<Surface> surface(Test::createSurface()); | 616 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
602 | QFETCH(Test::ShellSurfaceType, type); | 617 | QFETCH(Test::ShellSurfaceType, type); | ||
603 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | 618 | QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data())); | ||
604 | 619 | | |||
620 | ShellSurface* wlShellSurface = nullptr; | ||||
621 | XdgShellSurface *xdgShellSurface = nullptr; | ||||
622 | // fullscreen the window | ||||
623 | switch (type) { | ||||
624 | case Test::ShellSurfaceType::WlShell: | ||||
625 | wlShellSurface = qobject_cast<ShellSurface*>(shellSurface.data()); | ||||
626 | break; | ||||
627 | case Test::ShellSurfaceType::XdgShellV5: | ||||
628 | case Test::ShellSurfaceType::XdgShellV6: | ||||
629 | xdgShellSurface = qobject_cast<XdgShellSurface*>(shellSurface.data()); | ||||
630 | break; | ||||
631 | default: | ||||
632 | Q_UNREACHABLE(); | ||||
633 | break; | ||||
634 | } | ||||
635 | QVERIFY(wlShellSurface || xdgShellSurface); | ||||
636 | QVERIFY(!(wlShellSurface && xdgShellSurface)); | ||||
637 | | ||||
605 | // create deco | 638 | // create deco | ||
606 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | 639 | QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data())); | ||
607 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | 640 | QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged); | ||
608 | QVERIFY(decoSpy.isValid()); | 641 | QVERIFY(decoSpy.isValid()); | ||
609 | QVERIFY(decoSpy.wait()); | 642 | QVERIFY(decoSpy.wait()); | ||
610 | QFETCH(ServerSideDecoration::Mode, decoMode); | 643 | QFETCH(ServerSideDecoration::Mode, decoMode); | ||
611 | deco->requestMode(decoMode); | 644 | deco->requestMode(decoMode); | ||
612 | QVERIFY(decoSpy.wait()); | 645 | QVERIFY(decoSpy.wait()); | ||
613 | QCOMPARE(deco->mode(), decoMode); | 646 | QCOMPARE(deco->mode(), decoMode); | ||
614 | 647 | | |||
615 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 648 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
616 | QVERIFY(c); | 649 | QVERIFY(c); | ||
617 | QVERIFY(c->isActive()); | 650 | QVERIFY(c->isActive()); | ||
618 | QVERIFY(!c->isFullScreen()); | 651 | QVERIFY(!c->isFullScreen()); | ||
619 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 652 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
620 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | 653 | QCOMPARE(c->isDecorated(), decoMode == ServerSideDecoration::Mode::Server); | ||
621 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | 654 | QSignalSpy fullscreenChangedSpy(c, &ShellClient::fullScreenChanged); | ||
622 | QVERIFY(fullscreenChangedSpy.isValid()); | 655 | QVERIFY(fullscreenChangedSpy.isValid()); | ||
623 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | 656 | QSignalSpy geometryChangedSpy(c, &ShellClient::geometryChanged); | ||
624 | QVERIFY(geometryChangedSpy.isValid()); | 657 | QVERIFY(geometryChangedSpy.isValid()); | ||
625 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | 658 | QSignalSpy sizeChangeRequestedSpy(shellSurface.data(), SIGNAL(sizeChanged(QSize))); | ||
626 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 659 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
660 | QSignalSpy configureRequestedSpy(shellSurface.data(), SIGNAL(configureRequested(QSize, KWayland::Client::XdgShellSurface::States, quint32))); | ||||
661 | if (xdgShellSurface) { | ||||
662 | QVERIFY(configureRequestedSpy.isValid()); | ||||
663 | } | ||||
627 | 664 | | |||
628 | // change to maximize | 665 | // change to maximize | ||
629 | switch (type) { | 666 | if (wlShellSurface) { | ||
630 | case Test::ShellSurfaceType::WlShell: | 667 | wlShellSurface->setMaximized(); | ||
631 | qobject_cast<ShellSurface*>(shellSurface.data())->setMaximized(); | 668 | } | ||
632 | break; | 669 | if (xdgShellSurface) { | ||
633 | case Test::ShellSurfaceType::XdgShellV5: | 670 | xdgShellSurface->setMaximized(true); | ||
634 | case Test::ShellSurfaceType::XdgShellV6: | | |||
635 | qobject_cast<XdgShellSurface*>(shellSurface.data())->setMaximized(true); | | |||
636 | break; | | |||
637 | default: | | |||
638 | Q_UNREACHABLE(); | | |||
639 | break; | | |||
640 | } | 671 | } | ||
641 | QVERIFY(sizeChangeRequestedSpy.wait()); | 672 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
642 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | 673 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | ||
643 | QCOMPARE(c->maximizeMode(), MaximizeFull); | 674 | QCOMPARE(c->maximizeMode(), MaximizeFull); | ||
644 | QCOMPARE(geometryChangedSpy.isEmpty(), false); | 675 | QCOMPARE(geometryChangedSpy.isEmpty(), false); | ||
645 | geometryChangedSpy.clear(); | 676 | geometryChangedSpy.clear(); | ||
646 | 677 | | |||
647 | // fullscreen the window | 678 | // fullscreen the window | ||
648 | switch (type) { | 679 | if (wlShellSurface) { | ||
649 | case Test::ShellSurfaceType::WlShell: | 680 | wlShellSurface->setFullscreen(); | ||
650 | qobject_cast<ShellSurface*>(shellSurface.data())->setFullscreen(); | 681 | } | ||
651 | break; | 682 | if (xdgShellSurface) { | ||
652 | case Test::ShellSurfaceType::XdgShellV5: | 683 | xdgShellSurface->setFullscreen(true); | ||
653 | case Test::ShellSurfaceType::XdgShellV6: | | |||
654 | qobject_cast<XdgShellSurface*>(shellSurface.data())->setFullscreen(true); | | |||
655 | break; | | |||
656 | default: | | |||
657 | Q_UNREACHABLE(); | | |||
658 | break; | | |||
659 | } | 684 | } | ||
660 | QVERIFY(fullscreenChangedSpy.wait()); | 685 | QVERIFY(fullscreenChangedSpy.wait()); | ||
661 | if (decoMode == ServerSideDecoration::Mode::Server) { | 686 | if (decoMode == ServerSideDecoration::Mode::Server) { | ||
662 | QVERIFY(sizeChangeRequestedSpy.wait()); | 687 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
663 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | 688 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | ||
664 | } | 689 | } | ||
665 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(screens()->size(0))); | 690 | QCOMPARE(sizeChangeRequestedSpy.last().first().toSize(), QSize(screens()->size(0))); | ||
666 | // TODO: should switch to fullscreen once it's updated | 691 | // TODO: should switch to fullscreen once it's updated | ||
667 | QVERIFY(c->isFullScreen()); | 692 | QVERIFY(c->isFullScreen()); | ||
668 | QCOMPARE(c->clientSize(), QSize(100, 50)); | 693 | QCOMPARE(c->clientSize(), QSize(100, 50)); | ||
669 | QVERIFY(geometryChangedSpy.isEmpty()); | 694 | QVERIFY(geometryChangedSpy.isEmpty()); | ||
670 | 695 | | |||
696 | if (xdgShellSurface) { | ||||
697 | for (const auto &it: configureRequestedSpy) { | ||||
698 | xdgShellSurface->ackConfigure(it[2].toInt()); | ||||
699 | } | ||||
700 | } | ||||
701 | | ||||
671 | // render at the new size | 702 | // render at the new size | ||
672 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | 703 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | ||
673 | QVERIFY(geometryChangedSpy.wait()); | 704 | QVERIFY(geometryChangedSpy.wait()); | ||
674 | QCOMPARE(geometryChangedSpy.count(), 1); | 705 | QCOMPARE(geometryChangedSpy.count(), 1); | ||
675 | QVERIFY(c->isFullScreen()); | 706 | QVERIFY(c->isFullScreen()); | ||
676 | QVERIFY(!c->isDecorated()); | 707 | QVERIFY(!c->isDecorated()); | ||
677 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.last().first().toSize())); | 708 | QCOMPARE(c->geometry(), QRect(QPoint(0, 0), sizeChangeRequestedSpy.last().first().toSize())); | ||
678 | sizeChangeRequestedSpy.clear(); | 709 | sizeChangeRequestedSpy.clear(); | ||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |