Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_server_side_decoration.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 38 | private Q_SLOTS: | |||
---|---|---|---|---|---|
42 | void testCreate_data(); | 42 | void testCreate_data(); | ||
43 | void testCreate(); | 43 | void testCreate(); | ||
44 | 44 | | |||
45 | void testRequest_data(); | 45 | void testRequest_data(); | ||
46 | void testRequest(); | 46 | void testRequest(); | ||
47 | 47 | | |||
48 | void testSurfaceDestroy(); | 48 | void testSurfaceDestroy(); | ||
49 | 49 | | |||
50 | void testPalette_data(); | ||||
51 | void testPalette(); | ||||
52 | | ||||
50 | private: | 53 | private: | ||
51 | KWayland::Server::Display *m_display = nullptr; | 54 | KWayland::Server::Display *m_display = nullptr; | ||
52 | KWayland::Server::CompositorInterface *m_compositorInterface = nullptr; | 55 | KWayland::Server::CompositorInterface *m_compositorInterface = nullptr; | ||
53 | KWayland::Server::ServerSideDecorationManagerInterface *m_serverSideDecorationManagerInterface = nullptr; | 56 | KWayland::Server::ServerSideDecorationManagerInterface *m_serverSideDecorationManagerInterface = nullptr; | ||
54 | KWayland::Client::ConnectionThread *m_connection = nullptr; | 57 | KWayland::Client::ConnectionThread *m_connection = nullptr; | ||
55 | KWayland::Client::Compositor *m_compositor = nullptr; | 58 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
56 | KWayland::Client::EventQueue *m_queue = nullptr; | 59 | KWayland::Client::EventQueue *m_queue = nullptr; | ||
57 | KWayland::Client::ServerSideDecorationManager *m_serverSideDecorationManager = nullptr; | 60 | KWayland::Client::ServerSideDecorationManager *m_serverSideDecorationManager = nullptr; | ||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Line(s) | 299 | { | |||
319 | surface.reset(); | 322 | surface.reset(); | ||
320 | QVERIFY(surfaceDestroyedSpy.wait()); | 323 | QVERIFY(surfaceDestroyedSpy.wait()); | ||
321 | QVERIFY(decorationDestroyedSpy.isEmpty()); | 324 | QVERIFY(decorationDestroyedSpy.isEmpty()); | ||
322 | // destroy the blur | 325 | // destroy the blur | ||
323 | serverSideDecoration.reset(); | 326 | serverSideDecoration.reset(); | ||
324 | QVERIFY(decorationDestroyedSpy.wait()); | 327 | QVERIFY(decorationDestroyedSpy.wait()); | ||
325 | } | 328 | } | ||
326 | 329 | | |||
330 | void TestServerSideDecoration::testPalette_data() | ||||
331 | { | ||||
332 | QTest::addColumn<QString>("paletteName"); | ||||
333 | QTest::newRow("blank") << QString(); | ||||
334 | QTest::newRow("name") << QString("foobar"); | ||||
335 | QTest::newRow("path") << QString("/usr/share/foobar"); | ||||
336 | } | ||||
337 | | ||||
338 | void TestServerSideDecoration::testPalette() | ||||
339 | { | ||||
340 | using namespace KWayland::Client; | ||||
341 | using namespace KWayland::Server; | ||||
342 | QSignalSpy serverSurfaceCreated(m_compositorInterface, &CompositorInterface::surfaceCreated); | ||||
343 | QSignalSpy decorationCreated(m_serverSideDecorationManagerInterface, &ServerSideDecorationManagerInterface::decorationCreated); | ||||
344 | | ||||
345 | QScopedPointer<KWayland::Client::Surface> surface(m_compositor->createSurface()); | ||||
346 | QVERIFY(serverSurfaceCreated.wait()); | ||||
347 | | ||||
348 | auto serverSurface = serverSurfaceCreated.first().first().value<SurfaceInterface*>(); | ||||
349 | QScopedPointer<ServerSideDecoration> serverSideDecoration(m_serverSideDecorationManager->create(surface.data())); | ||||
350 | QCOMPARE(serverSideDecoration->mode(), ServerSideDecoration::Mode::None); | ||||
351 | QVERIFY(decorationCreated.wait()); | ||||
352 | auto serverDeco = decorationCreated.first().first().value<ServerSideDecorationInterface*>(); | ||||
353 | QVERIFY(serverDeco); | ||||
354 | | ||||
355 | QFETCH(QString, paletteName); | ||||
356 | | ||||
357 | QSignalSpy paletteChanged(serverDeco, &KWayland::Server::ServerSideDecorationInterface::paletteChanged); | ||||
358 | QVERIFY(serverDeco->palette().isEmpty()); | ||||
359 | | ||||
360 | //client sets a new palette | ||||
361 | serverSideDecoration->setPalette(paletteName); | ||||
362 | | ||||
363 | if (paletteName.isEmpty()) { | ||||
364 | //no-change == no emit | ||||
365 | QVERIFY(!paletteChanged.wait()); | ||||
366 | } else { | ||||
367 | QVERIFY(paletteChanged.wait()); | ||||
368 | } | ||||
369 | | ||||
370 | QCOMPARE(serverDeco->palette(), paletteName); | ||||
371 | } | ||||
372 | | ||||
373 | | ||||
327 | QTEST_GUILESS_MAIN(TestServerSideDecoration) | 374 | QTEST_GUILESS_MAIN(TestServerSideDecoration) | ||
328 | #include "test_server_side_decoration.moc" | 375 | #include "test_server_side_decoration.moc" |