Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/move_resize_window_test.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 56 | private Q_SLOTS: | |||
---|---|---|---|---|---|
71 | void testClientSideMove(); | 71 | void testClientSideMove(); | ||
72 | void testPlasmaShellSurfaceMovable_data(); | 72 | void testPlasmaShellSurfaceMovable_data(); | ||
73 | void testPlasmaShellSurfaceMovable(); | 73 | void testPlasmaShellSurfaceMovable(); | ||
74 | void testNetMove(); | 74 | void testNetMove(); | ||
75 | void testAdjustClientGeometryOfAutohidingX11Panel_data(); | 75 | void testAdjustClientGeometryOfAutohidingX11Panel_data(); | ||
76 | void testAdjustClientGeometryOfAutohidingX11Panel(); | 76 | void testAdjustClientGeometryOfAutohidingX11Panel(); | ||
77 | void testAdjustClientGeometryOfAutohidingWaylandPanel_data(); | 77 | void testAdjustClientGeometryOfAutohidingWaylandPanel_data(); | ||
78 | void testAdjustClientGeometryOfAutohidingWaylandPanel(); | 78 | void testAdjustClientGeometryOfAutohidingWaylandPanel(); | ||
79 | void testDestroyMoveClient(); | ||||
80 | void testDestroyResizeClient(); | ||||
81 | void testUnmapMoveClient(); | ||||
82 | void testUnmapResizeClient(); | ||||
79 | 83 | | |||
80 | private: | 84 | private: | ||
81 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 85 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
82 | KWayland::Client::Compositor *m_compositor = nullptr; | 86 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
83 | KWayland::Client::Shell *m_shell = nullptr; | 87 | KWayland::Client::Shell *m_shell = nullptr; | ||
84 | }; | 88 | }; | ||
85 | 89 | | |||
86 | void MoveResizeWindowTest::initTestCase() | 90 | void MoveResizeWindowTest::initTestCase() | ||
▲ Show 20 Lines • Show All 760 Lines • ▼ Show 20 Line(s) | 795 | { | |||
847 | // and close | 851 | // and close | ||
848 | QSignalSpy windowClosedSpy(testWindow, &ShellClient::windowClosed); | 852 | QSignalSpy windowClosedSpy(testWindow, &ShellClient::windowClosed); | ||
849 | QVERIFY(windowClosedSpy.isValid()); | 853 | QVERIFY(windowClosedSpy.isValid()); | ||
850 | shellSurface.reset(); | 854 | shellSurface.reset(); | ||
851 | surface.reset(); | 855 | surface.reset(); | ||
852 | QVERIFY(windowClosedSpy.wait()); | 856 | QVERIFY(windowClosedSpy.wait()); | ||
853 | } | 857 | } | ||
854 | 858 | | |||
859 | void MoveResizeWindowTest::testDestroyMoveClient() | ||||
860 | { | ||||
861 | // This test verifies that active move operation gets finished when | ||||
862 | // the associated client is destroyed. | ||||
863 | | ||||
864 | // Create the test client. | ||||
865 | using namespace KWayland::Client; | ||||
866 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
867 | QVERIFY(!surface.isNull()); | ||||
868 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
869 | QVERIFY(!shellSurface.isNull()); | ||||
870 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
871 | QVERIFY(client); | ||||
872 | | ||||
873 | // Start moving the client. | ||||
874 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
875 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
876 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
877 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
878 | | ||||
879 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
880 | QCOMPARE(client->isMove(), false); | ||||
881 | QCOMPARE(client->isResize(), false); | ||||
882 | workspace()->slotWindowMove(); | ||||
883 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
884 | QCOMPARE(workspace()->getMovingClient(), client); | ||||
885 | QCOMPARE(client->isMove(), true); | ||||
886 | QCOMPARE(client->isResize(), false); | ||||
887 | | ||||
888 | // Let's pretend that the client crashed. | ||||
889 | shellSurface.reset(); | ||||
890 | surface.reset(); | ||||
891 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
892 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
893 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
894 | } | ||||
895 | | ||||
896 | void MoveResizeWindowTest::testDestroyResizeClient() | ||||
897 | { | ||||
898 | // This test verifies that active resize operation gets finished when | ||||
899 | // the associated client is destroyed. | ||||
900 | | ||||
901 | // Create the test client. | ||||
902 | using namespace KWayland::Client; | ||||
903 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
904 | QVERIFY(!surface.isNull()); | ||||
905 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
906 | QVERIFY(!shellSurface.isNull()); | ||||
907 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
908 | QVERIFY(client); | ||||
909 | | ||||
910 | // Start resizing the client. | ||||
911 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
912 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
913 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
914 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
915 | | ||||
916 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
917 | QCOMPARE(client->isMove(), false); | ||||
918 | QCOMPARE(client->isResize(), false); | ||||
919 | workspace()->slotWindowResize(); | ||||
920 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
921 | QCOMPARE(workspace()->getMovingClient(), client); | ||||
922 | QCOMPARE(client->isMove(), false); | ||||
923 | QCOMPARE(client->isResize(), true); | ||||
924 | | ||||
925 | // Let's pretend that the client crashed. | ||||
926 | shellSurface.reset(); | ||||
927 | surface.reset(); | ||||
928 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
929 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
930 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
931 | } | ||||
932 | | ||||
933 | void MoveResizeWindowTest::testUnmapMoveClient() | ||||
934 | { | ||||
935 | // This test verifies that active move operation gets cancelled when | ||||
936 | // the associated client is unmapped. | ||||
937 | | ||||
938 | // Create the test client. | ||||
939 | using namespace KWayland::Client; | ||||
940 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
941 | QVERIFY(!surface.isNull()); | ||||
942 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
943 | QVERIFY(!shellSurface.isNull()); | ||||
944 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
945 | QVERIFY(client); | ||||
946 | | ||||
947 | // Start resizing the client. | ||||
948 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
949 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
950 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
951 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
952 | | ||||
953 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
954 | QCOMPARE(client->isMove(), false); | ||||
955 | QCOMPARE(client->isResize(), false); | ||||
956 | workspace()->slotWindowMove(); | ||||
957 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
958 | QCOMPARE(workspace()->getMovingClient(), client); | ||||
959 | QCOMPARE(client->isMove(), true); | ||||
960 | QCOMPARE(client->isResize(), false); | ||||
961 | | ||||
962 | // Unmap the client while we're moving it. | ||||
963 | QSignalSpy hiddenSpy(client, &ShellClient::windowHidden); | ||||
964 | QVERIFY(hiddenSpy.isValid()); | ||||
965 | surface->attachBuffer(Buffer::Ptr()); | ||||
966 | surface->commit(Surface::CommitFlag::None); | ||||
967 | QVERIFY(hiddenSpy.wait()); | ||||
968 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
969 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
970 | QCOMPARE(client->isMove(), false); | ||||
971 | QCOMPARE(client->isResize(), false); | ||||
972 | | ||||
973 | // Destroy the client. | ||||
974 | shellSurface.reset(); | ||||
975 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
976 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
977 | } | ||||
978 | | ||||
979 | void MoveResizeWindowTest::testUnmapResizeClient() | ||||
980 | { | ||||
981 | // This test verifies that active resize operation gets cancelled when | ||||
982 | // the associated client is unmapped. | ||||
983 | | ||||
984 | // Create the test client. | ||||
985 | using namespace KWayland::Client; | ||||
986 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
987 | QVERIFY(!surface.isNull()); | ||||
988 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
989 | QVERIFY(!shellSurface.isNull()); | ||||
990 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
991 | QVERIFY(client); | ||||
992 | | ||||
993 | // Start resizing the client. | ||||
994 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
995 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
996 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
997 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
998 | | ||||
999 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
1000 | QCOMPARE(client->isMove(), false); | ||||
1001 | QCOMPARE(client->isResize(), false); | ||||
1002 | workspace()->slotWindowResize(); | ||||
1003 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
1004 | QCOMPARE(workspace()->getMovingClient(), client); | ||||
1005 | QCOMPARE(client->isMove(), false); | ||||
1006 | QCOMPARE(client->isResize(), true); | ||||
1007 | | ||||
1008 | // Unmap the client while we're resizing it. | ||||
1009 | QSignalSpy hiddenSpy(client, &ShellClient::windowHidden); | ||||
1010 | QVERIFY(hiddenSpy.isValid()); | ||||
1011 | surface->attachBuffer(Buffer::Ptr()); | ||||
1012 | surface->commit(Surface::CommitFlag::None); | ||||
1013 | QVERIFY(hiddenSpy.wait()); | ||||
1014 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
1015 | QCOMPARE(workspace()->getMovingClient(), nullptr); | ||||
1016 | QCOMPARE(client->isMove(), false); | ||||
1017 | QCOMPARE(client->isResize(), false); | ||||
1018 | | ||||
1019 | // Destroy the client. | ||||
1020 | shellSurface.reset(); | ||||
1021 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1022 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
1023 | } | ||||
1024 | | ||||
855 | } | 1025 | } | ||
856 | 1026 | | |||
857 | WAYLANDTEST_MAIN(KWin::MoveResizeWindowTest) | 1027 | WAYLANDTEST_MAIN(KWin::MoveResizeWindowTest) | ||
858 | #include "move_resize_window_test.moc" | 1028 | #include "move_resize_window_test.moc" |