From e25abdf3bb51ca49c3e59395c5482c64adc9e394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 14 Apr 2014 10:50:56 +0200 Subject: [PATCH] [Xcb::Wrapper] Add unit test for CurrentInput --- autotests/test_xcb_wrapper.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/autotests/test_xcb_wrapper.cpp b/autotests/test_xcb_wrapper.cpp index 2558e2bba7..a13f351890 100644 --- a/autotests/test_xcb_wrapper.cpp +++ b/autotests/test_xcb_wrapper.cpp @@ -45,6 +45,7 @@ private Q_SLOTS: void assignmentAfterRetrieve(); void discard(); void testQueryTree(); + void testCurrentInput(); private: void testEmpty(WindowGeometry &geometry); void testGeometry(WindowGeometry &geometry, const QRect &rect); @@ -244,5 +245,25 @@ void TestXcbWrapper::testQueryTree() QVERIFY(doesntExist.isRetrieved()); } +void TestXcbWrapper::testCurrentInput() +{ + m_testWindow = createWindow(); + xcb_connection_t *c = QX11Info::connection(); + xcb_map_window(c, m_testWindow); + QX11Info::setAppTime(QX11Info::getTimestamp()); + + // let's set the input focus + xcb_set_input_focus(c, XCB_INPUT_FOCUS_PARENT, m_testWindow, QX11Info::appTime()); + xcb_flush(c); + + CurrentInput input; + QCOMPARE(input.window(), m_testWindow); + + // creating a copy should make the input object have no window any more + CurrentInput input2(input); + QCOMPARE(input2.window(), m_testWindow); + QCOMPARE(input.window(), xcb_window_t(XCB_WINDOW_NONE)); +} + KWIN_TEST_MAIN(TestXcbWrapper) #include "test_xcb_wrapper.moc"