[WBEMDISP_WINETEST] Sync with Wine Staging 2.9. CORE-13362
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 4 Jun 2017 01:47:40 +0000 (01:47 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 4 Jun 2017 01:47:40 +0000 (01:47 +0000)
svn path=/trunk/; revision=74858

rostests/winetests/wbemdisp/wbemdisp.c

index 3cc4c86..0c426c5 100644 (file)
 #include "initguid.h"
 #include "objidl.h"
 #include "wbemdisp.h"
+#include "wbemcli.h"
 #include "wine/test.h"
 
 DEFINE_GUID(CLSID_WINMGMTS,0x172bddf8,0xceea,0x11d1,0x8b,0x05,0x00,0x60,0x08,0x06,0xd9,0xb6);
 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
 
+static const LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
+
 static void test_ParseDisplayName(void)
 {
     static const WCHAR biosW[] = {'W','i','n','3','2','_','B','i','o','s',0};
@@ -58,7 +61,6 @@ static void test_ParseDisplayName(void)
         { name3, S_OK, &IID_ISWbemObject, sizeof(name3)/sizeof(name3[0]) - 1 },
         { name4, S_OK, &IID_ISWbemObject, sizeof(name4)/sizeof(name4[0]) - 1 }
     };
-    LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
     IParseDisplayName *displayname;
     IBindCtx *ctx;
     IMoniker *moniker;
@@ -243,15 +245,86 @@ static void test_ParseDisplayName(void)
     IParseDisplayName_Release( displayname );
 }
 
+static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
+static const WCHAR root[] = {'r','o','o','t','\\','C','I','M','V','2',0};
+static const WCHAR query[] = {'S','e','l','e','c','t',' ','P','r','o','c','e','s','s','o','r','I','d',' ','f','r','o','m',
+                              ' ','W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
+static const WCHAR lang[] = {'W','Q','L',0};
+static const WCHAR props[] = {'P','r','o','p','e','r','t','i','e','s','_',0};
+static const WCHAR procid[] = {'P','r','o','c','e','s','s','o','r','I','d',0};
+
 static void test_locator(void)
 {
-    IUnknown *locator;
     HRESULT hr;
+    DISPID id;
+    BSTR host_bstr, root_bstr, query_bstr, lang_bstr, props_bstr, procid_bstr;
+    ISWbemLocator *locator;
+    ISWbemServices *services;
+    ISWbemObjectSet *object_set;
+    IEnumVARIANT *enum_var;
+    ISWbemObject *object;
+    ISWbemPropertySet *prop_set;
+    ISWbemProperty *prop;
+    VARIANT var;
+
+    hr = CoCreateInstance( &CLSID_SWbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_ISWbemLocator, (void **)&locator );
+    ok( hr == S_OK, "got %x\n", hr );
+
+    host_bstr = SysAllocString(localhost);
+    root_bstr = SysAllocString(root);
+    hr = ISWbemLocator_ConnectServer( locator, host_bstr, root_bstr, NULL, NULL, NULL, NULL, 0, NULL, &services);
+    ok( hr == S_OK, "got %x\n", hr );
+    SysFreeString( root_bstr );
+    SysFreeString( host_bstr );
+
+    query_bstr = SysAllocString(query);
+    lang_bstr = SysAllocString(lang);
+    hr = ISWbemServices_ExecQuery( services, query_bstr, lang_bstr, wbemFlagForwardOnly, NULL, &object_set);
+    ok( hr == S_OK, "got %x\n", hr );
+    SysFreeString( lang_bstr );
+    SysFreeString( query_bstr );
+
+    hr = ISWbemObjectSet_get__NewEnum( object_set, (IUnknown**)&enum_var );
+    ok( hr == S_OK, "got %x\n", hr );
+
+    VariantInit( &var );
+    hr = IEnumVARIANT_Next( enum_var, 1, &var, NULL );
+    ok( hr == S_OK, "got %x\n", hr );
+    ok( V_VT(&var) == VT_DISPATCH, "got %x\n", V_VT(&var));
+
+    props_bstr = SysAllocString( props );
+    hr = IDispatch_GetIDsOfNames( V_DISPATCH(&var), &IID_NULL, &props_bstr, 1, english, &id );
+    ok( hr == S_OK, "got %x\n", hr );
+    ok( id == 21, "got %d\n", id );
+
+    hr = IDispatch_QueryInterface( V_DISPATCH(&var), &IID_ISWbemObject, (void**)&object );
+    ok( hr == S_OK, "got %x\n", hr );
+    VariantClear( &var );
+
+    hr = ISWbemObject_get_Properties_( object, &prop_set );
+    ok( hr == S_OK, "got %x\n", hr );
+
+    hr = ISWbemPropertySet_Item( prop_set, props_bstr, 0, &prop );
+    ok( hr == WBEM_E_NOT_FOUND, "got %x\n", hr );
+    SysFreeString( props_bstr );
+
+    procid_bstr = SysAllocString( procid );
+    hr = ISWbemPropertySet_Item( prop_set, procid_bstr, 0, &prop );
+    ok( hr == S_OK, "got %x\n", hr );
+    SysFreeString( procid_bstr );
 
-    hr = CoCreateInstance( &CLSID_SWbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&locator );
+    hr = ISWbemProperty_get_Value( prop, &var );
     ok( hr == S_OK, "got %x\n", hr );
+    ok( V_VT(&var) == VT_BSTR, "got %x\n", V_VT(&var) );
+    VariantClear( &var );
 
-    IUnknown_Release( locator );
+    ISWbemProperty_Release( prop );
+    ISWbemPropertySet_Release( prop_set );
+    ISWbemObject_Release( object );
+    IEnumVARIANT_Release( enum_var );
+    ISWbemObjectSet_Release( object_set );
+    ISWbemServices_Release( services );
+    ISWbemLocator_Release( locator );
 }
 
 START_TEST(wbemdisp)