From abf6c6927cbf9a156c8a95ce33bbb40651a42008 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Thu, 8 Nov 2018 12:33:57 +0200 Subject: [PATCH] [autotests] Fix maximize test Summary: testMaximizedPassedToDeco was failing because it didn't handle async maximization. testBorderlessMaximizedWindow was failing because setNoBorder can modify geometry, so we end up with a wrong restore geometry. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16755 --- autotests/integration/maximize_test.cpp | 16 +++++++++++++--- shell_client.cpp | 6 ++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp index 2db9fece2d..226099c56a 100644 --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -118,7 +118,14 @@ void TestMaximized::testMaximizedPassedToDeco() QVERIFY(bordersChangedSpy.isValid()); QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged); QVERIFY(maximizedChangedSpy.isValid()); + QSignalSpy geometryShapeChangedSpy(client, &AbstractClient::geometryShapeChanged); + QVERIFY(geometryShapeChangedSpy.isValid()); + workspace()->slotWindowMaximize(); + + Test::render(surface.data(), QSize(100, 50), Qt::red); + QVERIFY(geometryShapeChangedSpy.wait()); + QCOMPARE(geometryShapeChangedSpy.count(), 2); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(maximizedChangedSpy.count(), 1); QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); @@ -128,13 +135,15 @@ void TestMaximized::testMaximizedPassedToDeco() QCOMPARE(decoration->borderRight(), 0); QVERIFY(decoration->borderTop() != 0); - QVERIFY(sizeChangedSpy.isEmpty()); - QVERIFY(sizeChangedSpy.wait()); QCOMPARE(sizeChangedSpy.count(), 1); QCOMPARE(sizeChangedSpy.first().first().toSize(), QSize(1280, 1024 - decoration->borderTop())); // now unmaximize again workspace()->slotWindowMaximize(); + + Test::render(surface.data(), QSize(100, 50), Qt::red); + QVERIFY(geometryShapeChangedSpy.wait()); + QCOMPARE(geometryShapeChangedSpy.count(), 4); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); QCOMPARE(maximizedChangedSpy.count(), 2); QCOMPARE(maximizedChangedSpy.last().first().toBool(), false); @@ -144,7 +153,6 @@ void TestMaximized::testMaximizedPassedToDeco() QVERIFY(decoration->borderRight() != 0); QVERIFY(decoration->borderBottom() != 0); - QVERIFY(sizeChangedSpy.wait()); QCOMPARE(sizeChangedSpy.count(), 2); QCOMPARE(sizeChangedSpy.last().first().toSize(), QSize(100, 50)); } @@ -203,6 +211,7 @@ void TestMaximized::testBorderlessMaximizedWindow() QVERIFY(geometryChangedSpy.wait()); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); + QCOMPARE(client->geometryRestore(), origGeo); QCOMPARE(client->isDecorated(), false); // go back to normal @@ -213,6 +222,7 @@ void TestMaximized::testBorderlessMaximizedWindow() QVERIFY(geometryChangedSpy.wait()); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); QCOMPARE(client->geometry(), origGeo); + QCOMPARE(client->geometryRestore(), origGeo); QCOMPARE(client->isDecorated(), true); } diff --git a/shell_client.cpp b/shell_client.cpp index f758e2e7f3..f363a04409 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -828,7 +828,9 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust) workspace()->clientArea(MaximizeArea, Cursor::pos(), desktop()) : workspace()->clientArea(MaximizeArea, this); - MaximizeMode oldMode = m_requestedMaximizeMode; + const MaximizeMode oldMode = m_requestedMaximizeMode; + const QRect oldGeometry = geometry(); + StackingUpdatesBlocker blocker(workspace()); RequestGeometryBlocker geometryBlocker(this); // 'adjust == true' means to update the size only, e.g. after changing workspace size @@ -881,7 +883,7 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust) // TODO: check rules if (m_requestedMaximizeMode == MaximizeFull) { - m_geomMaximizeRestore = geometry(); + m_geomMaximizeRestore = oldGeometry; // TODO: Client has more checks if (options->electricBorderMaximize()) { updateQuickTileMode(QuickTileFlag::Maximize);