[autotests/integration] Test basic working of Alt+Tab and Alt+Shift+Tab

Dedicated test methods for Alt+Tab and Alt+Shift+Tab. Both open three
windows and simulate one press with opening the TabBox. Alt+Tab should
move to the previous window in the chain, Alt+Shift+tab to the last
window in the chain.
icc-effect-5.14.5
Martin Gräßlin 2016-09-13 16:11:58 +02:00
parent e8e6e31a87
commit a69300f762
1 changed files with 108 additions and 0 deletions

View File

@ -45,6 +45,8 @@ private Q_SLOTS:
void init();
void cleanup();
void testMoveForward();
void testMoveBackward();
void testCapsLock();
};
@ -147,5 +149,111 @@ void TabBoxTest::testCapsLock()
QVERIFY(Test::waitForWindowDestroyed(c1));
}
void TabBoxTest::testMoveForward()
{
// this test verifies that Alt+tab works correctly moving forward
// first create three windows
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<QObject> shellSurface1(Test::createShellSurface(Test::ShellSurfaceType::WlShell, surface1.data()));
auto c1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(c1);
QVERIFY(c1->isActive());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<QObject> shellSurface2(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface2.data()));
auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::red);
QVERIFY(c2);
QVERIFY(c2->isActive());
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<QObject> shellSurface3(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface3.data()));
auto c3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::red);
QVERIFY(c3);
QVERIFY(c3->isActive());
// Setup tabbox signal spies
QSignalSpy tabboxAddedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxAdded);
QVERIFY(tabboxAddedSpy.isValid());
QSignalSpy tabboxClosedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxClosed);
QVERIFY(tabboxClosedSpy.isValid());
// press alt+tab
quint32 timestamp = 0;
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::AltModifier);
kwinApp()->platform()->keyboardKeyPressed(KEY_TAB, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_TAB, timestamp++);
QVERIFY(tabboxAddedSpy.wait());
QVERIFY(TabBox::TabBox::self()->isGrabbed());
// release alt
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
QCOMPARE(tabboxClosedSpy.count(), 1);
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
QCOMPARE(workspace()->activeClient(), c2);
surface3.reset();
QVERIFY(Test::waitForWindowDestroyed(c3));
surface2.reset();
QVERIFY(Test::waitForWindowDestroyed(c2));
surface1.reset();
QVERIFY(Test::waitForWindowDestroyed(c1));
}
void TabBoxTest::testMoveBackward()
{
// this test verifies that Alt+Shift+tab works correctly moving backward
// first create three windows
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<QObject> shellSurface1(Test::createShellSurface(Test::ShellSurfaceType::WlShell, surface1.data()));
auto c1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(c1);
QVERIFY(c1->isActive());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<QObject> shellSurface2(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface2.data()));
auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::red);
QVERIFY(c2);
QVERIFY(c2->isActive());
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<QObject> shellSurface3(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface3.data()));
auto c3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::red);
QVERIFY(c3);
QVERIFY(c3->isActive());
// Setup tabbox signal spies
QSignalSpy tabboxAddedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxAdded);
QVERIFY(tabboxAddedSpy.isValid());
QSignalSpy tabboxClosedSpy(TabBox::TabBox::self(), &TabBox::TabBox::tabBoxClosed);
QVERIFY(tabboxClosedSpy.isValid());
// press alt+shift+tab
quint32 timestamp = 0;
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::AltModifier);
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::AltModifier | Qt::ShiftModifier);
kwinApp()->platform()->keyboardKeyPressed(KEY_TAB, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_TAB, timestamp++);
QVERIFY(tabboxAddedSpy.wait());
QVERIFY(TabBox::TabBox::self()->isGrabbed());
// release alt
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
QCOMPARE(tabboxClosedSpy.count(), 0);
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
QCOMPARE(tabboxClosedSpy.count(), 1);
QCOMPARE(TabBox::TabBox::self()->isGrabbed(), false);
QCOMPARE(workspace()->activeClient(), c1);
surface3.reset();
QVERIFY(Test::waitForWindowDestroyed(c3));
surface2.reset();
QVERIFY(Test::waitForWindowDestroyed(c2));
surface1.reset();
QVERIFY(Test::waitForWindowDestroyed(c1));
}
WAYLANDTEST_MAIN(TabBoxTest)
#include "tabbox_test.moc"