Add all three VirtualInputDevices for autotests

[3/6] Make autotests create fake input devices

This commit adds back all three VirtualInputDevices for simulating
keyboard, touch and pointer input events from autotests.
This commit is contained in:
Julius Zint 2022-02-26 09:22:31 +01:00 committed by Vlad Zahorodnii
parent 97f49edb1c
commit 33487c06d6
2 changed files with 58 additions and 0 deletions

View file

@ -87,12 +87,39 @@ WaylandTestApplication::~WaylandTestApplication()
}
delete m_xwayland;
m_xwayland = nullptr;
destroyVirtualInputDevices();
destroyWorkspace();
destroyInputMethod();
destroyCompositor();
destroyInput();
}
void WaylandTestApplication::createVirtualInputDevices()
{
m_virtualKeyboard.reset(new Test::VirtualInputDevice());
m_virtualKeyboard->setName(QStringLiteral("Virtual Keyboard 1"));
m_virtualKeyboard->setKeyboard(true);
m_virtualPointer.reset(new Test::VirtualInputDevice());
m_virtualPointer->setName(QStringLiteral("Virtual Pointer 1"));
m_virtualPointer->setPointer(true);
m_virtualTouch.reset(new Test::VirtualInputDevice());
m_virtualTouch->setName(QStringLiteral("Virtual Touch 1"));
m_virtualTouch->setTouch(true);
input()->addInputDevice(m_virtualPointer.get());
input()->addInputDevice(m_virtualTouch.get());
input()->addInputDevice(m_virtualKeyboard.get());
}
void WaylandTestApplication::destroyVirtualInputDevices()
{
input()->removeInputDevice(m_virtualPointer.get());
input()->removeInputDevice(m_virtualTouch.get());
input()->removeInputDevice(m_virtualKeyboard.get());
}
void WaylandTestApplication::performStartup()
{
if (!m_inputMethodServerToStart.isEmpty()) {
@ -114,6 +141,7 @@ void WaylandTestApplication::performStartup()
// try creating the Wayland Backend
createInput();
createPlugins();
createVirtualInputDevices();
if (!platform()->enabledOutputs().isEmpty()) {
continueStartupWithScreens();
@ -160,4 +188,18 @@ void WaylandTestApplication::continueStartupWithScene()
m_xwayland->start();
}
Test::VirtualInputDevice *WaylandTestApplication::virtualPointer() const
{
return m_virtualPointer.get();
}
Test::VirtualInputDevice *WaylandTestApplication::virtualKeyboard() const
{
return m_virtualKeyboard.get();
}
Test::VirtualInputDevice *WaylandTestApplication::virtualTouch() const
{
return m_virtualTouch.get();
}
}

View file

@ -64,6 +64,10 @@ class Xwayland;
}
class AbstractClient;
namespace Test
{
class VirtualInputDevice;
}
class WaylandTestApplication : public ApplicationWaylandAbstract
{
@ -75,6 +79,11 @@ public:
void setInputMethodServerToStart(const QString &inputMethodServer) {
m_inputMethodServerToStart = inputMethodServer;
}
Test::VirtualInputDevice *virtualPointer() const;
Test::VirtualInputDevice *virtualKeyboard() const;
Test::VirtualInputDevice *virtualTouch() const;
protected:
void performStartup() override;
@ -83,8 +92,15 @@ private:
void continueStartupWithScene();
void finalizeStartup();
void createVirtualInputDevices();
void destroyVirtualInputDevices();
Xwl::Xwayland *m_xwayland = nullptr;
QString m_inputMethodServerToStart;
QScopedPointer<Test::VirtualInputDevice> m_virtualPointer;
QScopedPointer<Test::VirtualInputDevice> m_virtualKeyboard;
QScopedPointer<Test::VirtualInputDevice> m_virtualTouch;
};
namespace Test