[autotest/integration] Introduce a Test helper library to have less code duplication
Summary: A new namespace KWin::Test is added which provides a few helper functions. It makes it easy to setup a KWayland client connection with the base set to be able to create a Surface and flags to create additional interfaces. This replaces the KWayland connection dance in init() methods. For cleanup() there is also a dedicated helper function. In addition there are helper functions to: * render a surface * create a surface * create a shell surface * flush the wayland client connection * access to the created interfaces - for compatibility with existing code The idea is to extend this Test library also for other common use cases like creating an X11 connection and X11 windows, etc. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2053
This commit is contained in:
parent
1f2b47a83b
commit
513878e20d
22 changed files with 619 additions and 1746 deletions
|
@ -2,7 +2,7 @@ add_definitions(-DKWINBACKENDPATH="${CMAKE_BINARY_DIR}/plugins/platforms/virtual
|
||||||
add_definitions(-DKWINQPAPATH="${CMAKE_BINARY_DIR}/plugins/qpa/")
|
add_definitions(-DKWINQPAPATH="${CMAKE_BINARY_DIR}/plugins/qpa/")
|
||||||
add_subdirectory(helper)
|
add_subdirectory(helper)
|
||||||
|
|
||||||
add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp)
|
add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp test_helpers.cpp)
|
||||||
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test)
|
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test)
|
||||||
|
|
||||||
function(integrationTest)
|
function(integrationTest)
|
||||||
|
|
|
@ -27,8 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
#include <KWayland/Client/shm_pool.h>
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
@ -46,6 +44,7 @@ class DebugConsoleTest : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
void cleanup();
|
||||||
void topLevelTest_data();
|
void topLevelTest_data();
|
||||||
void topLevelTest();
|
void topLevelTest();
|
||||||
void testX11Client();
|
void testX11Client();
|
||||||
|
@ -73,6 +72,11 @@ void DebugConsoleTest::initTestCase()
|
||||||
waylandServer()->initWorkspace();
|
waylandServer()->initWorkspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugConsoleTest::cleanup()
|
||||||
|
{
|
||||||
|
Test::destroyWaylandConnection();
|
||||||
|
}
|
||||||
|
|
||||||
void DebugConsoleTest::topLevelTest_data()
|
void DebugConsoleTest::topLevelTest_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<int>("row");
|
QTest::addColumn<int>("row");
|
||||||
|
@ -308,51 +312,15 @@ void DebugConsoleTest::testWaylandClient()
|
||||||
QVERIFY(rowsInsertedSpy.isValid());
|
QVERIFY(rowsInsertedSpy.isValid());
|
||||||
|
|
||||||
// create our connection
|
// create our connection
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
// setup connection
|
|
||||||
QScopedPointer<ConnectionThread> connection(new ConnectionThread);
|
|
||||||
QSignalSpy connectedSpy(connection.data(), &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
QScopedPointer<QThread> thread(new QThread);
|
|
||||||
connection->moveToThread(thread.data());
|
|
||||||
thread->start();
|
|
||||||
|
|
||||||
connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
QScopedPointer<EventQueue> queue(new EventQueue);
|
|
||||||
QVERIFY(!queue->isValid());
|
|
||||||
queue->setup(connection.data());
|
|
||||||
QVERIFY(queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(queue.data());
|
|
||||||
QSignalSpy interfacesAnnouncedSpy(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(interfacesAnnouncedSpy.isValid());
|
|
||||||
registry.create(connection.data());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(interfacesAnnouncedSpy.wait());
|
|
||||||
|
|
||||||
QScopedPointer<Compositor> compositor(registry.createCompositor(registry.interface(Registry::Interface::Compositor).name, registry.interface(Registry::Interface::Compositor).version));
|
|
||||||
QVERIFY(compositor->isValid());
|
|
||||||
QScopedPointer<ShmPool> shm(registry.createShmPool(registry.interface(Registry::Interface::Shm).name, registry.interface(Registry::Interface::Shm).version));
|
|
||||||
QVERIFY(shm->isValid());
|
|
||||||
QScopedPointer<Shell> shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version));
|
|
||||||
QVERIFY(shell->isValid());
|
|
||||||
|
|
||||||
// create the Surface and ShellSurface
|
// create the Surface and ShellSurface
|
||||||
QScopedPointer<Surface> surface(compositor->createSurface());
|
using namespace KWayland::Client;
|
||||||
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(surface->isValid());
|
QVERIFY(surface->isValid());
|
||||||
QScopedPointer<ShellSurface> shellSurface(shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(shellSurface->isValid());
|
QVERIFY(shellSurface->isValid());
|
||||||
QImage img(10, 10, QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(10, 10), Qt::red);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 10, 10));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
// now we have the window, it should be added to our model
|
// now we have the window, it should be added to our model
|
||||||
QVERIFY(rowsInsertedSpy.wait());
|
QVERIFY(rowsInsertedSpy.wait());
|
||||||
|
@ -410,18 +378,11 @@ void DebugConsoleTest::testWaylandClient()
|
||||||
surface->attachBuffer(Buffer::Ptr());
|
surface->attachBuffer(Buffer::Ptr());
|
||||||
surface->commit(Surface::CommitFlag::None);
|
surface->commit(Surface::CommitFlag::None);
|
||||||
shellSurface.reset();
|
shellSurface.reset();
|
||||||
connection->flush();
|
Test::flushWaylandConnection();
|
||||||
qDebug() << rowsRemovedSpy.count();
|
qDebug() << rowsRemovedSpy.count();
|
||||||
QEXPECT_FAIL("", "Deleting a ShellSurface does not result in the server removing the ShellClient", Continue);
|
QEXPECT_FAIL("", "Deleting a ShellSurface does not result in the server removing the ShellClient", Continue);
|
||||||
QVERIFY(rowsRemovedSpy.wait());
|
QVERIFY(rowsRemovedSpy.wait());
|
||||||
// also destroy the connection to ensure the ShellSurface goes away
|
|
||||||
surface.reset();
|
surface.reset();
|
||||||
shell.reset();
|
|
||||||
shm.reset();
|
|
||||||
compositor.reset();
|
|
||||||
connection.take()->deleteLater();
|
|
||||||
thread->quit();
|
|
||||||
QVERIFY(thread->wait());
|
|
||||||
|
|
||||||
QVERIFY(rowsRemovedSpy.wait());
|
QVERIFY(rowsRemovedSpy.wait());
|
||||||
QCOMPARE(rowsRemovedSpy.count(), 1);
|
QCOMPARE(rowsRemovedSpy.count(), 1);
|
||||||
|
|
|
@ -33,8 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/pointer.h>
|
#include <KWayland/Client/pointer.h>
|
||||||
#include <KWayland/Client/server_decoration.h>
|
#include <KWayland/Client/server_decoration.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
|
@ -74,14 +72,6 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractClient *showWindow();
|
AbstractClient *showWindow();
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MOTION(target) \
|
#define MOTION(target) \
|
||||||
|
@ -105,11 +95,11 @@ AbstractClient *DecorationInputTest::showWindow()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
VERIFY(clientAddedSpy.isValid());
|
VERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||||
VERIFY(surface);
|
VERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
VERIFY(shellSurface);
|
VERIFY(shellSurface);
|
||||||
auto deco = m_deco->create(surface, surface);
|
auto deco = Test::waylandServerSideDecoration()->create(surface, surface);
|
||||||
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
|
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
|
||||||
VERIFY(decoSpy.isValid());
|
VERIFY(decoSpy.isValid());
|
||||||
VERIFY(decoSpy.wait());
|
VERIFY(decoSpy.wait());
|
||||||
|
@ -117,13 +107,9 @@ AbstractClient *DecorationInputTest::showWindow()
|
||||||
VERIFY(decoSpy.wait());
|
VERIFY(decoSpy.wait());
|
||||||
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(500, 50), QImage::Format_ARGB32);
|
Test::render(surface, QSize(500, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 500, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
VERIFY(clientAddedSpy.wait());
|
VERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
VERIFY(c);
|
VERIFY(c);
|
||||||
|
@ -166,61 +152,8 @@ void DecorationInputTest::initTestCase()
|
||||||
void DecorationInputTest::init()
|
void DecorationInputTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration));
|
||||||
m_connection = new ConnectionThread;
|
QVERIFY(Test::waitForWaylandPointer());
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
QVERIFY(decorationSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
QVERIFY(!decorationSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value<quint32>(), decorationSpy.first().last().value<quint32>());
|
|
||||||
QVERIFY(m_deco->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -228,26 +161,7 @@ void DecorationInputTest::init()
|
||||||
|
|
||||||
void DecorationInputTest::cleanup()
|
void DecorationInputTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_deco;
|
|
||||||
m_deco = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecorationInputTest::testAxis_data()
|
void DecorationInputTest::testAxis_data()
|
||||||
|
|
|
@ -33,13 +33,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
#include <KWayland/Client/shm_pool.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -58,12 +56,6 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
void unlock();
|
void unlock();
|
||||||
AbstractClient *showWindow();
|
AbstractClient *showWindow();
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
|
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
|
||||||
|
@ -83,69 +75,12 @@ void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
|
||||||
|
|
||||||
void DontCrashCancelAnimationFromAnimationEndedTest::init()
|
void DontCrashCancelAnimationFromAnimationEndedTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
// setup connection
|
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DontCrashCancelAnimationFromAnimationEndedTest::cleanup()
|
void DontCrashCancelAnimationFromAnimationEndedTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
|
void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
|
||||||
|
@ -169,18 +104,14 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
QVERIFY(c);
|
QVERIFY(c);
|
||||||
|
|
|
@ -28,17 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "shell_client.h"
|
#include "shell_client.h"
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
|
||||||
#include <KWayland/Client/compositor.h>
|
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/pointer.h>
|
|
||||||
#include <KWayland/Client/server_decoration.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
|
||||||
#include <KWayland/Client/seat.h>
|
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
|
||||||
|
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
@ -54,18 +43,7 @@ class DontCrashEmptyDecorationTest : public QObject
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
|
||||||
void testBug361551();
|
void testBug361551();
|
||||||
|
|
||||||
private:
|
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void DontCrashEmptyDecorationTest::initTestCase()
|
void DontCrashEmptyDecorationTest::initTestCase()
|
||||||
|
@ -94,91 +72,10 @@ void DontCrashEmptyDecorationTest::initTestCase()
|
||||||
|
|
||||||
void DontCrashEmptyDecorationTest::init()
|
void DontCrashEmptyDecorationTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
|
||||||
// setup connection
|
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
QVERIFY(decorationSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
QVERIFY(!decorationSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value<quint32>(), decorationSpy.first().last().value<quint32>());
|
|
||||||
QVERIFY(m_deco->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DontCrashEmptyDecorationTest::cleanup()
|
|
||||||
{
|
|
||||||
delete m_compositor;
|
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_deco;
|
|
||||||
m_deco = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DontCrashEmptyDecorationTest::testBug361551()
|
void DontCrashEmptyDecorationTest::testBug361551()
|
||||||
{
|
{
|
||||||
// this test verifies that resizing an X11 window to an invalid size does not result in crash on unmap
|
// this test verifies that resizing an X11 window to an invalid size does not result in crash on unmap
|
||||||
|
|
|
@ -29,15 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "shell_client.h"
|
#include "shell_client.h"
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
|
||||||
#include <KWayland/Client/compositor.h>
|
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/pointer.h>
|
|
||||||
#include <KWayland/Client/server_decoration.h>
|
#include <KWayland/Client/server_decoration.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/seat.h>
|
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
|
@ -57,16 +50,6 @@ private Q_SLOTS:
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void testCreateWindow();
|
void testCreateWindow();
|
||||||
|
|
||||||
private:
|
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void DontCrashNoBorder::initTestCase()
|
void DontCrashNoBorder::initTestCase()
|
||||||
|
@ -100,62 +83,7 @@ void DontCrashNoBorder::initTestCase()
|
||||||
|
|
||||||
void DontCrashNoBorder::init()
|
void DontCrashNoBorder::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Decoration));
|
||||||
// setup connection
|
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
QVERIFY(decorationSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
QVERIFY(!decorationSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value<quint32>(), decorationSpy.first().last().value<quint32>());
|
|
||||||
QVERIFY(m_deco->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -163,26 +91,7 @@ void DontCrashNoBorder::init()
|
||||||
|
|
||||||
void DontCrashNoBorder::cleanup()
|
void DontCrashNoBorder::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_deco;
|
|
||||||
m_deco = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DontCrashNoBorder::testCreateWindow()
|
void DontCrashNoBorder::testCreateWindow()
|
||||||
|
@ -192,25 +101,21 @@ void DontCrashNoBorder::testCreateWindow()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(surface);
|
QVERIFY(!surface.isNull());
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
auto deco = m_deco->create(surface, surface);
|
QScopedPointer<ServerSideDecoration> deco(Test::waylandServerSideDecoration()->create(surface.data()));
|
||||||
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
|
QSignalSpy decoSpy(deco.data(), &ServerSideDecoration::modeChanged);
|
||||||
QVERIFY(decoSpy.isValid());
|
QVERIFY(decoSpy.isValid());
|
||||||
QVERIFY(decoSpy.wait());
|
QVERIFY(decoSpy.wait());
|
||||||
deco->requestMode(ServerSideDecoration::Mode::Server);
|
deco->requestMode(ServerSideDecoration::Mode::Server);
|
||||||
QVERIFY(decoSpy.wait());
|
QVERIFY(decoSpy.wait());
|
||||||
QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(500, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(500, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 500, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
QVERIFY(c);
|
QVERIFY(c);
|
||||||
|
|
|
@ -57,13 +57,6 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(KWayland::Client::Surface *surface);
|
void render(KWayland::Client::Surface *surface);
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void InputStackingOrderTest::initTestCase()
|
void InputStackingOrderTest::initTestCase()
|
||||||
|
@ -89,56 +82,8 @@ void InputStackingOrderTest::initTestCase()
|
||||||
void InputStackingOrderTest::init()
|
void InputStackingOrderTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
|
||||||
m_connection = new ConnectionThread;
|
QVERIFY(Test::waitForWaylandPointer());
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -146,34 +91,13 @@ void InputStackingOrderTest::init()
|
||||||
|
|
||||||
void InputStackingOrderTest::cleanup()
|
void InputStackingOrderTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputStackingOrderTest::render(KWayland::Client::Surface *surface)
|
void InputStackingOrderTest::render(KWayland::Client::Surface *surface)
|
||||||
{
|
{
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
Test::flushWaylandConnection();
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
|
void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
|
||||||
|
@ -184,7 +108,7 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
|
||||||
// other window should gain focus without a mouse event in between
|
// other window should gain focus without a mouse event in between
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
// create pointer and signal spy for enter and leave signals
|
// create pointer and signal spy for enter and leave signals
|
||||||
auto pointer = m_seat->createPointer(m_seat);
|
auto pointer = Test::waylandSeat()->createPointer(Test::waylandSeat());
|
||||||
QVERIFY(pointer);
|
QVERIFY(pointer);
|
||||||
QVERIFY(pointer->isValid());
|
QVERIFY(pointer->isValid());
|
||||||
QSignalSpy enteredSpy(pointer, &Pointer::entered);
|
QSignalSpy enteredSpy(pointer, &Pointer::entered);
|
||||||
|
@ -195,18 +119,18 @@ void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
|
||||||
// now create the two windows and make them overlap
|
// now create the two windows and make them overlap
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface1 = m_compositor->createSurface(m_compositor);
|
Surface *surface1 = Test::createSurface(Test::waylandCompositor());
|
||||||
QVERIFY(surface1);
|
QVERIFY(surface1);
|
||||||
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
|
ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
|
||||||
QVERIFY(shellSurface1);
|
QVERIFY(shellSurface1);
|
||||||
render(surface1);
|
render(surface1);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *window1 = workspace()->activeClient();
|
AbstractClient *window1 = workspace()->activeClient();
|
||||||
QVERIFY(window1);
|
QVERIFY(window1);
|
||||||
|
|
||||||
Surface *surface2 = m_compositor->createSurface(m_compositor);
|
Surface *surface2 = Test::createSurface(Test::waylandCompositor());
|
||||||
QVERIFY(surface2);
|
QVERIFY(surface2);
|
||||||
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
|
ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
|
||||||
QVERIFY(shellSurface2);
|
QVERIFY(shellSurface2);
|
||||||
render(surface2);
|
render(surface2);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
|
@ -25,6 +25,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Qt
|
// Qt
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
namespace KWayland
|
||||||
|
{
|
||||||
|
namespace Client
|
||||||
|
{
|
||||||
|
class ConnectionThread;
|
||||||
|
class Compositor;
|
||||||
|
class PlasmaShell;
|
||||||
|
class PlasmaWindowManagement;
|
||||||
|
class Seat;
|
||||||
|
class ServerSideDecorationManager;
|
||||||
|
class Shell;
|
||||||
|
class ShellSurface;
|
||||||
|
class ShmPool;
|
||||||
|
class Surface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -50,8 +67,61 @@ private:
|
||||||
QMetaObject::Connection m_xwaylandFailConnection;
|
QMetaObject::Connection m_xwaylandFailConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
|
||||||
|
enum class AdditionalWaylandInterface {
|
||||||
|
Seat = 1 << 0,
|
||||||
|
Decoration = 1 << 1,
|
||||||
|
PlasmaShell = 1 << 2,
|
||||||
|
WindowManagement = 1 << 3
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface)
|
||||||
|
/**
|
||||||
|
* Creates a Wayland Connection in a dedicated thread and creates various
|
||||||
|
* client side objects which can be used to create windows.
|
||||||
|
* @param socketName The name of the Wayland socket to connect to.
|
||||||
|
* @returns @c true if created successfully, @c false if there was an error
|
||||||
|
* @see destroyWaylandConnection
|
||||||
|
**/
|
||||||
|
bool setupWaylandConnection(const QString &socketName, AdditionalWaylandInterfaces flags = AdditionalWaylandInterfaces());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the Wayland Connection created with @link{setupWaylandConnection}.
|
||||||
|
* This can be called from cleanup in order to ensure that no Wayland Connection
|
||||||
|
* leaks into the next test method.
|
||||||
|
* @see setupWaylandConnection
|
||||||
|
*/
|
||||||
|
void destroyWaylandConnection();
|
||||||
|
|
||||||
|
KWayland::Client::ConnectionThread *waylandConnection();
|
||||||
|
KWayland::Client::Compositor *waylandCompositor();
|
||||||
|
KWayland::Client::Shell *waylandShell();
|
||||||
|
KWayland::Client::ShmPool *waylandShmPool();
|
||||||
|
KWayland::Client::Seat *waylandSeat();
|
||||||
|
KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration();
|
||||||
|
KWayland::Client::PlasmaShell *waylandPlasmaShell();
|
||||||
|
KWayland::Client::PlasmaWindowManagement *waylandWindowManagement();
|
||||||
|
|
||||||
|
bool waitForWaylandPointer();
|
||||||
|
bool waitForWaylandTouch();
|
||||||
|
|
||||||
|
void flushWaylandConnection();
|
||||||
|
|
||||||
|
KWayland::Client::Surface *createSurface(QObject *parent = nullptr);
|
||||||
|
KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface.
|
||||||
|
* The @p surface gets damaged and committed, thus it's rendered.
|
||||||
|
**/
|
||||||
|
void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces)
|
||||||
|
|
||||||
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI) \
|
#define WAYLANDTEST_MAIN_HELPER(TestObject, DPI) \
|
||||||
int main(int argc, char *argv[]) \
|
int main(int argc, char *argv[]) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/keyboard.h>
|
#include <KWayland/Client/keyboard.h>
|
||||||
#include <KWayland/Client/registry.h>
|
#include <KWayland/Client/registry.h>
|
||||||
#include <KWayland/Client/pointer.h>
|
#include <KWayland/Client/pointer.h>
|
||||||
|
@ -83,8 +82,6 @@ private:
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
KWayland::Client::Seat *m_seat = nullptr;
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
KWayland::Client::ShmPool *m_shm = nullptr;
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
KWayland::Client::Shell *m_shell = nullptr;
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class HelperEffect : public Effect
|
class HelperEffect : public Effect
|
||||||
|
@ -167,16 +164,12 @@ AbstractClient *LockScreenTest::showWindow()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
VERIFY(clientAddedSpy.isValid());
|
VERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
VERIFY(surface);
|
VERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
VERIFY(shellSurface);
|
VERIFY(shellSurface);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
VERIFY(clientAddedSpy.wait());
|
VERIFY(clientAddedSpy.wait());
|
||||||
|
@ -212,57 +205,13 @@ void LockScreenTest::initTestCase()
|
||||||
|
|
||||||
void LockScreenTest::init()
|
void LockScreenTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
|
||||||
// setup connection
|
QVERIFY(Test::waitForWaylandPointer());
|
||||||
m_connection = new ConnectionThread;
|
m_connection = Test::waylandConnection();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_compositor = Test::waylandCompositor();
|
||||||
QVERIFY(connectedSpy.isValid());
|
m_shell = Test::waylandShell();
|
||||||
m_connection->setSocketName(s_socketName);
|
m_shm = Test::waylandShmPool();
|
||||||
|
m_seat = Test::waylandSeat();
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -270,24 +219,7 @@ void LockScreenTest::init()
|
||||||
|
|
||||||
void LockScreenTest::cleanup()
|
void LockScreenTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LockScreenTest::testPointer()
|
void LockScreenTest::testPointer()
|
||||||
|
|
|
@ -25,10 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
#include <KWayland/Client/shm_pool.h>
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
@ -39,8 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
#include <KDecoration2/DecoratedClient>
|
#include <KDecoration2/DecoratedClient>
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
using namespace KWin;
|
using namespace KWin;
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
|
||||||
|
@ -56,15 +51,6 @@ private Q_SLOTS:
|
||||||
|
|
||||||
void testMaximizedPassedToDeco();
|
void testMaximizedPassedToDeco();
|
||||||
void testInitiallyMaximized();
|
void testInitiallyMaximized();
|
||||||
|
|
||||||
private:
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
Shell *m_shell = nullptr;
|
|
||||||
ShmPool *m_shm = nullptr;
|
|
||||||
EventQueue *m_queue = nullptr;
|
|
||||||
ServerSideDecorationManager *m_ssd = nullptr;
|
|
||||||
ConnectionThread *m_connection = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestMaximized::initTestCase()
|
void TestMaximized::initTestCase()
|
||||||
|
@ -87,49 +73,7 @@ void TestMaximized::initTestCase()
|
||||||
|
|
||||||
void TestMaximized::init()
|
void TestMaximized::init()
|
||||||
{
|
{
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Decoration));
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
|
|
||||||
registry.interface(Registry::Interface::Compositor).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
|
|
||||||
registry.interface(Registry::Interface::Shm).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
|
|
||||||
registry.interface(Registry::Interface::Shell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_ssd = registry.createServerSideDecorationManager(registry.interface(Registry::Interface::ServerSideDecorationManager).name,
|
|
||||||
registry.interface(Registry::Interface::ServerSideDecorationManager).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_ssd);
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
KWin::Cursor::setPos(QPoint(1280, 512));
|
KWin::Cursor::setPos(QPoint(1280, 512));
|
||||||
|
@ -137,28 +81,7 @@ void TestMaximized::init()
|
||||||
|
|
||||||
void TestMaximized::cleanup()
|
void TestMaximized::cleanup()
|
||||||
{
|
{
|
||||||
#define CLEANUP(name) \
|
Test::destroyWaylandConnection();
|
||||||
if (name) { \
|
|
||||||
delete name; \
|
|
||||||
name = nullptr; \
|
|
||||||
}
|
|
||||||
CLEANUP(m_compositor)
|
|
||||||
CLEANUP(m_shm)
|
|
||||||
CLEANUP(m_shell)
|
|
||||||
CLEANUP(m_ssd)
|
|
||||||
CLEANUP(m_queue)
|
|
||||||
|
|
||||||
if (m_connection) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
#undef CLEANUP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestMaximized::testMaximizedPassedToDeco()
|
void TestMaximized::testMaximizedPassedToDeco()
|
||||||
|
@ -166,15 +89,11 @@ void TestMaximized::testMaximizedPassedToDeco()
|
||||||
// this test verifies that when a ShellClient gets maximized the Decoration receives the signal
|
// this test verifies that when a ShellClient gets maximized the Decoration receives the signal
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QScopedPointer<ServerSideDecoration> ssd(m_ssd->create(surface.data()));
|
QScopedPointer<ServerSideDecoration> ssd(Test::waylandServerSideDecoration()->create(surface.data()));
|
||||||
|
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangedSpy.isValid());
|
QVERIFY(sizeChangedSpy.isValid());
|
||||||
|
@ -231,8 +150,8 @@ void TestMaximized::testInitiallyMaximized()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
|
|
||||||
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangedSpy.isValid());
|
QVERIFY(sizeChangedSpy.isValid());
|
||||||
|
@ -242,11 +161,7 @@ void TestMaximized::testInitiallyMaximized()
|
||||||
QCOMPARE(shellSurface->size(), QSize(1280, 1024));
|
QCOMPARE(shellSurface->size(), QSize(1280, 1024));
|
||||||
|
|
||||||
// now let's render in an incorrect size
|
// now let's render in an incorrect size
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(clientAddedSpy.isEmpty());
|
QVERIFY(clientAddedSpy.isEmpty());
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
|
@ -30,11 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/plasmashell.h>
|
#include <KWayland/Client/plasmashell.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
@ -71,11 +68,7 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
KWayland::Client::Shell *m_shell = nullptr;
|
||||||
KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void MoveResizeWindowTest::initTestCase()
|
void MoveResizeWindowTest::initTestCase()
|
||||||
|
@ -95,74 +88,17 @@ void MoveResizeWindowTest::initTestCase()
|
||||||
|
|
||||||
void MoveResizeWindowTest::init()
|
void MoveResizeWindowTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell));
|
||||||
// setup connection
|
m_connection = Test::waylandConnection();
|
||||||
m_connection = new ConnectionThread;
|
m_compositor = Test::waylandCompositor();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_shell = Test::waylandShell();
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, registry.interface(Registry::Interface::PlasmaShell).version, this);
|
|
||||||
QVERIFY(m_plasmaShell->isValid());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveResizeWindowTest::cleanup()
|
void MoveResizeWindowTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_plasmaShell;
|
|
||||||
m_plasmaShell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveResizeWindowTest::testMove()
|
void MoveResizeWindowTest::testMove()
|
||||||
|
@ -172,19 +108,15 @@ void MoveResizeWindowTest::testMove()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -274,19 +206,15 @@ void MoveResizeWindowTest::testPackTo()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -322,30 +250,26 @@ void MoveResizeWindowTest::testPackAgainstClient()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface1(m_compositor->createSurface());
|
QScopedPointer<Surface> surface1(Test::createSurface());
|
||||||
QVERIFY(!surface1.isNull());
|
QVERIFY(!surface1.isNull());
|
||||||
QScopedPointer<Surface> surface2(m_compositor->createSurface());
|
QScopedPointer<Surface> surface2(Test::createSurface());
|
||||||
QVERIFY(!surface2.isNull());
|
QVERIFY(!surface2.isNull());
|
||||||
QScopedPointer<Surface> surface3(m_compositor->createSurface());
|
QScopedPointer<Surface> surface3(Test::createSurface());
|
||||||
QVERIFY(!surface3.isNull());
|
QVERIFY(!surface3.isNull());
|
||||||
QScopedPointer<Surface> surface4(m_compositor->createSurface());
|
QScopedPointer<Surface> surface4(Test::createSurface());
|
||||||
QVERIFY(!surface4.isNull());
|
QVERIFY(!surface4.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface1.data()));
|
QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data()));
|
||||||
QVERIFY(!shellSurface1.isNull());
|
QVERIFY(!shellSurface1.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data()));
|
QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data()));
|
||||||
QVERIFY(!shellSurface2.isNull());
|
QVERIFY(!shellSurface2.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface3(m_shell->createSurface(surface3.data()));
|
QScopedPointer<ShellSurface> shellSurface3(Test::createShellSurface(surface3.data()));
|
||||||
QVERIFY(!shellSurface3.isNull());
|
QVERIFY(!shellSurface3.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface4(m_shell->createSurface(surface4.data()));
|
QScopedPointer<ShellSurface> shellSurface4(Test::createShellSurface(surface4.data()));
|
||||||
QVERIFY(!shellSurface4.isNull());
|
QVERIFY(!shellSurface4.isNull());
|
||||||
auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
|
auto renderWindow = [this, &clientAddedSpy] (Surface *surface, const QString &methodCall, const QRect &expectedGeometry) {
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(10, 10), QImage::Format_ARGB32);
|
Test::render(surface, QSize(10, 10), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 10, 10));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -365,15 +289,11 @@ void MoveResizeWindowTest::testPackAgainstClient()
|
||||||
renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10));
|
renderWindow(surface3.data(), QStringLiteral("slotWindowPackRight"), QRect(1270, 507, 10, 10));
|
||||||
renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10));
|
renderWindow(surface4.data(), QStringLiteral("slotWindowPackDown"), QRect(635, 1014, 10, 10));
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -407,34 +327,26 @@ void MoveResizeWindowTest::testGrowShrink()
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
// block geometry helper
|
// block geometry helper
|
||||||
QScopedPointer<Surface> surface1(m_compositor->createSurface());
|
QScopedPointer<Surface> surface1(Test::createSurface());
|
||||||
QVERIFY(!surface1.isNull());
|
QVERIFY(!surface1.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface1.data()));
|
QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data()));
|
||||||
QVERIFY(!shellSurface1.isNull());
|
QVERIFY(!shellSurface1.isNull());
|
||||||
QImage img1(QSize(650, 514), QImage::Format_ARGB32);
|
Test::render(surface1.data(), QSize(650, 514), Qt::blue);
|
||||||
img1.fill(Qt::blue);
|
|
||||||
surface1->attachBuffer(m_shm->createBuffer(img1));
|
|
||||||
surface1->damage(QRect(0, 0, 650, 514));
|
|
||||||
surface1->commit(Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
clientAddedSpy.clear();
|
clientAddedSpy.clear();
|
||||||
workspace()->slotWindowPackRight();
|
workspace()->slotWindowPackRight();
|
||||||
workspace()->slotWindowPackDown();
|
workspace()->slotWindowPackDown();
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -449,11 +361,7 @@ void MoveResizeWindowTest::testGrowShrink()
|
||||||
QFETCH(QString, methodCall);
|
QFETCH(QString, methodCall);
|
||||||
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
|
QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData());
|
||||||
QVERIFY(sizeChangeSpy.wait());
|
QVERIFY(sizeChangeSpy.wait());
|
||||||
QImage img2(shellSurface->size(), QImage::Format_ARGB32);
|
Test::render(surface.data(), shellSurface->size(), Qt::red);
|
||||||
img2.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img2));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), shellSurface->size()));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
|
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryChanged);
|
||||||
QVERIFY(geometryChangedSpy.isValid());
|
QVERIFY(geometryChangedSpy.isValid());
|
||||||
|
@ -486,19 +394,15 @@ void MoveResizeWindowTest::testPointerMoveEnd()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -547,22 +451,18 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
// and a PlasmaShellSurface
|
// and a PlasmaShellSurface
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data()));
|
||||||
QVERIFY(!plasmaSurface.isNull());
|
QVERIFY(!plasmaSurface.isNull());
|
||||||
QFETCH(KWayland::Client::PlasmaShellSurface::Role, role);
|
QFETCH(KWayland::Client::PlasmaShellSurface::Role, role);
|
||||||
plasmaSurface->setRole(role);
|
plasmaSurface->setRole(role);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
|
@ -52,11 +52,8 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
ConnectionThread *m_connection = nullptr;
|
ConnectionThread *m_connection = nullptr;
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
ShmPool *m_shm = nullptr;
|
|
||||||
Shell *m_shell = nullptr;
|
Shell *m_shell = nullptr;
|
||||||
PlasmaShell *m_plasmaShell = nullptr;
|
PlasmaShell *m_plasmaShell = nullptr;
|
||||||
EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void PlasmaSurfaceTest::initTestCase()
|
void PlasmaSurfaceTest::initTestCase()
|
||||||
|
@ -72,70 +69,15 @@ void PlasmaSurfaceTest::initTestCase()
|
||||||
|
|
||||||
void PlasmaSurfaceTest::init()
|
void PlasmaSurfaceTest::init()
|
||||||
{
|
{
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell));
|
||||||
m_connection = new ConnectionThread;
|
m_compositor = Test::waylandCompositor();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_shell = Test::waylandShell();
|
||||||
QVERIFY(connectedSpy.isValid());
|
m_plasmaShell = Test::waylandPlasmaShell();
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
|
|
||||||
registry.interface(Registry::Interface::Compositor).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
|
|
||||||
registry.interface(Registry::Interface::Shm).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
|
|
||||||
registry.interface(Registry::Interface::Shell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name,
|
|
||||||
registry.interface(Registry::Interface::PlasmaShell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_plasmaShell->isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaSurfaceTest::cleanup()
|
void PlasmaSurfaceTest::cleanup()
|
||||||
{
|
{
|
||||||
#define CLEANUP(name) delete name; name = nullptr;
|
Test::destroyWaylandConnection();
|
||||||
CLEANUP(m_plasmaShell)
|
|
||||||
CLEANUP(m_shell)
|
|
||||||
CLEANUP(m_shm)
|
|
||||||
CLEANUP(m_compositor)
|
|
||||||
CLEANUP(m_queue)
|
|
||||||
if (m_connection) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
#undef CLEANUP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
|
void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
|
||||||
|
@ -154,9 +96,9 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
|
||||||
void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
||||||
{
|
{
|
||||||
// this test verifies that a ShellClient is set on all desktops when the role changes
|
// this test verifies that a ShellClient is set on all desktops when the role changes
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
||||||
QVERIFY(!plasmaSurface.isNull());
|
QVERIFY(!plasmaSurface.isNull());
|
||||||
|
@ -165,11 +107,7 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
// now render to map the window
|
// now render to map the window
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit();
|
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
QVERIFY(c);
|
QVERIFY(c);
|
||||||
|
@ -189,16 +127,14 @@ void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
||||||
|
|
||||||
// let's create a second window where we init a little bit different
|
// let's create a second window where we init a little bit different
|
||||||
// first creating the PlasmaSurface then the Shell Surface
|
// first creating the PlasmaSurface then the Shell Surface
|
||||||
QScopedPointer<Surface> surface2(m_compositor->createSurface());
|
QScopedPointer<Surface> surface2(Test::createSurface());
|
||||||
QVERIFY(!surface2.isNull());
|
QVERIFY(!surface2.isNull());
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
|
||||||
QVERIFY(!plasmaSurface2.isNull());
|
QVERIFY(!plasmaSurface2.isNull());
|
||||||
plasmaSurface2->setRole(role);
|
plasmaSurface2->setRole(role);
|
||||||
QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data()));
|
QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data()));
|
||||||
QVERIFY(!shellSurface2.isNull());
|
QVERIFY(!shellSurface2.isNull());
|
||||||
surface2->attachBuffer(m_shm->createBuffer(img));
|
Test::render(surface2.data(), QSize(100, 50), Qt::blue);
|
||||||
surface2->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface2->commit();
|
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
||||||
QVERIFY(workspace()->activeClient() != c);
|
QVERIFY(workspace()->activeClient() != c);
|
||||||
|
@ -228,9 +164,9 @@ void PlasmaSurfaceTest::testAcceptsFocus_data()
|
||||||
void PlasmaSurfaceTest::testAcceptsFocus()
|
void PlasmaSurfaceTest::testAcceptsFocus()
|
||||||
{
|
{
|
||||||
// this test verifies that some surface roles don't get focus
|
// this test verifies that some surface roles don't get focus
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
||||||
QVERIFY(!plasmaSurface.isNull());
|
QVERIFY(!plasmaSurface.isNull());
|
||||||
|
@ -241,11 +177,7 @@ void PlasmaSurfaceTest::testAcceptsFocus()
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
// now render to map the window
|
// now render to map the window
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit();
|
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
||||||
auto c = clientAddedSpy.first().first().value<ShellClient*>();
|
auto c = clientAddedSpy.first().first().value<ShellClient*>();
|
||||||
|
|
|
@ -29,12 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/connection_thread.h>
|
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
#include <KWayland/Server/seat_interface.h>
|
#include <KWayland/Server/seat_interface.h>
|
||||||
//screenlocker
|
//screenlocker
|
||||||
|
@ -67,13 +63,9 @@ private Q_SLOTS:
|
||||||
void testDestroyedButNotUnmapped();
|
void testDestroyedButNotUnmapped();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConnectionThread *m_connection = nullptr;
|
|
||||||
PlasmaWindowManagement *m_windowManagement = nullptr;
|
PlasmaWindowManagement *m_windowManagement = nullptr;
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
Shell *m_shell = nullptr;
|
Shell *m_shell = nullptr;
|
||||||
ShmPool *m_shm = nullptr;
|
|
||||||
EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void PlasmaWindowTest::initTestCase()
|
void PlasmaWindowTest::initTestCase()
|
||||||
|
@ -98,49 +90,10 @@ void PlasmaWindowTest::initTestCase()
|
||||||
|
|
||||||
void PlasmaWindowTest::init()
|
void PlasmaWindowTest::init()
|
||||||
{
|
{
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::WindowManagement));
|
||||||
m_connection = new ConnectionThread;
|
m_windowManagement = Test::waylandWindowManagement();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_compositor = Test::waylandCompositor();
|
||||||
QVERIFY(connectedSpy.isValid());
|
m_shell = Test::waylandShell();
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
|
|
||||||
m_windowManagement = registry.createPlasmaWindowManagement(registry.interface(Registry::Interface::PlasmaWindowManagement).name,
|
|
||||||
registry.interface(Registry::Interface::PlasmaWindowManagement).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_windowManagement);
|
|
||||||
m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
|
|
||||||
registry.interface(Registry::Interface::Compositor).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_compositor);
|
|
||||||
m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
|
|
||||||
registry.interface(Registry::Interface::Shm).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shm);
|
|
||||||
m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
|
|
||||||
registry.interface(Registry::Interface::Shell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shell);
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -148,27 +101,7 @@ void PlasmaWindowTest::init()
|
||||||
|
|
||||||
void PlasmaWindowTest::cleanup()
|
void PlasmaWindowTest::cleanup()
|
||||||
{
|
{
|
||||||
#define CLEANUP(name) \
|
Test::destroyWaylandConnection();
|
||||||
if (name) { \
|
|
||||||
delete name; \
|
|
||||||
name = nullptr; \
|
|
||||||
}
|
|
||||||
CLEANUP(m_windowManagement)
|
|
||||||
CLEANUP(m_shm)
|
|
||||||
CLEANUP(m_shell)
|
|
||||||
CLEANUP(m_compositor)
|
|
||||||
CLEANUP(m_queue)
|
|
||||||
#undef CLEANUP
|
|
||||||
if (m_connection) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlasmaWindowTest::testCreateDestroyX11PlasmaWindow()
|
void PlasmaWindowTest::testCreateDestroyX11PlasmaWindow()
|
||||||
|
@ -304,35 +237,27 @@ void PlasmaWindowTest::testPopupWindowNoPlasmaWindow()
|
||||||
QVERIFY(plasmaWindowCreatedSpy.isValid());
|
QVERIFY(plasmaWindowCreatedSpy.isValid());
|
||||||
|
|
||||||
// first create the parent window
|
// first create the parent window
|
||||||
QScopedPointer<Surface> parentSurface(m_compositor->createSurface());
|
QScopedPointer<Surface> parentSurface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> parentShellSurface(m_shell->createSurface(parentSurface.data()));
|
QScopedPointer<ShellSurface> parentShellSurface(Test::createShellSurface(parentSurface.data()));
|
||||||
// map that window
|
// map that window
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(parentSurface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
parentSurface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
parentSurface->damage(QRect(0, 0, 100, 50));
|
|
||||||
parentSurface->commit();
|
|
||||||
// this should create a plasma window
|
// this should create a plasma window
|
||||||
QVERIFY(plasmaWindowCreatedSpy.wait());
|
QVERIFY(plasmaWindowCreatedSpy.wait());
|
||||||
|
|
||||||
// now let's create a popup window for it
|
// now let's create a popup window for it
|
||||||
QScopedPointer<Surface> popupSurface(m_compositor->createSurface());
|
QScopedPointer<Surface> popupSurface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> popupShellSurface(m_shell->createSurface(popupSurface.data()));
|
QScopedPointer<ShellSurface> popupShellSurface(Test::createShellSurface(popupSurface.data()));
|
||||||
popupShellSurface->setTransient(parentSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
|
popupShellSurface->setTransient(parentSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
|
||||||
// let's map it
|
// let's map it
|
||||||
popupSurface->attachBuffer(m_shm->createBuffer(img));
|
Test::render(popupSurface.data(), QSize(100, 50), Qt::blue);
|
||||||
popupSurface->damage(QRect(0, 0, 100, 50));
|
|
||||||
popupSurface->commit();
|
|
||||||
|
|
||||||
// this should not create a plasma window
|
// this should not create a plasma window
|
||||||
QVERIFY(!plasmaWindowCreatedSpy.wait());
|
QVERIFY(!plasmaWindowCreatedSpy.wait());
|
||||||
|
|
||||||
// now the same with an already mapped surface when we create the shell surface
|
// now the same with an already mapped surface when we create the shell surface
|
||||||
QScopedPointer<Surface> popup2Surface(m_compositor->createSurface());
|
QScopedPointer<Surface> popup2Surface(Test::createSurface());
|
||||||
popup2Surface->attachBuffer(m_shm->createBuffer(img));
|
Test::render(popup2Surface.data(), QSize(100, 50), Qt::blue);
|
||||||
popup2Surface->damage(QRect(0, 0, 100, 50));
|
QScopedPointer<ShellSurface> popup2ShellSurface(Test::createShellSurface(popup2Surface.data()));
|
||||||
popup2Surface->commit();
|
|
||||||
QScopedPointer<ShellSurface> popup2ShellSurface(m_shell->createSurface(popup2Surface.data()));
|
|
||||||
popup2ShellSurface->setTransient(popupSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
|
popup2ShellSurface->setTransient(popupSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus);
|
||||||
|
|
||||||
// this should not create a plasma window
|
// this should not create a plasma window
|
||||||
|
@ -409,14 +334,10 @@ void PlasmaWindowTest::testDestroyedButNotUnmapped()
|
||||||
QVERIFY(plasmaWindowCreatedSpy.isValid());
|
QVERIFY(plasmaWindowCreatedSpy.isValid());
|
||||||
|
|
||||||
// first create the parent window
|
// first create the parent window
|
||||||
QScopedPointer<Surface> parentSurface(m_compositor->createSurface());
|
QScopedPointer<Surface> parentSurface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> parentShellSurface(m_shell->createSurface(parentSurface.data()));
|
QScopedPointer<ShellSurface> parentShellSurface(Test::createShellSurface(parentSurface.data()));
|
||||||
// map that window
|
// map that window
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(parentSurface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
parentSurface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
parentSurface->damage(QRect(0, 0, 100, 50));
|
|
||||||
parentSurface->commit();
|
|
||||||
// this should create a plasma window
|
// this should create a plasma window
|
||||||
QVERIFY(plasmaWindowCreatedSpy.wait());
|
QVERIFY(plasmaWindowCreatedSpy.wait());
|
||||||
QCOMPARE(plasmaWindowCreatedSpy.count(), 1);
|
QCOMPARE(plasmaWindowCreatedSpy.count(), 1);
|
||||||
|
|
|
@ -33,8 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/pointer.h>
|
#include <KWayland/Client/pointer.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/seat.h>
|
#include <KWayland/Client/seat.h>
|
||||||
|
@ -75,13 +73,9 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50));
|
void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50));
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
KWayland::Client::Seat *m_seat = nullptr;
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
KWayland::Client::Shell *m_shell = nullptr;
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void PointerInputTest::initTestCase()
|
void PointerInputTest::initTestCase()
|
||||||
|
@ -111,57 +105,11 @@ void PointerInputTest::initTestCase()
|
||||||
|
|
||||||
void PointerInputTest::init()
|
void PointerInputTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
|
||||||
// setup connection
|
QVERIFY(Test::waitForWaylandPointer());
|
||||||
m_connection = new ConnectionThread;
|
m_compositor = Test::waylandCompositor();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_shell = Test::waylandShell();
|
||||||
QVERIFY(connectedSpy.isValid());
|
m_seat = Test::waylandSeat();
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -169,34 +117,13 @@ void PointerInputTest::init()
|
||||||
|
|
||||||
void PointerInputTest::cleanup()
|
void PointerInputTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointerInputTest::render(KWayland::Client::Surface *surface, const QSize &size)
|
void PointerInputTest::render(KWayland::Client::Surface *surface, const QSize &size)
|
||||||
{
|
{
|
||||||
QImage img(size, QImage::Format_ARGB32);
|
Test::render(surface, size, Qt::blue);
|
||||||
img.fill(Qt::blue);
|
Test::flushWaylandConnection();
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), size));
|
|
||||||
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointerInputTest::testWarpingUpdatesFocus()
|
void PointerInputTest::testWarpingUpdatesFocus()
|
||||||
|
@ -215,9 +142,9 @@ void PointerInputTest::testWarpingUpdatesFocus()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -262,9 +189,9 @@ void PointerInputTest::testWarpingGeneratesPointerMotion()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -304,9 +231,9 @@ void PointerInputTest::testUpdateFocusAfterScreenChange()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface, QSize(1280, 1024));
|
render(surface, QSize(1280, 1024));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -383,9 +310,9 @@ void PointerInputTest::testModifierClickUnrestrictedMove()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -453,9 +380,9 @@ void PointerInputTest::testModifierScrollOpacity()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -501,17 +428,17 @@ void PointerInputTest::testScrollAction()
|
||||||
// create two windows
|
// create two windows
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface1 = m_compositor->createSurface(m_compositor);
|
Surface *surface1 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface1);
|
QVERIFY(surface1);
|
||||||
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
|
ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
|
||||||
QVERIFY(shellSurface1);
|
QVERIFY(shellSurface1);
|
||||||
render(surface1);
|
render(surface1);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *window1 = workspace()->activeClient();
|
AbstractClient *window1 = workspace()->activeClient();
|
||||||
QVERIFY(window1);
|
QVERIFY(window1);
|
||||||
Surface *surface2 = m_compositor->createSurface(m_compositor);
|
Surface *surface2 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface2);
|
QVERIFY(surface2);
|
||||||
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
|
ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
|
||||||
QVERIFY(shellSurface2);
|
QVERIFY(shellSurface2);
|
||||||
render(surface2);
|
render(surface2);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -561,17 +488,17 @@ void PointerInputTest::testFocusFollowsMouse()
|
||||||
// create two windows
|
// create two windows
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface1 = m_compositor->createSurface(m_compositor);
|
Surface *surface1 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface1);
|
QVERIFY(surface1);
|
||||||
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
|
ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
|
||||||
QVERIFY(shellSurface1);
|
QVERIFY(shellSurface1);
|
||||||
render(surface1, QSize(800, 800));
|
render(surface1, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *window1 = workspace()->activeClient();
|
AbstractClient *window1 = workspace()->activeClient();
|
||||||
QVERIFY(window1);
|
QVERIFY(window1);
|
||||||
Surface *surface2 = m_compositor->createSurface(m_compositor);
|
Surface *surface2 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface2);
|
QVERIFY(surface2);
|
||||||
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
|
ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
|
||||||
QVERIFY(shellSurface2);
|
QVERIFY(shellSurface2);
|
||||||
render(surface2, QSize(800, 800));
|
render(surface2, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -647,17 +574,17 @@ void PointerInputTest::testMouseActionInactiveWindow()
|
||||||
// create two windows
|
// create two windows
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface1 = m_compositor->createSurface(m_compositor);
|
Surface *surface1 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface1);
|
QVERIFY(surface1);
|
||||||
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
|
ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
|
||||||
QVERIFY(shellSurface1);
|
QVERIFY(shellSurface1);
|
||||||
render(surface1, QSize(800, 800));
|
render(surface1, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *window1 = workspace()->activeClient();
|
AbstractClient *window1 = workspace()->activeClient();
|
||||||
QVERIFY(window1);
|
QVERIFY(window1);
|
||||||
Surface *surface2 = m_compositor->createSurface(m_compositor);
|
Surface *surface2 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface2);
|
QVERIFY(surface2);
|
||||||
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
|
ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
|
||||||
QVERIFY(shellSurface2);
|
QVERIFY(shellSurface2);
|
||||||
render(surface2, QSize(800, 800));
|
render(surface2, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -737,9 +664,9 @@ void PointerInputTest::testMouseActionActiveWindow()
|
||||||
// create two windows
|
// create two windows
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface1 = m_compositor->createSurface(m_compositor);
|
Surface *surface1 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface1);
|
QVERIFY(surface1);
|
||||||
ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1);
|
ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1);
|
||||||
QVERIFY(shellSurface1);
|
QVERIFY(shellSurface1);
|
||||||
render(surface1, QSize(800, 800));
|
render(surface1, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -747,9 +674,9 @@ void PointerInputTest::testMouseActionActiveWindow()
|
||||||
QVERIFY(window1);
|
QVERIFY(window1);
|
||||||
QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed);
|
QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed);
|
||||||
QVERIFY(window1DestroyedSpy.isValid());
|
QVERIFY(window1DestroyedSpy.isValid());
|
||||||
Surface *surface2 = m_compositor->createSurface(m_compositor);
|
Surface *surface2 = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface2);
|
QVERIFY(surface2);
|
||||||
ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2);
|
ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2);
|
||||||
QVERIFY(shellSurface2);
|
QVERIFY(shellSurface2);
|
||||||
render(surface2, QSize(800, 800));
|
render(surface2, QSize(800, 800));
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -817,9 +744,9 @@ void PointerInputTest::testCursorImage()
|
||||||
// create a window
|
// create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -833,13 +760,13 @@ void PointerInputTest::testCursorImage()
|
||||||
QVERIFY(enteredSpy.wait());
|
QVERIFY(enteredSpy.wait());
|
||||||
|
|
||||||
// create a cursor on the pointer
|
// create a cursor on the pointer
|
||||||
Surface *cursorSurface = m_compositor->createSurface(m_compositor);
|
Surface *cursorSurface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(cursorSurface);
|
QVERIFY(cursorSurface);
|
||||||
QSignalSpy cursorRenderedSpy(cursorSurface, &Surface::frameRendered);
|
QSignalSpy cursorRenderedSpy(cursorSurface, &Surface::frameRendered);
|
||||||
QVERIFY(cursorRenderedSpy.isValid());
|
QVERIFY(cursorRenderedSpy.isValid());
|
||||||
QImage red = QImage(QSize(10, 10), QImage::Format_ARGB32);
|
QImage red = QImage(QSize(10, 10), QImage::Format_ARGB32);
|
||||||
red.fill(Qt::red);
|
red.fill(Qt::red);
|
||||||
cursorSurface->attachBuffer(m_shm->createBuffer(red));
|
cursorSurface->attachBuffer(Test::waylandShmPool()->createBuffer(red));
|
||||||
cursorSurface->damage(QRect(0, 0, 10, 10));
|
cursorSurface->damage(QRect(0, 0, 10, 10));
|
||||||
cursorSurface->commit();
|
cursorSurface->commit();
|
||||||
pointer->setCursor(cursorSurface, QPoint(5, 5));
|
pointer->setCursor(cursorSurface, QPoint(5, 5));
|
||||||
|
@ -848,14 +775,14 @@ void PointerInputTest::testCursorImage()
|
||||||
QCOMPARE(p->cursorHotSpot(), QPoint(5, 5));
|
QCOMPARE(p->cursorHotSpot(), QPoint(5, 5));
|
||||||
// change hotspot
|
// change hotspot
|
||||||
pointer->setCursor(cursorSurface, QPoint(6, 6));
|
pointer->setCursor(cursorSurface, QPoint(6, 6));
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QTRY_COMPARE(p->cursorHotSpot(), QPoint(6, 6));
|
QTRY_COMPARE(p->cursorHotSpot(), QPoint(6, 6));
|
||||||
QCOMPARE(p->cursorImage(), red);
|
QCOMPARE(p->cursorImage(), red);
|
||||||
|
|
||||||
// change the buffer
|
// change the buffer
|
||||||
QImage blue = QImage(QSize(10, 10), QImage::Format_ARGB32);
|
QImage blue = QImage(QSize(10, 10), QImage::Format_ARGB32);
|
||||||
blue.fill(Qt::blue);
|
blue.fill(Qt::blue);
|
||||||
auto b = m_shm->createBuffer(blue);
|
auto b = Test::waylandShmPool()->createBuffer(blue);
|
||||||
cursorSurface->attachBuffer(b);
|
cursorSurface->attachBuffer(b);
|
||||||
cursorSurface->damage(QRect(0, 0, 10, 10));
|
cursorSurface->damage(QRect(0, 0, 10, 10));
|
||||||
cursorSurface->commit();
|
cursorSurface->commit();
|
||||||
|
@ -865,7 +792,7 @@ void PointerInputTest::testCursorImage()
|
||||||
|
|
||||||
// hide the cursor
|
// hide the cursor
|
||||||
pointer->setCursor(nullptr);
|
pointer->setCursor(nullptr);
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QTRY_VERIFY(p->cursorImage().isNull());
|
QTRY_VERIFY(p->cursorImage().isNull());
|
||||||
|
|
||||||
// move cursor somewhere else, should reset to fallback cursor
|
// move cursor somewhere else, should reset to fallback cursor
|
||||||
|
@ -904,9 +831,9 @@ void PointerInputTest::testEffectOverrideCursorImage()
|
||||||
// now let's create a window
|
// now let's create a window
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
QVERIFY(surface);
|
QVERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
QVERIFY(shellSurface);
|
QVERIFY(shellSurface);
|
||||||
render(surface);
|
render(surface);
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
|
@ -28,10 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
@ -63,10 +60,7 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
KWayland::Client::Shell *m_shell = nullptr;
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void QuickTilingTest::initTestCase()
|
void QuickTilingTest::initTestCase()
|
||||||
|
@ -97,71 +91,17 @@ void QuickTilingTest::initTestCase()
|
||||||
|
|
||||||
void QuickTilingTest::init()
|
void QuickTilingTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
// setup connection
|
m_connection = Test::waylandConnection();
|
||||||
m_connection = new ConnectionThread;
|
m_compositor = Test::waylandCompositor();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_shell = Test::waylandShell();
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickTilingTest::cleanup()
|
void QuickTilingTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickTilingTest::testQuickTiling_data()
|
void QuickTilingTest::testQuickTiling_data()
|
||||||
|
@ -194,19 +134,15 @@ void QuickTilingTest::testQuickTiling()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -235,11 +171,7 @@ void QuickTilingTest::testQuickTiling()
|
||||||
QCOMPARE(sizeChangeSpy.first().first().toSize(), expectedGeometry.size());
|
QCOMPARE(sizeChangeSpy.first().first().toSize(), expectedGeometry.size());
|
||||||
|
|
||||||
// attach a new image
|
// attach a new image
|
||||||
img = QImage(expectedGeometry.size(), QImage::Format_ARGB32);
|
Test::render(surface.data(), expectedGeometry.size(), Qt::red);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), expectedGeometry.size()));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
|
|
||||||
QVERIFY(geometryChangedSpy.wait());
|
QVERIFY(geometryChangedSpy.wait());
|
||||||
|
@ -276,19 +208,15 @@ void QuickTilingTest::testQuickMaximizing()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -329,11 +257,7 @@ void QuickTilingTest::testQuickMaximizing()
|
||||||
QCOMPARE(sizeChangeSpy.first().first().toSize(), QSize(1280, 1024));
|
QCOMPARE(sizeChangeSpy.first().first().toSize(), QSize(1280, 1024));
|
||||||
|
|
||||||
// attach a new image
|
// attach a new image
|
||||||
img = QImage(QSize(1280, 1024), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(1280, 1024), Qt::red);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 1280, 1024));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
|
|
||||||
QVERIFY(geometryChangedSpy.wait());
|
QVERIFY(geometryChangedSpy.wait());
|
||||||
|
@ -363,11 +287,7 @@ void QuickTilingTest::testQuickMaximizing()
|
||||||
QCOMPARE(sizeChangeSpy.last().first().toSize(), QSize(100, 50));
|
QCOMPARE(sizeChangeSpy.last().first().toSize(), QSize(100, 50));
|
||||||
|
|
||||||
// render again
|
// render again
|
||||||
img = QImage(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::yellow);
|
||||||
img.fill(Qt::yellow);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
|
|
||||||
QVERIFY(geometryChangedSpy.wait());
|
QVERIFY(geometryChangedSpy.wait());
|
||||||
|
@ -396,19 +316,15 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -477,19 +393,15 @@ void QuickTilingTest::testQuickTilingPointerMove()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
QSignalSpy sizeChangeSpy(shellSurface.data(), &ShellSurface::sizeChanged);
|
||||||
QVERIFY(sizeChangeSpy.isValid());
|
QVERIFY(sizeChangeSpy.isValid());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
m_connection->flush();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
|
|
@ -27,16 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
#include <KWayland/Server/shell_interface.h>
|
#include <KWayland/Server/shell_interface.h>
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
using namespace KWin;
|
using namespace KWin;
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
|
||||||
|
@ -51,14 +46,6 @@ private Q_SLOTS:
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
void testMapUnmapMap();
|
void testMapUnmapMap();
|
||||||
|
|
||||||
private:
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
Shell *m_shell = nullptr;
|
|
||||||
ShmPool *m_shm = nullptr;
|
|
||||||
EventQueue *m_queue = nullptr;
|
|
||||||
ConnectionThread *m_connection = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestShellClient::initTestCase()
|
void TestShellClient::initTestCase()
|
||||||
|
@ -81,45 +68,7 @@ void TestShellClient::initTestCase()
|
||||||
|
|
||||||
void TestShellClient::init()
|
void TestShellClient::init()
|
||||||
{
|
{
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name,
|
|
||||||
registry.interface(Registry::Interface::Compositor).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name,
|
|
||||||
registry.interface(Registry::Interface::Shm).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
|
|
||||||
registry.interface(Registry::Interface::Shell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
KWin::Cursor::setPos(QPoint(1280, 512));
|
KWin::Cursor::setPos(QPoint(1280, 512));
|
||||||
|
@ -127,27 +76,7 @@ void TestShellClient::init()
|
||||||
|
|
||||||
void TestShellClient::cleanup()
|
void TestShellClient::cleanup()
|
||||||
{
|
{
|
||||||
#define CLEANUP(name) \
|
Test::destroyWaylandConnection();
|
||||||
if (name) { \
|
|
||||||
delete name; \
|
|
||||||
name = nullptr; \
|
|
||||||
}
|
|
||||||
CLEANUP(m_compositor)
|
|
||||||
CLEANUP(m_shm)
|
|
||||||
CLEANUP(m_shell)
|
|
||||||
CLEANUP(m_queue)
|
|
||||||
|
|
||||||
if (m_connection) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
#undef CLEANUP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestShellClient::testMapUnmapMap()
|
void TestShellClient::testMapUnmapMap()
|
||||||
|
@ -156,15 +85,11 @@ void TestShellClient::testMapUnmapMap()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
|
|
||||||
// now let's render
|
// now let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(clientAddedSpy.isEmpty());
|
QVERIFY(clientAddedSpy.isEmpty());
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
|
@ -186,9 +111,7 @@ void TestShellClient::testMapUnmapMap()
|
||||||
|
|
||||||
QSignalSpy windowShownSpy(client, &ShellClient::windowShown);
|
QSignalSpy windowShownSpy(client, &ShellClient::windowShown);
|
||||||
QVERIFY(windowShownSpy.isValid());
|
QVERIFY(windowShownSpy.isValid());
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
QCOMPARE(clientAddedSpy.count(), 1);
|
QCOMPARE(clientAddedSpy.count(), 1);
|
||||||
QVERIFY(windowShownSpy.wait());
|
QVERIFY(windowShownSpy.wait());
|
||||||
QCOMPARE(windowShownSpy.count(), 1);
|
QCOMPARE(windowShownSpy.count(), 1);
|
||||||
|
|
|
@ -26,10 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -42,6 +39,7 @@ class StartTest : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
void cleanup();
|
||||||
void testScreens();
|
void testScreens();
|
||||||
void testNoWindowsAtStart();
|
void testNoWindowsAtStart();
|
||||||
void testCreateWindow();
|
void testCreateWindow();
|
||||||
|
@ -57,6 +55,11 @@ void StartTest::initTestCase()
|
||||||
QVERIFY(workspaceCreatedSpy.wait());
|
QVERIFY(workspaceCreatedSpy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StartTest::cleanup()
|
||||||
|
{
|
||||||
|
Test::destroyWaylandConnection();
|
||||||
|
}
|
||||||
|
|
||||||
void StartTest::testScreens()
|
void StartTest::testScreens()
|
||||||
{
|
{
|
||||||
QCOMPARE(screens()->count(), 1);
|
QCOMPARE(screens()->count(), 1);
|
||||||
|
@ -78,15 +81,7 @@ void StartTest::testCreateWindow()
|
||||||
{
|
{
|
||||||
// first we need to connect to the server
|
// first we need to connect to the server
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
auto connection = new ConnectionThread;
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
QSignalSpy connectedSpy(connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
connection->setSocketName(s_socketName);
|
|
||||||
QThread *thread = new QThread(this);
|
|
||||||
connection->moveToThread(thread);
|
|
||||||
thread->start();
|
|
||||||
connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(shellClientAddedSpy.isValid());
|
QVERIFY(shellClientAddedSpy.isValid());
|
||||||
|
@ -94,32 +89,14 @@ void StartTest::testCreateWindow()
|
||||||
QVERIFY(shellClientRemovedSpy.isValid());
|
QVERIFY(shellClientRemovedSpy.isValid());
|
||||||
|
|
||||||
{
|
{
|
||||||
EventQueue queue;
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
queue.setup(connection);
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(&queue);
|
|
||||||
registry.create(connection);
|
|
||||||
QSignalSpy registryAnnouncedSpy(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(registryAnnouncedSpy.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(registryAnnouncedSpy.wait());
|
|
||||||
|
|
||||||
const auto compositorData = registry.interface(Registry::Interface::Compositor);
|
|
||||||
const auto shellData = registry.interface(Registry::Interface::Shell);
|
|
||||||
const auto shmData = registry.interface(Registry::Interface::Shm);
|
|
||||||
QScopedPointer<KWayland::Client::Compositor> compositor(registry.createCompositor(compositorData.name, compositorData.version));
|
|
||||||
QVERIFY(!compositor.isNull());
|
|
||||||
QScopedPointer<Shell> shell(registry.createShell(shellData.name, shellData.version));
|
|
||||||
QVERIFY(!shell.isNull());
|
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(compositor->createSurface());
|
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
QSignalSpy surfaceRenderedSpy(surface.data(), &Surface::frameRendered);
|
QSignalSpy surfaceRenderedSpy(surface.data(), &Surface::frameRendered);
|
||||||
QVERIFY(surfaceRenderedSpy.isValid());
|
QVERIFY(surfaceRenderedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QVERIFY(waylandServer()->clients().isEmpty());
|
QVERIFY(waylandServer()->clients().isEmpty());
|
||||||
// now dispatch should give us the client
|
// now dispatch should give us the client
|
||||||
waylandServer()->dispatch();
|
waylandServer()->dispatch();
|
||||||
|
@ -132,15 +109,10 @@ void StartTest::testCreateWindow()
|
||||||
QVERIFY(waylandServer()->clients().first()->iconGeometry().isNull());
|
QVERIFY(waylandServer()->clients().first()->iconGeometry().isNull());
|
||||||
|
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
QScopedPointer<ShmPool> shm(registry.createShmPool(shmData.name, shmData.version));
|
|
||||||
QVERIFY(!shm.isNull());
|
|
||||||
surface->attachBuffer(shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit();
|
surface->commit();
|
||||||
|
|
||||||
connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QVERIFY(shellClientAddedSpy.wait());
|
QVERIFY(shellClientAddedSpy.wait());
|
||||||
QCOMPARE(workspace()->allClientList().count(), 1);
|
QCOMPARE(workspace()->allClientList().count(), 1);
|
||||||
QCOMPARE(workspace()->allClientList().first(), waylandServer()->clients().first());
|
QCOMPARE(workspace()->allClientList().first(), waylandServer()->clients().first());
|
||||||
|
@ -155,11 +127,6 @@ void StartTest::testCreateWindow()
|
||||||
// this should tear down everything again
|
// this should tear down everything again
|
||||||
QVERIFY(shellClientRemovedSpy.wait());
|
QVERIFY(shellClientRemovedSpy.wait());
|
||||||
QVERIFY(waylandServer()->clients().isEmpty());
|
QVERIFY(waylandServer()->clients().isEmpty());
|
||||||
|
|
||||||
// cleanup
|
|
||||||
connection->deleteLater();
|
|
||||||
thread->quit();
|
|
||||||
thread->wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "shell_client.h"
|
#include "shell_client.h"
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/plasmashell.h>
|
#include <KWayland/Client/plasmashell.h>
|
||||||
#include <KWayland/Client/pointer.h>
|
|
||||||
#include <KWayland/Client/server_decoration.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/seat.h>
|
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
#include <KDecoration2/Decoration>
|
#include <KDecoration2/Decoration>
|
||||||
|
@ -66,15 +59,8 @@ private Q_SLOTS:
|
||||||
void test363804();
|
void test363804();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
||||||
KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
|
KWayland::Client::PlasmaShell *m_plasmaShell = nullptr;
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void StrutsTest::initTestCase()
|
void StrutsTest::initTestCase()
|
||||||
|
@ -98,99 +84,18 @@ void StrutsTest::initTestCase()
|
||||||
|
|
||||||
void StrutsTest::init()
|
void StrutsTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell));
|
||||||
// setup connection
|
m_compositor = Test::waylandCompositor();
|
||||||
m_connection = new ConnectionThread;
|
m_plasmaShell = Test::waylandPlasmaShell();
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
QVERIFY(decorationSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
QVERIFY(!decorationSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value<quint32>(), decorationSpy.first().last().value<quint32>());
|
|
||||||
QVERIFY(m_deco->isValid());
|
|
||||||
m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name,
|
|
||||||
registry.interface(Registry::Interface::PlasmaShell).version,
|
|
||||||
this);
|
|
||||||
QVERIFY(m_plasmaShell);
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
QVERIFY(waylandServer()->clients().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrutsTest::cleanup()
|
void StrutsTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_deco;
|
|
||||||
m_deco = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_plasmaShell;
|
|
||||||
m_plasmaShell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
while (!waylandServer()->clients().isEmpty()) {
|
|
||||||
QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents);
|
|
||||||
}
|
|
||||||
QVERIFY(waylandServer()->clients().isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrutsTest::testWaylandStruts_data()
|
void StrutsTest::testWaylandStruts_data()
|
||||||
|
@ -252,21 +157,18 @@ void StrutsTest::testWaylandStruts()
|
||||||
// create the panels
|
// create the panels
|
||||||
QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(windowCreatedSpy.isValid());
|
QVERIFY(windowCreatedSpy.isValid());
|
||||||
|
QHash<Surface*, ShellClient*> clients;
|
||||||
for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) {
|
for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) {
|
||||||
const QRect windowGeometry = *it;
|
const QRect windowGeometry = *it;
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(m_compositor);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
Q_UNUSED(shellSurface)
|
Q_UNUSED(shellSurface)
|
||||||
PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface);
|
PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface);
|
||||||
plasmaSurface->setPosition(windowGeometry.topLeft());
|
plasmaSurface->setPosition(windowGeometry.topLeft());
|
||||||
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
||||||
|
|
||||||
// map the window
|
// map the window
|
||||||
QImage img(windowGeometry.size(), QImage::Format_RGB32);
|
Test::render(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), windowGeometry.size()));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(windowCreatedSpy.wait());
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||||
|
@ -277,6 +179,7 @@ void StrutsTest::testWaylandStruts()
|
||||||
QVERIFY(c->isDock());
|
QVERIFY(c->isDock());
|
||||||
QVERIFY(c->hasStrut());
|
QVERIFY(c->hasStrut());
|
||||||
windowCreatedSpy.clear();
|
windowCreatedSpy.clear();
|
||||||
|
clients.insert(surface, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some props are independent of struts - those first
|
// some props are independent of struts - those first
|
||||||
|
@ -299,6 +202,14 @@ void StrutsTest::testWaylandStruts()
|
||||||
QTEST(workspace()->clientArea(PlacementArea, 1, 1), "screen1Maximized");
|
QTEST(workspace()->clientArea(PlacementArea, 1, 1), "screen1Maximized");
|
||||||
QTEST(workspace()->clientArea(MaximizeArea, 1, 1), "screen1Maximized");
|
QTEST(workspace()->clientArea(MaximizeArea, 1, 1), "screen1Maximized");
|
||||||
QTEST(workspace()->clientArea(WorkArea, 0, 1), "workArea");
|
QTEST(workspace()->clientArea(WorkArea, 0, 1), "workArea");
|
||||||
|
|
||||||
|
// delete all surfaces
|
||||||
|
for (auto it = clients.begin(); it != clients.end(); it++) {
|
||||||
|
QSignalSpy destroyedSpy(it.value(), &QObject::destroyed);
|
||||||
|
QVERIFY(destroyedSpy.isValid());
|
||||||
|
delete it.key();
|
||||||
|
QVERIFY(destroyedSpy.wait());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StrutsTest::testMoveWaylandPanel()
|
void StrutsTest::testMoveWaylandPanel()
|
||||||
|
@ -306,8 +217,8 @@ void StrutsTest::testMoveWaylandPanel()
|
||||||
// this test verifies that repositioning a Wayland panel updates the client area
|
// this test verifies that repositioning a Wayland panel updates the client area
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
const QRect windowGeometry(0, 1000, 1280, 24);
|
const QRect windowGeometry(0, 1000, 1280, 24);
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
Q_UNUSED(shellSurface)
|
Q_UNUSED(shellSurface)
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
||||||
plasmaSurface->setPosition(windowGeometry.topLeft());
|
plasmaSurface->setPosition(windowGeometry.topLeft());
|
||||||
|
@ -317,11 +228,7 @@ void StrutsTest::testMoveWaylandPanel()
|
||||||
QVERIFY(windowCreatedSpy.isValid());
|
QVERIFY(windowCreatedSpy.isValid());
|
||||||
|
|
||||||
// map the window
|
// map the window
|
||||||
QImage img(windowGeometry.size(), QImage::Format_RGB32);
|
Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), windowGeometry.size()));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(windowCreatedSpy.wait());
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||||
|
@ -362,8 +269,8 @@ void StrutsTest::testWaylandMobilePanel()
|
||||||
|
|
||||||
// create first top panel
|
// create first top panel
|
||||||
const QRect windowGeometry(0, 0, 1280, 60);
|
const QRect windowGeometry(0, 0, 1280, 60);
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
Q_UNUSED(shellSurface)
|
Q_UNUSED(shellSurface)
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
||||||
plasmaSurface->setPosition(windowGeometry.topLeft());
|
plasmaSurface->setPosition(windowGeometry.topLeft());
|
||||||
|
@ -373,11 +280,7 @@ void StrutsTest::testWaylandMobilePanel()
|
||||||
QVERIFY(windowCreatedSpy.isValid());
|
QVERIFY(windowCreatedSpy.isValid());
|
||||||
|
|
||||||
// map the first panel
|
// map the first panel
|
||||||
QImage img(windowGeometry.size(), QImage::Format_RGB32);
|
Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32);
|
||||||
img.fill(Qt::red);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), windowGeometry.size()));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(windowCreatedSpy.wait());
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||||
|
@ -398,18 +301,14 @@ void StrutsTest::testWaylandMobilePanel()
|
||||||
|
|
||||||
// create another bottom panel
|
// create another bottom panel
|
||||||
const QRect windowGeometry2(0, 874, 1280, 150);
|
const QRect windowGeometry2(0, 874, 1280, 150);
|
||||||
QScopedPointer<Surface> surface2(m_compositor->createSurface());
|
QScopedPointer<Surface> surface2(Test::createSurface());
|
||||||
QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data()));
|
QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data()));
|
||||||
Q_UNUSED(shellSurface2)
|
Q_UNUSED(shellSurface2)
|
||||||
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
|
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
|
||||||
plasmaSurface2->setPosition(windowGeometry2.topLeft());
|
plasmaSurface2->setPosition(windowGeometry2.topLeft());
|
||||||
plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel);
|
plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel);
|
||||||
|
|
||||||
QImage img2(windowGeometry2.size(), QImage::Format_RGB32);
|
Test::render(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32);
|
||||||
img2.fill(Qt::blue);
|
|
||||||
surface2->attachBuffer(m_shm->createBuffer(img2));
|
|
||||||
surface2->damage(QRect(QPoint(0, 0), windowGeometry2.size()));
|
|
||||||
surface2->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
QVERIFY(windowCreatedSpy.wait());
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
QCOMPARE(windowCreatedSpy.count(), 1);
|
QCOMPARE(windowCreatedSpy.count(), 1);
|
||||||
|
|
281
autotests/integration/test_helpers.cpp
Normal file
281
autotests/integration/test_helpers.cpp
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
/********************************************************************
|
||||||
|
KWin - the KDE window manager
|
||||||
|
This file is part of the KDE project.
|
||||||
|
|
||||||
|
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/
|
||||||
|
#include "kwin_wayland_test.h"
|
||||||
|
|
||||||
|
#include <KWayland/Client/compositor.h>
|
||||||
|
#include <KWayland/Client/connection_thread.h>
|
||||||
|
#include <KWayland/Client/event_queue.h>
|
||||||
|
#include <KWayland/Client/registry.h>
|
||||||
|
#include <KWayland/Client/plasmashell.h>
|
||||||
|
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||||
|
#include <KWayland/Client/seat.h>
|
||||||
|
#include <KWayland/Client/server_decoration.h>
|
||||||
|
#include <KWayland/Client/shell.h>
|
||||||
|
#include <KWayland/Client/shm_pool.h>
|
||||||
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
using namespace KWayland::Client;
|
||||||
|
|
||||||
|
namespace KWin
|
||||||
|
{
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
ConnectionThread *connection = nullptr;
|
||||||
|
EventQueue *queue = nullptr;
|
||||||
|
Compositor *compositor = nullptr;
|
||||||
|
ServerSideDecorationManager *decoration = nullptr;
|
||||||
|
Shell *shell = nullptr;
|
||||||
|
ShmPool *shm = nullptr;
|
||||||
|
Seat *seat = nullptr;
|
||||||
|
PlasmaShell *plasmaShell = nullptr;
|
||||||
|
PlasmaWindowManagement *windowManagement = nullptr;
|
||||||
|
QThread *thread = nullptr;
|
||||||
|
} s_waylandConnection;
|
||||||
|
|
||||||
|
bool setupWaylandConnection(const QString &socketName, AdditionalWaylandInterfaces flags)
|
||||||
|
{
|
||||||
|
if (s_waylandConnection.connection) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// setup connection
|
||||||
|
s_waylandConnection.connection = new ConnectionThread;
|
||||||
|
QSignalSpy connectedSpy(s_waylandConnection.connection, &ConnectionThread::connected);
|
||||||
|
if (!connectedSpy.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_waylandConnection.connection->setSocketName(socketName);
|
||||||
|
|
||||||
|
s_waylandConnection.thread = new QThread(kwinApp());
|
||||||
|
s_waylandConnection.connection->moveToThread(s_waylandConnection.thread);
|
||||||
|
s_waylandConnection.thread->start();
|
||||||
|
|
||||||
|
s_waylandConnection.connection->initConnection();
|
||||||
|
if (!connectedSpy.wait()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_waylandConnection.queue = new EventQueue;
|
||||||
|
s_waylandConnection.queue->setup(s_waylandConnection.connection);
|
||||||
|
if (!s_waylandConnection.queue->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry registry;
|
||||||
|
registry.setEventQueue(s_waylandConnection.queue);
|
||||||
|
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
||||||
|
if (!allAnnounced.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
registry.create(s_waylandConnection.connection);
|
||||||
|
if (!registry.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
registry.setup();
|
||||||
|
if (!allAnnounced.wait()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_waylandConnection.compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name, registry.interface(Registry::Interface::Compositor).version);
|
||||||
|
if (!s_waylandConnection.compositor->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_waylandConnection.shm = registry.createShmPool(registry.interface(Registry::Interface::Shm).name, registry.interface(Registry::Interface::Shm).version);
|
||||||
|
if (!s_waylandConnection.shm->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_waylandConnection.shell = registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version);
|
||||||
|
if (!s_waylandConnection.shell->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (flags.testFlag(AdditionalWaylandInterface::Seat)) {
|
||||||
|
s_waylandConnection.seat = registry.createSeat(registry.interface(Registry::Interface::Seat).name, registry.interface(Registry::Interface::Seat).version);
|
||||||
|
if (!s_waylandConnection.seat->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flags.testFlag(AdditionalWaylandInterface::Decoration)) {
|
||||||
|
s_waylandConnection.decoration = registry.createServerSideDecorationManager(registry.interface(Registry::Interface::ServerSideDecorationManager).name,
|
||||||
|
registry.interface(Registry::Interface::ServerSideDecorationManager).version);
|
||||||
|
if (!s_waylandConnection.decoration->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flags.testFlag(AdditionalWaylandInterface::PlasmaShell)) {
|
||||||
|
s_waylandConnection.plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name,
|
||||||
|
registry.interface(Registry::Interface::PlasmaShell).version);
|
||||||
|
if (!s_waylandConnection.plasmaShell->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flags.testFlag(AdditionalWaylandInterface::WindowManagement)) {
|
||||||
|
s_waylandConnection.windowManagement = registry.createPlasmaWindowManagement(registry.interface(Registry::Interface::PlasmaWindowManagement).name,
|
||||||
|
registry.interface(Registry::Interface::PlasmaWindowManagement).version);
|
||||||
|
if (!s_waylandConnection.windowManagement->isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyWaylandConnection()
|
||||||
|
{
|
||||||
|
delete s_waylandConnection.compositor;
|
||||||
|
s_waylandConnection.compositor = nullptr;
|
||||||
|
delete s_waylandConnection.windowManagement;
|
||||||
|
s_waylandConnection.windowManagement = nullptr;
|
||||||
|
delete s_waylandConnection.plasmaShell;
|
||||||
|
s_waylandConnection.plasmaShell = nullptr;
|
||||||
|
delete s_waylandConnection.decoration;
|
||||||
|
s_waylandConnection.decoration = nullptr;
|
||||||
|
delete s_waylandConnection.decoration;
|
||||||
|
s_waylandConnection.decoration = nullptr;
|
||||||
|
delete s_waylandConnection.seat;
|
||||||
|
s_waylandConnection.seat = nullptr;
|
||||||
|
delete s_waylandConnection.shell;
|
||||||
|
s_waylandConnection.shell = nullptr;
|
||||||
|
delete s_waylandConnection.shm;
|
||||||
|
s_waylandConnection.shm = nullptr;
|
||||||
|
delete s_waylandConnection.queue;
|
||||||
|
s_waylandConnection.queue = nullptr;
|
||||||
|
if (s_waylandConnection.thread) {
|
||||||
|
QSignalSpy spy(s_waylandConnection.connection, &QObject::destroyed);
|
||||||
|
s_waylandConnection.connection->deleteLater();
|
||||||
|
QVERIFY(spy.wait());
|
||||||
|
s_waylandConnection.thread->quit();
|
||||||
|
s_waylandConnection.thread->wait();
|
||||||
|
delete s_waylandConnection.thread;
|
||||||
|
s_waylandConnection.thread = nullptr;
|
||||||
|
s_waylandConnection.connection = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionThread *waylandConnection()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Compositor *waylandCompositor()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.compositor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shell *waylandShell()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.shell;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShmPool *waylandShmPool()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.shm;
|
||||||
|
}
|
||||||
|
|
||||||
|
Seat *waylandSeat()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.seat;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerSideDecorationManager *waylandServerSideDecoration()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.decoration;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaShell *waylandPlasmaShell()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.plasmaShell;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaWindowManagement *waylandWindowManagement()
|
||||||
|
{
|
||||||
|
return s_waylandConnection.windowManagement;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool waitForWaylandPointer()
|
||||||
|
{
|
||||||
|
if (!s_waylandConnection.seat) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QSignalSpy hasPointerSpy(s_waylandConnection.seat, &Seat::hasPointerChanged);
|
||||||
|
if (!hasPointerSpy.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return hasPointerSpy.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool waitForWaylandTouch()
|
||||||
|
{
|
||||||
|
if (!s_waylandConnection.seat) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QSignalSpy hasTouchSpy(s_waylandConnection.seat, &Seat::hasTouchChanged);
|
||||||
|
if (!hasTouchSpy.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return hasTouchSpy.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void render(Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format)
|
||||||
|
{
|
||||||
|
QImage img(size, format);
|
||||||
|
img.fill(color);
|
||||||
|
surface->attachBuffer(s_waylandConnection.shm->createBuffer(img));
|
||||||
|
surface->damage(QRect(QPoint(0, 0), size));
|
||||||
|
surface->commit(Surface::CommitFlag::None);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flushWaylandConnection()
|
||||||
|
{
|
||||||
|
if (s_waylandConnection.connection) {
|
||||||
|
s_waylandConnection.connection->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Surface *createSurface(QObject *parent)
|
||||||
|
{
|
||||||
|
if (!s_waylandConnection.compositor) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto s = s_waylandConnection.compositor->createSurface(parent);
|
||||||
|
if (!s->isValid()) {
|
||||||
|
delete s;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShellSurface *createShellSurface(Surface *surface, QObject *parent)
|
||||||
|
{
|
||||||
|
if (!s_waylandConnection.shell) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto s = s_waylandConnection.shell->createSurface(surface, parent);
|
||||||
|
if (!s->isValid()) {
|
||||||
|
delete s;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,11 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/seat.h>
|
#include <KWayland/Client/seat.h>
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
#include <KWayland/Client/touch.h>
|
#include <KWayland/Client/touch.h>
|
||||||
|
|
||||||
|
@ -53,14 +50,7 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractClient *showWindow();
|
AbstractClient *showWindow();
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::Touch *m_touch = nullptr;
|
KWayland::Client::Touch *m_touch = nullptr;
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TouchInputTest::initTestCase()
|
void TouchInputTest::initTestCase()
|
||||||
|
@ -84,57 +74,9 @@ void TouchInputTest::initTestCase()
|
||||||
void TouchInputTest::init()
|
void TouchInputTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
// setup connection
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat));
|
||||||
m_connection = new ConnectionThread;
|
QVERIFY(Test::waitForWaylandTouch());
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
m_touch = Test::waylandSeat()->createTouch(Test::waylandSeat());
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
QSignalSpy hasTouchSpy(m_seat, &Seat::hasTouchChanged);
|
|
||||||
QVERIFY(hasTouchSpy.isValid());
|
|
||||||
QVERIFY(hasTouchSpy.wait());
|
|
||||||
m_touch = m_seat->createTouch(m_seat);
|
|
||||||
QVERIFY(m_touch);
|
QVERIFY(m_touch);
|
||||||
QVERIFY(m_touch->isValid());
|
QVERIFY(m_touch->isValid());
|
||||||
|
|
||||||
|
@ -144,26 +86,9 @@ void TouchInputTest::init()
|
||||||
|
|
||||||
void TouchInputTest::cleanup()
|
void TouchInputTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_touch;
|
delete m_touch;
|
||||||
m_touch = nullptr;
|
m_touch = nullptr;
|
||||||
delete m_seat;
|
Test::destroyWaylandConnection();
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractClient *TouchInputTest::showWindow()
|
AbstractClient *TouchInputTest::showWindow()
|
||||||
|
@ -178,18 +103,14 @@ AbstractClient *TouchInputTest::showWindow()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
VERIFY(clientAddedSpy.isValid());
|
VERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||||
VERIFY(surface);
|
VERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
VERIFY(shellSurface);
|
VERIFY(shellSurface);
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface, QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
VERIFY(clientAddedSpy.wait());
|
VERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
VERIFY(c);
|
VERIFY(c);
|
||||||
|
|
|
@ -27,10 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <KWayland/Client/connection_thread.h>
|
#include <KWayland/Client/connection_thread.h>
|
||||||
#include <KWayland/Client/compositor.h>
|
#include <KWayland/Client/compositor.h>
|
||||||
#include <KWayland/Client/event_queue.h>
|
|
||||||
#include <KWayland/Client/registry.h>
|
|
||||||
#include <KWayland/Client/shell.h>
|
#include <KWayland/Client/shell.h>
|
||||||
#include <KWayland/Client/shm_pool.h>
|
|
||||||
#include <KWayland/Client/surface.h>
|
#include <KWayland/Client/surface.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
|
@ -46,14 +43,6 @@ private Q_SLOTS:
|
||||||
void init();
|
void init();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void testTransientNoFocus();
|
void testTransientNoFocus();
|
||||||
|
|
||||||
private:
|
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TransientNoInputTest::initTestCase()
|
void TransientNoInputTest::initTestCase()
|
||||||
|
@ -69,68 +58,12 @@ void TransientNoInputTest::initTestCase()
|
||||||
|
|
||||||
void TransientNoInputTest::init()
|
void TransientNoInputTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName));
|
||||||
// setup connection
|
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransientNoInputTest::cleanup()
|
void TransientNoInputTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_compositor;
|
Test::destroyWaylandConnection();
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransientNoInputTest::testTransientNoFocus()
|
void TransientNoInputTest::testTransientNoFocus()
|
||||||
|
@ -140,38 +73,30 @@ void TransientNoInputTest::testTransientNoFocus()
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
QVERIFY(clientAddedSpy.isValid());
|
QVERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
QScopedPointer<Surface> surface(m_compositor->createSurface());
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
QVERIFY(!surface.isNull());
|
QVERIFY(!surface.isNull());
|
||||||
|
|
||||||
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
|
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||||
QVERIFY(!shellSurface.isNull());
|
QVERIFY(!shellSurface.isNull());
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(QSize(100, 50), QImage::Format_ARGB32);
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(0, 0, 100, 50));
|
|
||||||
surface->commit();
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
QVERIFY(c);
|
QVERIFY(c);
|
||||||
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
QCOMPARE(clientAddedSpy.first().first().value<ShellClient*>(), c);
|
||||||
|
|
||||||
// let's create a transient with no input
|
// let's create a transient with no input
|
||||||
QScopedPointer<Surface> transientSurface(m_compositor->createSurface());
|
QScopedPointer<Surface> transientSurface(Test::createSurface());
|
||||||
QVERIFY(!transientSurface.isNull());
|
QVERIFY(!transientSurface.isNull());
|
||||||
QScopedPointer<ShellSurface> transientShellSurface(m_shell->createSurface(transientSurface.data()));
|
QScopedPointer<ShellSurface> transientShellSurface(Test::createShellSurface(transientSurface.data()));
|
||||||
QVERIFY(!transientShellSurface.isNull());
|
QVERIFY(!transientShellSurface.isNull());
|
||||||
transientShellSurface->setTransient(surface.data(), QPoint(10, 20), ShellSurface::TransientFlag::NoFocus);
|
transientShellSurface->setTransient(surface.data(), QPoint(10, 20), ShellSurface::TransientFlag::NoFocus);
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
// let's render
|
// let's render
|
||||||
QImage img2(QSize(200, 20), QImage::Format_ARGB32);
|
Test::render(transientSurface.data(), QSize(200, 20), Qt::red);
|
||||||
img2.fill(Qt::red);
|
Test::flushWaylandConnection();
|
||||||
transientSurface->attachBuffer(m_shm->createBuffer(img2));
|
|
||||||
transientSurface->damage(QRect(0, 0, 200, 20));
|
|
||||||
transientSurface->commit();
|
|
||||||
m_connection->flush();
|
|
||||||
QVERIFY(clientAddedSpy.wait());
|
QVERIFY(clientAddedSpy.wait());
|
||||||
// get the latest ShellClient
|
// get the latest ShellClient
|
||||||
auto transientClient = clientAddedSpy.last().first().value<ShellClient*>();
|
auto transientClient = clientAddedSpy.last().first().value<ShellClient*>();
|
||||||
|
|
|
@ -63,14 +63,6 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
AbstractClient *showWindow(const QSize &size, bool decorated = false, KWayland::Client::Surface *parent = nullptr, const QPoint &offset = QPoint());
|
AbstractClient *showWindow(const QSize &size, bool decorated = false, KWayland::Client::Surface *parent = nullptr, const QPoint &offset = QPoint());
|
||||||
KWayland::Client::Surface *surfaceForClient(AbstractClient *c) const;
|
KWayland::Client::Surface *surfaceForClient(AbstractClient *c) const;
|
||||||
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
||||||
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
||||||
KWayland::Client::ServerSideDecorationManager *m_deco = nullptr;
|
|
||||||
KWayland::Client::Seat *m_seat = nullptr;
|
|
||||||
KWayland::Client::ShmPool *m_shm = nullptr;
|
|
||||||
KWayland::Client::Shell *m_shell = nullptr;
|
|
||||||
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
||||||
QThread *m_thread = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TransientPlacementTest::initTestCase()
|
void TransientPlacementTest::initTestCase()
|
||||||
|
@ -94,60 +86,7 @@ void TransientPlacementTest::initTestCase()
|
||||||
|
|
||||||
void TransientPlacementTest::init()
|
void TransientPlacementTest::init()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Decoration));
|
||||||
// setup connection
|
|
||||||
m_connection = new ConnectionThread;
|
|
||||||
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
|
|
||||||
QVERIFY(connectedSpy.isValid());
|
|
||||||
m_connection->setSocketName(s_socketName);
|
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_connection->moveToThread(m_thread);
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
m_connection->initConnection();
|
|
||||||
QVERIFY(connectedSpy.wait());
|
|
||||||
|
|
||||||
m_queue = new EventQueue(this);
|
|
||||||
QVERIFY(!m_queue->isValid());
|
|
||||||
m_queue->setup(m_connection);
|
|
||||||
QVERIFY(m_queue->isValid());
|
|
||||||
|
|
||||||
Registry registry;
|
|
||||||
registry.setEventQueue(m_queue);
|
|
||||||
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
|
|
||||||
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
|
|
||||||
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
|
|
||||||
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
|
|
||||||
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
|
|
||||||
QVERIFY(allAnnounced.isValid());
|
|
||||||
QVERIFY(shmSpy.isValid());
|
|
||||||
QVERIFY(shellSpy.isValid());
|
|
||||||
QVERIFY(compositorSpy.isValid());
|
|
||||||
QVERIFY(seatSpy.isValid());
|
|
||||||
registry.create(m_connection->display());
|
|
||||||
QVERIFY(registry.isValid());
|
|
||||||
registry.setup();
|
|
||||||
QVERIFY(allAnnounced.wait());
|
|
||||||
QVERIFY(!compositorSpy.isEmpty());
|
|
||||||
QVERIFY(!shmSpy.isEmpty());
|
|
||||||
QVERIFY(!shellSpy.isEmpty());
|
|
||||||
QVERIFY(!seatSpy.isEmpty());
|
|
||||||
|
|
||||||
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_compositor->isValid());
|
|
||||||
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shm->isValid());
|
|
||||||
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_shell->isValid());
|
|
||||||
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
|
||||||
QVERIFY(m_seat->isValid());
|
|
||||||
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
|
|
||||||
QVERIFY(hasPointerSpy.isValid());
|
|
||||||
QVERIFY(hasPointerSpy.wait());
|
|
||||||
|
|
||||||
m_deco = registry.createServerSideDecorationManager(registry.interface(Registry::Interface::ServerSideDecorationManager).name, registry.interface(Registry::Interface::ServerSideDecorationManager).version, this);
|
|
||||||
QVERIFY(m_deco->isValid());
|
|
||||||
|
|
||||||
screens()->setCurrent(0);
|
screens()->setCurrent(0);
|
||||||
Cursor::setPos(QPoint(640, 512));
|
Cursor::setPos(QPoint(640, 512));
|
||||||
|
@ -155,26 +94,7 @@ void TransientPlacementTest::init()
|
||||||
|
|
||||||
void TransientPlacementTest::cleanup()
|
void TransientPlacementTest::cleanup()
|
||||||
{
|
{
|
||||||
delete m_deco;
|
Test::destroyWaylandConnection();
|
||||||
m_deco = nullptr;
|
|
||||||
delete m_compositor;
|
|
||||||
m_compositor = nullptr;
|
|
||||||
delete m_seat;
|
|
||||||
m_seat = nullptr;
|
|
||||||
delete m_shm;
|
|
||||||
m_shm = nullptr;
|
|
||||||
delete m_shell;
|
|
||||||
m_shell = nullptr;
|
|
||||||
delete m_queue;
|
|
||||||
m_queue = nullptr;
|
|
||||||
if (m_thread) {
|
|
||||||
m_connection->deleteLater();
|
|
||||||
m_thread->quit();
|
|
||||||
m_thread->wait();
|
|
||||||
delete m_thread;
|
|
||||||
m_thread = nullptr;
|
|
||||||
m_connection = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decorated, KWayland::Client::Surface *parent, const QPoint &offset)
|
AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decorated, KWayland::Client::Surface *parent, const QPoint &offset)
|
||||||
|
@ -189,15 +109,15 @@ AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decor
|
||||||
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
|
||||||
VERIFY(clientAddedSpy.isValid());
|
VERIFY(clientAddedSpy.isValid());
|
||||||
|
|
||||||
Surface *surface = m_compositor->createSurface(m_compositor);
|
Surface *surface = Test::createSurface(Test::waylandCompositor());
|
||||||
VERIFY(surface);
|
VERIFY(surface);
|
||||||
ShellSurface *shellSurface = m_shell->createSurface(surface, surface);
|
ShellSurface *shellSurface = Test::createShellSurface(surface, surface);
|
||||||
VERIFY(shellSurface);
|
VERIFY(shellSurface);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
shellSurface->setTransient(parent, offset);
|
shellSurface->setTransient(parent, offset);
|
||||||
}
|
}
|
||||||
if (decorated) {
|
if (decorated) {
|
||||||
auto deco = m_deco->create(surface, surface);
|
auto deco = Test::waylandServerSideDecoration()->create(surface, surface);
|
||||||
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
|
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
|
||||||
VERIFY(decoSpy.isValid());
|
VERIFY(decoSpy.isValid());
|
||||||
VERIFY(decoSpy.wait());
|
VERIFY(decoSpy.wait());
|
||||||
|
@ -206,13 +126,9 @@ AbstractClient *TransientPlacementTest::showWindow(const QSize &size, bool decor
|
||||||
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
|
||||||
}
|
}
|
||||||
// let's render
|
// let's render
|
||||||
QImage img(size, QImage::Format_ARGB32);
|
Test::render(surface, size, Qt::blue);
|
||||||
img.fill(Qt::blue);
|
|
||||||
surface->attachBuffer(m_shm->createBuffer(img));
|
|
||||||
surface->damage(QRect(QPoint(0, 0), size));
|
|
||||||
surface->commit(Surface::CommitFlag::None);
|
|
||||||
|
|
||||||
m_connection->flush();
|
Test::flushWaylandConnection();
|
||||||
VERIFY(clientAddedSpy.wait());
|
VERIFY(clientAddedSpy.wait());
|
||||||
AbstractClient *c = workspace()->activeClient();
|
AbstractClient *c = workspace()->activeClient();
|
||||||
VERIFY(c);
|
VERIFY(c);
|
||||||
|
|
Loading…
Reference in a new issue