tstMouseImpl.cpp revision 8d0e08b1554426514051150bb804899260631334
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Main unit test - Mouse class.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * Copyright (C) 2011 Oracle Corporation
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * available from http://www.virtualbox.org. This file is free software;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * you can redistribute it and/or modify it under the terms of the GNU
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * General Public License (GPL) as published by the Free Software
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/******************************************************************************
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync* Header Files *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync******************************************************************************/
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync PPDMIVMMDEVPORT getVMMDevPort(void) { return &VMMDevPort; }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync void getFramebufferDimensions(int32_t *px1, int32_t *py1,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int getScreenResolution(uint32_t cScreen, ULONG *pcx, ULONG *pcy,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync VMMDevMouseInterface *getVMMDevMouseInterface() { return &mVMMDev; }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync DisplayMouseInterface *getDisplayMouseInterface() { return &mDisplay; }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** @todo why on earth is this not implemented? */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncstatic int pdmdrvhlpAttach(PPDMDRVINS pDrvIns, uint32_t fFlags,
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncstatic struct
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncstatic int mousePutEvent(PPDMIMOUSEPORT pInterface, int32_t iDeltaX,
d200be7337d4aad2bec2961a885e856f7866d4f6vboxsyncstatic struct
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int mousePutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t uX,
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsyncstatic void *pdmiBaseQuery(struct PDMIBASE *pInterface, const char *pszIID)
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsyncstatic struct
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsyncstatic int setAbsoluteMouse(PPDMIVMMDEVPORT, int32_t x, int32_t y)
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsyncstatic int updateMouseCapabilities(PPDMIVMMDEVPORT, uint32_t, uint32_t)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncvoid TestDisplay::getFramebufferDimensions(int32_t *px1, int32_t *py1,
d7dbbf62e47482dad97a2d17ae567e879b5d57b6vboxsyncint TestDisplay::getScreenResolution(uint32_t cScreen, ULONGt *pcx,
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsyncDECLEXPORT(bool) CFGMR3AreValuesValid(PCFGMNODE, const char *)
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync return true;
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsyncDECLEXPORT(int) CFGMR3QueryPtr(PCFGMNODE, const char *, void **pv)
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsync/******************************************************************************
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync* Main test code *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync******************************************************************************/
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic int setup(void)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync VMMDevPort.pfnUpdateMouseCapabilities = updateMouseCapabilities;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync ppdmdrvIns = (struct PDMDRVINS *) RTMemAllocZ( sizeof(struct PDMDRVINS)
e12084fc5287a5fa65e3a28bbeb05af29c22dad7vboxsyncstatic void teardown(void)
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/** @test testAbsToVMMDevNewProtocol */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncstatic void testAbsToVMMDevNewProtocol(RTTEST hTest)
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTestSub(hTest, "Absolute event to VMMDev, new protocol");
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector = (PPDMIMOUSECONNECTOR)pBase->pfnQueryInterface(pBase,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector->pfnReportModes(pConnector, true, false, false);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->onVMMDevGuestCapsChange( VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->PutMouseEventAbsolute(-319, -239, 0, 0, 0);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, 0xffff, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, 0xffff, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/** @test testAbsToVMMDevOldProtocol */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsyncstatic void testAbsToVMMDevOldProtocol(RTTEST hTest)
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTestSub(hTest, "Absolute event to VMMDev, old protocol");
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector = (PPDMIMOUSECONNECTOR)pBase->pfnQueryInterface(pBase,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector->pfnReportModes(pConnector, true, false, false);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->onVMMDevGuestCapsChange(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->PutMouseEventAbsolute(-319, -239, 0, 0, 0);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.x, -0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(absoluteMouse.y, -0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync/** @test testAbsToAbsDev */
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTestSub(hTest, "Absolute event to absolute device");
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector = (PPDMIMOUSECONNECTOR)pBase->pfnQueryInterface(pBase,
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pConnector->pfnReportModes(pConnector, false, true, false);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->onVMMDevGuestCapsChange( VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.x, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.y, 0x8000, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->PutMouseEventAbsolute(-319, -239, 0, 0, 0);
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.x, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.y, 0, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.x, 0xffff, 200),
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync RTTESTI_CHECK_MSG(approxEq(mouseEventAbs.y, 0xffff, 200),
ba6cd8af51db6aeff784fd6d73cadaf13ec45996vboxsync pMouse->PutMouseEventAbsolute(-640, -480, 0, 0, 0);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync/** @todo generate this using the @test blocks above */
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Init the runtime, test and say hello.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync RTEXITCODE rcExit = RTTestInitAndCreate("tstMouseImpl", &hTest);
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync * Run the tests.
8f5b7f9f15a5da4efe1115e1be6df372cc1d1818vboxsync for (unsigned i = 0; g_tests[i]; ++i)