autotests/integration: add more cases to OutputChangesTest
This commit is contained in:
parent
264ecf40f8
commit
3d9618316b
1 changed files with 139 additions and 0 deletions
|
@ -39,6 +39,8 @@ private Q_SLOTS:
|
|||
void testWindowRestoredAfterEnablingOutput();
|
||||
void testMaximizedWindowRestoredAfterEnablingOutput();
|
||||
void testFullScreenWindowRestoredAfterEnablingOutput();
|
||||
void testWindowRestoredAfterChangingScale();
|
||||
void testMaximizeStateRestoredAfterEnablingOutput();
|
||||
|
||||
void testWindowNotRestoredAfterMovingWindowAndEnablingOutput();
|
||||
};
|
||||
|
@ -448,6 +450,143 @@ void OutputChangesTest::testFullScreenWindowRestoredAfterEnablingOutput()
|
|||
QCOMPARE(window->fullscreenGeometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
||||
}
|
||||
|
||||
void OutputChangesTest::testWindowRestoredAfterChangingScale()
|
||||
{
|
||||
// This test verifies that a window will be moved to its original position after changing the scale of an output
|
||||
|
||||
const auto output = kwinApp()->platform()->outputs().front();
|
||||
|
||||
// Create a window.
|
||||
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
||||
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
||||
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(window);
|
||||
|
||||
// Move the window to the bottom right
|
||||
const QPointF originalPosition(output->geometry().width() - window->width(), output->geometry().height() - window->height());
|
||||
window->move(originalPosition);
|
||||
QCOMPARE(window->pos(), originalPosition);
|
||||
QCOMPARE(window->output(), output);
|
||||
|
||||
// change the scale of the output
|
||||
OutputConfiguration config1;
|
||||
{
|
||||
auto changeSet = config1.changeSet(output);
|
||||
changeSet->scale = 2;
|
||||
}
|
||||
workspace()->applyOutputConfiguration(config1);
|
||||
|
||||
// The window will be moved to still be in the monitor
|
||||
QCOMPARE(window->pos(), QPointF(output->geometry().width() - window->width(), output->geometry().height() - window->height()));
|
||||
QCOMPARE(window->output(), output);
|
||||
|
||||
// Change scale back
|
||||
OutputConfiguration config2;
|
||||
{
|
||||
auto changeSet = config2.changeSet(output);
|
||||
changeSet->scale = 1;
|
||||
}
|
||||
workspace()->applyOutputConfiguration(config2);
|
||||
|
||||
// The window will be moved back to where it was before
|
||||
QCOMPARE(window->pos(), originalPosition);
|
||||
QCOMPARE(window->output(), output);
|
||||
}
|
||||
|
||||
void OutputChangesTest::testMaximizeStateRestoredAfterEnablingOutput()
|
||||
{
|
||||
// This test verifies that the window state will get restored after disabling and enabling an output,
|
||||
// even if its maximize state changed in the process
|
||||
|
||||
const auto outputs = kwinApp()->platform()->outputs();
|
||||
|
||||
// Disable the right output
|
||||
{
|
||||
OutputConfiguration config;
|
||||
auto changeSet = config.changeSet(outputs[1]);
|
||||
changeSet->enabled = false;
|
||||
workspace()->applyOutputConfiguration(config);
|
||||
}
|
||||
|
||||
// Create a window.
|
||||
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
|
||||
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
|
||||
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(window);
|
||||
|
||||
// kwin will send a configure event with the actived state.
|
||||
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
|
||||
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
||||
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
||||
|
||||
const QRectF originalGeometry = window->moveResizeGeometry();
|
||||
|
||||
// Enable the right output
|
||||
{
|
||||
OutputConfiguration config;
|
||||
auto changeSet = config.changeSet(outputs[1]);
|
||||
changeSet->enabled = true;
|
||||
workspace()->applyOutputConfiguration(config);
|
||||
}
|
||||
|
||||
// Move the window to the right monitor and make it maximized.
|
||||
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
|
||||
window->move(QPointF(1280 + 50, 100));
|
||||
window->maximize(MaximizeFull);
|
||||
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
||||
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
|
||||
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
||||
Test::render(surface.get(), QSize(1280, 1024), Qt::blue);
|
||||
QVERIFY(frameGeometryChangedSpy.wait());
|
||||
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
||||
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
||||
QCOMPARE(window->output(), outputs[1]);
|
||||
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
||||
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
||||
QCOMPARE(window->geometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
||||
|
||||
// Disable the right output
|
||||
{
|
||||
OutputConfiguration config;
|
||||
auto changeSet = config.changeSet(outputs[1]);
|
||||
changeSet->enabled = false;
|
||||
workspace()->applyOutputConfiguration(config);
|
||||
}
|
||||
|
||||
// The window will be moved to its prior position on the left monitor and unmaximized
|
||||
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
||||
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), originalGeometry.size().toSize());
|
||||
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
||||
Test::render(surface.get(), originalGeometry.size().toSize(), Qt::blue);
|
||||
QVERIFY(frameGeometryChangedSpy.wait());
|
||||
QCOMPARE(window->frameGeometry(), originalGeometry);
|
||||
QCOMPARE(window->moveResizeGeometry(), originalGeometry);
|
||||
QCOMPARE(window->output(), outputs[0]);
|
||||
QCOMPARE(window->maximizeMode(), MaximizeRestore);
|
||||
QCOMPARE(window->requestedMaximizeMode(), MaximizeRestore);
|
||||
|
||||
// Enable the right output again
|
||||
{
|
||||
OutputConfiguration config;
|
||||
auto changeSet = config.changeSet(outputs[1]);
|
||||
changeSet->enabled = true;
|
||||
workspace()->applyOutputConfiguration(config);
|
||||
}
|
||||
|
||||
// The window will be moved back to the right monitor, maximized and the geometry restore will be updated
|
||||
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
||||
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), outputs[1]->geometry().size());
|
||||
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
|
||||
Test::render(surface.get(), outputs[1]->geometry().size(), Qt::blue);
|
||||
QVERIFY(frameGeometryChangedSpy.wait());
|
||||
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 1280, 1024));
|
||||
QCOMPARE(window->moveResizeGeometry(), QRectF(1280, 0, 1280, 1024));
|
||||
QCOMPARE(window->output(), outputs[1]);
|
||||
QCOMPARE(window->maximizeMode(), MaximizeFull);
|
||||
QCOMPARE(window->requestedMaximizeMode(), MaximizeFull);
|
||||
QCOMPARE(window->geometryRestore(), QRectF(1280 + 50, 100, 100, 50));
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
WAYLANDTEST_MAIN(KWin::OutputChangesTest)
|
||||
|
|
Loading…
Reference in a new issue