[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
This commit is contained in:
Vlad Zagorodniy 2018-11-08 12:33:57 +02:00
parent 80d0915cf8
commit abf6c6927c
2 changed files with 17 additions and 5 deletions

View file

@ -118,7 +118,14 @@ void TestMaximized::testMaximizedPassedToDeco()
QVERIFY(bordersChangedSpy.isValid()); QVERIFY(bordersChangedSpy.isValid());
QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged); QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged);
QVERIFY(maximizedChangedSpy.isValid()); QVERIFY(maximizedChangedSpy.isValid());
QSignalSpy geometryShapeChangedSpy(client, &AbstractClient::geometryShapeChanged);
QVERIFY(geometryShapeChangedSpy.isValid());
workspace()->slotWindowMaximize(); workspace()->slotWindowMaximize();
Test::render(surface.data(), QSize(100, 50), Qt::red);
QVERIFY(geometryShapeChangedSpy.wait());
QCOMPARE(geometryShapeChangedSpy.count(), 2);
QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull);
QCOMPARE(maximizedChangedSpy.count(), 1); QCOMPARE(maximizedChangedSpy.count(), 1);
QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); QCOMPARE(maximizedChangedSpy.last().first().toBool(), true);
@ -128,13 +135,15 @@ void TestMaximized::testMaximizedPassedToDeco()
QCOMPARE(decoration->borderRight(), 0); QCOMPARE(decoration->borderRight(), 0);
QVERIFY(decoration->borderTop() != 0); QVERIFY(decoration->borderTop() != 0);
QVERIFY(sizeChangedSpy.isEmpty());
QVERIFY(sizeChangedSpy.wait());
QCOMPARE(sizeChangedSpy.count(), 1); QCOMPARE(sizeChangedSpy.count(), 1);
QCOMPARE(sizeChangedSpy.first().first().toSize(), QSize(1280, 1024 - decoration->borderTop())); QCOMPARE(sizeChangedSpy.first().first().toSize(), QSize(1280, 1024 - decoration->borderTop()));
// now unmaximize again // now unmaximize again
workspace()->slotWindowMaximize(); workspace()->slotWindowMaximize();
Test::render(surface.data(), QSize(100, 50), Qt::red);
QVERIFY(geometryShapeChangedSpy.wait());
QCOMPARE(geometryShapeChangedSpy.count(), 4);
QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore);
QCOMPARE(maximizedChangedSpy.count(), 2); QCOMPARE(maximizedChangedSpy.count(), 2);
QCOMPARE(maximizedChangedSpy.last().first().toBool(), false); QCOMPARE(maximizedChangedSpy.last().first().toBool(), false);
@ -144,7 +153,6 @@ void TestMaximized::testMaximizedPassedToDeco()
QVERIFY(decoration->borderRight() != 0); QVERIFY(decoration->borderRight() != 0);
QVERIFY(decoration->borderBottom() != 0); QVERIFY(decoration->borderBottom() != 0);
QVERIFY(sizeChangedSpy.wait());
QCOMPARE(sizeChangedSpy.count(), 2); QCOMPARE(sizeChangedSpy.count(), 2);
QCOMPARE(sizeChangedSpy.last().first().toSize(), QSize(100, 50)); QCOMPARE(sizeChangedSpy.last().first().toSize(), QSize(100, 50));
} }
@ -203,6 +211,7 @@ void TestMaximized::testBorderlessMaximizedWindow()
QVERIFY(geometryChangedSpy.wait()); QVERIFY(geometryChangedSpy.wait());
QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull);
QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(client->geometryRestore(), origGeo);
QCOMPARE(client->isDecorated(), false); QCOMPARE(client->isDecorated(), false);
// go back to normal // go back to normal
@ -213,6 +222,7 @@ void TestMaximized::testBorderlessMaximizedWindow()
QVERIFY(geometryChangedSpy.wait()); QVERIFY(geometryChangedSpy.wait());
QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore);
QCOMPARE(client->geometry(), origGeo); QCOMPARE(client->geometry(), origGeo);
QCOMPARE(client->geometryRestore(), origGeo);
QCOMPARE(client->isDecorated(), true); QCOMPARE(client->isDecorated(), true);
} }

View file

@ -828,7 +828,9 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
workspace()->clientArea(MaximizeArea, Cursor::pos(), desktop()) : workspace()->clientArea(MaximizeArea, Cursor::pos(), desktop()) :
workspace()->clientArea(MaximizeArea, this); workspace()->clientArea(MaximizeArea, this);
MaximizeMode oldMode = m_requestedMaximizeMode; const MaximizeMode oldMode = m_requestedMaximizeMode;
const QRect oldGeometry = geometry();
StackingUpdatesBlocker blocker(workspace()); StackingUpdatesBlocker blocker(workspace());
RequestGeometryBlocker geometryBlocker(this); RequestGeometryBlocker geometryBlocker(this);
// 'adjust == true' means to update the size only, e.g. after changing workspace size // '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 // TODO: check rules
if (m_requestedMaximizeMode == MaximizeFull) { if (m_requestedMaximizeMode == MaximizeFull) {
m_geomMaximizeRestore = geometry(); m_geomMaximizeRestore = oldGeometry;
// TODO: Client has more checks // TODO: Client has more checks
if (options->electricBorderMaximize()) { if (options->electricBorderMaximize()) {
updateQuickTileMode(QuickTileFlag::Maximize); updateQuickTileMode(QuickTileFlag::Maximize);