Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_subsurface.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 44 | private Q_SLOTS: | |||
---|---|---|---|---|---|
49 | void testMode(); | 49 | void testMode(); | ||
50 | void testPosition(); | 50 | void testPosition(); | ||
51 | void testPlaceAbove(); | 51 | void testPlaceAbove(); | ||
52 | void testPlaceBelow(); | 52 | void testPlaceBelow(); | ||
53 | void testDestroy(); | 53 | void testDestroy(); | ||
54 | void testCast(); | 54 | void testCast(); | ||
55 | void testSyncMode(); | 55 | void testSyncMode(); | ||
56 | void testDeSyncMode(); | 56 | void testDeSyncMode(); | ||
57 | void testMainSurfaceFromTree(); | ||||
57 | 58 | | |||
58 | private: | 59 | private: | ||
59 | KWayland::Server::Display *m_display; | 60 | KWayland::Server::Display *m_display; | ||
60 | KWayland::Server::CompositorInterface *m_compositorInterface; | 61 | KWayland::Server::CompositorInterface *m_compositorInterface; | ||
61 | KWayland::Server::SubCompositorInterface *m_subcompositorInterface; | 62 | KWayland::Server::SubCompositorInterface *m_subcompositorInterface; | ||
62 | KWayland::Client::ConnectionThread *m_connection; | 63 | KWayland::Client::ConnectionThread *m_connection; | ||
63 | KWayland::Client::Compositor *m_compositor; | 64 | KWayland::Client::Compositor *m_compositor; | ||
64 | KWayland::Client::ShmPool *m_shm; | 65 | KWayland::Client::ShmPool *m_shm; | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 179 | { | |||
201 | 202 | | |||
202 | QVERIFY(subSurfaceCreatedSpy.wait()); | 203 | QVERIFY(subSurfaceCreatedSpy.wait()); | ||
203 | SubSurfaceInterface *serverSubSurface = subSurfaceCreatedSpy.first().first().value<KWayland::Server::SubSurfaceInterface*>(); | 204 | SubSurfaceInterface *serverSubSurface = subSurfaceCreatedSpy.first().first().value<KWayland::Server::SubSurfaceInterface*>(); | ||
204 | QVERIFY(serverSubSurface); | 205 | QVERIFY(serverSubSurface); | ||
205 | QVERIFY(serverSubSurface->parentSurface()); | 206 | QVERIFY(serverSubSurface->parentSurface()); | ||
206 | QCOMPARE(serverSubSurface->parentSurface().data(), serverParentSurface); | 207 | QCOMPARE(serverSubSurface->parentSurface().data(), serverParentSurface); | ||
207 | QCOMPARE(serverSubSurface->surface().data(), serverSurface); | 208 | QCOMPARE(serverSubSurface->surface().data(), serverSurface); | ||
208 | QCOMPARE(serverSurface->subSurface().data(), serverSubSurface); | 209 | QCOMPARE(serverSurface->subSurface().data(), serverSubSurface); | ||
210 | QCOMPARE(serverSubSurface->mainSurface().data(), serverParentSurface); | ||||
209 | // children are only added after committing the surface | 211 | // children are only added after committing the surface | ||
210 | QEXPECT_FAIL("", "Incorrect adding of child windows to workaround QtWayland behavior", Continue); | 212 | QEXPECT_FAIL("", "Incorrect adding of child windows to workaround QtWayland behavior", Continue); | ||
211 | QCOMPARE(serverParentSurface->childSubSurfaces().count(), 0); | 213 | QCOMPARE(serverParentSurface->childSubSurfaces().count(), 0); | ||
212 | // so let's commit the surface, to apply the stacking change | 214 | // so let's commit the surface, to apply the stacking change | ||
213 | parent->commit(Surface::CommitFlag::None); | 215 | parent->commit(Surface::CommitFlag::None); | ||
214 | wl_display_flush(m_connection->display()); | 216 | wl_display_flush(m_connection->display()); | ||
215 | QCoreApplication::processEvents(); | 217 | QCoreApplication::processEvents(); | ||
216 | QCOMPARE(serverParentSurface->childSubSurfaces().count(), 1); | 218 | QCOMPARE(serverParentSurface->childSubSurfaces().count(), 1); | ||
▲ Show 20 Lines • Show All 473 Lines • ▼ Show 20 Line(s) | 647 | { | |||
690 | surface->attachBuffer(m_shm->createBuffer(image)); | 692 | surface->attachBuffer(m_shm->createBuffer(image)); | ||
691 | surface->damage(QRect(0, 0, 200, 200)); | 693 | surface->damage(QRect(0, 0, 200, 200)); | ||
692 | surface->commit(Surface::CommitFlag::None); | 694 | surface->commit(Surface::CommitFlag::None); | ||
693 | QVERIFY(childDamagedSpy.wait()); | 695 | QVERIFY(childDamagedSpy.wait()); | ||
694 | QCOMPARE(subSurfaceTreeChangedSpy.count(), 3); | 696 | QCOMPARE(subSurfaceTreeChangedSpy.count(), 3); | ||
695 | QCOMPARE(childSurface->buffer()->data(), image); | 697 | QCOMPARE(childSurface->buffer()->data(), image); | ||
696 | } | 698 | } | ||
697 | 699 | | |||
700 | | ||||
701 | void TestSubSurface::testMainSurfaceFromTree() | ||||
702 | { | ||||
703 | // this test verifies that in a tree of surfaces every surface has the same main surface | ||||
704 | using namespace KWayland::Client; | ||||
705 | using namespace KWayland::Server; | ||||
706 | QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated); | ||||
707 | QVERIFY(surfaceCreatedSpy.isValid()); | ||||
708 | | ||||
709 | QScopedPointer<Surface> parentSurface(m_compositor->createSurface()); | ||||
710 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
711 | auto parentServerSurface = surfaceCreatedSpy.last().first().value<SurfaceInterface*>(); | ||||
712 | QVERIFY(parentServerSurface); | ||||
713 | QScopedPointer<Surface> childLevel1Surface(m_compositor->createSurface()); | ||||
714 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
715 | auto childLevel1ServerSurface = surfaceCreatedSpy.last().first().value<SurfaceInterface*>(); | ||||
716 | QVERIFY(childLevel1ServerSurface); | ||||
717 | QScopedPointer<Surface> childLevel2Surface(m_compositor->createSurface()); | ||||
718 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
719 | auto childLevel2ServerSurface = surfaceCreatedSpy.last().first().value<SurfaceInterface*>(); | ||||
720 | QVERIFY(childLevel2ServerSurface); | ||||
721 | QScopedPointer<Surface> childLevel3Surface(m_compositor->createSurface()); | ||||
722 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
723 | auto childLevel3ServerSurface = surfaceCreatedSpy.last().first().value<SurfaceInterface*>(); | ||||
724 | QVERIFY(childLevel3ServerSurface); | ||||
725 | | ||||
726 | QSignalSpy subSurfaceTreeChangedSpy(parentServerSurface, &SurfaceInterface::subSurfaceTreeChanged); | ||||
727 | QVERIFY(subSurfaceTreeChangedSpy.isValid()); | ||||
728 | | ||||
729 | m_subCompositor->createSubSurface(childLevel1Surface.data(), parentSurface.data()); | ||||
730 | m_subCompositor->createSubSurface(childLevel2Surface.data(), childLevel1Surface.data()); | ||||
731 | m_subCompositor->createSubSurface(childLevel3Surface.data(), childLevel2Surface.data()); | ||||
732 | | ||||
733 | parentSurface->commit(Surface::CommitFlag::None); | ||||
734 | QVERIFY(subSurfaceTreeChangedSpy.wait()); | ||||
735 | | ||||
736 | QCOMPARE(parentServerSurface->childSubSurfaces().count(), 1); | ||||
737 | auto child = parentServerSurface->childSubSurfaces().first(); | ||||
738 | QCOMPARE(child->parentSurface().data(), parentServerSurface); | ||||
739 | QCOMPARE(child->mainSurface().data(), parentServerSurface); | ||||
740 | QCOMPARE(child->surface()->childSubSurfaces().count(), 1); | ||||
741 | auto child2 = child->surface()->childSubSurfaces().first(); | ||||
742 | QCOMPARE(child2->parentSurface().data(), child->surface().data()); | ||||
743 | QCOMPARE(child2->mainSurface().data(), parentServerSurface); | ||||
744 | QCOMPARE(child2->surface()->childSubSurfaces().count(), 1); | ||||
745 | auto child3 = child2->surface()->childSubSurfaces().first(); | ||||
746 | QCOMPARE(child3->parentSurface().data(), child2->surface().data()); | ||||
747 | QCOMPARE(child3->mainSurface().data(), parentServerSurface); | ||||
748 | QCOMPARE(child3->surface()->childSubSurfaces().count(), 0); | ||||
749 | } | ||||
750 | | ||||
698 | QTEST_GUILESS_MAIN(TestSubSurface) | 751 | QTEST_GUILESS_MAIN(TestSubSurface) | ||
699 | #include "test_wayland_subsurface.moc" | 752 | #include "test_wayland_subsurface.moc" |