VirtualBox

Ignore:
Timestamp:
Apr 21, 2011 8:26:25 PM (14 years ago)
Author:
vboxsync
Message:

Additions/x11/seamless: extended unit test slightly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp

    r28800 r36802  
    247247}
    248248
     249static int g_SmlsEventType = 0;
     250static Window g_SmlsEventWindow = 0;
     251
    249252/* This should not be needed in the bits of the code we test. */
    250253extern "C" int XNextEvent(Display *display, XEvent *event_return);
    251254int XNextEvent(Display *display, XEvent *event_return)
    252255{
    253     AssertFailedReturn(0);
     256    event_return->xany.type = g_SmlsEventType;
     257    event_return->xany.window = g_SmlsEventWindow;
     258    event_return->xmap.window = g_SmlsEventWindow;
     259    return True;
     260}
     261
     262static void smlsSetNextEvent(int type, Window window)
     263{
     264    g_SmlsEventType = type;
     265    g_SmlsEventWindow = window;
    254266}
    255267
     
    269281    AssertFailedReturn(0);
    270282}
     283
     284/** Dummy observer class */
     285class testObserver: public VBoxGuestSeamlessObserver
     286{
     287    bool mfNotified;
     288public:
     289    testObserver() : mfNotified(false) {}
     290    virtual void notify(void)
     291    {
     292        mfNotified = true;
     293    }
     294    virtual ~testObserver() {}
     295    bool isNotified(void) { return mfNotified; }
     296};
    271297
    272298/*****************************
     
    287313 * windows will be the same whether we start the code before the event and
    288314 * handle it or start the code after the event.
    289  *
    290  * If it is ever needed I could write a small tool to record a fixture on
    291  * a live guest, but I will put that off as long as I can.
    292315 */
    293316struct SMLSFIXTURE
     
    530553{
    531554    VBoxGuestSeamlessX11 subject;
     555    testObserver observer;
    532556    unsigned cErrs = 0;
    533557
    534     subject.init(NULL);
     558    subject.init(&observer);
    535559    smlsSetWindowAttributes(pFixture->paAttribsBefore,
    536560                            pFixture->pahWindowsBefore,
     
    548572                           pFixture->cShapeRectsAfter,
    549573                           pFixture->paShapeRectsAfter);
    550     switch(pFixture->x11EventType)
     574    smlsSetNextEvent(pFixture->x11EventType, pFixture->hEventWindow);
     575    if (observer.isNotified())  /* Initial window tree rebuild */
    551576    {
    552         case ConfigureNotify:
    553             subject.doConfigureEvent(pFixture->hEventWindow);
    554             break;
    555         case MapNotify:
    556             subject.doMapEvent(pFixture->hEventWindow);
    557             break;
    558         case UnmapNotify:
    559             subject.doUnmapEvent(pFixture->hEventWindow);
    560             break;
    561         case VBoxShapeNotify:
    562             subject.doShapeEvent(pFixture->hEventWindow);
    563             break;
    564         default:
    565             break;
     577        RTPrintf("%s: fixture: %s.  Notification was set before the first event!!!\n",
     578                 g_pszTestName, pszDesc);
     579        ++cErrs;
     580    }
     581    subject.nextEvent();
     582    if (!observer.isNotified())
     583    {
     584        RTPrintf("%s: fixture: %s.  No notification was sent for the initial window tree rebuild.\n",
     585                 g_pszTestName, pszDesc);
     586        ++cErrs;
     587    }
     588    smlsSetNextEvent(0, 0);
     589    subject.nextEvent();
     590    if (!observer.isNotified())
     591    {
     592        RTPrintf("%s: fixture: %s.  No notification was sent after the event.\n",
     593                 g_pszTestName, pszDesc);
     594        ++cErrs;
    566595    }
    567596    std::auto_ptr<std::vector<RTRECT> > rects = subject.getRects();
Note: See TracChangeset for help on using the changeset viewer.

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