Commit 7879326f authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Add tests for Win32_Service methods.

parent d5cbcc1e
......@@ -125,6 +125,93 @@ static void test_select( IWbemServices *services )
SysFreeString( query );
}
static void test_Win32_Service( IWbemServices *services )
{
static const WCHAR returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
static const WCHAR pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
static const WCHAR resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
static const WCHAR startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
static const WCHAR stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
static const WCHAR stateW[] = {'S','t','a','t','e',0};
static const WCHAR stoppedW[] = {'S','t','o','p','p','e','d',0};
static const WCHAR serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e','.',
'N','a','m','e','=','"','S','p','o','o','l','e','r','"',0};
BSTR class = SysAllocString( serviceW ), method;
IWbemClassObject *service, *out;
VARIANT state, retval;
CIMTYPE type;
HRESULT hr;
hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
if (hr != S_OK)
{
win_skip( "Win32_Service not available\n" );
return;
}
type = 0xdeadbeef;
VariantInit( &state );
hr = IWbemClassObject_Get( service, stateW, 0, &state, &type, NULL );
ok( hr == S_OK, "failed to get service state %08x\n", hr );
ok( V_VT( &state ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &state ) );
ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
if (!lstrcmpW( V_BSTR( &state ), stoppedW ))
{
out = NULL;
method = SysAllocString( startserviceW );
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
ok( hr == S_OK, "failed to execute method %08x\n", hr );
SysFreeString( method );
VariantInit( &retval );
hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, NULL, NULL );
ok( hr == S_OK, "failed to get return value %08x\n", hr );
ok( !V_I4( &retval ), "unexpected error %u\n", V_UI4( &retval ) );
IWbemClassObject_Release( out );
}
out = NULL;
method = SysAllocString( pauseserviceW );
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
ok( hr == S_OK, "failed to execute method %08x\n", hr );
SysFreeString( method );
VariantInit( &retval );
hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, NULL, NULL );
ok( hr == S_OK, "failed to get return value %08x\n", hr );
ok( V_I4( &retval ), "unexpected success\n" );
IWbemClassObject_Release( out );
out = NULL;
method = SysAllocString( resumeserviceW );
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
ok( hr == S_OK, "failed to execute method %08x\n", hr );
SysFreeString( method );
VariantInit( &retval );
hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, NULL, NULL );
ok( hr == S_OK, "failed to get return value %08x\n", hr );
ok( V_I4( &retval ), "unexpected success\n" );
IWbemClassObject_Release( out );
if (!lstrcmpW( V_BSTR( &state ), stoppedW ))
{
out = NULL;
method = SysAllocString( stopserviceW );
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
ok( hr == S_OK, "failed to execute method %08x\n", hr );
SysFreeString( method );
VariantInit( &retval );
hr = IWbemClassObject_Get( out, returnvalueW, 0, &retval, NULL, NULL );
ok( hr == S_OK, "failed to get return value %08x\n", hr );
ok( !V_I4( &retval ), "unexpected error %u\n", V_UI4( &retval ) );
IWbemClassObject_Release( out );
}
VariantClear( &state );
IWbemClassObject_Release( service );
SysFreeString( class );
}
static void test_StdRegProv( IWbemServices *services )
{
static const WCHAR enumkeyW[] = {'E','n','u','m','K','e','y',0};
......@@ -327,6 +414,7 @@ START_TEST(query)
ok( hr == S_OK, "failed to set proxy blanket %08x\n", hr );
test_select( services );
test_Win32_Service( services );
test_StdRegProv( services );
SysFreeString( path );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment