[autotests] Extend pointer constraints test for closing window of locked pointer
This commit is contained in:
parent
9265d9fae7
commit
e2682c8405
1 changed files with 43 additions and 0 deletions
|
@ -64,6 +64,8 @@ private Q_SLOTS:
|
|||
void testLockedPointer();
|
||||
void testBreakConstrainedPointer_data();
|
||||
void testBreakConstrainedPointer();
|
||||
void testCloseWindowWithLockedPointer_data();
|
||||
void testCloseWindowWithLockedPointer();
|
||||
};
|
||||
|
||||
void TestPointerConstraints::initTestCase()
|
||||
|
@ -385,5 +387,46 @@ void TestPointerConstraints::testBreakConstrainedPointer()
|
|||
kwinApp()->platform()->keyboardKeyReleased(KEY_ESC, timestamp++);
|
||||
}
|
||||
|
||||
void TestPointerConstraints::testCloseWindowWithLockedPointer_data()
|
||||
{
|
||||
QTest::addColumn<Test::ShellSurfaceType>("type");
|
||||
|
||||
QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell;
|
||||
QTest::newRow("XdgShellV5") << Test::ShellSurfaceType::XdgShellV5;
|
||||
}
|
||||
|
||||
void TestPointerConstraints::testCloseWindowWithLockedPointer()
|
||||
{
|
||||
// test case which verifies that the pointer gets unlocked when the window for it gets closed
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QFETCH(Test::ShellSurfaceType, type);
|
||||
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
||||
QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer());
|
||||
QScopedPointer<LockedPointer> lockedPointer(Test::waylandPointerConstraints()->lockPointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::OneShot));
|
||||
QSignalSpy lockedSpy(lockedPointer.data(), &LockedPointer::locked);
|
||||
QVERIFY(lockedSpy.isValid());
|
||||
QSignalSpy unlockedSpy(lockedPointer.data(), &LockedPointer::unlocked);
|
||||
QVERIFY(unlockedSpy.isValid());
|
||||
|
||||
// now map the window
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 100), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QVERIFY(!c->geometry().contains(KWin::Cursor::pos()));
|
||||
|
||||
// now let's lock
|
||||
QCOMPARE(input()->pointer()->isConstrained(), false);
|
||||
KWin::Cursor::setPos(c->geometry().center());
|
||||
QCOMPARE(KWin::Cursor::pos(), c->geometry().center());
|
||||
QCOMPARE(input()->pointer()->isConstrained(), true);
|
||||
QVERIFY(lockedSpy.wait());
|
||||
|
||||
// close the window
|
||||
shellSurface.reset();
|
||||
surface.reset();
|
||||
// this should result in unlocked
|
||||
QVERIFY(unlockedSpy.wait());
|
||||
QCOMPARE(input()->pointer()->isConstrained(), false);
|
||||
}
|
||||
|
||||
WAYLANDTEST_MAIN(TestPointerConstraints)
|
||||
#include "pointer_constraints_test.moc"
|
||||
|
|
Loading…
Reference in a new issue