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
26 #include "wine/test.h"
28 static const WCHAR path1[] = {0};
29 static const WCHAR path2[] = {'\\',0};
30 static const WCHAR path3[] = {'\\','\\','s','e','r','v','e','r',0};
31 static const WCHAR path4[] = {'\\','\\','s','e','r','v','e','r','\\',0};
32 static const WCHAR path5[] = {'\\','\\','.','\\',0};
33 static const WCHAR path6[] = {'/','/','.','/','r','o','o','t','/','c','i','m','v','2',0};
34 static const WCHAR path7[] =
35 {'/','/','.','/','r','o','o','t','/','c','i','m','v','2',':','W','i','n','3','2','_',
36 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
37 static const WCHAR path8[] =
38 {'/','r','o','o','t','/','c','i','m','v','2',':','W','i','n','3','2','_',
39 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
40 static const WCHAR path9[] =
41 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
42 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
43 static const WCHAR path10[] =
44 {'/','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
45 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
46 static const WCHAR path11[] =
47 {'/','/','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
48 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
49 static const WCHAR path12[] =
50 {'r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
51 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
52 static const WCHAR path13[] =
53 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
54 static const WCHAR path14[] =
55 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
56 static const WCHAR path15[] =
57 {'r','o','o','t','\\','c','i','m','v','2',0};
58 static const WCHAR path16[] =
59 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
60 static const WCHAR path17[] =
61 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
62 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
64 static const WCHAR path18[] =
65 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
66 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
67 '"','C',':','"',',','D','r','i','v','e','T','y','p','e','=','3',0};
68 static const WCHAR path19[] =
69 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
70 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',0};
71 static const WCHAR path20[] =
72 {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
73 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d',' ','=',' ',
76 static IWbemPath *create_path(void)
81 hr = CoCreateInstance( &CLSID_WbemDefPath, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemPath, (void **)&path );
84 win_skip( "can't create WbemDefPath instance, skipping tests\n" );
90 static void test_IWbemPath_SetText(void)
100 { path1, 0, WBEM_E_INVALID_PARAMETER },
101 { path1, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
102 { path2, 0, WBEM_E_INVALID_PARAMETER },
103 { path2, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
104 { path3, 0, WBEM_E_INVALID_PARAMETER },
105 { path3, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
106 { path4, 0, WBEM_E_INVALID_PARAMETER },
107 { path4, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
108 { path5, 0, WBEM_E_INVALID_PARAMETER },
109 { path5, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
110 { path6, 0, WBEM_E_INVALID_PARAMETER },
111 { path6, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
112 { path7, 0, WBEM_E_INVALID_PARAMETER },
113 { path7, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
114 { path7, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
115 { path7, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
116 { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, 1 },
117 { path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
118 { path8, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
119 { path8, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, 1 },
120 { path8, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
121 { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, 1 },
122 { path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
123 { path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
124 { path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, 1 },
125 { path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK }
131 if (!(path = create_path())) return;
133 hr = IWbemPath_SetText( path, 0, NULL );
134 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
136 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, NULL );
137 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
139 for (i = 0; i < sizeof(test)/sizeof(test[0]); i++)
141 hr = IWbemPath_SetText( path, test[i].mode, test[i].path );
142 if (test[i].todo) todo_wine ok( hr == test[i].ret, "%u got %08x\n", i, hr );
143 else ok( hr == test[i].ret, "%u got %08x\n", i, hr );
145 if (test[i].ret == S_OK)
150 memset( buf, 0x55, sizeof(buf) );
151 len = sizeof(buf)/sizeof(buf[0]);
152 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
153 ok( hr == S_OK, "%u got %08x\n", i, hr );
154 ok( !lstrcmpW( buf, test[i].path ), "%u unexpected path %s\n", i, wine_dbgstr_w(buf) );
155 ok( len == lstrlenW( test[i].path ) + 1, "%u unexpected length %u\n", i, len );
158 IWbemPath_Release( path );
161 static void test_IWbemPath_GetText(void)
163 static const WCHAR expected1W[] =
164 {'r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
165 'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
167 static const WCHAR expected2W[] =
168 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.',
169 'D','e','v','i','c','e','I','d','=','"','C',':','"',0};
175 if (!(path = create_path())) return;
177 hr = IWbemPath_GetText( path, 0, NULL, NULL );
178 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
180 len = sizeof(buf)/sizeof(buf[0]);
181 hr = IWbemPath_GetText( path, 0, &len, NULL );
182 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
183 ok( len == sizeof(buf)/sizeof(buf[0]), "unexpected length %u\n", len );
185 len = sizeof(buf)/sizeof(buf[0]);
186 memset( buf, 0x55, sizeof(buf) );
187 hr = IWbemPath_GetText( path, 0, &len, buf );
188 ok( hr == S_OK, "got %08x\n", hr );
189 ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
190 ok( len == 1, "unexpected length %u\n", len );
192 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, NULL, NULL );
193 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
195 len = sizeof(buf)/sizeof(buf[0]);
196 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, NULL );
197 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
198 ok( len == sizeof(buf)/sizeof(buf[0]), "unexpected length %u\n", len );
200 len = sizeof(buf)/sizeof(buf[0]);
201 memset( buf, 0x55, sizeof(buf) );
202 hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
203 ok( hr == S_OK, "got %08x\n", hr );
204 ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
205 ok( len == 1, "unexpected length %u\n", len );
207 len = sizeof(buf)/sizeof(buf[0]);
208 memset( buf, 0x55, sizeof(buf) );
209 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
210 ok( hr == S_OK, "got %08x\n", hr );
211 todo_wine ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
212 todo_wine ok( len == 1, "unexpected length %u\n", len );
214 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path8 );
215 ok( hr == S_OK, "got %08x\n", hr );
218 hr = IWbemPath_GetNamespaceCount( path, &count );
219 ok( hr == S_OK, "got %08x\n", hr );
220 ok( count == 2, "got %u\n", count );
222 len = sizeof(buf)/sizeof(buf[0]);
223 memset( buf, 0x55, sizeof(buf) );
224 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
225 ok( hr == S_OK, "got %08x\n", hr );
226 ok( !lstrcmpW( buf, path9 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
227 ok( len == lstrlenW( path9 ) + 1, "unexpected length %u\n", len );
229 len = sizeof(buf)/sizeof(buf[0]);
230 memset( buf, 0x55, sizeof(buf) );
231 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY, &len, buf );
232 ok( hr == S_OK, "got %08x\n", hr );
233 ok( !lstrcmpW( buf, path13 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
234 ok( len == lstrlenW( path13 ) + 1, "unexpected length %u\n", len );
236 len = sizeof(buf)/sizeof(buf[0]);
237 memset( buf, 0x55, sizeof(buf) );
238 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
239 ok( hr == S_OK, "got %08x\n", hr );
240 ok( !lstrcmpW( buf, path14 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
241 ok( len == lstrlenW( path14 ) + 1, "unexpected length %u\n", len );
243 len = sizeof(buf)/sizeof(buf[0]);
244 memset( buf, 0x55, sizeof(buf) );
245 hr = IWbemPath_GetText( path, WBEMPATH_GET_NAMESPACE_ONLY, &len, buf );
246 ok( hr == S_OK, "got %08x\n", hr );
247 ok( !lstrcmpW( buf, path15 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
248 ok( len == lstrlenW( path15 ) + 1, "unexpected length %u\n", len );
250 len = sizeof(buf)/sizeof(buf[0]);
251 memset( buf, 0x55, sizeof(buf) );
252 hr = IWbemPath_GetText( path, 0, &len, buf );
253 ok( hr == S_OK, "got %08x\n", hr );
254 ok( !lstrcmpW( buf, path12 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
255 ok( len == lstrlenW( path12 ) + 1, "unexpected length %u\n", len );
257 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
258 ok( hr == S_OK, "got %08x\n", hr );
261 hr = IWbemPath_GetNamespaceCount( path, &count );
262 ok( hr == S_OK, "got %08x\n", hr );
263 ok( !count, "got %u\n", count );
265 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path6 );
266 ok( hr == S_OK, "got %08x\n", hr );
269 hr = IWbemPath_GetNamespaceCount( path, &count );
270 ok( hr == S_OK, "got %08x\n", hr );
271 ok( count == 2, "got %u\n", count );
274 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, NULL );
275 ok( hr == S_OK, "got %08x\n", hr );
276 ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
278 len = sizeof(buf)/sizeof(buf[0]);
279 memset( buf, 0x55, sizeof(buf) );
280 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
281 ok( hr == S_OK, "got %08x\n", hr );
282 ok( !lstrcmpW( buf, path16 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
283 ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
285 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
286 ok( hr == S_OK, "got %08x\n", hr );
288 len = sizeof(buf)/sizeof(buf[0]);
289 memset( buf, 0x55, sizeof(buf) );
290 hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
291 ok( hr == S_OK, "got %08x\n", hr );
292 ok( !lstrcmpW( buf, path17 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
293 ok( len == lstrlenW( path17 ) + 1, "unexpected length %u\n", len );
295 len = sizeof(buf)/sizeof(buf[0]);
296 memset( buf, 0x55, sizeof(buf) );
297 hr = IWbemPath_GetText( path, 0, &len, buf );
298 ok( hr == S_OK, "got %08x\n", hr );
299 ok( !lstrcmpW( buf, expected1W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
300 ok( len == lstrlenW( expected1W ) + 1, "unexpected length %u\n", len );
302 len = sizeof(buf)/sizeof(buf[0]);
303 memset( buf, 0x55, sizeof(buf) );
304 hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
305 ok( hr == S_OK, "got %08x\n", hr );
306 ok( !lstrcmpW( buf, expected2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
307 ok( len == lstrlenW( expected2W ) + 1, "unexpected length %u\n", len );
309 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path18 );
310 ok( hr == S_OK, "got %08x\n", hr );
312 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path19 );
313 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
315 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path20 );
316 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
318 IWbemPath_Release( path );
321 static void test_IWbemPath_GetClassName(void)
323 static const WCHAR classW[] = {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
329 if (!(path = create_path())) return;
331 hr = IWbemPath_GetClassName( path, NULL, NULL );
332 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
335 hr = IWbemPath_GetClassName( path, &len, NULL );
336 ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
338 len = sizeof(buf) / sizeof(buf[0]);
339 hr = IWbemPath_GetClassName( path, &len, buf );
340 ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
342 len = sizeof(buf) / sizeof(buf[0]);
343 hr = IWbemPath_GetClassName( path, &len, NULL );
344 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
345 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
347 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
348 ok( hr == S_OK, "got %08x\n", hr );
351 hr = IWbemPath_GetClassName( path, &len, NULL );
352 ok( hr == S_OK, "got %08x\n", hr );
354 len = sizeof(buf) / sizeof(buf[0]);
355 hr = IWbemPath_GetClassName( path, &len, NULL );
356 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
357 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
360 len = sizeof(buf) / sizeof(buf[0]);
361 hr = IWbemPath_GetClassName( path, &len, buf );
362 ok( hr == S_OK, "got %08x\n", hr );
363 ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
364 ok( len == lstrlenW( classW ) + 1, "unexpected length %u\n", len );
366 IWbemPath_Release( path );
369 static void test_IWbemPath_SetClassName(void)
371 static const WCHAR classW[] = {'c','l','a','s','s',0};
372 static const WCHAR emptyW[] = {0};
379 if (!(path = create_path())) return;
381 hr = IWbemPath_SetClassName( path, NULL );
382 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
384 hr = IWbemPath_SetClassName( path, emptyW );
385 ok( hr == S_OK, "got %08x\n", hr );
387 hr = IWbemPath_SetClassName( path, classW );
388 ok( hr == S_OK, "got %08x\n", hr );
391 len = sizeof(buf) / sizeof(buf[0]);
392 hr = IWbemPath_GetClassName( path, &len, buf );
393 ok( hr == S_OK, "got %08x\n", hr );
394 ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
397 hr = IWbemPath_GetInfo( path, 0, &flags );
398 ok( hr == S_OK, "got %08x\n", hr );
399 ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
400 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
401 WBEMPATH_INFO_CIM_COMPLIANT),
402 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
404 IWbemPath_Release( path );
407 static void test_IWbemPath_GetServer(void)
409 static const WCHAR dotW[] = {'.',0};
415 if (!(path = create_path())) return;
417 hr = IWbemPath_GetServer( path, NULL, NULL );
418 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
421 hr = IWbemPath_GetServer( path, &len, NULL );
422 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
424 len = sizeof(buf) / sizeof(buf[0]);
425 hr = IWbemPath_GetServer( path, &len, buf );
426 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
428 len = sizeof(buf) / sizeof(buf[0]);
429 hr = IWbemPath_GetServer( path, &len, NULL );
430 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
431 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
433 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
434 ok( hr == S_OK, "got %08x\n", hr );
437 hr = IWbemPath_GetServer( path, &len, NULL );
438 ok( hr == S_OK, "got %08x\n", hr );
440 len = sizeof(buf) / sizeof(buf[0]);
441 hr = IWbemPath_GetServer( path, &len, NULL );
442 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
443 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
446 len = sizeof(buf) / sizeof(buf[0]);
447 hr = IWbemPath_GetServer( path, &len, buf );
448 ok( hr == S_OK, "got %08x\n", hr );
449 ok( !lstrcmpW( buf, dotW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
450 ok( len == lstrlenW( dotW ) + 1, "unexpected length %u\n", len );
452 IWbemPath_Release( path );
455 static void test_IWbemPath_GetInfo(void)
461 if (!(path = create_path())) return;
463 hr = IWbemPath_GetInfo( path, 0, NULL );
464 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
466 hr = IWbemPath_GetInfo( path, 1, NULL );
467 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
470 hr = IWbemPath_GetInfo( path, 0, &resp );
471 ok( hr == S_OK, "got %08x\n", hr );
472 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
473 "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
475 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
476 ok( hr == S_OK, "got %08x\n", hr );
478 hr = IWbemPath_GetInfo( path, 0, NULL );
479 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
481 hr = IWbemPath_GetInfo( path, 1, NULL );
482 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
485 hr = IWbemPath_GetInfo( path, 0, &resp );
486 ok( hr == S_OK, "got %08x\n", hr );
487 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
488 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
489 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER),
490 "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
492 IWbemPath_Release( path );
493 if (!(path = create_path())) return;
495 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path12 );
496 ok( hr == S_OK, "got %08x\n", hr );
499 hr = IWbemPath_GetInfo( path, 0, &resp );
500 ok( hr == S_OK, "got %08x\n", hr );
501 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
502 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
503 WBEMPATH_INFO_CIM_COMPLIANT),
504 "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
506 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
507 ok( hr == S_OK, "got %08x\n", hr );
510 hr = IWbemPath_GetInfo( path, 0, &resp );
511 ok( hr == S_OK, "got %08x\n", hr );
512 ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
513 "got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
515 IWbemPath_Release( path );
518 static void test_IWbemPath_SetServer(void)
520 static const WCHAR serverW[] = {'s','e','r','v','e','r',0};
521 static const WCHAR emptyW[] = {0};
528 if (!(path = create_path())) return;
530 hr = IWbemPath_SetServer( path, NULL );
531 ok( hr == S_OK, "got %08x\n", hr );
533 len = sizeof(buf) / sizeof(buf[0]);
534 hr = IWbemPath_GetServer( path, &len, buf );
535 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
537 hr = IWbemPath_SetServer( path, emptyW );
538 ok( hr == S_OK, "got %08x\n", hr );
540 hr = IWbemPath_SetServer( path, serverW );
541 ok( hr == S_OK, "got %08x\n", hr );
544 len = sizeof(buf) / sizeof(buf[0]);
545 hr = IWbemPath_GetServer( path, &len, buf );
546 ok( hr == S_OK, "got %08x\n", hr );
547 ok( !lstrcmpW( buf, serverW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
550 hr = IWbemPath_GetInfo( path, 0, &flags );
551 ok( hr == S_OK, "got %08x\n", hr );
552 ok( flags == (WBEMPATH_INFO_HAS_MACHINE_NAME | WBEMPATH_INFO_V1_COMPLIANT |
553 WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
554 WBEMPATH_INFO_SERVER_NAMESPACE_ONLY | WBEMPATH_INFO_PATH_HAD_SERVER),
555 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
557 hr = IWbemPath_SetServer( path, NULL );
558 ok( hr == S_OK, "got %08x\n", hr );
560 len = sizeof(buf) / sizeof(buf[0]);
561 hr = IWbemPath_GetServer( path, &len, buf );
562 ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
565 hr = IWbemPath_GetInfo( path, 0, &flags );
566 ok( hr == S_OK, "got %08x\n", hr );
567 ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
568 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
570 IWbemPath_Release( path );
573 static void test_IWbemPath_GetNamespaceAt(void)
575 static const WCHAR rootW[] = {'r','o','o','t',0};
576 static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
582 if (!(path = create_path())) return;
584 hr = IWbemPath_GetNamespaceAt( path, 0, NULL, NULL );
585 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
588 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
589 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
591 len = sizeof(buf) / sizeof(buf[0]);
592 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
593 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
595 len = sizeof(buf) / sizeof(buf[0]);
596 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
597 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
598 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
600 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
601 ok( hr == S_OK, "got %08x\n", hr );
604 hr = IWbemPath_GetNamespaceAt( path, 2, &len, NULL );
605 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
607 len = sizeof(buf) / sizeof(buf[0]);
608 hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
609 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
610 ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
613 len = sizeof(buf) / sizeof(buf[0]);
614 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
615 ok( hr == S_OK, "got %08x\n", hr );
616 ok( !lstrcmpW( buf, rootW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
617 ok( len == lstrlenW( rootW ) + 1, "unexpected length %u\n", len );
620 len = sizeof(buf) / sizeof(buf[0]);
621 hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
622 ok( hr == S_OK, "got %08x\n", hr );
623 ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
624 ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
626 IWbemPath_Release( path );
629 static void test_IWbemPath_RemoveAllNamespaces(void)
631 static const ULONGLONG expected_flags =
632 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
633 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
634 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
641 if (!(path = create_path())) return;
643 hr = IWbemPath_RemoveAllNamespaces( path );
644 ok( hr == S_OK, "got %08x\n", hr );
646 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
647 ok( hr == S_OK, "got %08x\n", hr );
650 hr = IWbemPath_GetInfo( path, 0, &flags );
651 ok( hr == S_OK, "got %08x\n", hr );
652 ok( flags == expected_flags,
653 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
655 hr = IWbemPath_RemoveAllNamespaces( path );
656 ok( hr == S_OK, "got %08x\n", hr );
659 hr = IWbemPath_GetInfo( path, 0, &flags );
660 ok( hr == S_OK, "got %08x\n", hr );
661 ok( flags == expected_flags,
662 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
665 len = sizeof(buf) / sizeof(buf[0]);
666 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
667 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
669 IWbemPath_Release( path );
672 static void test_IWbemPath_RemoveNamespaceAt(void)
674 static const ULONGLONG expected_flags =
675 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
676 WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
677 WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
678 static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
685 if (!(path = create_path())) return;
687 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
688 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
690 hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
691 ok( hr == S_OK, "got %08x\n", hr );
694 hr = IWbemPath_GetInfo( path, 0, &flags );
695 ok( hr == S_OK, "got %08x\n", hr );
696 ok( flags == expected_flags,
697 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
700 hr = IWbemPath_GetNamespaceCount( path, &count );
701 ok( hr == S_OK, "got %08x\n", hr );
702 ok( count == 2, "got %u\n", count );
704 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
705 ok( hr == S_OK, "got %08x\n", hr );
708 hr = IWbemPath_GetInfo( path, 0, &flags );
709 ok( hr == S_OK, "got %08x\n", hr );
710 ok( flags == expected_flags,
711 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
714 hr = IWbemPath_GetNamespaceCount( path, &count );
715 ok( hr == S_OK, "got %08x\n", hr );
716 ok( count == 1, "got %u\n", count );
719 len = sizeof(buf) / sizeof(buf[0]);
720 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
721 ok( hr == S_OK, "got %08x\n", hr );
722 ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
723 ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
725 hr = IWbemPath_RemoveNamespaceAt( path, 0 );
726 ok( hr == S_OK, "got %08x\n", hr );
729 hr = IWbemPath_GetInfo( path, 0, &flags );
730 ok( hr == S_OK, "got %08x\n", hr );
731 ok( flags == expected_flags,
732 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
735 hr = IWbemPath_GetNamespaceCount( path, &count );
736 ok( hr == S_OK, "got %08x\n", hr );
737 ok( !count, "got %u\n", count );
740 len = sizeof(buf) / sizeof(buf[0]);
741 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
742 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
744 IWbemPath_Release( path );
747 static void test_IWbemPath_SetNamespaceAt(void)
749 static const ULONGLONG expected_flags =
750 WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_V1_COMPLIANT |
751 WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
752 WBEMPATH_INFO_SERVER_NAMESPACE_ONLY;
753 static const WCHAR rootW[] = {'r','o','o','t',0};
754 static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
761 if (!(path = create_path())) return;
763 hr = IWbemPath_SetNamespaceAt( path, 0, NULL );
764 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
766 hr = IWbemPath_SetNamespaceAt( path, 1, cimv2W );
767 ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
769 hr = IWbemPath_SetNamespaceAt( path, 0, cimv2W );
770 ok( hr == S_OK, "got %08x\n", hr );
773 hr = IWbemPath_GetNamespaceCount( path, &count );
774 ok( hr == S_OK, "got %08x\n", hr );
775 ok( count == 1, "got %u\n", count );
778 hr = IWbemPath_GetInfo( path, 0, &flags );
779 ok( hr == S_OK, "got %08x\n", hr );
780 ok( flags == expected_flags,
781 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
784 len = sizeof(buf) / sizeof(buf[0]);
785 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
786 ok( hr == S_OK, "got %08x\n", hr );
787 ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
788 ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
790 hr = IWbemPath_SetNamespaceAt( path, 0, rootW );
791 ok( hr == S_OK, "got %08x\n", hr );
794 hr = IWbemPath_GetInfo( path, 0, &flags );
795 ok( hr == S_OK, "got %08x\n", hr );
796 ok( flags == expected_flags,
797 "got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
800 hr = IWbemPath_GetNamespaceCount( path, &count );
801 ok( hr == S_OK, "got %08x\n", hr );
802 ok( count == 2, "got %u\n", count );
805 len = sizeof(buf) / sizeof(buf[0]);
806 hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
807 ok( hr == S_OK, "got %08x\n", hr );
808 ok( !lstrcmpW( buf, rootW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
809 ok( len == lstrlenW( rootW ) + 1, "unexpected length %u\n", len );
812 len = sizeof(buf) / sizeof(buf[0]);
813 hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
814 ok( hr == S_OK, "got %08x\n", hr );
815 ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
816 ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
818 IWbemPath_Release( path );
823 CoInitialize( NULL );
825 test_IWbemPath_SetText();
826 test_IWbemPath_GetText();
827 test_IWbemPath_GetClassName();
828 test_IWbemPath_SetClassName();
829 test_IWbemPath_GetServer();
830 test_IWbemPath_GetInfo();
831 test_IWbemPath_SetServer();
832 test_IWbemPath_GetNamespaceAt();
833 test_IWbemPath_RemoveAllNamespaces();
834 test_IWbemPath_RemoveNamespaceAt();
835 test_IWbemPath_SetNamespaceAt();