VirtualBox

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

Last change on this file since 69500 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

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