VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp@ 93115

最後變更 在這個檔案從93115是 93115,由 vboxsync 提交於 3 年 前

scm --update-copyright-year

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 23.6 KB
 
1/* $Id: tstSeamlessX11-auto.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * Automated test of the X11 seamless Additions code.
4 * @todo Better separate test data from implementation details!
5 */
6
7/*
8 * Copyright (C) 2007-2022 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#include <stdlib.h> /* exit() */
20
21#include <X11/Xatom.h>
22#include <X11/Xmu/WinUtil.h>
23
24#include <iprt/initterm.h>
25#include <iprt/mem.h>
26#include <iprt/path.h>
27#include <iprt/semaphore.h>
28#include <iprt/stream.h>
29#include <iprt/string.h>
30
31#include "../seamless.h"
32
33#undef DefaultRootWindow
34
35/******************************************************
36* Mock X11 functions needed by the seamless X11 class *
37******************************************************/
38
39int XFree(void *data)
40{
41 RTMemFree(data);
42 return 0;
43}
44
45#define TEST_DISPLAY ((Display *)0xffff)
46#define TEST_ROOT ((Window)1)
47
48void VBClLogError(const char *pszFormat, ...)
49{
50 va_list args;
51 va_start(args, pszFormat);
52 char *psz = NULL;
53 RTStrAPrintfV(&psz, pszFormat, args);
54 va_end(args);
55
56 AssertPtr(psz);
57 RTPrintf("Error: %s", psz);
58
59 RTStrFree(psz);
60}
61
62/** Exit with a fatal error. */
63void VBClLogFatalError(const char *pszFormat, ...)
64{
65 va_list args;
66 va_start(args, pszFormat);
67 char *psz = NULL;
68 RTStrAPrintfV(&psz, pszFormat, args);
69 va_end(args);
70
71 AssertPtr(psz);
72 RTPrintf("Fatal error: %s", psz);
73
74 RTStrFree(psz);
75
76 exit(1);
77}
78
79extern "C" Display *XOpenDisplay(const char *display_name);
80Display *XOpenDisplay(const char *display_name)
81{
82 RT_NOREF1(display_name);
83 return TEST_DISPLAY;
84}
85
86extern "C" int XCloseDisplay(Display *display);
87int XCloseDisplay(Display *display)
88{
89 RT_NOREF1(display);
90 Assert(display == TEST_DISPLAY);
91 return 0;
92}
93
94enum
95{
96 ATOM_PROP = 1,
97 ATOM_DESKTOP_PROP
98};
99
100extern "C" Atom XInternAtom(Display *display, const char *atom_name, Bool only_if_exists);
101Atom XInternAtom(Display *display, const char *atom_name, Bool only_if_exists)
102{
103 RT_NOREF2(only_if_exists, display);
104 Assert(display == TEST_DISPLAY);
105 if (!RTStrCmp(atom_name, WM_TYPE_PROP))
106 return (Atom) ATOM_PROP;
107 if (!RTStrCmp(atom_name, WM_TYPE_DESKTOP_PROP))
108 return (Atom) ATOM_DESKTOP_PROP;
109 AssertFailed();
110 return (Atom)0;
111}
112
113/** The window (if any) on which the WM_TYPE_PROP property is set to the
114 * WM_TYPE_DESKTOP_PROP atom. */
115static Window g_hSmlsDesktopWindow = 0;
116
117extern "C" int XGetWindowProperty(Display *display, Window w, Atom property,
118 long long_offset, long long_length,
119 Bool delProp, Atom req_type,
120 Atom *actual_type_return,
121 int *actual_format_return,
122 unsigned long *nitems_return,
123 unsigned long *bytes_after_return,
124 unsigned char **prop_return);
125int XGetWindowProperty(Display *display, Window w, Atom property,
126 long long_offset, long long_length, Bool delProp,
127 Atom req_type, Atom *actual_type_return,
128 int *actual_format_return,
129 unsigned long *nitems_return,
130 unsigned long *bytes_after_return,
131 unsigned char **prop_return)
132{
133 RT_NOREF2(display, long_length);
134 Assert(display == TEST_DISPLAY);
135 Atom atomType = XInternAtom (display, WM_TYPE_PROP, true);
136 Atom atomTypeDesktop = XInternAtom (display, WM_TYPE_DESKTOP_PROP, true);
137 /* We only handle things we expect. */
138 AssertReturn((req_type == XA_ATOM) || (req_type == AnyPropertyType),
139 0xffff);
140 AssertReturn(property == atomType, 0xffff);
141 *actual_type_return = XA_ATOM;
142 *actual_format_return = sizeof(Atom) * 8;
143 *nitems_return = 0;
144 *bytes_after_return = sizeof(Atom);
145 *prop_return = NULL;
146 if ((w != g_hSmlsDesktopWindow) || (g_hSmlsDesktopWindow == 0))
147 return Success;
148 AssertReturn(long_offset == 0, 0);
149 AssertReturn(delProp == false, 0);
150 unsigned char *pProp;
151 pProp = (unsigned char *)RTMemDup(&atomTypeDesktop,
152 sizeof(atomTypeDesktop));
153 AssertReturn(pProp, 0xffff);
154 *nitems_return = 1;
155 *prop_return = pProp;
156 *bytes_after_return = 0;
157 return 0;
158}
159
160#if 0 /* unused */
161/** Sets the current set of properties for all mock X11 windows */
162static void smlsSetDesktopWindow(Window hWin)
163{
164 g_hSmlsDesktopWindow = hWin;
165}
166#endif
167
168extern "C" Bool XShapeQueryExtension(Display *dpy, int *event_basep, int *error_basep);
169Bool XShapeQueryExtension(Display *dpy, int *event_basep, int *error_basep)
170{
171 RT_NOREF3(dpy, event_basep, error_basep);
172 Assert(dpy == TEST_DISPLAY);
173 return true;
174}
175
176/* We silently ignore this for now. */
177extern "C" int XSelectInput(Display *display, Window w, long event_mask);
178int XSelectInput(Display *display, Window w, long event_mask)
179{
180 RT_NOREF3(display, w, event_mask);
181 Assert(display == TEST_DISPLAY);
182 return 0;
183}
184
185/* We silently ignore this for now. */
186extern "C" void XShapeSelectInput(Display *display, Window w, unsigned long event_mask);
187void XShapeSelectInput(Display *display, Window w, unsigned long event_mask)
188{
189 RT_NOREF3(display, w, event_mask);
190 Assert(display == TEST_DISPLAY);
191}
192
193extern "C" Window XDefaultRootWindow(Display *display);
194Window XDefaultRootWindow(Display *display)
195{
196 RT_NOREF1(display);
197 Assert(display == TEST_DISPLAY);
198 return TEST_ROOT;
199}
200
201static unsigned g_cSmlsWindows = 0;
202static Window *g_paSmlsWindows = NULL;
203static XWindowAttributes *g_paSmlsWinAttribs = NULL;
204static const char **g_papszSmlsWinNames = NULL;
205
206extern "C" Status XQueryTree(Display *display, Window w, Window *root_return,
207 Window *parent_return, Window **children_return,
208 unsigned int *nchildren_return);
209Status XQueryTree(Display *display, Window w, Window *root_return,
210 Window *parent_return, Window **children_return,
211 unsigned int *nchildren_return)
212{
213 RT_NOREF1(display);
214 Assert(display == TEST_DISPLAY);
215 AssertReturn(w == TEST_ROOT, False); /* We support nothing else */
216 AssertPtrReturn(children_return, False);
217 AssertReturn(g_paSmlsWindows, False);
218 if (root_return)
219 *root_return = TEST_ROOT;
220 if (parent_return)
221 *parent_return = TEST_ROOT;
222 *children_return = (Window *)RTMemDup(g_paSmlsWindows,
223 g_cSmlsWindows * sizeof(Window));
224 if (nchildren_return)
225 *nchildren_return = g_cSmlsWindows;
226 return (g_cSmlsWindows != 0);
227}
228
229extern "C" Window XmuClientWindow(Display *dpy, Window win);
230Window XmuClientWindow(Display *dpy, Window win)
231{
232 RT_NOREF1(dpy);
233 Assert(dpy == TEST_DISPLAY);
234 return win;
235}
236
237extern "C" Status XGetWindowAttributes(Display *display, Window w,
238 XWindowAttributes *window_attributes_return);
239Status XGetWindowAttributes(Display *display, Window w,
240 XWindowAttributes *window_attributes_return)
241{
242 RT_NOREF1(display);
243 Assert(display == TEST_DISPLAY);
244 AssertPtrReturn(window_attributes_return, 1);
245 for (unsigned i = 0; i < g_cSmlsWindows; ++i)
246 if (g_paSmlsWindows[i] == w)
247 {
248 *window_attributes_return = g_paSmlsWinAttribs[i];
249 return 1;
250 }
251 return 0;
252}
253
254extern "C" Status XGetWMNormalHints(Display *display, Window w,
255 XSizeHints *hints_return,
256 long *supplied_return);
257
258Status XGetWMNormalHints(Display *display, Window w,
259 XSizeHints *hints_return, long *supplied_return)
260{
261 RT_NOREF4(display, w, hints_return, supplied_return);
262 Assert(display == TEST_DISPLAY);
263 return 1;
264}
265
266static void smlsSetWindowAttributes(XWindowAttributes *pAttribs,
267 Window *pWindows, unsigned cAttribs,
268 const char **paNames)
269{
270 g_paSmlsWinAttribs = pAttribs;
271 g_paSmlsWindows = pWindows;
272 g_cSmlsWindows = cAttribs;
273 g_papszSmlsWinNames = paNames;
274}
275
276static Window g_SmlsShapedWindow = 0;
277static int g_cSmlsShapeRectangles = 0;
278static XRectangle *g_pSmlsShapeRectangles = NULL;
279
280extern "C" XRectangle *XShapeGetRectangles (Display *dpy, Window window,
281 int kind, int *count,
282 int *ordering);
283XRectangle *XShapeGetRectangles (Display *dpy, Window window, int kind,
284 int *count, int *ordering)
285{
286 RT_NOREF2(dpy, kind);
287 Assert(dpy == TEST_DISPLAY);
288 if ((window != g_SmlsShapedWindow) || (window == 0))
289 return NULL; /* Probably not correct, but works for us. */
290 *count = g_cSmlsShapeRectangles;
291 *ordering = 0;
292 return (XRectangle *)RTMemDup(g_pSmlsShapeRectangles,
293 sizeof(XRectangle)
294 * g_cSmlsShapeRectangles);
295}
296
297static void smlsSetShapeRectangles(Window window, int cRects,
298 XRectangle *pRects)
299{
300 g_SmlsShapedWindow = window;
301 g_cSmlsShapeRectangles = cRects;
302 g_pSmlsShapeRectangles = pRects;
303}
304
305static int g_SmlsEventType = 0;
306static Window g_SmlsEventWindow = 0;
307
308/* This should not be needed in the bits of the code we test. */
309extern "C" int XNextEvent(Display *display, XEvent *event_return);
310int XNextEvent(Display *display, XEvent *event_return)
311{
312 RT_NOREF1(display);
313 Assert(display == TEST_DISPLAY);
314 event_return->xany.type = g_SmlsEventType;
315 event_return->xany.window = g_SmlsEventWindow;
316 event_return->xmap.window = g_SmlsEventWindow;
317 return True;
318}
319
320/* Mock XPending(): this also should not be needed. Just in case, always
321 * return that at least one event is pending to be processed. */
322extern "C" int XPending(Display *display);
323int XPending(Display *display)
324{
325 RT_NOREF1(display);
326 return 1;
327}
328
329static void smlsSetNextEvent(int type, Window window)
330{
331 g_SmlsEventType = type;
332 g_SmlsEventWindow = window;
333}
334
335/* This should not be needed in the bits of the code we test. */
336extern "C" Status XSendEvent(Display *display, Window w, Bool propagate,
337 long event_mask, XEvent *event_send);
338Status XSendEvent(Display *display, Window w, Bool propagate,
339 long event_mask, XEvent *event_send)
340{
341 RT_NOREF5(display, w, propagate, event_mask, event_send);
342 Assert(display == TEST_DISPLAY);
343 AssertFailedReturn(0);
344}
345
346/* This should not be needed in the bits of the code we test. */
347extern "C" int XFlush(Display *display);
348int XFlush(Display *display)
349{
350 RT_NOREF1(display);
351 Assert(display == TEST_DISPLAY);
352 AssertFailedReturn(0);
353}
354
355/** Global "received a notification" flag. */
356static bool g_fNotified = false;
357
358/** Dummy host call-back. */
359static void sendRegionUpdate(RTRECT *pRects, size_t cRects)
360{
361 RT_NOREF2(pRects, cRects);
362 g_fNotified = true;
363}
364
365static bool gotNotification(void)
366{
367 if (!g_fNotified)
368 return false;
369 g_fNotified = false;
370 return true;
371}
372
373/*****************************
374* The actual tests to be run *
375*****************************/
376
377/** The name of the unit test */
378static const char *g_pszTestName = NULL;
379
380/*** Test fixture data and data structures ***/
381
382/** A structure describing a test fixture to be run through. Each fixture
383 * describes the state of the windows visible (and unmapped) on the X server
384 * before and after a particular event is delivered, and the expected
385 * on-screen positions of all interesting visible windows at the end of the
386 * fixture as reported by the code (currently in the order it is likely to
387 * report them in, @todo sort this). We expect that the set of visible
388 * windows will be the same whether we start the code before the event and
389 * handle it or start the code after the event.
390 */
391struct SMLSFIXTURE
392{
393 /** The number of windows visible before the event */
394 unsigned cWindowsBefore;
395 /** An array of Window IDs for the visible and unmapped windows before
396 * the event */
397 Window *pahWindowsBefore;
398 /** The window attributes matching the windows in @a paWindowsBefore */
399 XWindowAttributes *paAttribsBefore;
400 /** The window names matching the windows in @a paWindowsBefore */
401 const char **papszNamesBefore;
402 /** The shaped window before the event - we allow at most one of these.
403 * Zero for none. */
404 Window hShapeWindowBefore;
405 /** The number of rectangles in the shaped window before the event. */
406 int cShapeRectsBefore;
407 /** The rectangles in the shaped window before the event */
408 XRectangle *paShapeRectsBefore;
409 /** The number of windows visible after the event */
410 unsigned cWindowsAfter;
411 /** An array of Window IDs for the visible and unmapped windows after
412 * the event */
413 Window *pahWindowsAfter;
414 /** The window attributes matching the windows in @a paWindowsAfter */
415 XWindowAttributes *paAttribsAfter;
416 /** The window names matching the windows in @a paWindowsAfter */
417 const char **papszNamesAfter;
418 /** The shaped window after the event - we allow at most one of these.
419 * Zero for none. */
420 Window hShapeWindowAfter;
421 /** The number of rectangles in the shaped window after the event. */
422 int cShapeRectsAfter;
423 /** The rectangles in the shaped window after the event */
424 XRectangle *paShapeRectsAfter;
425 /** The event to delivered */
426 int x11EventType;
427 /** The window for which the event in @enmEvent is delivered */
428 Window hEventWindow;
429 /** The number of windows expected to be reported at the end of the
430 * fixture */
431 unsigned cReportedRects;
432 /** The onscreen positions of those windows. */
433 RTRECT *paReportedRects;
434 /** Do we expect notification after the event? */
435 bool fExpectNotification;
436};
437
438/*** Test fixture to test the code against X11 configure (move) events ***/
439
440static Window g_ahWin1[] = { 20 };
441static XWindowAttributes g_aAttrib1Before[] =
442{ { 100, 200, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
443};
444static XRectangle g_aRectangle1[] =
445{
446 { 0, 0, 50, 50 },
447 { 50, 50, 150, 250 }
448};
449static XWindowAttributes g_aAttrib1After[] =
450{ { 200, 300, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
451};
452static const char *g_apszNames1[] = { "Test Window" };
453
454AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib1Before));
455AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib1After));
456AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_apszNames1));
457
458static RTRECT g_aRects1[] =
459{
460 { 200, 300, 250, 350 },
461 { 250, 350, 400, 600 }
462};
463
464static SMLSFIXTURE g_testMove =
465{
466 RT_ELEMENTS(g_ahWin1),
467 g_ahWin1,
468 g_aAttrib1Before,
469 g_apszNames1,
470 20,
471 RT_ELEMENTS(g_aRectangle1),
472 g_aRectangle1,
473 RT_ELEMENTS(g_ahWin1),
474 g_ahWin1,
475 g_aAttrib1After,
476 g_apszNames1,
477 20,
478 RT_ELEMENTS(g_aRectangle1),
479 g_aRectangle1,
480 ConfigureNotify,
481 20,
482 RT_ELEMENTS(g_aRects1),
483 g_aRects1,
484 true
485};
486
487/*** Test fixture to test the code against X11 configure (resize) events ***/
488
489static XWindowAttributes g_aAttrib2Before[] =
490{ { 100, 200, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
491};
492static XRectangle g_aRectangle2Before[] =
493{
494 { 0, 0, 50, 50 },
495 { 50, 50, 100, 100 }
496};
497
498AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib2Before));
499
500static SMLSFIXTURE g_testResize =
501{
502 RT_ELEMENTS(g_ahWin1),
503 g_ahWin1,
504 g_aAttrib2Before,
505 g_apszNames1,
506 20,
507 RT_ELEMENTS(g_aRectangle2Before),
508 g_aRectangle2Before,
509 RT_ELEMENTS(g_ahWin1),
510 g_ahWin1,
511 g_aAttrib1After,
512 g_apszNames1,
513 20,
514 RT_ELEMENTS(g_aRectangle1),
515 g_aRectangle1,
516 ConfigureNotify,
517 20,
518 RT_ELEMENTS(g_aRects1),
519 g_aRects1,
520 true
521};
522
523/*** Test fixture to test the code against X11 map events ***/
524
525static XWindowAttributes g_aAttrib3Before[] =
526{ { 200, 300, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsUnmapped }
527};
528
529AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib3Before));
530
531static SMLSFIXTURE g_testMap =
532{
533 RT_ELEMENTS(g_ahWin1),
534 g_ahWin1,
535 g_aAttrib3Before,
536 g_apszNames1,
537 20,
538 RT_ELEMENTS(g_aRectangle1),
539 g_aRectangle1,
540 RT_ELEMENTS(g_ahWin1),
541 g_ahWin1,
542 g_aAttrib1After,
543 g_apszNames1,
544 20,
545 RT_ELEMENTS(g_aRectangle1),
546 g_aRectangle1,
547 MapNotify,
548 20,
549 RT_ELEMENTS(g_aRects1),
550 g_aRects1,
551 true
552};
553
554/*** Test fixtures to test the code against X11 unmap events ***/
555
556static XWindowAttributes g_aAttrib4After[] =
557{ { 100, 200, 300, 400, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsUnmapped }
558};
559
560AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib4After));
561
562static SMLSFIXTURE g_testUnmap =
563{
564 RT_ELEMENTS(g_ahWin1),
565 g_ahWin1,
566 g_aAttrib1Before,
567 g_apszNames1,
568 20,
569 RT_ELEMENTS(g_aRectangle1),
570 g_aRectangle1,
571 RT_ELEMENTS(g_ahWin1),
572 g_ahWin1,
573 g_aAttrib4After,
574 g_apszNames1,
575 20,
576 RT_ELEMENTS(g_aRectangle1),
577 g_aRectangle1,
578 UnmapNotify,
579 20,
580 0,
581 NULL,
582 true
583};
584
585/*** A window we are not monitoring has been unmapped. Nothing should
586 *** happen, especially nothing bad. ***/
587
588static RTRECT g_aRects2[] =
589{
590 { 100, 200, 150, 250 },
591 { 150, 250, 300, 500 }
592};
593
594static SMLSFIXTURE g_testUnmapOther =
595{
596 RT_ELEMENTS(g_ahWin1),
597 g_ahWin1,
598 g_aAttrib1Before,
599 g_apszNames1,
600 20,
601 RT_ELEMENTS(g_aRectangle1),
602 g_aRectangle1,
603 RT_ELEMENTS(g_ahWin1),
604 g_ahWin1,
605 g_aAttrib1Before,
606 g_apszNames1,
607 20,
608 RT_ELEMENTS(g_aRectangle1),
609 g_aRectangle1,
610 UnmapNotify,
611 21,
612 RT_ELEMENTS(g_aRects2),
613 g_aRects2,
614 false
615};
616
617/*** Test fixture to test the code against X11 shape events ***/
618
619static XRectangle g_aRectangle5Before[] =
620{
621 { 0, 0, 200, 200 }
622};
623
624static SMLSFIXTURE g_testShape =
625{
626 RT_ELEMENTS(g_ahWin1),
627 g_ahWin1,
628 g_aAttrib1After,
629 g_apszNames1,
630 20,
631 RT_ELEMENTS(g_aRectangle5Before),
632 g_aRectangle5Before,
633 RT_ELEMENTS(g_ahWin1),
634 g_ahWin1,
635 g_aAttrib1After,
636 g_apszNames1,
637 20,
638 RT_ELEMENTS(g_aRectangle1),
639 g_aRectangle1,
640 VBoxShapeNotify,
641 20,
642 RT_ELEMENTS(g_aRects1),
643 g_aRects1,
644 true
645};
646
647/*** And the test code proper ***/
648
649/** Compare two RTRECT structures */
650static bool smlsCompRect(RTRECT *pFirst, RTRECT *pSecond)
651{
652 return ( (pFirst->xLeft == pSecond->xLeft)
653 && (pFirst->yTop == pSecond->yTop)
654 && (pFirst->xRight == pSecond->xRight)
655 && (pFirst->yBottom == pSecond->yBottom));
656}
657
658static void smlsPrintDiffRects(RTRECT *pExp, RTRECT *pGot)
659{
660 RTPrintf(" Expected: %d, %d, %d, %d. Got: %d, %d, %d, %d\n",
661 pExp->xLeft, pExp->yTop, pExp->xRight, pExp->yBottom,
662 pGot->xLeft, pGot->yTop, pGot->xRight, pGot->yBottom);
663}
664
665/** Run through a test fixture */
666static unsigned smlsDoFixture(SMLSFIXTURE *pFixture, const char *pszDesc)
667{
668 SeamlessX11 subject;
669 unsigned cErrs = 0;
670
671 subject.init(sendRegionUpdate);
672 smlsSetWindowAttributes(pFixture->paAttribsBefore,
673 pFixture->pahWindowsBefore,
674 pFixture->cWindowsBefore,
675 pFixture->papszNamesBefore);
676 smlsSetShapeRectangles(pFixture->hShapeWindowBefore,
677 pFixture->cShapeRectsBefore,
678 pFixture->paShapeRectsBefore);
679 subject.start();
680 smlsSetWindowAttributes(pFixture->paAttribsAfter,
681 pFixture->pahWindowsAfter,
682 pFixture->cWindowsAfter,
683 pFixture->papszNamesAfter);
684 smlsSetShapeRectangles(pFixture->hShapeWindowAfter,
685 pFixture->cShapeRectsAfter,
686 pFixture->paShapeRectsAfter);
687 smlsSetNextEvent(pFixture->x11EventType, pFixture->hEventWindow);
688 if (gotNotification()) /* Initial window tree rebuild */
689 {
690 RTPrintf("%s: fixture: %s. Notification was set before the first event!!!\n",
691 g_pszTestName, pszDesc);
692 ++cErrs;
693 }
694 subject.nextConfigurationEvent();
695 if (!gotNotification())
696 {
697 RTPrintf("%s: fixture: %s. No notification was sent for the initial window tree rebuild.\n",
698 g_pszTestName, pszDesc);
699 ++cErrs;
700 }
701 smlsSetNextEvent(0, 0);
702 subject.nextConfigurationEvent();
703 if (pFixture->fExpectNotification && !gotNotification())
704 {
705 RTPrintf("%s: fixture: %s. No notification was sent after the event.\n",
706 g_pszTestName, pszDesc);
707 ++cErrs;
708 }
709 RTRECT *pRects = subject.getRects();
710 size_t cRects = subject.getRectCount();
711 if (cRects != pFixture->cReportedRects)
712 {
713 RTPrintf("%s: fixture: %s. Wrong number of rectangles reported after processing event (expected %u, got %u).\n",
714 g_pszTestName, pszDesc, pFixture->cReportedRects,
715 cRects);
716 ++cErrs;
717 }
718 else
719 for (unsigned i = 0; i < cRects; ++i)
720 if (!smlsCompRect(&pRects[i], &pFixture->paReportedRects[i]))
721 {
722 RTPrintf("%s: fixture: %s. Rectangle %u wrong after processing event.\n",
723 g_pszTestName, pszDesc, i);
724 smlsPrintDiffRects(&pFixture->paReportedRects[i],
725 &pRects[i]);
726 ++cErrs;
727 break;
728 }
729 subject.stop();
730 subject.start();
731 if (cRects != pFixture->cReportedRects)
732 {
733 RTPrintf("%s: fixture: %s. Wrong number of rectangles reported without processing event (expected %u, got %u).\n",
734 g_pszTestName, pszDesc, pFixture->cReportedRects,
735 cRects);
736 ++cErrs;
737 }
738 else
739 for (unsigned i = 0; i < cRects; ++i)
740 if (!smlsCompRect(&pRects[i], &pFixture->paReportedRects[i]))
741 {
742 RTPrintf("%s: fixture: %s. Rectangle %u wrong without processing event.\n",
743 g_pszTestName, pszDesc, i);
744 smlsPrintDiffRects(&pFixture->paReportedRects[i],
745 &pRects[i]);
746 ++cErrs;
747 break;
748 }
749 return cErrs;
750}
751
752int main(int argc, char **argv)
753{
754 RTR3InitExe(argc, &argv, 0);
755 unsigned cErrs = 0;
756 g_pszTestName = RTPathFilename(argv[0]);
757
758 RTPrintf("%s: TESTING\n", g_pszTestName);
759
760/** @todo r=bird: This testcase is broken and we didn't notice because we
761 * don't run it on the testboxes! @bugref{9842} */
762if (argc == 1)
763{
764 RTPrintf("%s: Note! This testcase is broken, skipping!\n", g_pszTestName);
765 return RTEXITCODE_SUCCESS;
766}
767
768 cErrs += smlsDoFixture(&g_testMove,
769 "ConfigureNotify event (window moved)");
770 // Currently not working
771 cErrs += smlsDoFixture(&g_testResize,
772 "ConfigureNotify event (window resized)");
773 cErrs += smlsDoFixture(&g_testMap, "MapNotify event");
774 cErrs += smlsDoFixture(&g_testUnmap, "UnmapNotify event");
775 cErrs += smlsDoFixture(&g_testUnmapOther,
776 "UnmapNotify event for unmonitored window");
777 cErrs += smlsDoFixture(&g_testShape, "ShapeNotify event");
778 if (cErrs > 0)
779 RTPrintf("%u errors\n", cErrs);
780 return cErrs == 0 ? 0 : 1;
781}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette