Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/move_resize_window_test.cpp
Show All 30 Lines | |||||
31 | #include "shell_client.h" | 31 | #include "shell_client.h" | ||
32 | 32 | | |||
33 | #include <KWayland/Client/connection_thread.h> | 33 | #include <KWayland/Client/connection_thread.h> | ||
34 | #include <KWayland/Client/compositor.h> | 34 | #include <KWayland/Client/compositor.h> | ||
35 | #include <KWayland/Client/pointer.h> | 35 | #include <KWayland/Client/pointer.h> | ||
36 | #include <KWayland/Client/plasmashell.h> | 36 | #include <KWayland/Client/plasmashell.h> | ||
37 | #include <KWayland/Client/seat.h> | 37 | #include <KWayland/Client/seat.h> | ||
38 | #include <KWayland/Client/shell.h> | 38 | #include <KWayland/Client/shell.h> | ||
39 | #include <KWayland/Client/xdgshell.h> | ||||
39 | #include <KWayland/Client/surface.h> | 40 | #include <KWayland/Client/surface.h> | ||
40 | #include <KWayland/Client/xdgshell.h> | 41 | #include <KWayland/Client/xdgshell.h> | ||
41 | 42 | | |||
42 | #include <linux/input.h> | 43 | #include <linux/input.h> | ||
43 | #include <xcb/xcb_icccm.h> | 44 | #include <xcb/xcb_icccm.h> | ||
44 | 45 | | |||
45 | Q_DECLARE_METATYPE(KWin::QuickTileMode) | 46 | Q_DECLARE_METATYPE(KWin::QuickTileMode) | ||
46 | Q_DECLARE_METATYPE(KWin::MaximizeMode) | 47 | Q_DECLARE_METATYPE(KWin::MaximizeMode) | ||
Show All 24 Lines | 57 | private Q_SLOTS: | |||
71 | void testClientSideMove(); | 72 | void testClientSideMove(); | ||
72 | void testPlasmaShellSurfaceMovable_data(); | 73 | void testPlasmaShellSurfaceMovable_data(); | ||
73 | void testPlasmaShellSurfaceMovable(); | 74 | void testPlasmaShellSurfaceMovable(); | ||
74 | void testNetMove(); | 75 | void testNetMove(); | ||
75 | void testAdjustClientGeometryOfAutohidingX11Panel_data(); | 76 | void testAdjustClientGeometryOfAutohidingX11Panel_data(); | ||
76 | void testAdjustClientGeometryOfAutohidingX11Panel(); | 77 | void testAdjustClientGeometryOfAutohidingX11Panel(); | ||
77 | void testAdjustClientGeometryOfAutohidingWaylandPanel_data(); | 78 | void testAdjustClientGeometryOfAutohidingWaylandPanel_data(); | ||
78 | void testAdjustClientGeometryOfAutohidingWaylandPanel(); | 79 | void testAdjustClientGeometryOfAutohidingWaylandPanel(); | ||
80 | void testResizeForVirtualKeyboard(); | ||||
81 | void testResizeForVirtualKeyboardWithMaximize(); | ||||
82 | void testResizeForVirtualKeyboardWithFullScreen(); | ||||
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::testResizeForVirtualKeyboard() | ||||
860 | { | ||||
861 | using namespace KWayland::Client; | ||||
862 | | ||||
863 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
864 | QVERIFY(!surface.isNull()); | ||||
865 | | ||||
866 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||||
867 | Test::ShellSurfaceType::XdgShellStable, surface.data())); | ||||
868 | QVERIFY(!shellSurface.isNull()); | ||||
869 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
870 | | ||||
871 | // let's render | ||||
872 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(500, 800), Qt::blue); | ||||
873 | client->move(100, 300); | ||||
874 | QSignalSpy geometryChangedSpy(client, &ShellClient::geometryChanged); | ||||
875 | | ||||
876 | QCOMPARE(client->geometry(), QRect(100, 300, 500, 800)); | ||||
877 | client->setVirtualKeyboardGeometry(QRect(0, 100, 1280, 500)); | ||||
878 | configureRequestedSpy.wait(); | ||||
879 | | ||||
880 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
881 | // render at the new size | ||||
882 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
883 | geometryChangedSpy.wait(); | ||||
884 | | ||||
885 | QCOMPARE(client->geometry(), QRect(100, 0, 500, 101)); | ||||
886 | client->setVirtualKeyboardGeometry(QRect()); | ||||
887 | configureRequestedSpy.wait(); | ||||
888 | | ||||
889 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
890 | // render at the new size | ||||
891 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
892 | geometryChangedSpy.wait(); | ||||
893 | QCOMPARE(client->geometry(), QRect(100, 300, 500, 800)); | ||||
894 | } | ||||
895 | | ||||
896 | void MoveResizeWindowTest::testResizeForVirtualKeyboardWithMaximize() | ||||
897 | { | ||||
898 | using namespace KWayland::Client; | ||||
899 | | ||||
900 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
901 | QVERIFY(!surface.isNull()); | ||||
902 | | ||||
903 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||||
904 | Test::ShellSurfaceType::XdgShellStable, surface.data())); | ||||
905 | QVERIFY(!shellSurface.isNull()); | ||||
906 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
907 | | ||||
908 | // let's render | ||||
909 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(500, 800), Qt::blue); | ||||
910 | client->move(100, 300); | ||||
911 | QSignalSpy geometryChangedSpy(client, &ShellClient::geometryChanged); | ||||
912 | | ||||
913 | QCOMPARE(client->geometry(), QRect(100, 300, 500, 800)); | ||||
914 | client->setVirtualKeyboardGeometry(QRect(0, 100, 1280, 500)); | ||||
915 | configureRequestedSpy.wait(); | ||||
916 | | ||||
917 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
918 | // render at the new size | ||||
919 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
920 | geometryChangedSpy.wait(); | ||||
921 | | ||||
922 | QCOMPARE(client->geometry(), QRect(100, 0, 500, 101)); | ||||
923 | | ||||
924 | client->setMaximize(true, true); | ||||
925 | configureRequestedSpy.wait(); | ||||
926 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
927 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
928 | geometryChangedSpy.wait(); | ||||
929 | QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); | ||||
930 | | ||||
931 | | ||||
932 | client->setVirtualKeyboardGeometry(QRect()); | ||||
933 | QVERIFY(!configureRequestedSpy.wait(10)); | ||||
934 | | ||||
935 | // render at the size of the configureRequested.. it won't have changed | ||||
936 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
937 | QVERIFY(!geometryChangedSpy.wait(10)); | ||||
938 | | ||||
939 | // Size will NOT be restored | ||||
940 | QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); | ||||
941 | } | ||||
942 | | ||||
943 | void MoveResizeWindowTest::testResizeForVirtualKeyboardWithFullScreen() | ||||
944 | { | ||||
945 | using namespace KWayland::Client; | ||||
946 | | ||||
947 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
948 | QVERIFY(!surface.isNull()); | ||||
949 | | ||||
950 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellSurface( | ||||
951 | Test::ShellSurfaceType::XdgShellStable, surface.data())); | ||||
952 | QVERIFY(!shellSurface.isNull()); | ||||
953 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
954 | | ||||
955 | // let's render | ||||
956 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(500, 800), Qt::blue); | ||||
957 | client->move(100, 300); | ||||
958 | QSignalSpy geometryChangedSpy(client, &ShellClient::geometryChanged); | ||||
959 | | ||||
960 | QCOMPARE(client->geometry(), QRect(100, 300, 500, 800)); | ||||
961 | client->setVirtualKeyboardGeometry(QRect(0, 100, 1280, 500)); | ||||
962 | configureRequestedSpy.wait(); | ||||
963 | | ||||
964 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
965 | // render at the new size | ||||
966 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
967 | geometryChangedSpy.wait(); | ||||
968 | | ||||
969 | QCOMPARE(client->geometry(), QRect(100, 0, 500, 101)); | ||||
970 | | ||||
971 | client->setFullScreen(true, true); | ||||
972 | configureRequestedSpy.wait(); | ||||
973 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
974 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
975 | geometryChangedSpy.wait(); | ||||
976 | QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); | ||||
977 | | ||||
978 | | ||||
979 | client->setVirtualKeyboardGeometry(QRect()); | ||||
980 | QVERIFY(!configureRequestedSpy.wait(10)); | ||||
981 | | ||||
982 | // render at the size of the configureRequested.. it won't have changed | ||||
davidedmundson: This line is a bit misleading, there isn't a new size requested.
You're resizing to a… | |||||
983 | Test::render(surface.data(), configureRequestedSpy.last().first().toSize(), Qt::blue); | ||||
984 | QVERIFY(!geometryChangedSpy.wait(10)); | ||||
985 | // Size will NOT be restored | ||||
986 | QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); | ||||
987 | } | ||||
988 | | ||||
855 | } | 989 | } | ||
856 | 990 | | |||
857 | WAYLANDTEST_MAIN(KWin::MoveResizeWindowTest) | 991 | WAYLANDTEST_MAIN(KWin::MoveResizeWindowTest) | ||
858 | #include "move_resize_window_test.moc" | 992 | #include "move_resize_window_test.moc" |
This line is a bit misleading, there isn't a new size requested.
You're resizing to a configure request from ages ago.
Arguably it's a nice test to show that the window hasn't moved afterwards, so maybe leave the code and change this comment.