Hans Leidekker : wbemprox: Add tests for Win32_Service methods.
Alexandre Julliard
julliard at winehq.org
Wed Oct 17 14:32:27 CDT 2012
Module: wine
Branch: master
Commit: 7879326f8a96541d2b8a63382ed5118cf0b5e552
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7879326f8a96541d2b8a63382ed5118cf0b5e552
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Oct 17 11:08:40 2012 +0200
wbemprox: Add tests for Win32_Service methods.
---
dlls/wbemprox/tests/query.c | 88 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index e531b3c..07e8632 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -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 );
More information about the wine-cvs
mailing list