VirtualBox

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

Last change on this file since 85924 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.1 KB
Line 
1/* $Id: tstSeamlessX11-auto.cpp 82968 2020-02-04 10:35:17Z 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-2020 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.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
320static void smlsSetNextEvent(int type, Window window)
321{
322 g_SmlsEventType = type;
323 g_SmlsEventWindow = window;
324}
325
326/* This should not be needed in the bits of the code we test. */
327extern "C" Status XSendEvent(Display *display, Window w, Bool propagate,
328 long event_mask, XEvent *event_send);
329Status XSendEvent(Display *display, Window w, Bool propagate,
330 long event_mask, XEvent *event_send)
331{
332 RT_NOREF5(display, w, propagate, event_mask, event_send);
333 Assert(display == TEST_DISPLAY);
334 AssertFailedReturn(0);
335}
336
337/* This should not be needed in the bits of the code we test. */
338extern "C" int XFlush(Display *display);
339int XFlush(Display *display)
340{
341 RT_NOREF1(display);
342 Assert(display == TEST_DISPLAY);
343 AssertFailedReturn(0);
344}
345
346/** Global "received a notification" flag. */
347static bool g_fNotified = false;
348
349/** Dummy host call-back. */
350static void sendRegionUpdate(RTRECT *pRects, size_t cRects)
351{
352 RT_NOREF2(pRects, cRects);
353 g_fNotified = true;
354}
355
356static bool gotNotification(void)
357{
358 if (!g_fNotified)
359 return false;
360 g_fNotified = false;
361 return true;
362}
363
364/*****************************
365* The actual tests to be run *
366*****************************/
367
368/** The name of the unit test */
369static const char *g_pszTestName = NULL;
370
371/*** Test fixture data and data structures ***/
372
373/** A structure describing a test fixture to be run through. Each fixture
374 * describes the state of the windows visible (and unmapped) on the X server
375 * before and after a particular event is delivered, and the expected
376 * on-screen positions of all interesting visible windows at the end of the
377 * fixture as reported by the code (currently in the order it is likely to
378 * report them in, @todo sort this). We expect that the set of visible
379 * windows will be the same whether we start the code before the event and
380 * handle it or start the code after the event.
381 */
382struct SMLSFIXTURE
383{
384 /** The number of windows visible before the event */
385 unsigned cWindowsBefore;
386 /** An array of Window IDs for the visible and unmapped windows before
387 * the event */
388 Window *pahWindowsBefore;
389 /** The window attributes matching the windows in @a paWindowsBefore */
390 XWindowAttributes *paAttribsBefore;
391 /** The window names matching the windows in @a paWindowsBefore */
392 const char **papszNamesBefore;
393 /** The shaped window before the event - we allow at most one of these.
394 * Zero for none. */
395 Window hShapeWindowBefore;
396 /** The number of rectangles in the shaped window before the event. */
397 int cShapeRectsBefore;
398 /** The rectangles in the shaped window before the event */
399 XRectangle *paShapeRectsBefore;
400 /** The number of windows visible after the event */
401 unsigned cWindowsAfter;
402 /** An array of Window IDs for the visible and unmapped windows after
403 * the event */
404 Window *pahWindowsAfter;
405 /** The window attributes matching the windows in @a paWindowsAfter */
406 XWindowAttributes *paAttribsAfter;
407 /** The window names matching the windows in @a paWindowsAfter */
408 const char **papszNamesAfter;
409 /** The shaped window after the event - we allow at most one of these.
410 * Zero for none. */
411 Window hShapeWindowAfter;
412 /** The number of rectangles in the shaped window after the event. */
413 int cShapeRectsAfter;
414 /** The rectangles in the shaped window after the event */
415 XRectangle *paShapeRectsAfter;
416 /** The event to delivered */
417 int x11EventType;
418 /** The window for which the event in @enmEvent is delivered */
419 Window hEventWindow;
420 /** The number of windows expected to be reported at the end of the
421 * fixture */
422 unsigned cReportedRects;
423 /** The onscreen positions of those windows. */
424 RTRECT *paReportedRects;
425 /** Do we expect notification after the event? */
426 bool fExpectNotification;
427};
428
429/*** Test fixture to test the code against X11 configure (move) events ***/
430
431static Window g_ahWin1[] = { 20 };
432static XWindowAttributes g_aAttrib1Before[] =
433{ { 100, 200, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
434};
435static XRectangle g_aRectangle1[] =
436{
437 { 0, 0, 50, 50 },
438 { 50, 50, 150, 250 }
439};
440static XWindowAttributes g_aAttrib1After[] =
441{ { 200, 300, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
442};
443static const char *g_apszNames1[] = { "Test Window" };
444
445AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib1Before));
446AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib1After));
447AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_apszNames1));
448
449static RTRECT g_aRects1[] =
450{
451 { 200, 300, 250, 350 },
452 { 250, 350, 400, 600 }
453};
454
455static SMLSFIXTURE g_testMove =
456{
457 RT_ELEMENTS(g_ahWin1),
458 g_ahWin1,
459 g_aAttrib1Before,
460 g_apszNames1,
461 20,
462 RT_ELEMENTS(g_aRectangle1),
463 g_aRectangle1,
464 RT_ELEMENTS(g_ahWin1),
465 g_ahWin1,
466 g_aAttrib1After,
467 g_apszNames1,
468 20,
469 RT_ELEMENTS(g_aRectangle1),
470 g_aRectangle1,
471 ConfigureNotify,
472 20,
473 RT_ELEMENTS(g_aRects1),
474 g_aRects1,
475 true
476};
477
478/*** Test fixture to test the code against X11 configure (resize) events ***/
479
480static XWindowAttributes g_aAttrib2Before[] =
481{ { 100, 200, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsViewable }
482};
483static XRectangle g_aRectangle2Before[] =
484{
485 { 0, 0, 50, 50 },
486 { 50, 50, 100, 100 }
487};
488
489AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib2Before));
490
491static SMLSFIXTURE g_testResize =
492{
493 RT_ELEMENTS(g_ahWin1),
494 g_ahWin1,
495 g_aAttrib2Before,
496 g_apszNames1,
497 20,
498 RT_ELEMENTS(g_aRectangle2Before),
499 g_aRectangle2Before,
500 RT_ELEMENTS(g_ahWin1),
501 g_ahWin1,
502 g_aAttrib1After,
503 g_apszNames1,
504 20,
505 RT_ELEMENTS(g_aRectangle1),
506 g_aRectangle1,
507 ConfigureNotify,
508 20,
509 RT_ELEMENTS(g_aRects1),
510 g_aRects1,
511 true
512};
513
514/*** Test fixture to test the code against X11 map events ***/
515
516static XWindowAttributes g_aAttrib3Before[] =
517{ { 200, 300, 200, 300, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsUnmapped }
518};
519
520AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib3Before));
521
522static SMLSFIXTURE g_testMap =
523{
524 RT_ELEMENTS(g_ahWin1),
525 g_ahWin1,
526 g_aAttrib3Before,
527 g_apszNames1,
528 20,
529 RT_ELEMENTS(g_aRectangle1),
530 g_aRectangle1,
531 RT_ELEMENTS(g_ahWin1),
532 g_ahWin1,
533 g_aAttrib1After,
534 g_apszNames1,
535 20,
536 RT_ELEMENTS(g_aRectangle1),
537 g_aRectangle1,
538 MapNotify,
539 20,
540 RT_ELEMENTS(g_aRects1),
541 g_aRects1,
542 true
543};
544
545/*** Test fixtures to test the code against X11 unmap events ***/
546
547static XWindowAttributes g_aAttrib4After[] =
548{ { 100, 200, 300, 400, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IsUnmapped }
549};
550
551AssertCompile(RT_ELEMENTS(g_ahWin1) == RT_ELEMENTS(g_aAttrib4After));
552
553static SMLSFIXTURE g_testUnmap =
554{
555 RT_ELEMENTS(g_ahWin1),
556 g_ahWin1,
557 g_aAttrib1Before,
558 g_apszNames1,
559 20,
560 RT_ELEMENTS(g_aRectangle1),
561 g_aRectangle1,
562 RT_ELEMENTS(g_ahWin1),
563 g_ahWin1,
564 g_aAttrib4After,
565 g_apszNames1,
566 20,
567 RT_ELEMENTS(g_aRectangle1),
568 g_aRectangle1,
569 UnmapNotify,
570 20,
571 0,
572 NULL,
573 true
574};
575
576/*** A window we are not monitoring has been unmapped. Nothing should
577 *** happen, especially nothing bad. ***/
578
579static RTRECT g_aRects2[] =
580{
581 { 100, 200, 150, 250 },
582 { 150, 250, 300, 500 }
583};
584
585static SMLSFIXTURE g_testUnmapOther =
586{
587 RT_ELEMENTS(g_ahWin1),
588 g_ahWin1,
589 g_aAttrib1Before,
590 g_apszNames1,
591 20,
592 RT_ELEMENTS(g_aRectangle1),
593 g_aRectangle1,
594 RT_ELEMENTS(g_ahWin1),
595 g_ahWin1,
596 g_aAttrib1Before,
597 g_apszNames1,
598 20,
599 RT_ELEMENTS(g_aRectangle1),
600 g_aRectangle1,
601 UnmapNotify,
602 21,
603 RT_ELEMENTS(g_aRects2),
604 g_aRects2,
605 false
606};
607
608/*** Test fixture to test the code against X11 shape events ***/
609
610static XRectangle g_aRectangle5Before[] =
611{
612 { 0, 0, 200, 200 }
613};
614
615static SMLSFIXTURE g_testShape =
616{
617 RT_ELEMENTS(g_ahWin1),
618 g_ahWin1,
619 g_aAttrib1After,
620 g_apszNames1,
621 20,
622 RT_ELEMENTS(g_aRectangle5Before),
623 g_aRectangle5Before,
624 RT_ELEMENTS(g_ahWin1),
625 g_ahWin1,
626 g_aAttrib1After,
627 g_apszNames1,
628 20,
629 RT_ELEMENTS(g_aRectangle1),
630 g_aRectangle1,
631 VBoxShapeNotify,
632 20,
633 RT_ELEMENTS(g_aRects1),
634 g_aRects1,
635 true
636};
637
638/*** And the test code proper ***/
639
640/** Compare two RTRECT structures */
641static bool smlsCompRect(RTRECT *pFirst, RTRECT *pSecond)
642{
643 return ( (pFirst->xLeft == pSecond->xLeft)
644 && (pFirst->yTop == pSecond->yTop)
645 && (pFirst->xRight == pSecond->xRight)
646 && (pFirst->yBottom == pSecond->yBottom));
647}
648
649static void smlsPrintDiffRects(RTRECT *pExp, RTRECT *pGot)
650{
651 RTPrintf(" Expected: %d, %d, %d, %d. Got: %d, %d, %d, %d\n",
652 pExp->xLeft, pExp->yTop, pExp->xRight, pExp->yBottom,
653 pGot->xLeft, pGot->yTop, pGot->xRight, pGot->yBottom);
654}
655
656/** Run through a test fixture */
657static unsigned smlsDoFixture(SMLSFIXTURE *pFixture, const char *pszDesc)
658{
659 SeamlessX11 subject;
660 unsigned cErrs = 0;
661
662 subject.init(sendRegionUpdate);
663 smlsSetWindowAttributes(pFixture->paAttribsBefore,
664 pFixture->pahWindowsBefore,
665 pFixture->cWindowsBefore,
666 pFixture->papszNamesBefore);
667 smlsSetShapeRectangles(pFixture->hShapeWindowBefore,
668 pFixture->cShapeRectsBefore,
669 pFixture->paShapeRectsBefore);
670 subject.start();
671 smlsSetWindowAttributes(pFixture->paAttribsAfter,
672 pFixture->pahWindowsAfter,
673 pFixture->cWindowsAfter,
674 pFixture->papszNamesAfter);
675 smlsSetShapeRectangles(pFixture->hShapeWindowAfter,
676 pFixture->cShapeRectsAfter,
677 pFixture->paShapeRectsAfter);
678 smlsSetNextEvent(pFixture->x11EventType, pFixture->hEventWindow);
679 if (gotNotification()) /* Initial window tree rebuild */
680 {
681 RTPrintf("%s: fixture: %s. Notification was set before the first event!!!\n",
682 g_pszTestName, pszDesc);
683 ++cErrs;
684 }
685 subject.nextConfigurationEvent();
686 if (!gotNotification())
687 {
688 RTPrintf("%s: fixture: %s. No notification was sent for the initial window tree rebuild.\n",
689 g_pszTestName, pszDesc);
690 ++cErrs;
691 }
692 smlsSetNextEvent(0, 0);
693 subject.nextConfigurationEvent();
694 if (pFixture->fExpectNotification && !gotNotification())
695 {
696 RTPrintf("%s: fixture: %s. No notification was sent after the event.\n",
697 g_pszTestName, pszDesc);
698 ++cErrs;
699 }
700 RTRECT *pRects = subject.getRects();
701 size_t cRects = subject.getRectCount();
702 if (cRects != pFixture->cReportedRects)
703 {
704 RTPrintf("%s: fixture: %s. Wrong number of rectangles reported after processing event (expected %u, got %u).\n",
705 g_pszTestName, pszDesc, pFixture->cReportedRects,
706 cRects);
707 ++cErrs;
708 }
709 else
710 for (unsigned i = 0; i < cRects; ++i)
711 if (!smlsCompRect(&pRects[i], &pFixture->paReportedRects[i]))
712 {
713 RTPrintf("%s: fixture: %s. Rectangle %u wrong after processing event.\n",
714 g_pszTestName, pszDesc, i);
715 smlsPrintDiffRects(&pFixture->paReportedRects[i],
716 &pRects[i]);
717 ++cErrs;
718 break;
719 }
720 subject.stop();
721 subject.start();
722 if (cRects != pFixture->cReportedRects)
723 {
724 RTPrintf("%s: fixture: %s. Wrong number of rectangles reported without processing event (expected %u, got %u).\n",
725 g_pszTestName, pszDesc, pFixture->cReportedRects,
726 cRects);
727 ++cErrs;
728 }
729 else
730 for (unsigned i = 0; i < cRects; ++i)
731 if (!smlsCompRect(&pRects[i], &pFixture->paReportedRects[i]))
732 {
733 RTPrintf("%s: fixture: %s. Rectangle %u wrong without processing event.\n",
734 g_pszTestName, pszDesc, i);
735 smlsPrintDiffRects(&pFixture->paReportedRects[i],
736 &pRects[i]);
737 ++cErrs;
738 break;
739 }
740 return cErrs;
741}
742
743int main( int argc, char **argv)
744{
745 RTR3InitExe(argc, &argv, 0);
746 unsigned cErrs = 0;
747 g_pszTestName = RTPathFilename(argv[0]);
748
749 RTPrintf("%s: TESTING\n", g_pszTestName);
750 cErrs += smlsDoFixture(&g_testMove,
751 "ConfigureNotify event (window moved)");
752 // Currently not working
753 cErrs += smlsDoFixture(&g_testResize,
754 "ConfigureNotify event (window resized)");
755 cErrs += smlsDoFixture(&g_testMap, "MapNotify event");
756 cErrs += smlsDoFixture(&g_testUnmap, "UnmapNotify event");
757 cErrs += smlsDoFixture(&g_testUnmapOther,
758 "UnmapNotify event for unmonitored window");
759 cErrs += smlsDoFixture(&g_testShape, "ShapeNotify event");
760 if (cErrs > 0)
761 RTPrintf("%u errors\n", cErrs);
762 return cErrs == 0 ? 0 : 1;
763}
Note: See TracBrowser for help on using the repository browser.

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