tstSeamlessX11.cpp revision bd8e360cd1db83dcb2694ea9122ce3bc5bae678a
/** @file
* Linux seamless guest additions unit tests.
*/
/*
* Copyright (C) 2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/** Uncomment this to get logging which shows the flow of data received and the
Xlib calls executed. */
// #define LOG_OUTPUT
#include <iostream>
#include <memory>
#include <vector>
/* We want access to the elements of struct Display */
#define XLIB_ILLEGAL_ACCESS
#include "../seamless-guest.h"
/*****************************************************************************
* Defines and macros *
*****************************************************************************/
#define TEST_MAX_WINDOWS 7
/*****************************************************************************
* Event sequence functions *
*****************************************************************************/
/** X11 events to be sent to the testcase. */
/* Move window 3. */
static XConfigureEvent testConfig1 =
/* Map window 6. */
/* Reshape window 4. */
static XShapeEvent testShape1 =
{ { 20, 20, 40, 50 }, { 60, 40, 30, 30 }, { 0, 0, 0, 0} };
/* Unmap window 3. */
static XMapEvent testUnmap1 =
/* Unmap our desktop window. */
static XMapEvent testUnmap2 =
/* And map it again. */
/* Remove the desktop window (what should happen here?) */
static XPropertyEvent testProperty1 =
/* And put the desktop window back again. */
static XPropertyEvent testProperty2 =
{
{ (XEvent *) &testConfig1, 0, 0 },
{ (XEvent *) &testUnmap1, 0, 0 },
{ (XEvent *) &testUnmap2, 0, 0 },
{}
};
static unsigned iEvent = 0;
/** Does this window currently exist? Indexed by window ID. */
static bool aWindowList[TEST_MAX_WINDOWS] = { false, true, true, true, true, true, false };
/** Window attributes of windows created during the test */
{
{ 0 },
};
/** Visible rectangles for the child windows */
{
{ 10, 10, 110, 110 },
{ 60, 70, 160, 170 },
{ 90, 90, 190, 140 },
{ 0, 0, 0, 0 }
};
{
{ 50, 50, 150, 150 },
{ 60, 70, 160, 170 },
{ 90, 90, 190, 140 },
{ 0, 0, 0, 0 }
};
{
{ 50, 50, 150, 150 },
{ 60, 70, 160, 170 },
{ 90, 90, 190, 140 },
{ 200, 200, 210, 210 },
{ 0, 0, 0, 0 }
};
{
{ 50, 50, 150, 150 },
{ 70, 70, 110, 120 },
{ 110, 90, 140, 120 },
{ 90, 90, 190, 140 },
{ 200, 200, 210, 210 },
{ 0, 0, 0, 0 }
};
{
{ 70, 70, 110, 120 },
{ 110, 90, 140, 120 },
{ 90, 90, 190, 140 },
{ 200, 200, 210, 210 },
{ 0, 0, 0, 0 }
};
{
{ 0, 0, 0, 0 }
};
{
{ 0, 0, 640, 480 },
{ 0, 0, 0, 0 }
};
static RTRECT *testOutput[] =
static unsigned iOutput = 0;
/*****************************************************************************
* Event sequence functions *
*****************************************************************************/
static bool eventsLeft(void)
{
#ifdef LOG_OUTPUT
#endif
}
/*****************************************************************************
* X11 function emulation *
*****************************************************************************/
/** Return a static display object. */
{
#ifdef LOG_OUTPUT
#endif
return &gsDisplay;
}
/** Empty stub. */
/** No need to free data in a short testcase. */
/** Empty stub. */
/** Return the rectangle information from our array. */
int *priOrdering)
{
int i;
#ifdef LOG_OUTPUT
#endif
/* We have allocated rectangle information to all windows which need to be queried! */
CPPUNIT_ASSERT(0 != aRects[w]);
for (
i = 0;
(0 != aRects[w][i].x)
|| (0 != aRects[w][i].y)
++i
);
*priCount = i;
*priOrdering = 0;
return aRects[w];
}
/** Just check inputs. */
{
#ifdef LOG_OUTPUT
#endif
)
);
return true;
}
/** Empty stub. */
/** Return our hard-coded window attributes. */
{
#ifdef LOG_OUTPUT
#endif
*pAttrib = aWindowAttrib[w];
return true;
}
/** We only have one atom - _NET_VIRTUAL_ROOTS - equal to 1. */
{
#ifdef LOG_OUTPUT
#endif
return TEST_ROOT_ATOM;
}
/** The only property currently available is _NET_VIRTUAL_ROOTS_ on the root window. */
unsigned char **pProp)
{
int i;
#ifdef LOG_OUTPUT
#endif
for (i = 0; gDesktopWindows[i] != 0; ++i);
*nItems = i;
*pProp = (unsigned char *) gDesktopWindows;
return Success;
}
/** Works for the desktop window, asserts for all others. */
{
int cChildren = 0;
#ifdef LOG_OUTPUT
#endif
/* We only have information available for the desktop window. */
if (TEST_ROOT == w)
{
cChildren = 1;
}
else /* TEST_DESKTOP_WINDOW */
{
/* 0 is unused, 1 is root, 2 is desktop. */
for (int i = 3; i < TEST_MAX_WINDOWS; ++i)
{
if (aWindowList[i])
{
ahChildren[cChildren] = i;
++cChildren;
}
}
}
*prnChildren = cChildren;
return true;
}
/** Process and send out the next X11 event from our queue as long as it is not empty. */
{
#ifdef LOG_OUTPUT
#endif
{
{
case ConfigureNotify:
break;
case MapNotify:
break;
case PropertyNotify:
break;
case ShapeNotify:
break;
case UnmapNotify:
break;
default:
/* So far we don't actually change the property in a PropertyNotify event. */
CPPUNIT_FAIL("Unhandled event");
break;
}
++iEvent;
}
else
{
}
return true;
}
/** Return "supported". */
/*****************************************************************************
* Test classes *
*****************************************************************************/
/**
* Observer class for the guest test fixture
*/
class VBoxSeamlessX11TestObserver : public VBoxGuestSeamlessObserver
{
private:
public:
/** This is the notification function that is called by the class when new rectangle
data is available. We compare the data sent with what we were expecting. */
virtual void notify(void)
{
#ifdef LOG_OUTPUT
#endif
int i = 0;
{
#ifdef LOG_OUTPUT
#endif
}
++iOutput;
}
};
/**
* Test fixture for guest proxy class
*/
{
CPPUNIT_TEST( testX11 );
private:
public:
void setUp()
{
mX11 = new VBoxGuestSeamlessX11;
}
void tearDown()
{
delete mObserver;
delete mX11;
}
void testX11()
{
while (eventsLeft())
{
}
/* Make sure we get notification from the last event. */
}
};
// Create text test runner and run all tests.
{
}