VirtualBox

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

Last change on this file since 62530 was 62530, checked in by vboxsync, 9 years ago

(C) 2016

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

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