Directory: | ./ |
---|---|
File: | autotests/client/shadow.cpp |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 196 | 196 | 100.0% |
Branches: | 358 | 714 | 50.1% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /******************************************************************** | ||
2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||
8 | later version accepted by the membership of KDE e.V. (or its | ||
9 | successor approved by the membership of KDE e.V.), which shall | ||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | |||
12 | This library is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Lesser General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | ||
20 | #include <QtTest> | ||
21 | |||
22 | #include "../../src/client/compositor.h" | ||
23 | #include "../../src/client/connection_thread.h" | ||
24 | #include "../../src/client/event_queue.h" | ||
25 | #include "../../src/client/registry.h" | ||
26 | #include "../../src/client/shadow.h" | ||
27 | #include "../../src/client/shm_pool.h" | ||
28 | #include "../../src/client/surface.h" | ||
29 | |||
30 | #include "../../server/buffer.h" | ||
31 | #include "../../server/client.h" | ||
32 | #include "../../server/compositor.h" | ||
33 | #include "../../server/display.h" | ||
34 | #include "../../server/shadow.h" | ||
35 | #include "../../server/surface.h" | ||
36 | |||
37 | #include "../../tests/globals.h" | ||
38 | |||
39 | 1 | class ShadowTest : public QObject | |
40 | { | ||
41 | Q_OBJECT | ||
42 | private Q_SLOTS: | ||
43 | void init(); | ||
44 | void cleanup(); | ||
45 | |||
46 | void testCreateShadow(); | ||
47 | void testShadowElements(); | ||
48 | void testSurfaceDestroy(); | ||
49 | |||
50 | private: | ||
51 | 1 | struct { | |
52 | std::unique_ptr<Wrapland::Server::Display> display; | ||
53 | Wrapland::Server::globals globals; | ||
54 | } server; | ||
55 | |||
56 | 1 | Wrapland::Client::ConnectionThread* m_connection = nullptr; | |
57 | 1 | QThread* m_thread = nullptr; | |
58 | 1 | Wrapland::Client::EventQueue* m_queue = nullptr; | |
59 | 1 | Wrapland::Client::ShmPool* m_shm = nullptr; | |
60 | 1 | Wrapland::Client::Compositor* m_compositor = nullptr; | |
61 | 1 | Wrapland::Client::ShadowManager* m_shadow = nullptr; | |
62 | }; | ||
63 | |||
64 | constexpr auto socket_name{"wrapland-test-shadow-0"}; | ||
65 | |||
66 | 3 | void ShadowTest::init() | |
67 | { | ||
68 | 3 | qRegisterMetaType<Wrapland::Server::Surface*>(); | |
69 | |||
70 | 3 | server.display = std::make_unique<Wrapland::Server::Display>(); | |
71 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | server.display->set_socket_name(socket_name); |
72 | 3 | server.display->start(); | |
73 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | QVERIFY(server.display->running()); |
74 | |||
75 | 3 | server.display->createShm(); | |
76 | 6 | server.globals.compositor | |
77 | 6 | = std::make_unique<Wrapland::Server::Compositor>(server.display.get()); | |
78 | 6 | server.globals.shadow_manager | |
79 | 6 | = std::make_unique<Wrapland::Server::ShadowManager>(server.display.get()); | |
80 | |||
81 | // setup connection | ||
82 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_connection = new Wrapland::Client::ConnectionThread; |
83 | 3 | QSignalSpy connectedSpy(m_connection, &Wrapland::Client::ConnectionThread::establishedChanged); | |
84 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(connectedSpy.isValid()); |
85 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | m_connection->setSocketName(socket_name); |
86 | |||
87 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | m_thread = new QThread(this); |
88 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_connection->moveToThread(m_thread); |
89 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_thread->start(); |
90 | |||
91 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_connection->establishConnection(); |
92 |
6/12✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
|
3 | QVERIFY(connectedSpy.count() || connectedSpy.wait()); |
93 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | QCOMPARE(connectedSpy.count(), 1); |
94 | |||
95 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | m_queue = new Wrapland::Client::EventQueue(this); |
96 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_queue->setup(m_connection); |
97 | |||
98 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | Wrapland::Client::Registry registry; |
99 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | QSignalSpy interfacesAnnouncedSpy(®istry, &Wrapland::Client::Registry::interfacesAnnounced); |
100 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(interfacesAnnouncedSpy.isValid()); |
101 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.setEventQueue(m_queue); |
102 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.create(m_connection); |
103 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(registry.isValid()); |
104 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.setup(); |
105 |
5/10✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
|
3 | QVERIFY(interfacesAnnouncedSpy.wait()); |
106 | |||
107 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_shm = registry.createShmPool( |
108 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Shm).name, |
109 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Shm).version, |
110 | this); | ||
111 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(m_shm->isValid()); |
112 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_compositor = registry.createCompositor( |
113 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Compositor).name, |
114 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Compositor).version, |
115 | this); | ||
116 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(m_compositor->isValid()); |
117 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | m_shadow = registry.createShadowManager( |
118 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Shadow).name, |
119 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | registry.interface(Wrapland::Client::Registry::Interface::Shadow).version, |
120 | this); | ||
121 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | QVERIFY(m_shadow->isValid()); |
122 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | } |
123 | |||
124 | 3 | void ShadowTest::cleanup() | |
125 | { | ||
126 | #define CLEANUP(variable) \ | ||
127 | if (variable) { \ | ||
128 | delete variable; \ | ||
129 | variable = nullptr; \ | ||
130 | } | ||
131 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
3 | CLEANUP(m_shm) |
132 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | CLEANUP(m_compositor) |
133 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | CLEANUP(m_shadow) |
134 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | CLEANUP(m_queue) |
135 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (m_connection) { |
136 | 3 | m_connection->deleteLater(); | |
137 | 3 | m_connection = nullptr; | |
138 | 3 | } | |
139 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (m_thread) { |
140 | 3 | m_thread->quit(); | |
141 | 3 | m_thread->wait(); | |
142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | delete m_thread; |
143 | 3 | m_thread = nullptr; | |
144 | 3 | } | |
145 | #undef CLEANUP | ||
146 | |||
147 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | server = {}; |
148 | 3 | } | |
149 | |||
150 | 1 | void ShadowTest::testCreateShadow() | |
151 | { | ||
152 | // this test verifies the basic shadow behavior, create for surface, commit it, etc. | ||
153 | 1 | QSignalSpy serverSurfaceCreated(server.globals.compositor.get(), | |
154 | &Wrapland::Server::Compositor::surfaceCreated); | ||
155 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(serverSurfaceCreated.isValid()); |
156 | |||
157 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Surface> surface{m_compositor->createSurface()}; |
158 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(serverSurfaceCreated.wait()); |
159 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | auto serverSurface = serverSurfaceCreated.first().first().value<Wrapland::Server::Surface*>(); |
160 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverSurface); |
161 | |||
162 | // a surface without anything should not have a Shadow | ||
163 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(!serverSurface->state().shadow); |
164 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QSignalSpy commit_spy(serverSurface, &Wrapland::Server::Surface::committed); |
165 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(commit_spy.isValid()); |
166 | |||
167 | // let's create a shadow for the Surface | ||
168 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Shadow> shadow(m_shadow->createShadow(surface.get())); |
169 | // that should not have triggered the commit_spy) | ||
170 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(!commit_spy.wait(100)); |
171 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QCOMPARE(serverSurface->state().updates, Wrapland::Server::surface_change::none); |
172 | |||
173 | // now let's commit the surface, that should trigger the shadow changed | ||
174 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | surface->commit(Wrapland::Client::Surface::CommitFlag::None); |
175 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(commit_spy.wait()); |
176 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | QCOMPARE(commit_spy.count(), 1); |
177 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(serverSurface->state().updates & Wrapland::Server::surface_change::shadow); |
178 | |||
179 | // we didn't set anything on the shadow, so it should be all default values | ||
180 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto serverShadow = serverSurface->state().shadow; |
181 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverShadow); |
182 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QCOMPARE(serverShadow->offset(), QMarginsF()); |
183 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->topLeft()); |
184 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->top()); |
185 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->topRight()); |
186 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->right()); |
187 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottomRight()); |
188 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottom()); |
189 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottomLeft()); |
190 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->left()); |
191 | |||
192 | // now let's remove the shadow | ||
193 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | m_shadow->removeShadow(surface.get()); |
194 | |||
195 | // just removing should not remove it yet, surface needs to be committed | ||
196 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(!commit_spy.wait(100)); |
197 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | surface->commit(Wrapland::Client::Surface::CommitFlag::None); |
198 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(commit_spy.wait()); |
199 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | QCOMPARE(commit_spy.count(), 2); |
200 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(!serverSurface->state().shadow); |
201 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | } |
202 | |||
203 | 1 | void ShadowTest::testShadowElements() | |
204 | { | ||
205 | |||
206 | // this test verifies that all shadow elements are correctly passed to the server | ||
207 | // first create surface | ||
208 | 1 | QSignalSpy serverSurfaceCreated(server.globals.compositor.get(), | |
209 | &Wrapland::Server::Compositor::surfaceCreated); | ||
210 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(serverSurfaceCreated.isValid()); |
211 | |||
212 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Surface> surface{m_compositor->createSurface()}; |
213 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(serverSurfaceCreated.wait()); |
214 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | auto serverSurface = serverSurfaceCreated.first().first().value<Wrapland::Server::Surface*>(); |
215 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverSurface); |
216 | |||
217 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QSignalSpy commit_spy(serverSurface, &Wrapland::Server::Surface::committed); |
218 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(commit_spy.isValid()); |
219 | |||
220 | // now create the shadow | ||
221 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Shadow> shadow(m_shadow->createShadow(surface.get())); |
222 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage topLeftImage(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); |
223 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | topLeftImage.fill(Qt::white); |
224 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachTopLeft(m_shm->createBuffer(topLeftImage)); |
225 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage topImage(QSize(11, 11), QImage::Format_ARGB32_Premultiplied); |
226 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | topImage.fill(Qt::black); |
227 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachTop(m_shm->createBuffer(topImage)); |
228 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage topRightImage(QSize(12, 12), QImage::Format_ARGB32_Premultiplied); |
229 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | topRightImage.fill(Qt::red); |
230 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachTopRight(m_shm->createBuffer(topRightImage)); |
231 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage rightImage(QSize(13, 13), QImage::Format_ARGB32_Premultiplied); |
232 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | rightImage.fill(Qt::darkRed); |
233 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachRight(m_shm->createBuffer(rightImage)); |
234 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage bottomRightImage(QSize(14, 14), QImage::Format_ARGB32_Premultiplied); |
235 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | bottomRightImage.fill(Qt::green); |
236 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachBottomRight(m_shm->createBuffer(bottomRightImage)); |
237 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage bottomImage(QSize(15, 15), QImage::Format_ARGB32_Premultiplied); |
238 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | bottomImage.fill(Qt::darkGreen); |
239 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachBottom(m_shm->createBuffer(bottomImage)); |
240 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage bottomLeftImage(QSize(16, 16), QImage::Format_ARGB32_Premultiplied); |
241 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | bottomLeftImage.fill(Qt::blue); |
242 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachBottomLeft(m_shm->createBuffer(bottomLeftImage)); |
243 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QImage leftImage(QSize(17, 17), QImage::Format_ARGB32_Premultiplied); |
244 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | leftImage.fill(Qt::darkBlue); |
245 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachLeft(m_shm->createBuffer(leftImage)); |
246 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | shadow->setOffsets(QMarginsF(1, 2, 3, 4)); |
247 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | shadow->commit(); |
248 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | surface->commit(Wrapland::Client::Surface::CommitFlag::None); |
249 | |||
250 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(commit_spy.wait()); |
251 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto serverShadow = serverSurface->state().shadow; |
252 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverShadow); |
253 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QCOMPARE(serverShadow->offset(), QMarginsF(1, 2, 3, 4)); |
254 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->topLeft()->shmImage()->createQImage(), topLeftImage); |
255 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->top()->shmImage()->createQImage(), topImage); |
256 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->topRight()->shmImage()->createQImage(), topRightImage); |
257 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->right()->shmImage()->createQImage(), rightImage); |
258 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->bottomRight()->shmImage()->createQImage(), bottomRightImage); |
259 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->bottom()->shmImage()->createQImage(), bottomImage); |
260 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->bottomLeft()->shmImage()->createQImage(), bottomLeftImage); |
261 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QCOMPARE(serverShadow->left()->shmImage()->createQImage(), leftImage); |
262 | |||
263 | // try to destroy the buffer | ||
264 | // first attach one buffer | ||
265 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | shadow->attachTopLeft(m_shm->createBuffer(topLeftImage)); |
266 | |||
267 | // We need to reference the shared_ptr buffer to guarantee receiving the destroyed signal. | ||
268 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto buf = serverShadow->topLeft(); |
269 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QSignalSpy destroyedSpy(serverShadow->topLeft().get(), |
270 | &Wrapland::Server::Buffer::resourceDestroyed); | ||
271 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(destroyedSpy.isValid()); |
272 | |||
273 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | delete m_shm; |
274 | 1 | m_shm = nullptr; | |
275 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(destroyedSpy.wait()); |
276 | |||
277 | // now all buffers should be gone | ||
278 | // TODO: does that need a signal? | ||
279 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->topLeft()); |
280 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->top()); |
281 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->topRight()); |
282 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->right()); |
283 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottomRight()); |
284 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottom()); |
285 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->bottomLeft()); |
286 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | QVERIFY(!serverShadow->left()); |
287 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | } |
288 | |||
289 | 1 | void ShadowTest::testSurfaceDestroy() | |
290 | { | ||
291 | 1 | QSignalSpy serverSurfaceCreated(server.globals.compositor.get(), | |
292 | &Wrapland::Server::Compositor::surfaceCreated); | ||
293 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(serverSurfaceCreated.isValid()); |
294 | |||
295 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Surface> surface{m_compositor->createSurface()}; |
296 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(serverSurfaceCreated.wait()); |
297 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | auto serverSurface = serverSurfaceCreated.first().first().value<Wrapland::Server::Surface*>(); |
298 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverSurface); |
299 | |||
300 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QSignalSpy commit_spy(serverSurface, &Wrapland::Server::Surface::committed); |
301 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(commit_spy.isValid()); |
302 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::unique_ptr<Wrapland::Client::Shadow> shadow(m_shadow->createShadow(surface.get())); |
303 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | shadow->commit(); |
304 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | surface->commit(Wrapland::Client::Surface::CommitFlag::None); |
305 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(commit_spy.wait()); |
306 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto serverShadow = serverSurface->state().shadow; |
307 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(serverShadow); |
308 | |||
309 | // destroy the parent surface | ||
310 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); |
311 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(surfaceDestroyedSpy.isValid()); |
312 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | QSignalSpy shadowDestroyedSpy(serverShadow, &QObject::destroyed); |
313 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | QVERIFY(shadowDestroyedSpy.isValid()); |
314 | 1 | surface.reset(); | |
315 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(surfaceDestroyedSpy.wait()); |
316 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | QVERIFY(shadowDestroyedSpy.isEmpty()); |
317 | // destroy the shadow | ||
318 | 1 | shadow.reset(); | |
319 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
|
1 | QVERIFY(shadowDestroyedSpy.wait()); |
320 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | QCOMPARE(shadowDestroyedSpy.count(), 1); |
321 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | } |
322 | |||
323 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | QTEST_GUILESS_MAIN(ShadowTest) |
324 | #include "shadow.moc" | ||
325 |