diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 5 | ||||
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.cpp | 8 | ||||
-rw-r--r-- | tests/auto/compositor/testcompositor.cpp | 32 | ||||
-rw-r--r-- | tests/auto/compositor/testcompositor.h | 17 | ||||
-rw-r--r-- | tests/auto/compositor/testinputdevice.cpp | 4 | ||||
-rw-r--r-- | tests/auto/compositor/testinputdevice.h | 4 | ||||
-rw-r--r-- | tests/auto/compositor/testkeyboardgrabber.cpp | 34 | ||||
-rw-r--r-- | tests/auto/compositor/testkeyboardgrabber.h | 21 | ||||
-rw-r--r-- | tests/auto/compositor/tst_compositor.cpp | 156 |
10 files changed, 147 insertions, 136 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 822fdeb88..c503803b4 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -4,6 +4,7 @@ TEMPLATE=subdirs #building QtCompositor contains(CONFIG, wayland-compositor) { SUBDIRS += compositor - SUBDIRS += client - SUBDIRS += cmake } + +SUBDIRS += client +SUBDIRS += cmake diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 9041fff95..270d11aa6 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -11,7 +11,7 @@ set(Qt5_MODULE_TEST_DEPENDS Quick) include("${_Qt5CTestMacros}") test_module_includes( - Compositor QWaylandBufferRef + WaylandCompositor QWaylandBufferRef ) # Can't test in `test_module_includes`, WaylandClient has no public headers diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/mockclient.cpp index fd7fedfe1..d4765b894 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/mockclient.cpp @@ -45,7 +45,7 @@ const struct wl_registry_listener MockClient::registryListener = { }; MockClient::MockClient() - : display(wl_display_connect(0)) + : display(wl_display_connect("wayland-qt-test-0")) , compositor(0) , output(0) , registry(0) @@ -93,6 +93,8 @@ void MockClient::outputGeometryEvent(void *data, wl_output *, int, const char *, const char *, int32_t ) { + Q_UNUSED(width); + Q_UNUSED(height); resolve(data)->geometry.moveTopLeft(QPoint(x, y)); } @@ -125,6 +127,8 @@ void MockClient::flushDisplay() void MockClient::handleGlobal(void *data, wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { + Q_UNUSED(registry); + Q_UNUSED(version); resolve(data)->handleGlobal(id, QByteArray(interface)); } @@ -186,7 +190,7 @@ ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm) return; } - image = QImage(static_cast<uchar *>(data), size.width(), size.height(), stride, QImage::Format_ARGB32); + image = QImage(static_cast<uchar *>(data), size.width(), size.height(), stride, QImage::Format_ARGB32_Premultiplied); shm_pool = wl_shm_create_pool(shm,fd,alloc); handle = wl_shm_pool_create_buffer(shm_pool,0, size.width(), size.height(), stride, WL_SHM_FORMAT_ARGB8888); diff --git a/tests/auto/compositor/testcompositor.cpp b/tests/auto/compositor/testcompositor.cpp index 897c6f813..b4b106815 100644 --- a/tests/auto/compositor/testcompositor.cpp +++ b/tests/auto/compositor/testcompositor.cpp @@ -27,21 +27,43 @@ ****************************************************************************/ #include "testcompositor.h" +#include "testinputdevice.h" +#include "testkeyboardgrabber.h" -TestCompositor::TestCompositor(QWaylandCompositor::ExtensionFlag flags) : QWaylandCompositor(0, flags) +TestCompositor::TestCompositor(bool createInputDev) + : QWaylandCompositor() + , shell(new QWaylandShell(this)) + , m_createInputDevice(createInputDev) { - createOutput(0, "", ""); - addDefaultShell(); } -void TestCompositor::surfaceCreated(QWaylandSurface *surface) +void TestCompositor::create() +{ + new QWaylandOutput(this, Q_NULLPTR); + QWaylandCompositor::create(); + + connect(this, &QWaylandCompositor::surfaceCreated, this, &TestCompositor::onSurfaceCreated); + connect(this, &QWaylandCompositor::surfaceAboutToBeDestroyed, this, &TestCompositor::onSurfaceAboutToBeDestroyed); +} + +void TestCompositor::onSurfaceCreated(QWaylandSurface *surface) { surfaces << surface; } -void TestCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface) +void TestCompositor::onSurfaceAboutToBeDestroyed(QWaylandSurface *surface) { surfaces.removeOne(surface); } +QWaylandInputDevice *TestCompositor::createInputDevice() +{ + if (m_createInputDevice) + return new TestInputDevice(this, QWaylandInputDevice::Pointer | QWaylandInputDevice::Keyboard); + else + return QWaylandCompositor::createInputDevice(); +} +QWaylandKeyboard *TestCompositor::createKeyboardDevice(QWaylandInputDevice *inputDevice) { + return new TestKeyboardGrabber(inputDevice); +} diff --git a/tests/auto/compositor/testcompositor.h b/tests/auto/compositor/testcompositor.h index 2762c4529..affef7ec8 100644 --- a/tests/auto/compositor/testcompositor.h +++ b/tests/auto/compositor/testcompositor.h @@ -28,15 +28,26 @@ #include "qwaylandcompositor.h" #include "qwaylandsurface.h" +#include "qwaylandshell.h" class TestCompositor : public QWaylandCompositor { + Q_OBJECT public: - TestCompositor(QWaylandCompositor::ExtensionFlag flags = QWaylandCompositor::DefaultExtensions); + TestCompositor(bool createInputDev = false); + void create(); - void surfaceCreated(QWaylandSurface *surface); - void surfaceAboutToBeDestroyed(QWaylandSurface *surface); +public slots: + void onSurfaceCreated(QWaylandSurface *surface); + void onSurfaceAboutToBeDestroyed(QWaylandSurface *surface); +protected: + QWaylandInputDevice *createInputDevice() Q_DECL_OVERRIDE; + QWaylandKeyboard *createKeyboardDevice(QWaylandInputDevice *inputDevice) Q_DECL_OVERRIDE; + +public: QList<QWaylandSurface *> surfaces; + QWaylandShell* shell; + bool m_createInputDevice; }; diff --git a/tests/auto/compositor/testinputdevice.cpp b/tests/auto/compositor/testinputdevice.cpp index 706dfdfbe..5c02dff85 100644 --- a/tests/auto/compositor/testinputdevice.cpp +++ b/tests/auto/compositor/testinputdevice.cpp @@ -27,7 +27,6 @@ ****************************************************************************/ #include "testinputdevice.h" - #include <QMouseEvent> TestInputDevice::TestInputDevice(QWaylandCompositor *compositor, QWaylandInputDevice::CapabilityFlags caps) @@ -40,7 +39,7 @@ TestInputDevice::~TestInputDevice() { } -bool TestInputDevice::isOwner(QInputEvent *event) +bool TestInputDevice::isOwner(QInputEvent *event) const { m_queryCount++; QMouseEvent *me = dynamic_cast<QMouseEvent *>(event); @@ -54,4 +53,3 @@ QList<QMouseEvent *> TestInputDevice::createMouseEvents(int count) } return m_events; } - diff --git a/tests/auto/compositor/testinputdevice.h b/tests/auto/compositor/testinputdevice.h index 7e2ab15c8..710fc82d1 100644 --- a/tests/auto/compositor/testinputdevice.h +++ b/tests/auto/compositor/testinputdevice.h @@ -40,13 +40,13 @@ public: TestInputDevice(QWaylandCompositor *compositor, QWaylandInputDevice::CapabilityFlags caps); ~TestInputDevice(); - bool isOwner(QInputEvent *event); + bool isOwner(QInputEvent *inputEvent) const Q_DECL_OVERRIDE; QList<QMouseEvent *> createMouseEvents(int count); int queryCount() { return m_queryCount; } private: - int m_queryCount; + mutable int m_queryCount; QList<QMouseEvent *> m_events; }; diff --git a/tests/auto/compositor/testkeyboardgrabber.cpp b/tests/auto/compositor/testkeyboardgrabber.cpp index aef2d7045..f252e2c8c 100644 --- a/tests/auto/compositor/testkeyboardgrabber.cpp +++ b/tests/auto/compositor/testkeyboardgrabber.cpp @@ -28,33 +28,31 @@ #include "testkeyboardgrabber.h" -namespace QtWayland { - KeyboardGrabber::~KeyboardGrabber() {} +TestKeyboardGrabber::TestKeyboardGrabber(QWaylandInputDevice *inputDevice) + : QWaylandKeyboard(inputDevice) +{ } -void TestKeyboardGrabber::focused(QtWayland::Surface *surface) +bool TestKeyboardGrabber::setFocus(QWaylandSurface *surface) { - Q_UNUSED(surface); Q_EMIT focusedCalled(); + return QWaylandKeyboard::setFocus(surface); } -void TestKeyboardGrabber::key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) +void TestKeyboardGrabber::sendKeyPressEvent(uint code) { - Q_UNUSED(serial); - Q_UNUSED(time); - Q_UNUSED(key); - Q_UNUSED(state); - Q_EMIT keyCalled(); + Q_EMIT keyPressCalled(); + QWaylandKeyboard::sendKeyPressEvent(code); } -void TestKeyboardGrabber::modifiers(uint32_t serial, uint32_t mods_depressed, - uint32_t mods_latched, uint32_t mods_locked, uint32_t group) +void TestKeyboardGrabber::sendKeyReleaseEvent(uint code) { - Q_UNUSED(serial); - Q_UNUSED(mods_depressed); - Q_UNUSED(mods_latched); - Q_UNUSED(mods_locked); - Q_UNUSED(group); - Q_EMIT modifiersCalled(); + Q_EMIT keyReleaseCalled(); + QWaylandKeyboard::sendKeyReleaseEvent(code); } +void TestKeyboardGrabber::sendKeyModifiers(QWaylandClient *client, uint32_t serial) +{ + Q_EMIT modifiersCalled(); + QWaylandKeyboard::sendKeyModifiers(client, serial); +} diff --git a/tests/auto/compositor/testkeyboardgrabber.h b/tests/auto/compositor/testkeyboardgrabber.h index a54c27ab8..350bacbdd 100644 --- a/tests/auto/compositor/testkeyboardgrabber.h +++ b/tests/auto/compositor/testkeyboardgrabber.h @@ -26,26 +26,23 @@ ** ****************************************************************************/ -#include "QtCompositor/private/qwlkeyboard_p.h" -#include "QtCompositor/private/qwlsurface_p.h" +#include "qwaylandkeyboard.h" -class TestKeyboardGrabber : public QObject, public QtWayland::KeyboardGrabber +class TestKeyboardGrabber : public QWaylandKeyboard { Q_OBJECT - public: + TestKeyboardGrabber(QWaylandInputDevice *inputDevice); - TestKeyboardGrabber() {} - ~TestKeyboardGrabber() {} - - void focused(QtWayland::Surface *surface); - void key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state); - void modifiers(uint32_t serial, uint32_t mods_depressed, - uint32_t mods_latched, uint32_t mods_locked, uint32_t group); + bool setFocus(QWaylandSurface *surface) Q_DECL_OVERRIDE; + void sendKeyModifiers(QWaylandClient *client, uint32_t serial) Q_DECL_OVERRIDE; + void sendKeyPressEvent(uint code) Q_DECL_OVERRIDE; + void sendKeyReleaseEvent(uint code) Q_DECL_OVERRIDE; signals: void focusedCalled(); - void keyCalled(); + void keyPressCalled(); + void keyReleaseCalled(); void modifiersCalled(); }; diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/tst_compositor.cpp index c9eb95b9b..422e378dc 100644 --- a/tests/auto/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/tst_compositor.cpp @@ -29,18 +29,14 @@ #include "mockclient.h" #include "testcompositor.h" #include "testkeyboardgrabber.h" - -#include "QtCompositor/private/qwlkeyboard_p.h" -#include "QtCompositor/private/qwlinputdevice_p.h" -#include "QtCompositor/private/qwlcompositor_p.h" #include "testinputdevice.h" +#include "qwaylandview.h" #include "qwaylandbufferref.h" +#include "qwaylandinput.h" #include <QtTest/QtTest> -#include <QtCompositor/private/qwlinputdevice_p.h> - class tst_WaylandCompositor : public QObject { Q_OBJECT @@ -48,6 +44,7 @@ class tst_WaylandCompositor : public QObject public: tst_WaylandCompositor() { setenv("XDG_RUNTIME_DIR", ".", 1); + setenv("WAYLAND_DISPLAY", "wayland-qt-test-0", 1); } private slots: @@ -65,6 +62,7 @@ private slots: void tst_WaylandCompositor::singleClient() { TestCompositor compositor; + compositor.create(); MockClient client; @@ -95,6 +93,7 @@ void tst_WaylandCompositor::singleClient() void tst_WaylandCompositor::multipleClients() { TestCompositor compositor; + compositor.create(); MockClient a; MockClient b; @@ -133,7 +132,8 @@ void tst_WaylandCompositor::multipleClients() void tst_WaylandCompositor::keyboardGrab() { - TestCompositor compositor((QWaylandCompositor::ExtensionFlag)0); + TestCompositor compositor; + compositor.create(); MockClient mc; mc.createSurface(); @@ -144,46 +144,47 @@ void tst_WaylandCompositor::keyboardGrab() // Set the focused surface so that key event will flow through QWaylandSurface *waylandSurface = compositor.surfaces.at(0); QWaylandInputDevice* inputDevice = compositor.defaultInputDevice(); - inputDevice->handle()->keyboardDevice()->setFocus(waylandSurface->handle()); - TestKeyboardGrabber grab; - QSignalSpy grabFocusSpy(&grab, SIGNAL(focusedCalled())); - QSignalSpy grabKeySpy(&grab, SIGNAL(keyCalled())); - QSignalSpy grabModifierSpy(&grab, SIGNAL(modifiersCalled())); - - QtWayland::Keyboard *keyboard = inputDevice->handle()->keyboardDevice(); - keyboard->startGrab(&grab); + TestKeyboardGrabber* grab = static_cast<TestKeyboardGrabber *>(inputDevice->keyboard()); + QTRY_COMPARE(grab, inputDevice->keyboard()); + QSignalSpy grabFocusSpy(grab, SIGNAL(focusedCalled())); + QSignalSpy grabKeyPressSpy(grab, SIGNAL(keyPressCalled())); + QSignalSpy grabKeyReleaseSpy(grab, SIGNAL(keyReleaseCalled())); + //QSignalSpy grabModifierSpy(grab, SIGNAL(modifiersCalled())); + inputDevice->setKeyboardFocus(waylandSurface); QTRY_COMPARE(grabFocusSpy.count(), 1); - QCOMPARE(grab.m_keyboard, inputDevice->handle()->keyboardDevice()); QKeyEvent ke(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, 30, 0, 0); QKeyEvent ke1(QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier, 30, 0, 0); inputDevice->sendFullKeyEvent(&ke); inputDevice->sendFullKeyEvent(&ke1); - QTRY_COMPARE(grabKeySpy.count(), 2); + QTRY_COMPARE(grabKeyPressSpy.count(), 1); + QTRY_COMPARE(grabKeyReleaseSpy.count(), 1); QKeyEvent ke2(QEvent::KeyPress, Qt::Key_Shift, Qt::NoModifier, 50, 0, 0); QKeyEvent ke3(QEvent::KeyRelease, Qt::Key_Shift, Qt::NoModifier, 50, 0, 0); inputDevice->sendFullKeyEvent(&ke2); inputDevice->sendFullKeyEvent(&ke3); - QTRY_COMPARE(grabModifierSpy.count(), 2); + //QTRY_COMPARE(grabModifierSpy.count(), 2); // Modifiers are also keys - QTRY_COMPARE(grabKeySpy.count(), 4); + QTRY_COMPARE(grabKeyPressSpy.count(), 2); + QTRY_COMPARE(grabKeyReleaseSpy.count(), 2); // Stop grabbing - keyboard->endGrab(); + inputDevice->setKeyboardFocus(Q_NULLPTR); inputDevice->sendFullKeyEvent(&ke); inputDevice->sendFullKeyEvent(&ke1); - QTRY_COMPARE(grabKeySpy.count(), 4); + QTRY_COMPARE(grabKeyPressSpy.count(), 2); } void tst_WaylandCompositor::geometry() { TestCompositor compositor; + compositor.create(); QRect geometry(0, 0, 4096, 3072); - compositor.setOutputGeometry(geometry); + compositor.defaultOutput()->setGeometry(geometry); MockClient client; @@ -193,6 +194,7 @@ void tst_WaylandCompositor::geometry() void tst_WaylandCompositor::mapSurface() { TestCompositor compositor; + compositor.create(); MockClient client; @@ -201,10 +203,10 @@ void tst_WaylandCompositor::mapSurface() QWaylandSurface *waylandSurface = compositor.surfaces.at(0); - QSignalSpy mappedSpy(waylandSurface, SIGNAL(mapped())); + QSignalSpy mappedSpy(waylandSurface, SIGNAL(mappedChanged())); QCOMPARE(waylandSurface->size(), QSize()); - QCOMPARE(waylandSurface->type(), QWaylandSurface::Invalid); + QCOMPARE(waylandSurface->isMapped(), false); QSize size(256, 256); ShmBuffer buffer(size, client.shm); @@ -216,7 +218,7 @@ void tst_WaylandCompositor::mapSurface() wl_surface_commit(surface); QTRY_COMPARE(waylandSurface->size(), size); - QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); + QTRY_COMPARE(waylandSurface->isMapped(), true); QTRY_COMPARE(mappedSpy.count(), 1); wl_surface_destroy(surface); @@ -239,20 +241,18 @@ static void registerFrameCallback(wl_surface *surface, int *counter) void tst_WaylandCompositor::frameCallback() { - class BufferAttacher : public QWaylandBufferAttacher + class BufferView : public QWaylandView { public: - void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE + void attach(const QWaylandBufferRef &ref, const QRegion &damage) Q_DECL_OVERRIDE { + Q_UNUSED(damage); bufferRef = ref; } - void unmap() Q_DECL_OVERRIDE - { - } QImage image() const { - if (!bufferRef || !bufferRef.isShm()) + if (bufferRef.isNull() || !bufferRef.isShm()) return QImage(); return bufferRef.image(); } @@ -261,6 +261,7 @@ void tst_WaylandCompositor::frameCallback() }; TestCompositor compositor; + compositor.create(); MockClient client; @@ -270,8 +271,10 @@ void tst_WaylandCompositor::frameCallback() QTRY_COMPARE(compositor.surfaces.size(), 1); QWaylandSurface *waylandSurface = compositor.surfaces.at(0); - BufferAttacher attacher; - waylandSurface->setBufferAttacher(&attacher); + BufferView* view = new BufferView; + view->setSurface(waylandSurface); + view->setOutput(compositor.defaultOutput()); + QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRegion &))); for (int i = 0; i < 10; ++i) { @@ -284,12 +287,12 @@ void tst_WaylandCompositor::frameCallback() wl_surface_damage(surface, 0, 0, size.width(), size.height()); wl_surface_commit(surface); - QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm); + QTRY_COMPARE(waylandSurface->isMapped(), true); QTRY_COMPARE(damagedSpy.count(), i + 1); - QCOMPARE(static_cast<BufferAttacher *>(waylandSurface->bufferAttacher())->image(), buffer.image); - compositor.frameStarted(); - compositor.sendFrameCallbacks(QList<QWaylandSurface *>() << waylandSurface); + QCOMPARE(static_cast<BufferView*>(waylandSurface->views().first())->image(), buffer.image); + compositor.defaultOutput()->frameStarted(); + compositor.defaultOutput()->sendFrameCallbacks(); QTRY_COMPARE(frameCounter, i + 1); } @@ -300,64 +303,51 @@ void tst_WaylandCompositor::frameCallback() void tst_WaylandCompositor::inputDeviceCapabilities() { TestCompositor compositor; - QtWayland::InputDevice dev(NULL, compositor.handle(), QWaylandInputDevice::Pointer); + compositor.create(); + + MockClient client; + Q_UNUSED(client); - QTRY_VERIFY(dev.pointerDevice()); - QTRY_VERIFY(!dev.keyboardDevice()); - QTRY_VERIFY(!dev.touchDevice()); + QWaylandInputDevice dev(&compositor, QWaylandInputDevice::Pointer); - dev.setCapabilities(QWaylandInputDevice::Keyboard | QWaylandInputDevice::Touch); - QTRY_VERIFY(!dev.pointerDevice()); - QTRY_VERIFY(dev.keyboardDevice()); - QTRY_VERIFY(dev.touchDevice()); + QTRY_VERIFY(dev.pointer()); + QTRY_VERIFY(!dev.keyboard()); + QTRY_VERIFY(!dev.touch()); - // Test that existing devices do not change when another is removed - QtWayland::Keyboard *k = dev.keyboardDevice(); - dev.setCapabilities(QWaylandInputDevice::Keyboard); - QTRY_COMPARE(k, dev.keyboardDevice()); + QWaylandInputDevice dev2(&compositor, QWaylandInputDevice::Keyboard | QWaylandInputDevice::Touch); + QTRY_VERIFY(!dev2.pointer()); + QTRY_VERIFY(dev2.keyboard()); + QTRY_VERIFY(dev2.touch()); } void tst_WaylandCompositor::inputDeviceCreation() { - TestCompositor compositor; - TestInputDevice dev1(&compositor, QWaylandInputDevice::Pointer | QWaylandInputDevice::Keyboard); - TestInputDevice dev2(&compositor, QWaylandInputDevice::Pointer | QWaylandInputDevice::Keyboard); + TestCompositor compositor(true); + compositor.create(); + + MockClient client; + Q_UNUSED(client); - compositor.handle()->registerInputDevice(&dev1); - compositor.handle()->registerInputDevice(&dev2); + TestInputDevice* dev = static_cast<TestInputDevice*>(compositor.defaultInputDevice()); // The compositor will create the default input device - QTRY_COMPARE(compositor.handle()->inputDevices().count(), 3); - // Test the order - QTRY_COMPARE(compositor.handle()->inputDevices().at(0), &dev2); - QTRY_COMPARE(compositor.handle()->inputDevices().at(1), &dev1); - QTRY_COMPARE(compositor.handle()->inputDevices().at(2), compositor.defaultInputDevice()); + QTRY_COMPARE(compositor.defaultInputDevice(), dev); QList<QMouseEvent *> allEvents; - allEvents += dev1.createMouseEvents(2); - allEvents += dev2.createMouseEvents(5); + allEvents += dev->createMouseEvents(5); foreach (QMouseEvent *me, allEvents) { compositor.inputDeviceFor(me); } - // The first input device will only get called exatly the number of times it has created + // The default input device will get called exatly the number of times it has created // the events - QTRY_COMPARE(dev1.queryCount(), 2); - // The second will get called the total number of times as it sits as the first item in - // the registered input devices list - QTRY_COMPARE(dev2.queryCount(), 7); + QTRY_COMPARE(dev->queryCount(), 5); } void tst_WaylandCompositor::inputDeviceKeyboardFocus() { - TestCompositor compositor; - - - TestInputDevice dev1(&compositor, QWaylandInputDevice::Keyboard); - TestInputDevice dev2(&compositor, QWaylandInputDevice::Keyboard); - - compositor.handle()->registerInputDevice(&dev1); - compositor.handle()->registerInputDevice(&dev2); + TestCompositor compositor(true); + compositor.create(); // Create client after all the input devices have been set up as the mock client // does not dynamically listen to new seats @@ -366,24 +356,14 @@ void tst_WaylandCompositor::inputDeviceKeyboardFocus() QTRY_COMPARE(compositor.surfaces.size(), 1); QWaylandSurface *waylandSurface = compositor.surfaces.at(0); - QList<QWaylandInputDevice *> devices = compositor.handle()->inputDevices(); - foreach (QWaylandInputDevice *dev, devices) { - dev->setKeyboardFocus(waylandSurface); - } + QWaylandInputDevice* dev = compositor.defaultInputDevice(); + dev->setKeyboardFocus(waylandSurface); QTRY_COMPARE(compositor.defaultInputDevice()->keyboardFocus(), waylandSurface); - QTRY_COMPARE(dev1.keyboardFocus(), waylandSurface); - QTRY_COMPARE(dev2.keyboardFocus(), waylandSurface); wl_surface_destroy(surface); QTRY_VERIFY(compositor.surfaces.size() == 0); - // This will normally be called for example in the quick compositor - // but here call it manually to get rid of the surface and have it reset - // the focus - compositor.handle()->cleanupGraphicsResources(); - - QTRY_VERIFY(!compositor.defaultInputDevice()->keyboardFocus()); - QTRY_VERIFY(!dev1.keyboardFocus()); - QTRY_VERIFY(!dev2.keyboardFocus()); + + QTRY_VERIFY(!compositor.defaultInputDevice()->keyboardFocus()); } #include <tst_compositor.moc> |