summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2017-10-25 14:06:54 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2017-10-25 14:06:54 +0200
commit523cf490b4c46916c6f5253c666a492f5cce2aad (patch)
treeb4514f338b143ab430fe2b91ec7699cb176a147e /tests/auto/compositor/compositor/tst_compositor.cpp
parent8e3c71b2d1ec37222bf1648aa23eb033062b4ea6 (diff)
parentf1407493d6d25f24a3c71fbcedc00598baa44b56 (diff)
Merge remote-tracking branch 'qt/5.9' into 5.10v5.10.0-beta3
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 52428eb4..c51c13bd 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -27,6 +27,8 @@
****************************************************************************/
#include "mockclient.h"
+#include "mockseat.h"
+#include "mockpointer.h"
#include "testcompositor.h"
#include "testkeyboardgrabber.h"
#include "testseat.h"
@@ -57,6 +59,7 @@ private slots:
void keyboardGrab();
void seatCreation();
void seatKeyboardFocus();
+ void seatMouseFocus();
void singleClient();
void multipleClients();
void geometry();
@@ -442,6 +445,59 @@ void tst_WaylandCompositor::seatKeyboardFocus()
QTRY_VERIFY(!compositor.defaultSeat()->keyboardFocus());
}
+void tst_WaylandCompositor::seatMouseFocus()
+{
+ TestCompositor compositor(true);
+ compositor.create();
+
+ // Create client after all the seats have been set up as the mock client
+ // does not dynamically listen to new seats
+ MockClient client;
+ wl_surface *surface = client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+
+ QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
+ auto view = new QWaylandView;
+ view->setSurface(waylandSurface);
+
+ QWaylandSeat* seat = compositor.defaultSeat();
+ seat->setMouseFocus(view);
+ seat->sendMouseMoveEvent(view, QPointF(10, 10), QPointF(100, 100));
+
+ compositor.flushClients();
+
+ QTRY_VERIFY(seat->mouseFocus());
+ QTRY_VERIFY(seat->pointer());
+ QTRY_COMPARE(seat->mouseFocus()->surface(), waylandSurface);
+
+ QTRY_COMPARE(client.m_seats.size(), 1);
+ MockPointer *mockPointer = client.m_seats.first()->pointer();
+ QVERIFY(mockPointer);
+ QTRY_COMPARE(mockPointer->m_enteredSurface, surface);
+
+ delete view;
+
+ compositor.flushClients();
+
+ QTRY_COMPARE(mockPointer->m_enteredSurface, nullptr);
+ QTRY_VERIFY(!compositor.defaultSeat()->mouseFocus());
+
+ view = new QWaylandView;
+ view->setSurface(waylandSurface);
+ seat->sendMouseMoveEvent(view, QPointF(10, 10), QPointF(100, 100));
+ QTRY_COMPARE(compositor.defaultSeat()->mouseFocus(), view);
+
+ compositor.flushClients();
+
+ QTRY_COMPARE(mockPointer->m_enteredSurface, surface);
+
+ wl_surface_destroy(surface);
+ QTRY_VERIFY(compositor.surfaces.size() == 0);
+ QTRY_VERIFY(!compositor.defaultSeat()->mouseFocus());
+
+ delete view;
+}
+
class XdgTestCompositor: public TestCompositor {
Q_OBJECT
public: