Added testing of key events to client auto test.
This requires passing on the native key code as well when calling into QWindowSystemInterface from QWaylandInputDevice. Change-Id: Iea1f98dcc9e050bb42cc48927da17aa54085a5e8 Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
This commit is contained in:
parent
8feb960ff8
commit
54331754cb
@ -114,6 +114,20 @@ void MockCompositor::sendMouseRelease(const QSharedPointer<MockSurface> &surface
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void MockCompositor::sendKeyPress(const QSharedPointer<MockSurface> &surface, uint code)
|
||||
{
|
||||
Command command = makeCommand(Impl::Compositor::sendKeyPress, m_compositor);
|
||||
command.parameters << QVariant::fromValue(surface) << code;
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void MockCompositor::sendKeyRelease(const QSharedPointer<MockSurface> &surface, uint code)
|
||||
{
|
||||
Command command = makeCommand(Impl::Compositor::sendKeyRelease, m_compositor);
|
||||
command.parameters << QVariant::fromValue(surface) << code;
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
QSharedPointer<MockSurface> MockCompositor::surface()
|
||||
{
|
||||
QSharedPointer<MockSurface> result;
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
static void setKeyboardFocus(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendMousePress(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendMouseRelease(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendKeyPress(void *data, const QList<QVariant> ¶meters);
|
||||
static void sendKeyRelease(void *data, const QList<QVariant> ¶meters);
|
||||
|
||||
private:
|
||||
static void bindCompositor(wl_client *client, void *data, uint32_t version, uint32_t id);
|
||||
@ -142,6 +144,8 @@ public:
|
||||
void setKeyboardFocus(const QSharedPointer<MockSurface> &surface);
|
||||
void sendMousePress(const QSharedPointer<MockSurface> &surface, const QPoint &pos);
|
||||
void sendMouseRelease(const QSharedPointer<MockSurface> &surface);
|
||||
void sendKeyPress(const QSharedPointer<MockSurface> &surface, uint code);
|
||||
void sendKeyRelease(const QSharedPointer<MockSurface> &surface, uint code);
|
||||
|
||||
QSharedPointer<MockSurface> surface();
|
||||
|
||||
|
@ -121,5 +121,26 @@ void Compositor::sendMouseRelease(void *data, const QList<QVariant> ¶meters)
|
||||
wl_input_device_send_button(compositor->m_input.pointer_focus_resource, compositor->time(), 0x110, 0);
|
||||
}
|
||||
|
||||
void Compositor::sendKeyPress(void *data, const QList<QVariant> ¶meters)
|
||||
{
|
||||
Compositor *compositor = static_cast<Compositor *>(data);
|
||||
wl_surface *surface = resolveSurface(parameters.first());
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
QPoint pos = parameters.last().toPoint();
|
||||
wl_input_device_send_key(compositor->m_input.keyboard_focus_resource, compositor->time(), parameters.last().toUInt() - 8, 1);
|
||||
}
|
||||
|
||||
void Compositor::sendKeyRelease(void *data, const QList<QVariant> ¶meters)
|
||||
{
|
||||
Compositor *compositor = static_cast<Compositor *>(data);
|
||||
wl_surface *surface = resolveSurface(parameters.first());
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
wl_input_device_send_key(compositor->m_input.keyboard_focus_resource, compositor->time(), parameters.last().toUInt() - 8, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
, keyReleaseEventCount(0)
|
||||
, mousePressEventCount(0)
|
||||
, mouseReleaseEventCount(0)
|
||||
, keyCode(0)
|
||||
{
|
||||
setSurfaceType(QSurface::RasterSurface);
|
||||
setGeometry(0, 0, 32, 32);
|
||||
@ -71,14 +72,16 @@ public:
|
||||
++focusOutEventCount;
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent *)
|
||||
void keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
++keyPressEventCount;
|
||||
keyCode = event->nativeScanCode();
|
||||
}
|
||||
|
||||
void keyReleaseEvent(QKeyEvent *)
|
||||
void keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
++keyReleaseEventCount;
|
||||
keyCode = event->nativeScanCode();
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *event)
|
||||
@ -99,6 +102,7 @@ public:
|
||||
int mousePressEventCount;
|
||||
int mouseReleaseEventCount;
|
||||
|
||||
uint keyCode;
|
||||
QPoint mousePressPos;
|
||||
};
|
||||
|
||||
@ -166,6 +170,17 @@ void tst_WaylandClient::events()
|
||||
QTRY_COMPARE(window.focusInEventCount, 2);
|
||||
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
|
||||
|
||||
uint keyCode = 80; // arbitrarily chosen
|
||||
QCOMPARE(window.keyPressEventCount, 0);
|
||||
compositor->sendKeyPress(surface, keyCode);
|
||||
QTRY_COMPARE(window.keyPressEventCount, 1);
|
||||
QTRY_COMPARE(window.keyCode, keyCode);
|
||||
|
||||
QCOMPARE(window.keyReleaseEventCount, 0);
|
||||
compositor->sendKeyRelease(surface, keyCode);
|
||||
QTRY_COMPARE(window.keyReleaseEventCount, 1);
|
||||
QCOMPARE(window.keyCode, keyCode);
|
||||
|
||||
QPoint mousePressPos(16, 16);
|
||||
QCOMPARE(window.mousePressEventCount, 0);
|
||||
compositor->sendMousePress(surface, mousePressPos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user