Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/placement_test.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
53 | private Q_SLOTS: | 53 | private Q_SLOTS: | ||
54 | void init(); | 54 | void init(); | ||
55 | void cleanup(); | 55 | void cleanup(); | ||
56 | void initTestCase(); | 56 | void initTestCase(); | ||
57 | 57 | | |||
58 | void testPlaceSmart(); | 58 | void testPlaceSmart(); | ||
59 | void testPlaceZeroCornered(); | 59 | void testPlaceZeroCornered(); | ||
60 | void testPlaceMaximized(); | 60 | void testPlaceMaximized(); | ||
61 | void testPlaceMaximizedLeavesFullscreen(); | ||||
61 | void testPlaceCentered(); | 62 | void testPlaceCentered(); | ||
62 | void testPlaceUnderMouse(); | 63 | void testPlaceUnderMouse(); | ||
63 | void testPlaceCascaded(); | 64 | void testPlaceCascaded(); | ||
64 | void testPlaceRandom(); | 65 | void testPlaceRandom(); | ||
65 | 66 | | |||
66 | private: | 67 | private: | ||
67 | void setPlacementPolicy(Placement::Policy policy); | 68 | void setPlacementPolicy(Placement::Policy policy); | ||
68 | /* | 69 | /* | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 186 | { | |||
199 | for (int i = 0; i < 4; i++) { | 200 | for (int i = 0; i < 4; i++) { | ||
200 | PlaceWindowResult windowPlacement = createAndPlaceWindow(QSize(600, 500), testParent.data()); | 201 | PlaceWindowResult windowPlacement = createAndPlaceWindow(QSize(600, 500), testParent.data()); | ||
201 | QVERIFY(windowPlacement.initiallyConfiguredStates & XdgShellSurface::State::Maximized); | 202 | QVERIFY(windowPlacement.initiallyConfiguredStates & XdgShellSurface::State::Maximized); | ||
202 | QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(1280, 1024 - 20)); | 203 | QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(1280, 1024 - 20)); | ||
203 | QCOMPARE(windowPlacement.finalGeometry, QRect(0, 20, 1280, 1024 - 20)); // under the panel | 204 | QCOMPARE(windowPlacement.finalGeometry, QRect(0, 20, 1280, 1024 - 20)); // under the panel | ||
204 | } | 205 | } | ||
205 | } | 206 | } | ||
206 | 207 | | |||
208 | void TestPlacement::testPlaceMaximizedLeavesFullscreen() | ||||
209 | { | ||||
210 | setPlacementPolicy(Placement::Maximizing); | ||||
211 | | ||||
212 | // add a top panel | ||||
213 | QScopedPointer<Surface> panelSurface(Test::createSurface()); | ||||
214 | QScopedPointer<QObject> panelShellSurface(Test::createXdgShellStableSurface(panelSurface.data())); | ||||
215 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data())); | ||||
216 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||||
217 | plasmaSurface->setPosition(QPoint(0, 0)); | ||||
218 | Test::renderAndWaitForShown(panelSurface.data(), QSize(1280, 20), Qt::blue); | ||||
219 | | ||||
220 | QScopedPointer<QObject> testParent(new QObject); | ||||
221 | | ||||
222 | // all windows should be initially fullscreen with an initial configure size sent, despite the policy | ||||
223 | for (int i = 0; i < 4; i++) { | ||||
224 | auto surface = Test::createSurface(testParent.data()); | ||||
225 | auto shellSurface = Test::createXdgShellStableSurface(surface, surface, Test::CreationSetup::CreateOnly); | ||||
226 | shellSurface->setFullscreen(true); | ||||
227 | QSignalSpy configSpy(shellSurface, &XdgShellSurface::configureRequested); | ||||
228 | surface->commit(Surface::CommitFlag::None); | ||||
229 | configSpy.wait(); | ||||
230 | | ||||
231 | auto initiallyConfiguredSize = configSpy[0][0].toSize(); | ||||
232 | auto initiallyConfiguredStates = configSpy[0][1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
233 | shellSurface->ackConfigure(configSpy[0][2].toUInt()); | ||||
234 | | ||||
235 | auto c = Test::renderAndWaitForShown(surface, initiallyConfiguredSize, Qt::red); | ||||
236 | | ||||
237 | QVERIFY(initiallyConfiguredStates & XdgShellSurface::State::Fullscreen); | ||||
238 | QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024 )); | ||||
239 | QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024)); | ||||
240 | } | ||||
241 | } | ||||
242 | | ||||
207 | void TestPlacement::testPlaceCentered() | 243 | void TestPlacement::testPlaceCentered() | ||
208 | { | 244 | { | ||
209 | // This test verifies that Centered placement policy works. | 245 | // This test verifies that Centered placement policy works. | ||
210 | 246 | | |||
211 | KConfigGroup group = kwinApp()->config()->group("Windows"); | 247 | KConfigGroup group = kwinApp()->config()->group("Windows"); | ||
212 | group.writeEntry("Placement", Placement::policyToString(Placement::Centered)); | 248 | group.writeEntry("Placement", Placement::policyToString(Placement::Centered)); | ||
213 | group.sync(); | 249 | group.sync(); | ||
214 | workspace()->slotReconfigure(); | 250 | workspace()->slotReconfigure(); | ||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |