Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/x11_client_test.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
43 | class X11ClientTest : public QObject | 43 | class X11ClientTest : public QObject | ||
44 | { | 44 | { | ||
45 | Q_OBJECT | 45 | Q_OBJECT | ||
46 | private Q_SLOTS: | 46 | private Q_SLOTS: | ||
47 | void initTestCase(); | 47 | void initTestCase(); | ||
48 | void init(); | 48 | void init(); | ||
49 | void cleanup(); | 49 | void cleanup(); | ||
50 | 50 | | |||
51 | void testMinimumSize(); | ||||
52 | void testMaximumSize(); | ||||
53 | void testResizeIncrements(); | ||||
54 | void testResizeIncrementsNoBaseSize(); | ||||
51 | void testTrimCaption_data(); | 55 | void testTrimCaption_data(); | ||
52 | void testTrimCaption(); | 56 | void testTrimCaption(); | ||
53 | void testFullscreenLayerWithActiveWaylandWindow(); | 57 | void testFullscreenLayerWithActiveWaylandWindow(); | ||
54 | void testFocusInWithWaylandLastActiveWindow(); | 58 | void testFocusInWithWaylandLastActiveWindow(); | ||
55 | void testX11WindowId(); | 59 | void testX11WindowId(); | ||
56 | void testCaptionChanges(); | 60 | void testCaptionChanges(); | ||
57 | void testCaptionWmName(); | 61 | void testCaptionWmName(); | ||
58 | void testCaptionMultipleWindows(); | 62 | void testCaptionMultipleWindows(); | ||
Show All 30 Lines | |||||
89 | struct XcbConnectionDeleter | 93 | struct XcbConnectionDeleter | ||
90 | { | 94 | { | ||
91 | static inline void cleanup(xcb_connection_t *pointer) | 95 | static inline void cleanup(xcb_connection_t *pointer) | ||
92 | { | 96 | { | ||
93 | xcb_disconnect(pointer); | 97 | xcb_disconnect(pointer); | ||
94 | } | 98 | } | ||
95 | }; | 99 | }; | ||
96 | 100 | | |||
101 | void X11ClientTest::testMinimumSize() | ||||
102 | { | ||||
103 | // This test verifies that the minimum size constraint is correctly applied. | ||||
104 | | ||||
105 | // Create an xcb window. | ||||
106 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||||
107 | QVERIFY(!xcb_connection_has_error(c.data())); | ||||
108 | const QRect windowGeometry(0, 0, 100, 200); | ||||
109 | xcb_window_t w = xcb_generate_id(c.data()); | ||||
110 | xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), | ||||
111 | windowGeometry.x(), | ||||
112 | windowGeometry.y(), | ||||
113 | windowGeometry.width(), | ||||
114 | windowGeometry.height(), | ||||
115 | 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); | ||||
116 | xcb_size_hints_t hints; | ||||
117 | memset(&hints, 0, sizeof(hints)); | ||||
118 | xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); | ||||
119 | xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); | ||||
120 | xcb_icccm_size_hints_set_min_size(&hints, windowGeometry.width(), windowGeometry.height()); | ||||
121 | xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); | ||||
122 | xcb_map_window(c.data(), w); | ||||
123 | xcb_flush(c.data()); | ||||
124 | | ||||
125 | QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); | ||||
126 | QVERIFY(windowCreatedSpy.isValid()); | ||||
127 | QVERIFY(windowCreatedSpy.wait()); | ||||
128 | X11Client *client = windowCreatedSpy.last().first().value<X11Client *>(); | ||||
129 | QVERIFY(client); | ||||
130 | QVERIFY(client->isDecorated()); | ||||
131 | | ||||
132 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
133 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
134 | QSignalSpy clientStepUserMovedResizedSpy(client, &AbstractClient::clientStepUserMovedResized); | ||||
135 | QVERIFY(clientStepUserMovedResizedSpy.isValid()); | ||||
136 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
137 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
138 | | ||||
139 | // Begin resize. | ||||
140 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
141 | QVERIFY(!client->isResize()); | ||||
142 | workspace()->slotWindowResize(); | ||||
143 | QCOMPARE(workspace()->moveResizeClient(), client); | ||||
144 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
145 | QVERIFY(client->isResize()); | ||||
146 | | ||||
147 | const QPoint cursorPos = KWin::Cursor::pos(); | ||||
148 | | ||||
149 | client->keyPressEvent(Qt::Key_Left); | ||||
150 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
151 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(-8, 0)); | ||||
152 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
153 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); | ||||
154 | QCOMPARE(client->clientSize().width(), 100); | ||||
155 | | ||||
156 | client->keyPressEvent(Qt::Key_Right); | ||||
157 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
158 | QCOMPARE(KWin::Cursor::pos(), cursorPos); | ||||
159 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
160 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); | ||||
161 | QCOMPARE(client->clientSize().width(), 100); | ||||
162 | | ||||
163 | client->keyPressEvent(Qt::Key_Right); | ||||
164 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
165 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
166 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
167 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
168 | QCOMPARE(client->clientSize().width(), 108); | ||||
169 | | ||||
170 | client->keyPressEvent(Qt::Key_Up); | ||||
171 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
172 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, -8)); | ||||
173 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
174 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
175 | QCOMPARE(client->clientSize().height(), 200); | ||||
176 | | ||||
177 | client->keyPressEvent(Qt::Key_Down); | ||||
178 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
179 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
180 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
181 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
182 | QCOMPARE(client->clientSize().height(), 200); | ||||
183 | | ||||
184 | client->keyPressEvent(Qt::Key_Down); | ||||
185 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
186 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 8)); | ||||
187 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
188 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); | ||||
189 | QCOMPARE(client->clientSize().height(), 208); | ||||
190 | | ||||
191 | // Finish the resize operation. | ||||
192 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
193 | client->keyPressEvent(Qt::Key_Enter); | ||||
194 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
195 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
196 | QVERIFY(!client->isResize()); | ||||
197 | | ||||
198 | // Destroy the window. | ||||
199 | QSignalSpy windowClosedSpy(client, &X11Client::windowClosed); | ||||
200 | QVERIFY(windowClosedSpy.isValid()); | ||||
201 | xcb_unmap_window(c.data(), w); | ||||
202 | xcb_destroy_window(c.data(), w); | ||||
203 | xcb_flush(c.data()); | ||||
204 | QVERIFY(windowClosedSpy.wait()); | ||||
205 | c.reset(); | ||||
206 | } | ||||
207 | | ||||
208 | void X11ClientTest::testMaximumSize() | ||||
209 | { | ||||
210 | // This test verifies that the maximum size constraint is correctly applied. | ||||
211 | | ||||
212 | // Create an xcb window. | ||||
213 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||||
214 | QVERIFY(!xcb_connection_has_error(c.data())); | ||||
215 | const QRect windowGeometry(0, 0, 100, 200); | ||||
216 | xcb_window_t w = xcb_generate_id(c.data()); | ||||
217 | xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), | ||||
218 | windowGeometry.x(), | ||||
219 | windowGeometry.y(), | ||||
220 | windowGeometry.width(), | ||||
221 | windowGeometry.height(), | ||||
222 | 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); | ||||
223 | xcb_size_hints_t hints; | ||||
224 | memset(&hints, 0, sizeof(hints)); | ||||
225 | xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); | ||||
226 | xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); | ||||
227 | xcb_icccm_size_hints_set_max_size(&hints, windowGeometry.width(), windowGeometry.height()); | ||||
228 | xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); | ||||
229 | xcb_map_window(c.data(), w); | ||||
230 | xcb_flush(c.data()); | ||||
231 | | ||||
232 | QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); | ||||
233 | QVERIFY(windowCreatedSpy.isValid()); | ||||
234 | QVERIFY(windowCreatedSpy.wait()); | ||||
235 | X11Client *client = windowCreatedSpy.last().first().value<X11Client *>(); | ||||
236 | QVERIFY(client); | ||||
237 | QVERIFY(client->isDecorated()); | ||||
238 | | ||||
239 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
240 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
241 | QSignalSpy clientStepUserMovedResizedSpy(client, &AbstractClient::clientStepUserMovedResized); | ||||
242 | QVERIFY(clientStepUserMovedResizedSpy.isValid()); | ||||
243 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
244 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
245 | | ||||
246 | // Begin resize. | ||||
247 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
248 | QVERIFY(!client->isResize()); | ||||
249 | workspace()->slotWindowResize(); | ||||
250 | QCOMPARE(workspace()->moveResizeClient(), client); | ||||
251 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
252 | QVERIFY(client->isResize()); | ||||
253 | | ||||
254 | const QPoint cursorPos = KWin::Cursor::pos(); | ||||
255 | | ||||
256 | client->keyPressEvent(Qt::Key_Right); | ||||
257 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
258 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
259 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
260 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); | ||||
261 | QCOMPARE(client->clientSize().width(), 100); | ||||
262 | | ||||
263 | client->keyPressEvent(Qt::Key_Left); | ||||
264 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
265 | QCOMPARE(KWin::Cursor::pos(), cursorPos); | ||||
266 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
267 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 0); | ||||
268 | QCOMPARE(client->clientSize().width(), 100); | ||||
269 | | ||||
270 | client->keyPressEvent(Qt::Key_Left); | ||||
271 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
272 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(-8, 0)); | ||||
273 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
274 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
275 | QCOMPARE(client->clientSize().width(), 92); | ||||
276 | | ||||
277 | client->keyPressEvent(Qt::Key_Down); | ||||
278 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
279 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(-8, 8)); | ||||
280 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
281 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
282 | QCOMPARE(client->clientSize().height(), 200); | ||||
283 | | ||||
284 | client->keyPressEvent(Qt::Key_Up); | ||||
285 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
286 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(-8, 0)); | ||||
287 | QVERIFY(!clientStepUserMovedResizedSpy.wait(1000)); | ||||
288 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
289 | QCOMPARE(client->clientSize().height(), 200); | ||||
290 | | ||||
291 | client->keyPressEvent(Qt::Key_Up); | ||||
292 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
293 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(-8, -8)); | ||||
294 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
295 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); | ||||
296 | QCOMPARE(client->clientSize().height(), 192); | ||||
297 | | ||||
298 | // Finish the resize operation. | ||||
299 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
300 | client->keyPressEvent(Qt::Key_Enter); | ||||
301 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
302 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
303 | QVERIFY(!client->isResize()); | ||||
304 | | ||||
305 | // Destroy the window. | ||||
306 | QSignalSpy windowClosedSpy(client, &X11Client::windowClosed); | ||||
307 | QVERIFY(windowClosedSpy.isValid()); | ||||
308 | xcb_unmap_window(c.data(), w); | ||||
309 | xcb_destroy_window(c.data(), w); | ||||
310 | xcb_flush(c.data()); | ||||
311 | QVERIFY(windowClosedSpy.wait()); | ||||
312 | c.reset(); | ||||
313 | } | ||||
314 | | ||||
315 | void X11ClientTest::testResizeIncrements() | ||||
316 | { | ||||
317 | // This test verifies that the resize increments constraint is correctly applied. | ||||
318 | | ||||
319 | // Create an xcb window. | ||||
320 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||||
321 | QVERIFY(!xcb_connection_has_error(c.data())); | ||||
322 | const QRect windowGeometry(0, 0, 100, 200); | ||||
323 | xcb_window_t w = xcb_generate_id(c.data()); | ||||
324 | xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), | ||||
325 | windowGeometry.x(), | ||||
326 | windowGeometry.y(), | ||||
327 | windowGeometry.width(), | ||||
328 | windowGeometry.height(), | ||||
329 | 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); | ||||
330 | xcb_size_hints_t hints; | ||||
331 | memset(&hints, 0, sizeof(hints)); | ||||
332 | xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); | ||||
333 | xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); | ||||
334 | xcb_icccm_size_hints_set_base_size(&hints, windowGeometry.width(), windowGeometry.height()); | ||||
335 | xcb_icccm_size_hints_set_resize_inc(&hints, 3, 5); | ||||
336 | xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); | ||||
337 | xcb_map_window(c.data(), w); | ||||
338 | xcb_flush(c.data()); | ||||
339 | | ||||
340 | QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); | ||||
341 | QVERIFY(windowCreatedSpy.isValid()); | ||||
342 | QVERIFY(windowCreatedSpy.wait()); | ||||
343 | X11Client *client = windowCreatedSpy.last().first().value<X11Client *>(); | ||||
344 | QVERIFY(client); | ||||
345 | QVERIFY(client->isDecorated()); | ||||
346 | | ||||
347 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
348 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
349 | QSignalSpy clientStepUserMovedResizedSpy(client, &AbstractClient::clientStepUserMovedResized); | ||||
350 | QVERIFY(clientStepUserMovedResizedSpy.isValid()); | ||||
351 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
352 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
353 | | ||||
354 | // Begin resize. | ||||
355 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
356 | QVERIFY(!client->isResize()); | ||||
357 | workspace()->slotWindowResize(); | ||||
358 | QCOMPARE(workspace()->moveResizeClient(), client); | ||||
359 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
360 | QVERIFY(client->isResize()); | ||||
361 | | ||||
362 | const QPoint cursorPos = KWin::Cursor::pos(); | ||||
363 | | ||||
364 | client->keyPressEvent(Qt::Key_Right); | ||||
365 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
366 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
367 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
368 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
369 | QCOMPARE(client->clientSize(), QSize(106, 200)); | ||||
370 | | ||||
371 | client->keyPressEvent(Qt::Key_Down); | ||||
372 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
373 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 8)); | ||||
374 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
375 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); | ||||
376 | QCOMPARE(client->clientSize(), QSize(106, 205)); | ||||
377 | | ||||
378 | // Finish the resize operation. | ||||
379 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
380 | client->keyPressEvent(Qt::Key_Enter); | ||||
381 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
382 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
383 | QVERIFY(!client->isResize()); | ||||
384 | | ||||
385 | // Destroy the window. | ||||
386 | QSignalSpy windowClosedSpy(client, &X11Client::windowClosed); | ||||
387 | QVERIFY(windowClosedSpy.isValid()); | ||||
388 | xcb_unmap_window(c.data(), w); | ||||
389 | xcb_destroy_window(c.data(), w); | ||||
390 | xcb_flush(c.data()); | ||||
391 | QVERIFY(windowClosedSpy.wait()); | ||||
392 | c.reset(); | ||||
393 | } | ||||
394 | | ||||
395 | void X11ClientTest::testResizeIncrementsNoBaseSize() | ||||
396 | { | ||||
397 | // Create an xcb window. | ||||
398 | QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr)); | ||||
399 | QVERIFY(!xcb_connection_has_error(c.data())); | ||||
400 | const QRect windowGeometry(0, 0, 100, 200); | ||||
401 | xcb_window_t w = xcb_generate_id(c.data()); | ||||
402 | xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), | ||||
403 | windowGeometry.x(), | ||||
404 | windowGeometry.y(), | ||||
405 | windowGeometry.width(), | ||||
406 | windowGeometry.height(), | ||||
407 | 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); | ||||
408 | xcb_size_hints_t hints; | ||||
409 | memset(&hints, 0, sizeof(hints)); | ||||
410 | xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); | ||||
411 | xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); | ||||
412 | xcb_icccm_size_hints_set_min_size(&hints, windowGeometry.width(), windowGeometry.height()); | ||||
413 | xcb_icccm_size_hints_set_resize_inc(&hints, 3, 5); | ||||
414 | xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); | ||||
415 | xcb_map_window(c.data(), w); | ||||
416 | xcb_flush(c.data()); | ||||
417 | | ||||
418 | QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); | ||||
419 | QVERIFY(windowCreatedSpy.isValid()); | ||||
420 | QVERIFY(windowCreatedSpy.wait()); | ||||
421 | X11Client *client = windowCreatedSpy.last().first().value<X11Client *>(); | ||||
422 | QVERIFY(client); | ||||
423 | QVERIFY(client->isDecorated()); | ||||
424 | | ||||
425 | QSignalSpy clientStartMoveResizedSpy(client, &AbstractClient::clientStartUserMovedResized); | ||||
426 | QVERIFY(clientStartMoveResizedSpy.isValid()); | ||||
427 | QSignalSpy clientStepUserMovedResizedSpy(client, &AbstractClient::clientStepUserMovedResized); | ||||
428 | QVERIFY(clientStepUserMovedResizedSpy.isValid()); | ||||
429 | QSignalSpy clientFinishUserMovedResizedSpy(client, &AbstractClient::clientFinishUserMovedResized); | ||||
430 | QVERIFY(clientFinishUserMovedResizedSpy.isValid()); | ||||
431 | | ||||
432 | // Begin resize. | ||||
433 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
434 | QVERIFY(!client->isResize()); | ||||
435 | workspace()->slotWindowResize(); | ||||
436 | QCOMPARE(workspace()->moveResizeClient(), client); | ||||
437 | QCOMPARE(clientStartMoveResizedSpy.count(), 1); | ||||
438 | QVERIFY(client->isResize()); | ||||
439 | | ||||
440 | const QPoint cursorPos = KWin::Cursor::pos(); | ||||
441 | | ||||
442 | client->keyPressEvent(Qt::Key_Right); | ||||
443 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
444 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 0)); | ||||
445 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
446 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); | ||||
447 | QCOMPARE(client->clientSize().width(), 106); | ||||
448 | | ||||
449 | client->keyPressEvent(Qt::Key_Down); | ||||
450 | client->updateMoveResize(KWin::Cursor::pos()); | ||||
451 | QCOMPARE(KWin::Cursor::pos(), cursorPos + QPoint(8, 8)); | ||||
452 | QVERIFY(clientStepUserMovedResizedSpy.wait()); | ||||
453 | QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); | ||||
454 | QCOMPARE(client->clientSize().height(), 205); | ||||
455 | | ||||
456 | // Finish the resize operation. | ||||
457 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0); | ||||
458 | client->keyPressEvent(Qt::Key_Enter); | ||||
459 | QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1); | ||||
460 | QCOMPARE(workspace()->moveResizeClient(), nullptr); | ||||
461 | QVERIFY(!client->isResize()); | ||||
462 | | ||||
463 | // Destroy the window. | ||||
464 | QSignalSpy windowClosedSpy(client, &X11Client::windowClosed); | ||||
465 | QVERIFY(windowClosedSpy.isValid()); | ||||
466 | xcb_unmap_window(c.data(), w); | ||||
467 | xcb_destroy_window(c.data(), w); | ||||
468 | xcb_flush(c.data()); | ||||
469 | QVERIFY(windowClosedSpy.wait()); | ||||
470 | c.reset(); | ||||
471 | } | ||||
472 | | ||||
97 | void X11ClientTest::testTrimCaption_data() | 473 | void X11ClientTest::testTrimCaption_data() | ||
98 | { | 474 | { | ||
99 | QTest::addColumn<QByteArray>("originalTitle"); | 475 | QTest::addColumn<QByteArray>("originalTitle"); | ||
100 | QTest::addColumn<QByteArray>("expectedTitle"); | 476 | QTest::addColumn<QByteArray>("expectedTitle"); | ||
101 | 477 | | |||
102 | QTest::newRow("simplified") | 478 | QTest::newRow("simplified") | ||
103 | << QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox") | 479 | << QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox") | ||
104 | << QByteArrayLiteral("Was tun, wenn Schüler Autismus haben? – Marlies Hübner - Mozilla Firefox"); | 480 | << QByteArrayLiteral("Was tun, wenn Schüler Autismus haben? – Marlies Hübner - Mozilla Firefox"); | ||
▲ Show 20 Lines • Show All 526 Lines • Show Last 20 Lines |