VirtualBox

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

Last change on this file since 56474 was 55401, checked in by vboxsync, 10 years ago

added a couple of missing Id headers

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