summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/shared/mockcompositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-08-18 17:28:01 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-11-15 08:34:27 +0000
commit69d587b9a8e336cff4356c49e4f37aae2a474a4f (patch)
treecd53978cb4c7ea0b8933034e04b600d0f41e3c41 /tests/auto/client/shared/mockcompositor.cpp
parent9cf680f94b78baf1bb92051021ebc243dec1f02e (diff)
Client: Test that the current screen is updated by surface events
Change-Id: If96691a2d844263a1e01a86df8b0d58f23848a4c Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'tests/auto/client/shared/mockcompositor.cpp')
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 411a89757..67c05b90a 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -28,6 +28,7 @@
#include "mockcompositor.h"
#include "mockinput.h"
+#include "mockoutput.h"
#include "mocksurface.h"
#include <wayland-xdg-shell-unstable-v6-server-protocol.h>
@@ -77,10 +78,10 @@ void MockCompositor::processWaylandEvents()
m_waitCondition.wakeOne();
}
-void MockCompositor::setOutputGeometry(const QRect &rect)
+void MockCompositor::setOutputMode(const QSize &size)
{
- Command command = makeCommand(Impl::Compositor::setOutputGeometry, m_compositor);
- command.parameters << rect;
+ Command command = makeCommand(Impl::Compositor::setOutputMode, m_compositor);
+ command.parameters << size;
processCommand(command);
}
@@ -182,6 +183,28 @@ void MockCompositor::sendDataDeviceLeave(const QSharedPointer<MockSurface> &surf
processCommand(command);
}
+void MockCompositor::sendAddOutput()
+{
+ Command command = makeCommand(Impl::Compositor::sendAddOutput, m_compositor);
+ processCommand(command);
+}
+
+void MockCompositor::sendSurfaceEnter(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output)
+{
+ Command command = makeCommand(Impl::Compositor::sendSurfaceEnter, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ command.parameters << QVariant::fromValue(output);
+ processCommand(command);
+}
+
+void MockCompositor::sendSurfaceLeave(const QSharedPointer<MockSurface> &surface, QSharedPointer<MockOutput> &output)
+{
+ Command command = makeCommand(Impl::Compositor::sendSurfaceLeave, m_compositor);
+ command.parameters << QVariant::fromValue(surface);
+ command.parameters << QVariant::fromValue(output);
+ processCommand(command);
+}
+
void MockCompositor::waitForStartDrag()
{
Command command = makeCommand(Impl::Compositor::waitForStartDrag, m_compositor);
@@ -204,6 +227,15 @@ QSharedPointer<MockSurface> MockCompositor::surface()
return result;
}
+QSharedPointer<MockOutput> MockCompositor::output(int index)
+{
+ QSharedPointer<MockOutput> result;
+ lock();
+ result = m_compositor->outputs().at(index)->mockOutput();
+ unlock();
+ return result;
+}
+
MockCompositor::Command MockCompositor::makeCommand(Command::Callback callback, void *target)
{
Command command;
@@ -267,8 +299,6 @@ namespace Impl {
Compositor::Compositor()
: m_display(wl_display_create())
{
- wl_list_init(&m_outputResources);
-
if (wl_display_add_socket(m_display, 0)) {
fprintf(stderr, "Fatal: Failed to open server socket\n");
exit(EXIT_FAILURE);
@@ -285,7 +315,7 @@ Compositor::Compositor()
m_keyboard = m_seat->keyboard();
m_touch = m_seat->touch();
- wl_global_create(m_display, &wl_output_interface, 1, this, bindOutput);
+ m_outputs.append(new Output(m_display, QSize(1920, 1080), QPoint(0, 0)));
wl_global_create(m_display, &wl_shell_interface, 1, this, bindShell);
wl_global_create(m_display, &zxdg_shell_v6_interface, 1, this, bindXdgShellV6);
@@ -350,6 +380,11 @@ QVector<Surface *> Compositor::surfaces() const
return m_surfaces;
}
+QVector<Output *> Compositor::outputs() const
+{
+ return m_outputs;
+}
+
uint32_t Compositor::nextSerial()
{
return wl_display_next_serial(m_display);
@@ -367,5 +402,17 @@ void Compositor::removeSurface(Surface *surface)
m_pointer->handleSurfaceDestroyed(surface);
}
+Surface *Compositor::resolveSurface(const QVariant &v)
+{
+ QSharedPointer<MockSurface> mockSurface = v.value<QSharedPointer<MockSurface> >();
+ return mockSurface ? mockSurface->handle() : nullptr;
+}
+
+Output *Compositor::resolveOutput(const QVariant &v)
+{
+ QSharedPointer<MockOutput> mockOutput = v.value<QSharedPointer<MockOutput> >();
+ return mockOutput ? mockOutput->handle() : nullptr;
+}
+
}