widl: Generate helper macros for WinRT implementation.
[wine/zf.git] / dlls / wmiutils / tests / path.c
blob0b5473c4d0d1c66a8e7ab5f40746cee083afea82
1 /*
2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include <stdarg.h>
22 #include "windows.h"
23 #include "initguid.h"
24 #include "wmiutils.h"
25 #include "wbemcli.h"
26 #include "wine/test.h"
28 static const WCHAR path1[] = L"";
29 static const WCHAR path2[] = L"\\";
30 static const WCHAR path3[] = L"\\\\server";
31 static const WCHAR path4[] = L"\\\\server\\";
32 static const WCHAR path5[] = L"\\\\.\\";
33 static const WCHAR path6[] = L"//./root/cimv2";
34 static const WCHAR path7[] = L"//./root/cimv2:Win32_OperatingSystem";
35 static const WCHAR path8[] = L"/root/cimv2:Win32_OperatingSystem";
36 static const WCHAR path9[] = L"\\\\.\\root\\cimv2:Win32_OperatingSystem";
37 static const WCHAR path10[] = L"/\\.\\root\\cimv2:Win32_OperatingSystem";
38 static const WCHAR path11[] = L"//.\\root\\cimv2:Win32_OperatingSystem";
39 static const WCHAR path12[] = L"root\\cimv2:Win32_OperatingSystem";
40 static const WCHAR path13[] = L"\\\\.\\root\\cimv2";
41 static const WCHAR path14[] = L"Win32_OperatingSystem";
42 static const WCHAR path15[] = L"root\\cimv2";
43 static const WCHAR path16[] = L"\\\\.\\root\\cimv2";
44 static const WCHAR path17[] = L"\\\\.\\root\\cimv2:Win32_LogicalDisk.DeviceId=\"C:\"";
45 static const WCHAR path18[] = L"\\\\.\\root\\cimv2:Win32_LogicalDisk.DeviceId=\"C:\",DriveType=3";
46 static const WCHAR path19[] = L"\\\\.\\root\\cimv2:Win32_LogicalDisk.DeviceId=";
47 static const WCHAR path20[] = L"\\\\.\\root\\cimv2:Win32_LogicalDisk.DeviceId = \"C:\"";
49 static IWbemPath *create_path(void)
51 HRESULT hr;
52 IWbemPath *path;
54 hr = CoCreateInstance( &CLSID_WbemDefPath, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemPath, (void **)&path );
55 if (hr != S_OK)
57 win_skip( "can't create WbemDefPath instance, skipping tests\n" );
58 return NULL;
60 return path;
63 static void test_IWbemPath_SetText(void)
65 static const struct
67 const WCHAR *path;
68 ULONG mode;
69 HRESULT ret;
70 BOOL todo;
71 } test[] =
73 { path1, 0, WBEM_E_INVALID_PARAMETER },
74 { path1, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
75 { path2, 0, WBEM_E_INVALID_PARAMETER },
76 { path2, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
77 { path3, 0, WBEM_E_INVALID_PARAMETER },
78 { path3, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
79 { path4, 0, WBEM_E_INVALID_PARAMETER },
80 { path4, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
81 { path5, 0, WBEM_E_INVALID_PARAMETER },
82 { path5, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
83 { path6, 0, WBEM_E_INVALID_PARAMETER },
84 { path6, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
85 { path7, 0, WBEM_E_INVALID_PARAMETER },
86 { path7, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
87 { path7, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
88 { path7, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
89 { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE },
90 { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
91 { path8, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
92 { path8, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE },
93 { path8, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
94 { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE },
95 { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
96 { path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
97 { path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE },
98 { path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
99 { path15, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }
101 IWbemPath *path;
102 HRESULT hr;
103 UINT i;
105 if (!(path = create_path())) return;
107 hr = IWbemPath_SetText( path, 0, NULL );
108 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
110 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, NULL );
111 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
113 for (i = 0; i < ARRAY_SIZE(test); i++)
115 hr = IWbemPath_SetText( path, test[i].mode, test[i].path );
116 todo_wine_if (test[i].todo)
117 ok( hr == test[i].ret, "%u got %08x\n", i, hr );
119 if (test[i].ret == S_OK)
121 WCHAR buf[128];
122 ULONG len;
124 memset( buf, 0x55, sizeof(buf) );
125 len = ARRAY_SIZE(buf);
126 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
127 ok( hr == S_OK, "%u got %08x\n", i, hr );
128 ok( !lstrcmpW( buf, test[i].path ), "%u unexpected path %s\n", i, wine_dbgstr_w(buf) );
129 ok( len == lstrlenW( test[i].path ) + 1, "%u unexpected length %u\n", i, len );
132 IWbemPath_Release( path );
135 static void test_IWbemPath_GetText(void)
137 static const WCHAR serviceW[] = L"Win32_Service.Name=\"Service\"";
138 static const WCHAR classW[] = L"Win32_Class";
139 static const WCHAR expected1W[] = L"root\\cimv2:Win32_LogicalDisk.DeviceId=\"C:\"";
140 static const WCHAR expected2W[] = L"Win32_LogicalDisk.DeviceId=\"C:\"";
141 static const WCHAR expected3W[] = L"\\\\.\\root\\cimv2";
142 WCHAR buf[128];
143 ULONG len, count;
144 IWbemPath *path;
145 HRESULT hr;
147 if (!(path = create_path())) return;
149 hr = IWbemPath_GetText( path, 0, NULL, NULL );
150 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
152 len = ARRAY_SIZE(buf);
153 hr = IWbemPath_GetText( path, 0, &len, NULL );
154 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
155 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
157 len = ARRAY_SIZE(buf);
158 memset( buf, 0x55, sizeof(buf) );
159 hr = IWbemPath_GetText( path, 0, &len, buf );
160 ok( hr == S_OK, "got %08x\n", hr );
161 ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
162 ok( len == 1, "unexpected length %u\n", len );
164 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, NULL, NULL );
165 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
167 len = ARRAY_SIZE(buf);
168 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, NULL );
169 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
170 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
172 len = ARRAY_SIZE(buf);
173 memset( buf, 0x55, sizeof(buf) );
174 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
175 ok( hr == S_OK, "got %08x\n", hr );
176 ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
177 ok( len == 1, "unexpected length %u\n", len );
179 len = ARRAY_SIZE(buf);
180 memset( buf, 0x55, sizeof(buf) );
181 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
182 ok( hr == S_OK, "got %08x\n", hr );
183 todo_wine ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
184 todo_wine ok( len == 1, "unexpected length %u\n", len );
186 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path8 );
187 ok( hr == S_OK, "got %08x\n", hr );
189 count = 0xdeadbeef;
190 hr = IWbemPath_GetNamespaceCount( path, &count );
191 ok( hr == S_OK, "got %08x\n", hr );
192 ok( count == 2, "got %u\n", count );
194 len = ARRAY_SIZE(buf);
195 memset( buf, 0x55, sizeof(buf) );
196 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
197 ok( hr == S_OK, "got %08x\n", hr );
198 ok( !lstrcmpW( buf, path9 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
199 ok( len == lstrlenW( path9 ) + 1, "unexpected length %u\n", len );
201 len = ARRAY_SIZE(buf);
202 memset( buf, 0x55, sizeof(buf) );
203 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY, &len, buf );
204 ok( hr == S_OK, "got %08x\n", hr );
205 ok( !lstrcmpW( buf, path13 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
206 ok( len == lstrlenW( path13 ) + 1, "unexpected length %u\n", len );
208 len = ARRAY_SIZE(buf);
209 memset( buf, 0x55, sizeof(buf) );
210 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
211 ok( hr == S_OK, "got %08x\n", hr );
212 ok( !lstrcmpW( buf, path14 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
213 ok( len == lstrlenW( path14 ) + 1, "unexpected length %u\n", len );
215 len = ARRAY_SIZE(buf);
216 memset( buf, 0x55, sizeof(buf) );
217 hr = IWbemPath_GetText( path, WBEMPATH_GET_NAMESPACE_ONLY, &len, buf );
218 ok( hr == S_OK, "got %08x\n", hr );
219 ok( !lstrcmpW( buf, path15 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
220 ok( len == lstrlenW( path15 ) + 1, "unexpected length %u\n", len );
222 len = ARRAY_SIZE(buf);
223 memset( buf, 0x55, sizeof(buf) );
224 hr = IWbemPath_GetText( path, 0, &len, buf );
225 ok( hr == S_OK, "got %08x\n", hr );
226 ok( !lstrcmpW( buf, path12 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
227 ok( len == lstrlenW( path12 ) + 1, "unexpected length %u\n", len );
229 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
230 ok( hr == S_OK, "got %08x\n", hr );
232 count = 0xdeadbeef;
233 hr = IWbemPath_GetNamespaceCount( path, &count );
234 ok( hr == S_OK, "got %08x\n", hr );
235 ok( !count, "got %u\n", count );
237 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path6 );
238 ok( hr == S_OK, "got %08x\n", hr );
240 count = 0xdeadbeef;
241 hr = IWbemPath_GetNamespaceCount( path, &count );
242 ok( hr == S_OK, "got %08x\n", hr );
243 ok( count == 2, "got %u\n", count );
245 len = 0;
246 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, NULL );
247 ok( hr == S_OK, "got %08x\n", hr );
248 ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
250 len = ARRAY_SIZE(buf);
251 memset( buf, 0x55, sizeof(buf) );
252 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
253 ok( hr == S_OK, "got %08x\n", hr );
254 ok( !lstrcmpW( buf, path16 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
255 ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
257 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
258 ok( hr == S_OK, "got %08x\n", hr );
260 len = ARRAY_SIZE(buf);
261 memset( buf, 0x55, sizeof(buf) );
262 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
263 ok( hr == S_OK, "got %08x\n", hr );
264 ok( !lstrcmpW( buf, path17 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
265 ok( len == lstrlenW( path17 ) + 1, "unexpected length %u\n", len );
267 len = ARRAY_SIZE(buf);
268 memset( buf, 0x55, sizeof(buf) );
269 hr = IWbemPath_GetText( path, 0, &len, buf );
270 ok( hr == S_OK, "got %08x\n", hr );
271 ok( !lstrcmpW( buf, expected1W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
272 ok( len == lstrlenW( expected1W ) + 1, "unexpected length %u\n", len );
274 len = ARRAY_SIZE(buf);
275 memset( buf, 0x55, sizeof(buf) );
276 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
277 ok( hr == S_OK, "got %08x\n", hr );
278 ok( !lstrcmpW( buf, expected2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
279 ok( len == lstrlenW( expected2W ) + 1, "unexpected length %u\n", len );
281 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path15 );
282 ok( hr == S_OK, "got %08x\n", hr );
284 len = ARRAY_SIZE(buf);
285 memset( buf, 0x55, sizeof(buf) );
286 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
287 ok( hr == S_OK, "got %08x\n", hr );
288 ok( !lstrcmpW( buf, expected3W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
289 ok( len == lstrlenW( expected3W ) + 1, "unexpected length %u\n", len );
291 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path18 );
292 ok( hr == S_OK, "got %08x\n", hr );
294 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path19 );
295 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
297 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path20 );
298 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
300 IWbemPath_Release( path );
301 if (!(path = create_path())) return;
303 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, serviceW );
304 ok( hr == S_OK, "got %08x\n", hr );
306 len = ARRAY_SIZE(buf);
307 memset( buf, 0x55, sizeof(buf) );
308 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
309 ok( hr == S_OK, "got %08x\n", hr );
310 ok( !lstrcmpW( buf, serviceW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
311 ok( len == lstrlenW( serviceW ) + 1, "unexpected length %u\n", len );
313 IWbemPath_Release( path );
314 if (!(path = create_path())) return;
316 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, classW );
317 ok( hr == S_OK, "got %08x\n", hr );
319 len = ARRAY_SIZE(buf);
320 memset( buf, 0x55, sizeof(buf) );
321 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
322 ok( hr == S_OK, "got %08x\n", hr );
323 ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
324 ok( len == lstrlenW( classW ) + 1, "unexpected length %u\n", len );
326 IWbemPath_Release( path );
329 static void test_IWbemPath_GetClassName(void)
331 static const WCHAR classW[] = L"Win32_LogicalDisk";
332 IWbemPath *path;
333 HRESULT hr;
334 WCHAR buf[32];
335 ULONG len;
337 if (!(path = create_path())) return;
339 hr = IWbemPath_GetClassName( path, NULL, NULL );
340 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
342 len = 0;
343 hr = IWbemPath_GetClassName( path, &len, NULL );
344 ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
346 len = ARRAY_SIZE(buf);
347 hr = IWbemPath_GetClassName( path, &len, buf );
348 ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
350 len = ARRAY_SIZE(buf);
351 hr = IWbemPath_GetClassName( path, &len, NULL );
352 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
353 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
355 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
356 ok( hr == S_OK, "got %08x\n", hr );
358 len = 0;
359 hr = IWbemPath_GetClassName( path, &len, NULL );
360 ok( hr == S_OK, "got %08x\n", hr );
362 len = ARRAY_SIZE(buf);
363 hr = IWbemPath_GetClassName( path, &len, NULL );
364 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
365 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
367 buf[0] = 0;
368 len = ARRAY_SIZE(buf);
369 hr = IWbemPath_GetClassName( path, &len, buf );
370 ok( hr == S_OK, "got %08x\n", hr );
371 ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
372 ok( len == lstrlenW( classW ) + 1, "unexpected length %u\n", len );
374 IWbemPath_Release( path );
377 static void test_IWbemPath_SetClassName(void)
379 static const WCHAR classW[] = L"class";
380 IWbemPath *path;
381 WCHAR buf[16];
382 ULONG len;
383 ULONGLONG flags;
384 HRESULT hr;
386 if (!(path = create_path())) return;
388 hr = IWbemPath_SetClassName( path, NULL );
389 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
391 hr = IWbemPath_SetClassName( path, L"" );
392 ok( hr == S_OK, "got %08x\n", hr );
394 hr = IWbemPath_SetClassName( path, classW );
395 ok( hr == S_OK, "got %08x\n", hr );
397 buf[0] = 0;
398 len = ARRAY_SIZE(buf);
399 hr = IWbemPath_GetClassName( path, &len, buf );
400 ok( hr == S_OK, "got %08x\n", hr );
401 ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
403 flags = 0;
404 hr = IWbemPath_GetInfo( path, 0, &flags );
405 ok( hr == S_OK, "got %08x\n", hr );
406 ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
407 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
408 WBEMPATH_INFO_CIM_COMPLIANT),
409 "got %s\n", wine_dbgstr_longlong(flags) );
411 IWbemPath_Release( path );
414 static void test_IWbemPath_GetServer(void)
416 IWbemPath *path;
417 HRESULT hr;
418 WCHAR buf[32];
419 ULONG len;
421 if (!(path = create_path())) return;
423 hr = IWbemPath_GetServer( path, NULL, NULL );
424 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
426 len = 0;
427 hr = IWbemPath_GetServer( path, &len, NULL );
428 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
430 len = ARRAY_SIZE(buf);
431 hr = IWbemPath_GetServer( path, &len, buf );
432 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
434 len = ARRAY_SIZE(buf);
435 hr = IWbemPath_GetServer( path, &len, NULL );
436 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
437 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
439 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
440 ok( hr == S_OK, "got %08x\n", hr );
442 len = 0;
443 hr = IWbemPath_GetServer( path, &len, NULL );
444 ok( hr == S_OK, "got %08x\n", hr );
446 len = ARRAY_SIZE(buf);
447 hr = IWbemPath_GetServer( path, &len, NULL );
448 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
449 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
451 buf[0] = 0;
452 len = ARRAY_SIZE(buf);
453 hr = IWbemPath_GetServer( path, &len, buf );
454 ok( hr == S_OK, "got %08x\n", hr );
455 ok( !lstrcmpW( buf, L"." ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
456 ok( len == lstrlenW(L"." ) + 1, "unexpected length %u\n", len );
458 IWbemPath_Release( path );
461 static void test_IWbemPath_GetInfo(void)
463 IWbemPath *path;
464 HRESULT hr;
465 ULONGLONG resp;
467 if (!(path = create_path())) return;
469 hr = IWbemPath_GetInfo( path, 0, NULL );
470 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
472 hr = IWbemPath_GetInfo( path, 1, NULL );
473 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
475 resp = 0xdeadbeef;
476 hr = IWbemPath_GetInfo( path, 0, &resp );
477 ok( hr == S_OK, "got %08x\n", hr );
478 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
479 "got %s\n", wine_dbgstr_longlong(resp) );
481 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
482 ok( hr == S_OK, "got %08x\n", hr );
484 hr = IWbemPath_GetInfo( path, 0, NULL );
485 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
487 hr = IWbemPath_GetInfo( path, 1, NULL );
488 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
490 resp = 0xdeadbeef;
491 hr = IWbemPath_GetInfo( path, 0, &resp );
492 ok( hr == S_OK, "got %08x\n", hr );
493 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
494 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
495 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER),
496 "got %s\n", wine_dbgstr_longlong(resp) );
498 IWbemPath_Release( path );
499 if (!(path = create_path())) return;
501 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path12 );
502 ok( hr == S_OK, "got %08x\n", hr );
504 resp = 0xdeadbeef;
505 hr = IWbemPath_GetInfo( path, 0, &resp );
506 ok( hr == S_OK, "got %08x\n", hr );
507 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
508 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
509 WBEMPATH_INFO_CIM_COMPLIANT),
510 "got %s\n", wine_dbgstr_longlong(resp) );
512 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
513 ok( hr == S_OK, "got %08x\n", hr );
515 resp = 0xdeadbeef;
516 hr = IWbemPath_GetInfo( path, 0, &resp );
517 ok( hr == S_OK, "got %08x\n", hr );
518 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
519 "got %s\n", wine_dbgstr_longlong(resp) );
521 IWbemPath_Release( path );
524 static void test_IWbemPath_SetServer(void)
526 IWbemPath *path;
527 WCHAR buf[16];
528 ULONG len;
529 ULONGLONG flags;
530 HRESULT hr;
532 if (!(path = create_path())) return;
534 hr = IWbemPath_SetServer( path, NULL );
535 ok( hr == S_OK, "got %08x\n", hr );
537 len = ARRAY_SIZE(buf);
538 hr = IWbemPath_GetServer( path, &len, buf );
539 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
541 hr = IWbemPath_SetServer( path, L"" );
542 ok( hr == S_OK, "got %08x\n", hr );
544 hr = IWbemPath_SetServer( path, L"server" );
545 ok( hr == S_OK, "got %08x\n", hr );
547 buf[0] = 0;
548 len = ARRAY_SIZE(buf);
549 hr = IWbemPath_GetServer( path, &len, buf );
550 ok( hr == S_OK, "got %08x\n", hr );
551 ok( !lstrcmpW( buf, L"server" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
553 flags = 0;
554 hr = IWbemPath_GetInfo( path, 0, &flags );
555 ok( hr == S_OK, "got %08x\n", hr );
556 ok( flags == (WBEMPATH_INFO_HAS_MACHINE_NAME | WBEMPATH_INFO_V1_COMPLIANT |
557 WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
558 WBEMPATH_INFO_SERVER_NAMESPACE_ONLY | WBEMPATH_INFO_PATH_HAD_SERVER),
559 "got %s\n", wine_dbgstr_longlong(flags) );
561 hr = IWbemPath_SetServer( path, NULL );
562 ok( hr == S_OK, "got %08x\n", hr );
564 len = ARRAY_SIZE(buf);
565 hr = IWbemPath_GetServer( path, &len, buf );
566 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
568 flags = 0;
569 hr = IWbemPath_GetInfo( path, 0, &flags );
570 ok( hr == S_OK, "got %08x\n", hr );
571 ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
572 "got %s\n", wine_dbgstr_longlong(flags) );
574 IWbemPath_Release( path );
577 static void test_IWbemPath_GetNamespaceAt(void)
579 IWbemPath *path;
580 HRESULT hr;
581 WCHAR buf[32];
582 ULONG len;
584 if (!(path = create_path())) return;
586 hr = IWbemPath_GetNamespaceAt( path, 0, NULL, NULL );
587 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
589 len = 0;
590 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
591 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
593 len = ARRAY_SIZE(buf);
594 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
595 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
597 len = ARRAY_SIZE(buf);
598 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
599 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
600 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
602 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
603 ok( hr == S_OK, "got %08x\n", hr );
605 len = 0;
606 hr = IWbemPath_GetNamespaceAt( path, 2, &len, NULL );
607 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
609 len = ARRAY_SIZE(buf);
610 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
611 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
612 ok( len == ARRAY_SIZE(buf), "unexpected length %u\n", len );
614 buf[0] = 0;
615 len = ARRAY_SIZE(buf);
616 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
617 ok( hr == S_OK, "got %08x\n", hr );
618 ok( !lstrcmpW( buf, L"root" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
619 ok( len == lstrlenW( L"root" ) + 1, "unexpected length %u\n", len );
621 buf[0] = 0;
622 len = ARRAY_SIZE(buf);
623 hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
624 ok( hr == S_OK, "got %08x\n", hr );
625 ok( !lstrcmpW( buf, L"cimv2" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
626 ok( len == lstrlenW( L"cimv2" ) + 1, "unexpected length %u\n", len );
628 IWbemPath_Release( path );
631 static void test_IWbemPath_RemoveAllNamespaces(void)
633 static const ULONGLONG expected_flags =
634 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
635 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
636 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
637 IWbemPath *path;
638 WCHAR buf[16];
639 ULONG len;
640 ULONGLONG flags;
641 HRESULT hr;
643 if (!(path = create_path())) return;
645 hr = IWbemPath_RemoveAllNamespaces( path );
646 ok( hr == S_OK, "got %08x\n", hr );
648 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
649 ok( hr == S_OK, "got %08x\n", hr );
651 flags = 0;
652 hr = IWbemPath_GetInfo( path, 0, &flags );
653 ok( hr == S_OK, "got %08x\n", hr );
654 ok( flags == expected_flags,
655 "got %s\n", wine_dbgstr_longlong(flags) );
657 hr = IWbemPath_RemoveAllNamespaces( path );
658 ok( hr == S_OK, "got %08x\n", hr );
660 flags = 0;
661 hr = IWbemPath_GetInfo( path, 0, &flags );
662 ok( hr == S_OK, "got %08x\n", hr );
663 ok( flags == expected_flags,
664 "got %s\n", wine_dbgstr_longlong(flags) );
666 buf[0] = 0;
667 len = ARRAY_SIZE(buf);
668 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
669 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
671 IWbemPath_Release( path );
674 static void test_IWbemPath_RemoveNamespaceAt(void)
676 static const ULONGLONG expected_flags =
677 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
678 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
679 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
680 IWbemPath *path;
681 WCHAR buf[16];
682 ULONG len, count;
683 ULONGLONG flags;
684 HRESULT hr;
686 if (!(path = create_path())) return;
688 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
689 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
691 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
692 ok( hr == S_OK, "got %08x\n", hr );
694 flags = 0;
695 hr = IWbemPath_GetInfo( path, 0, &flags );
696 ok( hr == S_OK, "got %08x\n", hr );
697 ok( flags == expected_flags,
698 "got %s\n", wine_dbgstr_longlong(flags) );
700 count = 0xdeadbeef;
701 hr = IWbemPath_GetNamespaceCount( path, &count );
702 ok( hr == S_OK, "got %08x\n", hr );
703 ok( count == 2, "got %u\n", count );
705 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
706 ok( hr == S_OK, "got %08x\n", hr );
708 flags = 0;
709 hr = IWbemPath_GetInfo( path, 0, &flags );
710 ok( hr == S_OK, "got %08x\n", hr );
711 ok( flags == expected_flags,
712 "got %s\n", wine_dbgstr_longlong(flags) );
714 count = 0xdeadbeef;
715 hr = IWbemPath_GetNamespaceCount( path, &count );
716 ok( hr == S_OK, "got %08x\n", hr );
717 ok( count == 1, "got %u\n", count );
719 buf[0] = 0;
720 len = ARRAY_SIZE(buf);
721 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
722 ok( hr == S_OK, "got %08x\n", hr );
723 ok( !lstrcmpW( buf, L"cimv2" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
724 ok( len == lstrlenW( L"cimv2" ) + 1, "unexpected length %u\n", len );
726 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
727 ok( hr == S_OK, "got %08x\n", hr );
729 flags = 0;
730 hr = IWbemPath_GetInfo( path, 0, &flags );
731 ok( hr == S_OK, "got %08x\n", hr );
732 ok( flags == expected_flags,
733 "got %s\n", wine_dbgstr_longlong(flags) );
735 count = 0xdeadbeef;
736 hr = IWbemPath_GetNamespaceCount( path, &count );
737 ok( hr == S_OK, "got %08x\n", hr );
738 ok( !count, "got %u\n", count );
740 buf[0] = 0;
741 len = ARRAY_SIZE(buf);
742 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
743 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
745 IWbemPath_Release( path );
748 static void test_IWbemPath_SetNamespaceAt(void)
750 static const ULONGLONG expected_flags =
751 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_V1_COMPLIANT |
752 WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
753 WBEMPATH_INFO_SERVER_NAMESPACE_ONLY;
754 IWbemPath *path;
755 WCHAR buf[16];
756 ULONG len, count;
757 ULONGLONG flags;
758 HRESULT hr;
760 if (!(path = create_path())) return;
762 hr = IWbemPath_SetNamespaceAt( path, 0, NULL );
763 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
765 hr = IWbemPath_SetNamespaceAt( path, 1, L"cimv2" );
766 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
768 hr = IWbemPath_SetNamespaceAt( path, 0, L"cimv2" );
769 ok( hr == S_OK, "got %08x\n", hr );
771 count = 0xdeadbeef;
772 hr = IWbemPath_GetNamespaceCount( path, &count );
773 ok( hr == S_OK, "got %08x\n", hr );
774 ok( count == 1, "got %u\n", count );
776 flags = 0;
777 hr = IWbemPath_GetInfo( path, 0, &flags );
778 ok( hr == S_OK, "got %08x\n", hr );
779 ok( flags == expected_flags,
780 "got %s\n", wine_dbgstr_longlong(flags) );
782 buf[0] = 0;
783 len = ARRAY_SIZE(buf);
784 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
785 ok( hr == S_OK, "got %08x\n", hr );
786 ok( !lstrcmpW( buf, L"cimv2" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
787 ok( len == lstrlenW( L"cimv2" ) + 1, "unexpected length %u\n", len );
789 hr = IWbemPath_SetNamespaceAt( path, 0, L"root" );
790 ok( hr == S_OK, "got %08x\n", hr );
792 flags = 0;
793 hr = IWbemPath_GetInfo( path, 0, &flags );
794 ok( hr == S_OK, "got %08x\n", hr );
795 ok( flags == expected_flags,
796 "got %s\n", wine_dbgstr_longlong(flags) );
798 count = 0xdeadbeef;
799 hr = IWbemPath_GetNamespaceCount( path, &count );
800 ok( hr == S_OK, "got %08x\n", hr );
801 ok( count == 2, "got %u\n", count );
803 buf[0] = 0;
804 len = ARRAY_SIZE(buf);
805 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
806 ok( hr == S_OK, "got %08x\n", hr );
807 ok( !lstrcmpW( buf, L"root" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
808 ok( len == lstrlenW( L"root" ) + 1, "unexpected length %u\n", len );
810 buf[0] = 0;
811 len = ARRAY_SIZE(buf);
812 hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
813 ok( hr == S_OK, "got %08x\n", hr );
814 ok( !lstrcmpW( buf, L"cimv2" ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
815 ok( len == lstrlenW( L"cimv2" ) + 1, "unexpected length %u\n", len );
817 IWbemPath_Release( path );
820 START_TEST (path)
822 CoInitialize( NULL );
824 test_IWbemPath_SetText();
825 test_IWbemPath_GetText();
826 test_IWbemPath_GetClassName();
827 test_IWbemPath_SetClassName();
828 test_IWbemPath_GetServer();
829 test_IWbemPath_GetInfo();
830 test_IWbemPath_SetServer();
831 test_IWbemPath_GetNamespaceAt();
832 test_IWbemPath_RemoveAllNamespaces();
833 test_IWbemPath_RemoveNamespaceAt();
834 test_IWbemPath_SetNamespaceAt();
836 CoUninitialize();