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