Commit 7b7a1793 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

autotests: Add more test cases in OutputChangesTest

It adds more test cases in OutputChangesTest, particularly swapping
outputs.

Swapping outputs is an interesting case because outputs can temporarily
overlap so workspace()->outputAt() can return wrong output and the
window is going to stick to wrong output.
parent a1e1d72f
Pipeline #231682 passed with stage
in 13 minutes and 46 seconds
......@@ -33,6 +33,8 @@ private Q_SLOTS:
void testWindowSticksToOutputAfterOutputIsDisabled();
void testWindowSticksToOutputAfterAnotherOutputIsDisabled();
void testWindowSticksToOutputAfterOutputIsMoved();
void testWindowSticksToOutputAfterOutputsAreSwappedLeftToRight();
void testWindowSticksToOutputAfterOutputsAreSwappedRightToLeft();
};
void OutputChangesTest::initTestCase()
......@@ -149,7 +151,73 @@ void OutputChangesTest::testWindowSticksToOutputAfterOutputIsMoved()
QCOMPARE(window->frameGeometry(), QRect(-10 + 42, 20 + 67, 100, 50));
}
void OutputChangesTest::testWindowSticksToOutputAfterOutputsAreSwappedLeftToRight()
{
// This test verifies that a window placed on the left monitor sticks
// to that monitor even after the monitors are swapped horizontally.
const auto outputs = kwinApp()->platform()->outputs();
// 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 left output.
window->move(QPointF(0, 0));
QCOMPARE(window->output(), outputs[0]);
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 100, 50));
// Swap outputs.
OutputConfiguration config;
{
auto changeSet1 = config.changeSet(outputs[0]);
changeSet1->pos = QPoint(1280, 0);
auto changeSet2 = config.changeSet(outputs[1]);
changeSet2->pos = QPoint(0, 0);
}
workspace()->applyOutputConfiguration(config);
// The window should be still on its original output.
QCOMPARE(window->output(), outputs[0]);
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 100, 50));
}
void OutputChangesTest::testWindowSticksToOutputAfterOutputsAreSwappedRightToLeft()
{
// This test verifies that a window placed on the right monitor sticks
// to that monitor even after the monitors are swapped horizontally.
const auto outputs = kwinApp()->platform()->outputs();
// 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 right output.
window->move(QPointF(1280, 0));
QCOMPARE(window->output(), outputs[1]);
QCOMPARE(window->frameGeometry(), QRectF(1280, 0, 100, 50));
// Swap outputs.
OutputConfiguration config;
{
auto changeSet1 = config.changeSet(outputs[0]);
changeSet1->pos = QPoint(1280, 0);
auto changeSet2 = config.changeSet(outputs[1]);
changeSet2->pos = QPoint(0, 0);
}
workspace()->applyOutputConfiguration(config);
// The window should be still on its original output.
QCOMPARE(window->output(), outputs[1]);
QCOMPARE(window->frameGeometry(), QRectF(0, 0, 100, 50));
}
} // namespace KWin
WAYLANDTEST_MAIN(KWin::OutputChangesTest)
#include "outputchanges_test.moc"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment