tstMouseImpl.cpp revision a7fa70aa3f4882730fdba02b706acaef5616cbfb
/* $Id$ */
/** @file
* Main unit test - Mouse class.
*/
/*
* Copyright (C) 2011-2013 Oracle Corporation
*
* 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.
*/
/******************************************************************************
* Header Files *
******************************************************************************/
#define IN_VMM_R3 /* Kill most Windows warnings on CFGMR3* implementations. */
#include "MouseImpl.h"
#include "VMMDev.h"
#include "DisplayImpl.h"
#ifndef RT_OS_WINDOWS
#endif
class TestVMMDev : public VMMDevMouseInterface
{
};
class TestDisplay : public DisplayMouseInterface
{
};
class TestConsole : public ConsoleMouseInterface
{
public:
/** @todo why on earth is this not implemented? */
private:
};
{
return VERR_PDM_NO_ATTACHED_DRIVER;
}
static struct PDMDRVHLPR3 pdmHlpR3 =
{
NULL, /* pfnDetach */
NULL, /* pfnDetachSelf */
NULL, /* pfnMountPrepare */
NULL, /* pfnAssertEMT */
NULL, /* pfnAssertOther */
NULL, /* pfnVMSetError */
NULL, /* pfnVMSetErrorV */
NULL, /* pfnVMSetRuntimeError */
NULL, /* pfnVMSetRuntimeErrorV */
NULL, /* pfnVMState */
NULL, /* pfnVMTeleportedAndNotFullyResumedYet */
NULL, /* pfnGetSupDrvSession */
NULL, /* pfnQueueCreate */
NULL, /* pfnTMGetVirtualFreq */
NULL, /* pfnTMGetVirtualTime */
NULL, /* pfnTMTimerCreate */
NULL, /* pfnSSMRegister */
NULL, /* pfnSSMDeregister */
NULL, /* pfnDBGFInfoRegister */
NULL, /* pfnDBGFInfoDeregister */
NULL, /* pfnSTAMRegister */
NULL, /* pfnSTAMRegisterF */
NULL, /* pfnSTAMRegisterV */
NULL, /* pfnSTAMDeregister */
NULL, /* pfnSUPCallVMMR0Ex */
NULL, /* pfnUSBRegisterHub */
NULL, /* pfnSetAsyncNotification */
NULL, /* pfnAsyncNotificationCompleted */
NULL, /* pfnThreadCreate */
NULL, /* pfnAsyncCompletionTemplateCreate */
#ifdef VBOX_WITH_NETSHAPER
NULL, /* pfnNetShaperAttach */
NULL, /* pfnNetShaperDetach */
#endif
NULL, /* pfnLdrGetRCInterfaceSymbols */
NULL, /* pfnLdrGetR0InterfaceSymbols */
NULL, /* pfnCritSectInit */
NULL, /* pfnCallR0 */
NULL, /* pfnFTSetCheckpoint */
NULL, /* pfnBlkCacheRetain */
NULL, /* pfnVMGetSuspendReason */
NULL, /* pfnVMGetResumeReason */
NULL, /* pfnReserved0 */
NULL, /* pfnReserved1 */
NULL, /* pfnReserved2 */
NULL, /* pfnReserved3 */
NULL, /* pfnReserved4 */
NULL, /* pfnReserved5 */
NULL, /* pfnReserved6 */
NULL, /* pfnReserved7 */
NULL, /* pfnReserved8 */
NULL, /* pfnReserved9 */
PDM_DRVHLPR3_VERSION /* u32TheEnd */
};
static struct
{
} mouseEvent;
{
return VINF_SUCCESS;
}
static struct
{
int32_t x;
int32_t y;
{
mouseEventAbs.x = uX;
mouseEventAbs.y = uY;
return VINF_SUCCESS;
}
static struct PDMIMOUSEPORT pdmiMousePort =
{
NULL /* pfnPutEventMT */
};
{
return &pdmiMousePort;
}
{
};
static struct PDMDRVINS pdmdrvInsCore =
{
0, /* iInstance */
NIL_RTRCPTR, /* pHlpRC */
NIL_RTRCPTR, /* pvInstanceDataRC */
NIL_RTR0PTR, /* pHelpR0 */
NIL_RTR0PTR, /* pvInstanceDataR0 */
&pdmHlpR3,
NULL, /* pvInstanceDataR3 */
NIL_RTR3PTR, /* pReg */
NIL_RTR3PTR, /* pCfg */
&pdmiBase,
NULL, /* pDownBase */
{ /* IBase */
NULL /* pfnQueryInterface */
},
0, /* fTracing */
0, /* idTracing */
#if HC_ARCH_BITS == 32
{ 0 }, /* au32Padding */
#endif
{
{ 0 } /* padding */
}, /* Internal */
{ 0 } /* achInstanceData */
};
static struct
{
int32_t x;
int32_t y;
{
absoluteMouse.x = x;
absoluteMouse.y = y;
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
{
if (px1)
*px1 = -320;
if (py1)
*py1 = -240;
if (px2)
*px2 = 320;
if (py2)
*py2 = 240;
}
{
if (pcx)
*pcx = 640;
if (pcy)
*pcy = 480;
if (pcBPP)
*pcBPP = 32;
return S_OK;
}
{
return true;
}
{
return VINF_SUCCESS;
}
/******************************************************************************
* Main test code *
******************************************************************************/
static int setup(void)
{
return VERR_GENERAL_FAILURE;
pConsole = new TestConsole;
return VINF_SUCCESS;
}
static void teardown(void)
{
if (pConsole)
delete pConsole;
if (ppdmdrvIns)
}
{
}
/** @test testAbsToVMMDevNewProtocol */
{
pMouse->PutMouseEventAbsolute(0, 0, 0, 0, 0);
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
}
/** @test testAbsToVMMDevOldProtocol */
{
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
pMouse->PutMouseEventAbsolute(0, 0, 0, 0, 0);
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
("absoluteMouse.x=%d\n", absoluteMouse.x));
("absoluteMouse.y=%d\n", absoluteMouse.y));
}
/** @test testAbsToAbsDev */
{
pMouse->PutMouseEventAbsolute(0, 0, 0, 0, 0);
("mouseEventAbs.x=%d\n", mouseEventAbs.x));
("mouseEventAbs.y=%d\n", mouseEventAbs.y));
("mouseEventAbs.x=%d\n", mouseEventAbs.x));
("mouseEventAbs.y=%d\n", mouseEventAbs.y));
("mouseEventAbs.x=%d\n", mouseEventAbs.x));
("mouseEventAbs.y=%d\n", mouseEventAbs.y));
("mouseEventAbs.x=%d\n", mouseEventAbs.x));
("mouseEventAbs.y=%d\n", mouseEventAbs.y));
}
/** @todo generate this using the @test blocks above */
{
};
int main(void)
{
/*
* Init the runtime, test and say hello.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
/*
* Run the tests.
*/
for (unsigned i = 0; g_tests[i]; ++i)
{
if (RT_SUCCESS(rc))
teardown();
}
/*
* Summary
*/
return RTTestSummaryAndDestroy(hTest);
}