Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/maximize_test.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 105 | { | |||
---|---|---|---|---|---|
128 | // TODO: we should test both cases with fixed fake decoration for autotests. | 128 | // TODO: we should test both cases with fixed fake decoration for autotests. | ||
129 | const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; | 129 | const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; | ||
130 | 130 | | |||
131 | // now maximize | 131 | // now maximize | ||
132 | QSignalSpy bordersChangedSpy(decoration, &KDecoration2::Decoration::bordersChanged); | 132 | QSignalSpy bordersChangedSpy(decoration, &KDecoration2::Decoration::bordersChanged); | ||
133 | QVERIFY(bordersChangedSpy.isValid()); | 133 | QVERIFY(bordersChangedSpy.isValid()); | ||
134 | QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged); | 134 | QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged); | ||
135 | QVERIFY(maximizedChangedSpy.isValid()); | 135 | QVERIFY(maximizedChangedSpy.isValid()); | ||
136 | QSignalSpy geometryShapeChangedSpy(client, &AbstractClient::geometryShapeChanged); | 136 | QSignalSpy frameGeometryChangedSpy(client, &AbstractClient::frameGeometryChanged); | ||
137 | QVERIFY(geometryShapeChangedSpy.isValid()); | 137 | QVERIFY(frameGeometryChangedSpy.isValid()); | ||
138 | 138 | | |||
139 | workspace()->slotWindowMaximize(); | 139 | workspace()->slotWindowMaximize(); | ||
140 | QVERIFY(configureRequestedSpy.wait()); | 140 | QVERIFY(configureRequestedSpy.wait()); | ||
141 | QCOMPARE(configureRequestedSpy.count(), 2); | 141 | QCOMPARE(configureRequestedSpy.count(), 2); | ||
142 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024 - decoration->borderTop())); | 142 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024 - decoration->borderTop())); | ||
143 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 143 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
144 | Test::render(surface.data(), configureRequestedSpy.last().at(0).toSize(), Qt::red); | 144 | Test::render(surface.data(), configureRequestedSpy.last().at(0).toSize(), Qt::red); | ||
145 | QVERIFY(geometryShapeChangedSpy.wait()); | 145 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
146 | 146 | | |||
147 | // If no borders, there is only the initial geometry shape change, but none through border resizing. | 147 | // If no borders, there is only the initial geometry shape change, but none through border resizing. | ||
148 | QCOMPARE(geometryShapeChangedSpy.count(), hasBorders ? 2 : 1); | 148 | QCOMPARE(frameGeometryChangedSpy.count(), hasBorders ? 2 : 1); | ||
149 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); | 149 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); | ||
150 | QCOMPARE(maximizedChangedSpy.count(), 1); | 150 | QCOMPARE(maximizedChangedSpy.count(), 1); | ||
151 | QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); | 151 | QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); | ||
152 | QCOMPARE(bordersChangedSpy.count(), hasBorders ? 1 : 0); | 152 | QCOMPARE(bordersChangedSpy.count(), hasBorders ? 1 : 0); | ||
153 | QCOMPARE(decoration->borderLeft(), 0); | 153 | QCOMPARE(decoration->borderLeft(), 0); | ||
154 | QCOMPARE(decoration->borderBottom(), 0); | 154 | QCOMPARE(decoration->borderBottom(), 0); | ||
155 | QCOMPARE(decoration->borderRight(), 0); | 155 | QCOMPARE(decoration->borderRight(), 0); | ||
156 | QVERIFY(decoration->borderTop() != 0); | 156 | QVERIFY(decoration->borderTop() != 0); | ||
157 | 157 | | |||
158 | // now unmaximize again | 158 | // now unmaximize again | ||
159 | workspace()->slotWindowMaximize(); | 159 | workspace()->slotWindowMaximize(); | ||
160 | QVERIFY(configureRequestedSpy.wait()); | 160 | QVERIFY(configureRequestedSpy.wait()); | ||
161 | QCOMPARE(configureRequestedSpy.count(), 3); | 161 | QCOMPARE(configureRequestedSpy.count(), 3); | ||
162 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(100, 50)); | 162 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(100, 50)); | ||
163 | 163 | | |||
164 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 164 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
165 | Test::render(surface.data(), QSize(100, 50), Qt::red); | 165 | Test::render(surface.data(), QSize(100, 50), Qt::red); | ||
166 | QVERIFY(geometryShapeChangedSpy.wait()); | 166 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
167 | QCOMPARE(geometryShapeChangedSpy.count(), hasBorders ? 4 : 2); | 167 | QCOMPARE(frameGeometryChangedSpy.count(), hasBorders ? 4 : 2); | ||
168 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | 168 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||
169 | QCOMPARE(maximizedChangedSpy.count(), 2); | 169 | QCOMPARE(maximizedChangedSpy.count(), 2); | ||
170 | QCOMPARE(maximizedChangedSpy.last().first().toBool(), false); | 170 | QCOMPARE(maximizedChangedSpy.last().first().toBool(), false); | ||
171 | QCOMPARE(bordersChangedSpy.count(), hasBorders ? 2 : 0); | 171 | QCOMPARE(bordersChangedSpy.count(), hasBorders ? 2 : 0); | ||
172 | QVERIFY(decoration->borderTop() != 0); | 172 | QVERIFY(decoration->borderTop() != 0); | ||
173 | QVERIFY(decoration->borderLeft() != !hasBorders); | 173 | QVERIFY(decoration->borderLeft() != !hasBorders); | ||
174 | QVERIFY(decoration->borderRight() != !hasBorders); | 174 | QVERIFY(decoration->borderRight() != !hasBorders); | ||
175 | QVERIFY(decoration->borderBottom() != !hasBorders); | 175 | QVERIFY(decoration->borderBottom() != !hasBorders); | ||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 217 | { | |||
268 | workspace()->slotWindowMaximize(); | 268 | workspace()->slotWindowMaximize(); | ||
269 | QVERIFY(configureRequestedSpy.wait()); | 269 | QVERIFY(configureRequestedSpy.wait()); | ||
270 | QCOMPARE(configureRequestedSpy.count(), 3); | 270 | QCOMPARE(configureRequestedSpy.count(), 3); | ||
271 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024)); | 271 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024)); | ||
272 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | 272 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
273 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | 273 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||
274 | QVERIFY(states.testFlag(XdgShellSurface::State::Maximized)); | 274 | QVERIFY(states.testFlag(XdgShellSurface::State::Maximized)); | ||
275 | 275 | | |||
276 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | 276 | QSignalSpy frameGeometryChangedSpy(client, &AbstractClient::frameGeometryChanged); | ||
277 | QVERIFY(geometryChangedSpy.isValid()); | 277 | QVERIFY(frameGeometryChangedSpy.isValid()); | ||
278 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 278 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
279 | Test::render(surface.data(), QSize(1280, 1024), Qt::blue); | 279 | Test::render(surface.data(), QSize(1280, 1024), Qt::blue); | ||
280 | QVERIFY(geometryChangedSpy.wait()); | 280 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
281 | QCOMPARE(client->frameGeometry(), QRect(0, 0, 1280, 1024)); | 281 | QCOMPARE(client->frameGeometry(), QRect(0, 0, 1280, 1024)); | ||
282 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); | 282 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); | ||
283 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeFull); | 283 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeFull); | ||
284 | QCOMPARE(client->isDecorated(), false); | 284 | QCOMPARE(client->isDecorated(), false); | ||
285 | 285 | | |||
286 | // Restore the client. | 286 | // Restore the client. | ||
287 | workspace()->slotWindowMaximize(); | 287 | workspace()->slotWindowMaximize(); | ||
288 | QVERIFY(configureRequestedSpy.wait()); | 288 | QVERIFY(configureRequestedSpy.wait()); | ||
289 | QCOMPARE(configureRequestedSpy.count(), 4); | 289 | QCOMPARE(configureRequestedSpy.count(), 4); | ||
290 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(100, 50)); | 290 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(100, 50)); | ||
291 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | 291 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
292 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | 292 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||
293 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | 293 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||
294 | 294 | | |||
295 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 295 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
296 | Test::render(surface.data(), QSize(100, 50), Qt::red); | 296 | Test::render(surface.data(), QSize(100, 50), Qt::red); | ||
297 | QVERIFY(geometryChangedSpy.wait()); | 297 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
298 | QCOMPARE(client->frameGeometry(), maximizeRestoreGeometry); | 298 | QCOMPARE(client->frameGeometry(), maximizeRestoreGeometry); | ||
299 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | 299 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||
300 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeRestore); | 300 | QCOMPARE(client->requestedMaximizeMode(), MaximizeMode::MaximizeRestore); | ||
301 | QCOMPARE(client->isDecorated(), true); | 301 | QCOMPARE(client->isDecorated(), true); | ||
302 | 302 | | |||
303 | // Destroy the client. | 303 | // Destroy the client. | ||
304 | shellSurface.reset(); | 304 | shellSurface.reset(); | ||
305 | QVERIFY(Test::waitForWindowDestroyed(client)); | 305 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||
Show All 15 Lines | 309 | { | |||
321 | QScopedPointer<XdgShellSurface> xdgShellSurface(Test::createXdgShellStableSurface(surface.data())); | 321 | QScopedPointer<XdgShellSurface> xdgShellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
322 | QScopedPointer<XdgDecoration> deco(Test::xdgDecorationManager()->getToplevelDecoration(xdgShellSurface.data())); | 322 | QScopedPointer<XdgDecoration> deco(Test::xdgDecorationManager()->getToplevelDecoration(xdgShellSurface.data())); | ||
323 | 323 | | |||
324 | QSignalSpy decorationConfiguredSpy(deco.data(), &XdgDecoration::modeChanged); | 324 | QSignalSpy decorationConfiguredSpy(deco.data(), &XdgDecoration::modeChanged); | ||
325 | QVERIFY(decorationConfiguredSpy.isValid()); | 325 | QVERIFY(decorationConfiguredSpy.isValid()); | ||
326 | 326 | | |||
327 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 327 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
328 | 328 | | |||
329 | QSignalSpy geometryChangedSpy(client, &XdgShellClient::geometryChanged); | 329 | QSignalSpy frameGeometryChangedSpy(client, &XdgShellClient::frameGeometryChanged); | ||
330 | QVERIFY(geometryChangedSpy.isValid()); | 330 | QVERIFY(frameGeometryChangedSpy.isValid()); | ||
331 | QSignalSpy sizeChangeRequestedSpy(xdgShellSurface.data(), &XdgShellSurface::sizeChanged); | 331 | QSignalSpy sizeChangeRequestedSpy(xdgShellSurface.data(), &XdgShellSurface::sizeChanged); | ||
332 | QVERIFY(sizeChangeRequestedSpy.isValid()); | 332 | QVERIFY(sizeChangeRequestedSpy.isValid()); | ||
333 | QSignalSpy configureRequestedSpy(xdgShellSurface.data(), &XdgShellSurface::configureRequested); | 333 | QSignalSpy configureRequestedSpy(xdgShellSurface.data(), &XdgShellSurface::configureRequested); | ||
334 | QVERIFY(configureRequestedSpy.isValid()); | 334 | QVERIFY(configureRequestedSpy.isValid()); | ||
335 | 335 | | |||
336 | QVERIFY(client->isDecorated()); | 336 | QVERIFY(client->isDecorated()); | ||
337 | QVERIFY(!client->noBorder()); | 337 | QVERIFY(!client->noBorder()); | ||
338 | configureRequestedSpy.wait(); | 338 | configureRequestedSpy.wait(); | ||
339 | QCOMPARE(decorationConfiguredSpy.count(), 1); | 339 | QCOMPARE(decorationConfiguredSpy.count(), 1); | ||
340 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | 340 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | ||
341 | 341 | | |||
342 | // go to maximized | 342 | // go to maximized | ||
343 | xdgShellSurface->setMaximized(true); | 343 | xdgShellSurface->setMaximized(true); | ||
344 | QVERIFY(sizeChangeRequestedSpy.wait()); | 344 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
345 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | 345 | QCOMPARE(sizeChangeRequestedSpy.count(), 1); | ||
346 | 346 | | |||
347 | for (const auto &it: configureRequestedSpy) { | 347 | for (const auto &it: configureRequestedSpy) { | ||
348 | xdgShellSurface->ackConfigure(it[2].toInt()); | 348 | xdgShellSurface->ackConfigure(it[2].toInt()); | ||
349 | } | 349 | } | ||
350 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | 350 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | ||
351 | QVERIFY(geometryChangedSpy.wait()); | 351 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
352 | 352 | | |||
353 | // no deco | 353 | // no deco | ||
354 | QVERIFY(!client->isDecorated()); | 354 | QVERIFY(!client->isDecorated()); | ||
355 | QVERIFY(client->noBorder()); | 355 | QVERIFY(client->noBorder()); | ||
356 | // but still server-side | 356 | // but still server-side | ||
357 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | 357 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | ||
358 | 358 | | |||
359 | // go back to normal | 359 | // go back to normal | ||
360 | xdgShellSurface->setMaximized(false); | 360 | xdgShellSurface->setMaximized(false); | ||
361 | QVERIFY(sizeChangeRequestedSpy.wait()); | 361 | QVERIFY(sizeChangeRequestedSpy.wait()); | ||
362 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | 362 | QCOMPARE(sizeChangeRequestedSpy.count(), 2); | ||
363 | 363 | | |||
364 | for (const auto &it: configureRequestedSpy) { | 364 | for (const auto &it: configureRequestedSpy) { | ||
365 | xdgShellSurface->ackConfigure(it[2].toInt()); | 365 | xdgShellSurface->ackConfigure(it[2].toInt()); | ||
366 | } | 366 | } | ||
367 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | 367 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | ||
368 | QVERIFY(geometryChangedSpy.wait()); | 368 | QVERIFY(frameGeometryChangedSpy.wait()); | ||
369 | 369 | | |||
370 | QVERIFY(client->isDecorated()); | 370 | QVERIFY(client->isDecorated()); | ||
371 | QVERIFY(!client->noBorder()); | 371 | QVERIFY(!client->noBorder()); | ||
372 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | 372 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | ||
373 | } | 373 | } | ||
374 | 374 | | |||
375 | WAYLANDTEST_MAIN(TestMaximized) | 375 | WAYLANDTEST_MAIN(TestMaximized) | ||
376 | #include "maximize_test.moc" | 376 | #include "maximize_test.moc" |