Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/xdgshellclient_test.cpp
Show All 32 Lines | |||||
33 | #include <KDecoration2/DecoratedClient> | 33 | #include <KDecoration2/DecoratedClient> | ||
34 | #include <KDecoration2/Decoration> | 34 | #include <KDecoration2/Decoration> | ||
35 | #include <KDecoration2/DecorationSettings> | 35 | #include <KDecoration2/DecorationSettings> | ||
36 | 36 | | |||
37 | #include <KWayland/Client/connection_thread.h> | 37 | #include <KWayland/Client/connection_thread.h> | ||
38 | #include <KWayland/Client/compositor.h> | 38 | #include <KWayland/Client/compositor.h> | ||
39 | #include <KWayland/Client/output.h> | 39 | #include <KWayland/Client/output.h> | ||
40 | #include <KWayland/Client/server_decoration.h> | 40 | #include <KWayland/Client/server_decoration.h> | ||
41 | #include <KWayland/Client/subsurface.h> | ||||
41 | #include <KWayland/Client/surface.h> | 42 | #include <KWayland/Client/surface.h> | ||
42 | #include <KWayland/Client/xdgshell.h> | 43 | #include <KWayland/Client/xdgshell.h> | ||
43 | #include <KWayland/Client/xdgdecoration.h> | 44 | #include <KWayland/Client/xdgdecoration.h> | ||
44 | #include <KWayland/Client/appmenu.h> | 45 | #include <KWayland/Client/appmenu.h> | ||
45 | 46 | | |||
46 | #include <KWayland/Server/clientconnection.h> | 47 | #include <KWayland/Server/clientconnection.h> | ||
47 | #include <KWayland/Server/display.h> | 48 | #include <KWayland/Server/display.h> | ||
48 | #include <KWayland/Server/xdgdecoration_interface.h> | 49 | #include <KWayland/Server/xdgdecoration_interface.h> | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 68 | private Q_SLOTS: | |||
108 | void testMinimizeWindowWithTransients_data(); | 109 | void testMinimizeWindowWithTransients_data(); | ||
109 | void testMinimizeWindowWithTransients(); | 110 | void testMinimizeWindowWithTransients(); | ||
110 | void testXdgDecoration_data(); | 111 | void testXdgDecoration_data(); | ||
111 | void testXdgDecoration(); | 112 | void testXdgDecoration(); | ||
112 | void testXdgNeverCommitted(); | 113 | void testXdgNeverCommitted(); | ||
113 | void testXdgInitialState(); | 114 | void testXdgInitialState(); | ||
114 | void testXdgInitiallyMaximised(); | 115 | void testXdgInitiallyMaximised(); | ||
115 | void testXdgInitiallyMinimized(); | 116 | void testXdgInitiallyMinimized(); | ||
116 | void testXdgWindowGeometry(); | 117 | void testXdgWindowGeometryIsntSet(); | ||
118 | void testXdgWindowGeometryAttachBuffer(); | ||||
119 | void testXdgWindowGeometryAttachSubSurface(); | ||||
120 | void testXdgWindowGeometryInteractiveResize(); | ||||
121 | void testXdgWindowGeometryFullScreen(); | ||||
122 | void testXdgWindowGeometryMaximize(); | ||||
117 | }; | 123 | }; | ||
118 | 124 | | |||
119 | void TestXdgShellClient::initTestCase() | 125 | void TestXdgShellClient::initTestCase() | ||
120 | { | 126 | { | ||
121 | qRegisterMetaType<KWin::Deleted*>(); | 127 | qRegisterMetaType<KWin::Deleted*>(); | ||
122 | qRegisterMetaType<KWin::XdgShellClient *>(); | 128 | qRegisterMetaType<KWin::XdgShellClient *>(); | ||
123 | qRegisterMetaType<KWin::AbstractClient*>(); | 129 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
124 | qRegisterMetaType<KWayland::Client::Output*>(); | 130 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
▲ Show 20 Lines • Show All 1140 Lines • ▼ Show 20 Line(s) | 1253 | { | |||
1265 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1271 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | ||
1266 | 1272 | | |||
1267 | QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort); | 1273 | QEXPECT_FAIL("", "Client created in a minimised state is not exposed to kwin bug 404838", Abort); | ||
1268 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue, QImage::Format_ARGB32, 10); | 1274 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue, QImage::Format_ARGB32, 10); | ||
1269 | QVERIFY(c); | 1275 | QVERIFY(c); | ||
1270 | QVERIFY(c->isMinimized()); | 1276 | QVERIFY(c->isMinimized()); | ||
1271 | } | 1277 | } | ||
1272 | 1278 | | |||
1273 | void TestXdgShellClient::testXdgWindowGeometry() | 1279 | void TestXdgShellClient::testXdgWindowGeometryIsntSet() | ||
1274 | { | 1280 | { | ||
1281 | // This test verifies that the effective window geometry corresponds to the | ||||
1282 | // bounding rectangle of the main surface and its sub-surfaces if no window | ||||
1283 | // geometry is set by the client. | ||||
1284 | | ||||
1275 | QScopedPointer<Surface> surface(Test::createSurface()); | 1285 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1276 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly)); | 1286 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1287 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1288 | QVERIFY(client); | ||||
1289 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1290 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1291 | | ||||
1292 | const QPoint oldPosition = client->pos(); | ||||
1293 | | ||||
1294 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1295 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1296 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||||
1297 | QVERIFY(geometryChangedSpy.wait()); | ||||
1298 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1299 | QCOMPARE(client->frameGeometry().size(), QSize(100, 50)); | ||||
1300 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition); | ||||
1301 | QCOMPARE(client->bufferGeometry().size(), QSize(100, 50)); | ||||
1302 | | ||||
1303 | QScopedPointer<Surface> childSurface(Test::createSurface()); | ||||
1304 | QScopedPointer<SubSurface> subSurface(Test::createSubSurface(childSurface.data(), surface.data())); | ||||
1305 | QVERIFY(subSurface); | ||||
1306 | subSurface->setPosition(QPoint(-20, -10)); | ||||
1307 | Test::render(childSurface.data(), QSize(100, 50), Qt::blue); | ||||
1308 | surface->commit(Surface::CommitFlag::None); | ||||
1309 | QVERIFY(geometryChangedSpy.wait()); | ||||
1310 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1311 | QCOMPARE(client->frameGeometry().size(), QSize(120, 60)); | ||||
davidedmundson: Generally it's a lot easier to read something like
QCOMPARE(..., QSize(100 + 20, 50 + 10))… | |||||
1312 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition + QPoint(20, 10)); | ||||
1313 | QCOMPARE(client->bufferGeometry().size(), QSize(100, 50)); | ||||
1314 | } | ||||
1315 | | ||||
1316 | void TestXdgShellClient::testXdgWindowGeometryAttachBuffer() | ||||
1317 | { | ||||
1318 | // This test verifies that the effective window geometry remains the same when | ||||
1319 | // a new buffer is attached and xdg_surface.set_window_geometry is not called | ||||
1320 | // again. Notice that the window geometry must remain the same even if the new | ||||
1321 | // buffer is smaller. | ||||
1322 | | ||||
1323 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1324 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1325 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1326 | QVERIFY(client); | ||||
1327 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1328 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1329 | | ||||
1330 | const QPoint oldPosition = client->pos(); | ||||
1331 | | ||||
1332 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1333 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1334 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1335 | surface->commit(Surface::CommitFlag::None); | ||||
1336 | QVERIFY(geometryChangedSpy.wait()); | ||||
1337 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1338 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1339 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10)); | ||||
1340 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1341 | | ||||
1342 | Test::render(surface.data(), QSize(100, 50), Qt::blue); | ||||
1343 | QVERIFY(geometryChangedSpy.wait()); | ||||
1344 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1345 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1346 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10)); | ||||
1347 | QCOMPARE(client->bufferGeometry().size(), QSize(100, 50)); | ||||
1348 | | ||||
1349 | shellSurface->setWindowGeometry(QRect(5, 5, 90, 40)); | ||||
1350 | surface->commit(Surface::CommitFlag::None); | ||||
1351 | QVERIFY(geometryChangedSpy.wait()); | ||||
1352 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1353 | QCOMPARE(client->frameGeometry().size(), QSize(90, 40)); | ||||
1354 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(5, 5)); | ||||
1355 | QCOMPARE(client->bufferGeometry().size(), QSize(100, 50)); | ||||
1356 | | ||||
1357 | shellSurface.reset(); | ||||
1358 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1359 | } | ||||
1360 | | ||||
1361 | void TestXdgShellClient::testXdgWindowGeometryAttachSubSurface() | ||||
1362 | { | ||||
1363 | // This test verifies that the effective window geometry remains the same | ||||
1364 | // when a new sub-surface is added and xdg_surface.set_window_geometry is | ||||
1365 | // not called again. | ||||
1366 | | ||||
1367 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1368 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1369 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1370 | QVERIFY(client); | ||||
1371 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1372 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1373 | | ||||
1374 | const QPoint oldPosition = client->pos(); | ||||
1375 | | ||||
1376 | QSignalSpy geometryChangedSpy(client, &XdgShellClient::geometryChanged); | ||||
1377 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1378 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1379 | surface->commit(Surface::CommitFlag::None); | ||||
1380 | QVERIFY(geometryChangedSpy.wait()); | ||||
1381 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1382 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1383 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10)); | ||||
1384 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1385 | | ||||
1386 | QScopedPointer<Surface> childSurface(Test::createSurface()); | ||||
1387 | QScopedPointer<SubSurface> subSurface(Test::createSubSurface(childSurface.data(), surface.data())); | ||||
1388 | QVERIFY(subSurface); | ||||
1389 | subSurface->setPosition(QPoint(-20, -20)); | ||||
1390 | Test::render(childSurface.data(), QSize(100, 50), Qt::blue); | ||||
1391 | surface->commit(Surface::CommitFlag::None); | ||||
1392 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1393 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1394 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(10, 10)); | ||||
1395 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1396 | | ||||
1397 | shellSurface->setWindowGeometry(QRect(-15, -15, 50, 40)); | ||||
1398 | surface->commit(Surface::CommitFlag::None); | ||||
1399 | QVERIFY(geometryChangedSpy.wait()); | ||||
1400 | QCOMPARE(client->frameGeometry().topLeft(), oldPosition); | ||||
1401 | QCOMPARE(client->frameGeometry().size(), QSize(50, 40)); | ||||
1402 | QCOMPARE(client->bufferGeometry().topLeft(), oldPosition - QPoint(-15, -15)); | ||||
1403 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1404 | } | ||||
1405 | | ||||
1406 | void TestXdgShellClient::testXdgWindowGeometryInteractiveResize() | ||||
1407 | { | ||||
1408 | // This test verifies that correct window geometry is provided along each | ||||
1409 | // configure event when an xdg-shell is being interactively resized. | ||||
1410 | | ||||
1411 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1412 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1413 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1414 | QVERIFY(client); | ||||
1415 | QVERIFY(client->isActive()); | ||||
1416 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1417 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1418 | | ||||
1277 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | 1419 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||
1420 | QVERIFY(configureRequestedSpy.isValid()); | ||||
1421 | QVERIFY(configureRequestedSpy.wait()); | ||||
1422 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1423 | | ||||
1424 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1425 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1426 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1278 | surface->commit(Surface::CommitFlag::None); | 1427 | surface->commit(Surface::CommitFlag::None); | ||
1428 | QVERIFY(geometryChangedSpy.wait()); | ||||
1429 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1430 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1279 | 1431 | | |||
1280 | configureRequestedSpy.wait(); | 1432 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||
1281 | shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt()); | 1433 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||
1434 | QSignalSpy clientStepUserMovedResizedSpy(client, &AbstractClient::clientStepUserMovedResized); | ||||
1435 | QVERIFY(clientStepUserMovedResizedSpy.isValid()); | ||||
1436 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
1437 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
1438 | | ||||
1439 | // Start interactively resizing the client. | ||||
1440 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
1441 | workspace()->slotWindowResize(); | ||||
1442 | QCOMPARE(workspace()->moveResizeClient(), client); | ||||
1443 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
1444 | QVERIFY(configureRequestedSpy.wait()); | ||||
1445 | QCOMPARE(configureRequestedSpy.count(), 2); | ||||
1446 | XdgShellSurface::States states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1447 | QVERIFY(states.testFlag(XdgShellSurface::State::Resizing)); | ||||
1448 | | ||||
1449 | // Go right. | ||||
1450 | QPoint cursorPos = KWin::Cursor::pos(); | ||||
1451 | client->keyPressEvent(Qt::Key_Right); | ||||
1452 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
1453 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
1454 | QVERIFY(configureRequestedSpy.wait()); | ||||
1455 | QCOMPARE(configureRequestedSpy.count(), 3); | ||||
1456 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1457 | QVERIFY(states.testFlag(XdgShellSurface::State::Resizing)); | ||||
1458 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(188, 80)); | ||||
1459 | shellSurface->setWindowGeometry(QRect(10, 10, 188, 80)); | ||||
1460 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1461 | Test::render(surface.data(), QSize(208, 100), Qt::blue); | ||||
1462 | QVERIFY(geometryChangedSpy.wait()); | ||||
1463 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
1464 | QCOMPARE(client->bufferGeometry().size(), QSize(208, 100)); | ||||
1465 | QCOMPARE(client->frameGeometry().size(), QSize(188, 80)); | ||||
1466 | | ||||
1467 | // Go down. | ||||
1468 | cursorPos = KWin::Cursor::pos(); | ||||
1469 | client->keyPressEvent(Qt::Key_Down); | ||||
1470 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
1471 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(0, 8)); | ||||
1472 | QVERIFY(configureRequestedSpy.wait()); | ||||
1473 | QCOMPARE(configureRequestedSpy.count(), 4); | ||||
1474 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1475 | QVERIFY(states.testFlag(XdgShellSurface::State::Resizing)); | ||||
1476 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(188, 88)); | ||||
1477 | shellSurface->setWindowGeometry(QRect(10, 10, 188, 88)); | ||||
1478 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1479 | Test::render(surface.data(), QSize(208, 108), Qt::blue); | ||||
1480 | QVERIFY(geometryChangedSpy.wait()); | ||||
1481 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); | ||||
1482 | QCOMPARE(client->bufferGeometry().size(), QSize(208, 108)); | ||||
1483 | QCOMPARE(client->frameGeometry().size(), QSize(188, 88)); | ||||
1484 | | ||||
1485 | // Finish resizing the client. | ||||
1486 | client->keyPressEvent(Qt::Key_Enter); | ||||
1487 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
1488 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
1489 | #if 0 | ||||
1490 | QEXPECT_FAIL("", "XdgShellClient currently doesn't send final configure event", Abort); | ||||
1491 | QVERIFY(configureRequestedSpy.wait()); | ||||
1492 | QCOMPARE(configureRequestedSpy.count(), 5); | ||||
1493 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1494 | QVERIFY(!states.testFlag(XdgShellSurface::State::Resizing)); | ||||
1495 | #endif | ||||
1282 | 1496 | | |||
1283 | // Create a 160x140 window in with a margin of 10(left), 20(top), 30(right), 40(bottom). Giving a total buffer size 200, 100 | 1497 | shellSurface.reset(); | ||
1284 | shellSurface->setWindowGeometry(QRect(10, 20, 160, 40)); | 1498 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||
1285 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); | 1499 | } | ||
1286 | configureRequestedSpy.wait(); //window activated after being shown | | |||
1287 | 1500 | | |||
1288 | QSignalSpy geometryChangedSpy(c, &XdgShellClient::geometryChanged); | 1501 | void TestXdgShellClient::testXdgWindowGeometryFullScreen() | ||
1289 | // resize to 300,200 in kwin terms | 1502 | { | ||
1290 | c->setFrameGeometry(QRect(100, 100, 300, 200)); | 1503 | // This test verifies that an xdg-shell receives correct window geometry when | ||
1504 | // its fullscreen state gets changed. | ||||
1505 | | ||||
1506 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1507 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1508 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1509 | QVERIFY(client); | ||||
1510 | QVERIFY(client->isActive()); | ||||
1511 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1512 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1513 | | ||||
1514 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1515 | QVERIFY(configureRequestedSpy.isValid()); | ||||
1291 | QVERIFY(configureRequestedSpy.wait()); | 1516 | QVERIFY(configureRequestedSpy.wait()); | ||
1292 | // requested geometry should not include the margins we had above | 1517 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
1293 | const QSize requestedSize = configureRequestedSpy.last()[0].value<QSize>(); | | |||
1294 | QCOMPARE(requestedSize, QSize(300, 200) - QSize(10 + 30, 20 + 40)); | | |||
1295 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toUInt()); | | |||
1296 | Test::render(surface.data(), requestedSize + QSize(10 + 30, 20 + 40), Qt::blue); | | |||
1297 | geometryChangedSpy.wait(); | | |||
1298 | 1518 | | |||
1299 | // kwin's concept of geometry should remain the same | 1519 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||
1300 | QCOMPARE(c->frameGeometry(), QRect(100, 100, 300, 200)); | 1520 | QVERIFY(geometryChangedSpy.isValid()); | ||
1521 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1522 | surface->commit(Surface::CommitFlag::None); | ||||
1523 | QVERIFY(geometryChangedSpy.wait()); | ||||
1524 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1525 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1301 | 1526 | | |||
1302 | c->setFullScreen(true); | 1527 | workspace()->slotWindowFullScreen(); | ||
1303 | configureRequestedSpy.wait(); | 1528 | QVERIFY(configureRequestedSpy.wait()); | ||
1304 | // when full screen, the window geometry (i.e without margins) should fill the screen | 1529 | QCOMPARE(configureRequestedSpy.count(), 2); | ||
1305 | const QSize requestedFullScreenSize = configureRequestedSpy.last()[0].value<QSize>(); | 1530 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024)); | ||
1306 | QCOMPARE(requestedFullScreenSize, QSize(1280, 1024)); | 1531 | XdgShellSurface::States states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
1532 | QVERIFY(states.testFlag(XdgShellSurface::State::Fullscreen)); | ||||
1533 | shellSurface->setWindowGeometry(QRect(0, 0, 1280, 1024)); | ||||
1534 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1535 | Test::render(surface.data(), QSize(1280, 1024), Qt::blue); | ||||
1536 | QVERIFY(geometryChangedSpy.wait()); | ||||
1537 | QCOMPARE(client->bufferGeometry().size(), QSize(1280, 1024)); | ||||
1538 | QCOMPARE(client->frameGeometry().size(), QSize(1280, 1024)); | ||||
1539 | | ||||
1540 | workspace()->slotWindowFullScreen(); | ||||
1541 | QVERIFY(configureRequestedSpy.wait()); | ||||
1542 | QCOMPARE(configureRequestedSpy.count(), 3); | ||||
1543 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(180, 80)); | ||||
1544 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1545 | QVERIFY(!states.testFlag(XdgShellSurface::State::Fullscreen)); | ||||
1546 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1547 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1548 | Test::render(surface.data(), QSize(200, 100), Qt::blue); | ||||
1549 | QVERIFY(geometryChangedSpy.wait()); | ||||
1550 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1551 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1552 | | ||||
1553 | shellSurface.reset(); | ||||
1554 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1555 | } | ||||
1556 | | ||||
1557 | void TestXdgShellClient::testXdgWindowGeometryMaximize() | ||||
1558 | { | ||||
1559 | // This test verifies that an xdg-shell receives correct window geometry when | ||||
1560 | // its maximized state gets changed. | ||||
1561 | | ||||
1562 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1563 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1564 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::red); | ||||
1565 | QVERIFY(client); | ||||
1566 | QVERIFY(client->isActive()); | ||||
1567 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1568 | QCOMPARE(client->frameGeometry().size(), QSize(200, 100)); | ||||
1569 | | ||||
1570 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1571 | QVERIFY(configureRequestedSpy.isValid()); | ||||
1572 | QVERIFY(configureRequestedSpy.wait()); | ||||
1573 | QCOMPARE(configureRequestedSpy.count(), 1); | ||||
1574 | | ||||
1575 | QSignalSpy geometryChangedSpy(client, &AbstractClient::geometryChanged); | ||||
1576 | QVERIFY(geometryChangedSpy.isValid()); | ||||
1577 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1578 | surface->commit(Surface::CommitFlag::None); | ||||
1579 | QVERIFY(geometryChangedSpy.wait()); | ||||
1580 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1581 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1582 | | ||||
1583 | workspace()->slotWindowMaximize(); | ||||
1584 | QVERIFY(configureRequestedSpy.wait()); | ||||
1585 | QCOMPARE(configureRequestedSpy.count(), 2); | ||||
1586 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(1280, 1024)); | ||||
1587 | XdgShellSurface::States states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1588 | QVERIFY(states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1589 | shellSurface->setWindowGeometry(QRect(0, 0, 1280, 1024)); | ||||
1590 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1591 | Test::render(surface.data(), QSize(1280, 1024), Qt::blue); | ||||
1592 | QVERIFY(geometryChangedSpy.wait()); | ||||
1593 | QCOMPARE(client->bufferGeometry().size(), QSize(1280, 1024)); | ||||
1594 | QCOMPARE(client->frameGeometry().size(), QSize(1280, 1024)); | ||||
1595 | | ||||
1596 | workspace()->slotWindowMaximize(); | ||||
1597 | QVERIFY(configureRequestedSpy.wait()); | ||||
1598 | QCOMPARE(configureRequestedSpy.count(), 3); | ||||
1599 | QCOMPARE(configureRequestedSpy.last().at(0).toSize(), QSize(180, 80)); | ||||
1600 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||||
1601 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||||
1602 | shellSurface->setWindowGeometry(QRect(10, 10, 180, 80)); | ||||
1603 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||||
1604 | Test::render(surface.data(), QSize(200, 100), Qt::blue); | ||||
1605 | QVERIFY(geometryChangedSpy.wait()); | ||||
1606 | QCOMPARE(client->bufferGeometry().size(), QSize(200, 100)); | ||||
1607 | QCOMPARE(client->frameGeometry().size(), QSize(180, 80)); | ||||
1608 | | ||||
1609 | shellSurface.reset(); | ||||
1610 | QVERIFY(Test::waitForWindowDestroyed(client)); | ||||
1307 | } | 1611 | } | ||
1308 | 1612 | | |||
1309 | WAYLANDTEST_MAIN(TestXdgShellClient) | 1613 | WAYLANDTEST_MAIN(TestXdgShellClient) | ||
1310 | #include "xdgshellclient_test.moc" | 1614 | #include "xdgshellclient_test.moc" |
Generally it's a lot easier to read something like
QCOMPARE(..., QSize(100 + 20, 50 + 10));
and then it's apparent where the new numbers come from
(don't bother changing it though)