From e40344c6bba0ba99d06dd8e1d1af36e4e26d401f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 16 Aug 2016 15:39:47 +0200 Subject: [PATCH] [autotests/integration] Split InternalWindowTest::testKeyboard into two test methods Creating a dedicated method for the leave event on client. This restructuring of the test should hopefully work around the failing test condition on build.kde.org. --- autotests/integration/internal_window.cpp | 38 +++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index 7d9f224bad..0ec728ffab 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -54,6 +54,7 @@ private Q_SLOTS: void testPointerAxis(); void testKeyboard_data(); void testKeyboard(); + void testKeyboardTriggersLeave(); void testTouch(); }; @@ -315,15 +316,12 @@ void InternalWindowTest::testKeyboard() kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QTRY_COMPARE(releaseSpy.count(), 1); QCOMPARE(pressSpy.count(), 1); +} - // let's hide the window again and create a "real" window - QSignalSpy internalClientUnmappedSpy(internalClient, &ShellClient::windowHidden); - QVERIFY(internalClientUnmappedSpy.isValid()); - win.hide(); - QVERIFY(internalClientUnmappedSpy.wait()); - QCOMPARE(internalClientUnmappedSpy.count(), 1); - clientAddedSpy.clear(); - +void InternalWindowTest::testKeyboardTriggersLeave() +{ + // this test verifies that a leave event is sent to a client when an internal window + // gets a key event QScopedPointer keyboard(Test::waylandSeat()->createKeyboard()); QVERIFY(!keyboard.isNull()); QVERIFY(keyboard->isValid()); @@ -345,20 +343,34 @@ void InternalWindowTest::testKeyboard() } QCOMPARE(enteredSpy.count(), 1); - QSignalSpy windowShownSpy(internalClient, &ShellClient::windowShown); - QVERIFY(windowShownSpy.isValid()); + // create internal window + QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); + QVERIFY(clientAddedSpy.isValid()); + HelperWindow win; + win.setGeometry(0, 0, 100, 100); win.show(); - QTRY_COMPARE(windowShownSpy.count(), 1); + QSignalSpy pressSpy(&win, &HelperWindow::keyPressed); + QVERIFY(pressSpy.isValid()); + QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased); + QVERIFY(releaseSpy.isValid()); + QVERIFY(clientAddedSpy.wait()); + QCOMPARE(clientAddedSpy.count(), 1); + auto internalClient = clientAddedSpy.first().first().value(); + QVERIFY(internalClient); + QVERIFY(internalClient->isInternal()); + QVERIFY(internalClient->readyForPainting()); + QVERIFY(leftSpy.isEmpty()); QVERIFY(!leftSpy.wait(100)); // now let's trigger a key, which should result in a leave + quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); QVERIFY(leftSpy.wait()); - QCOMPARE(pressSpy.count(), 2); + QCOMPARE(pressSpy.count(), 1); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); - QTRY_COMPARE(releaseSpy.count(), 2); + QTRY_COMPARE(releaseSpy.count(), 1); // after hiding the internal window, next key press should trigger an enter win.hide();