tstUSBProxyLinux.cpp revision 1d7eb4842eb34752cbc8655fc26097b97806314d
/* $Id$ */
/** @file
* USBProxyServiceLinux test case.
*/
/*
* Copyright (C) 2011 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 *
******************************************************************************/
#include "USBProxyService.h"
#include "USBGetDevices.h"
/*** BEGIN STUBS ***/
USBProxyService::~USBProxyService() {}
void USBProxyService::removeFilter(void*) {}
void USBProxyService::serviceThreadInit() {}
void USBProxyService::serviceThreadTerm() {}
void USBProxyService::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines, PUSBDEVICE aUSBDevice) {}
void USBProxyService::deviceChanged(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList*, SessionMachine*) {}
bool USBProxyService::updateDeviceState(HostUSBDevice*, USBDEVICE*, bool*, SessionMachine**) { return true; }
bool USBProxyService::updateDeviceStateFake(HostUSBDevice*, USBDEVICE*, bool*, SessionMachine**) { return true; }
bool USBProxyService::isActive() { return true; }
VBoxMainHotplugWaiter::VBoxMainHotplugWaiter(char const*) {}
{
return Utf8Str();
}
static bool s_fGetDeviceRootPreferSysfs = false;
{
return &s_deviceRoot;
}
static struct
{
const char *pcszDevicesRoot;
bool fUseSysfs;
} s_getDevices;
bool fUseSysfs)
{
return NULL;
}
{
Assert(0);
}
/*** END STUBS ***/
class tstUSBProxyLinux : public USBProxyServiceLinux
{
protected:
virtual int initUsbfs(void) { return VINF_SUCCESS; }
virtual int initSysfs(void) { return VINF_SUCCESS; }
public:
PUSBDEVICE getDevices(void)
{
return USBProxyServiceLinux::getDevices();
}
};
static struct
{
const char *pcszVBOX_USB;
const char *pcszVBOX_USB_ROOT;
const char *pcszReturnedRoot;
bool fReturnedUseSysfs;
bool fRequestedUseSysfs;
const char *pcszFinalRoot;
bool fFinalUseSysfs;
} s_testEnvironment[] =
{
};
/** @note Fiddling with the real environment for this is not nice, in my
* opinion at least. */
{
for (unsigned i = 0; i < RT_ELEMENTS(s_testEnvironment); ++i)
{
if (s_testEnvironment[i].pcszVBOX_USB)
else
RTEnvUnset("VBOX_USB");
if (s_testEnvironment[i].pcszVBOX_USB_ROOT)
RTEnvSet("VBOX_USB_ROOT",
else
RTEnvUnset("VBOX_USB_ROOT");
test.getDevices();
== s_testEnvironment[i].fFinalUseSysfs,
}
}
int main(void)
{
/*
* Init the runtime, test and say hello.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
/*
* Run the tests.
*/
/*
* Summary
*/
return RTTestSummaryAndDestroy(hTest);
}