sapi: Implement ISpObjectToken::CreateKey.
[wine.git] / dlls / sapi / tests / token.c
blob287c74a3e58abfa38e767bf66f21f17ea6fa2b54
1 /*
2 * Speech API (SAPI) token tests.
4 * Copyright (C) 2017 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "initguid.h"
24 #include "sapiddk.h"
25 #include "sperror.h"
27 #include "wine/test.h"
29 static void test_data_key(void)
31 ISpRegDataKey *data_key;
32 ISpDataKey *sub;
33 HRESULT hr;
34 HKEY key;
35 LONG res;
36 WCHAR *value = NULL;
38 hr = CoCreateInstance( &CLSID_SpDataKey, NULL, CLSCTX_INPROC_SERVER,
39 &IID_ISpRegDataKey, (void **)&data_key );
40 ok( hr == S_OK, "got %08lx\n", hr );
42 res = RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Winetest\\sapi", 0, NULL, 0, KEY_ALL_ACCESS,
43 NULL, &key, NULL );
44 ok( res == ERROR_SUCCESS, "got %ld\n", res );
46 hr = ISpRegDataKey_CreateKey( data_key, L"Testing", &sub );
47 ok( hr == E_HANDLE, "got %08lx\n", hr );
49 hr = ISpRegDataKey_GetStringValue( data_key, L"Voice", &value );
50 ok( hr == E_HANDLE, "got %08lx\n", hr );
52 hr = ISpRegDataKey_SetStringValue( data_key, L"Voice", L"Test" );
53 ok( hr == E_HANDLE, "got %08lx\n", hr );
55 hr = ISpRegDataKey_SetKey( data_key, key, FALSE );
56 ok( hr == S_OK, "got %08lx\n", hr );
57 hr = ISpRegDataKey_SetKey( data_key, key, FALSE );
58 ok( hr == SPERR_ALREADY_INITIALIZED, "got %08lx\n", hr );
60 hr = ISpRegDataKey_GetStringValue( data_key, L"Voice", &value );
61 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
63 hr = ISpRegDataKey_GetStringValue( data_key, L"", &value );
64 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
66 hr = ISpRegDataKey_SetStringValue( data_key, L"Voice", L"Test" );
67 ok( hr == S_OK, "got %08lx\n", hr );
69 hr = ISpRegDataKey_GetStringValue( data_key, L"Voice", &value );
70 ok( hr == S_OK, "got %08lx\n", hr );
71 ok( !wcscmp( value, L"Test" ), "got %s\n", wine_dbgstr_w(value) );
72 CoTaskMemFree( value );
74 hr = ISpRegDataKey_OpenKey( data_key, L"Testing", &sub );
75 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
77 hr = ISpRegDataKey_CreateKey( data_key, L"Testing", &sub );
78 ok( hr == S_OK, "got %08lx\n", hr );
79 ISpDataKey_Release(sub);
81 hr = ISpRegDataKey_OpenKey( data_key, L"Testing", &sub );
82 ok( hr == S_OK, "got %08lx\n", hr );
83 ISpDataKey_Release(sub);
85 ISpRegDataKey_Release( data_key );
87 hr = CoCreateInstance( &CLSID_SpDataKey, NULL, CLSCTX_INPROC_SERVER,
88 &IID_ISpRegDataKey, (void **)&data_key );
89 ok( hr == S_OK, "got %08lx\n", hr );
91 res = RegOpenKeyExA( HKEY_CURRENT_USER, "Software\\Winetest\\sapi", 0, KEY_ALL_ACCESS, &key );
92 ok( res == ERROR_SUCCESS, "got %ld\n", res );
94 hr = ISpRegDataKey_SetKey( data_key, key, TRUE );
95 ok( hr == S_OK, "got %08lx\n", hr );
97 hr = ISpRegDataKey_SetStringValue( data_key, L"Voice2", L"Test2" );
98 ok( hr == S_OK, "got %08lx\n", hr );
100 hr = ISpRegDataKey_GetStringValue( data_key, L"Voice2", &value );
101 ok( hr == S_OK, "got %08lx\n", hr );
102 ok( !wcscmp( value, L"Test2" ), "got %s\n", wine_dbgstr_w(value) );
103 CoTaskMemFree( value );
105 hr = ISpRegDataKey_CreateKey( data_key, L"Testing2", &sub );
106 ok( hr == S_OK, "got %08lx\n", hr );
107 ISpDataKey_Release(sub);
109 ISpRegDataKey_Release( data_key );
112 static void test_token_category(void)
114 ISpObjectTokenCategory *cat;
115 IEnumSpObjectTokens *enum_tokens;
116 HRESULT hr;
117 ULONG count;
119 hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
120 &IID_ISpObjectTokenCategory, (void **)&cat );
121 ok( hr == S_OK, "got %08lx\n", hr );
123 hr = ISpObjectTokenCategory_EnumTokens( cat, NULL, NULL, &enum_tokens );
124 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
126 hr = ISpObjectTokenCategory_SetId( cat, L"bogus", FALSE );
127 ok( hr == SPERR_INVALID_REGISTRY_KEY, "got %08lx\n", hr );
129 hr = ISpObjectTokenCategory_SetId( cat, SPCAT_VOICES, FALSE );
130 ok( hr == S_OK, "got %08lx\n", hr );
132 hr = ISpObjectTokenCategory_SetId( cat, SPCAT_VOICES, FALSE );
133 ok( hr == SPERR_ALREADY_INITIALIZED, "got %08lx\n", hr );
135 hr = ISpObjectTokenCategory_EnumTokens( cat, NULL, NULL, &enum_tokens );
136 ok( hr == S_OK, "got %08lx\n", hr );
138 hr = IEnumSpObjectTokens_GetCount( enum_tokens, &count );
139 ok( hr == S_OK, "got %08lx\n", hr );
141 IEnumSpObjectTokens_Release( enum_tokens );
142 ISpObjectTokenCategory_Release( cat );
145 static void test_token_enum(void)
147 ISpObjectTokenEnumBuilder *token_enum;
148 HRESULT hr;
149 ISpObjectToken *token;
150 ULONG count;
152 hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER,
153 &IID_ISpObjectTokenEnumBuilder, (void **)&token_enum );
154 ok( hr == S_OK, "got %08lx\n", hr );
156 hr = ISpObjectTokenEnumBuilder_GetCount( token_enum, &count );
157 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
159 hr = ISpObjectTokenEnumBuilder_Next( token_enum, 1, &token, &count );
160 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
162 hr = ISpObjectTokenEnumBuilder_SetAttribs( token_enum, NULL, NULL );
163 ok( hr == S_OK, "got %08lx\n", hr );
165 count = 0xdeadbeef;
166 hr = ISpObjectTokenEnumBuilder_GetCount( token_enum, &count );
167 ok( hr == S_OK, "got %08lx\n", hr );
168 ok( count == 0, "got %lu\n", count );
170 count = 0xdeadbeef;
171 hr = ISpObjectTokenEnumBuilder_Next( token_enum, 1, &token, &count );
172 ok( hr == S_FALSE, "got %08lx\n", hr );
173 ok( count == 0, "got %lu\n", count );
175 ISpObjectTokenEnumBuilder_Release( token_enum );
178 static void test_default_token_id(void)
180 ISpObjectTokenCategory *cat;
181 HRESULT hr;
182 LPWSTR token_id = NULL;
183 LONG res;
184 WCHAR regvalue[512];
185 DWORD regvalue_size;
187 hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
188 &IID_ISpObjectTokenCategory, (void **)&cat );
189 ok( hr == S_OK, "got %08lx\n", hr );
191 token_id = (LPWSTR)0xdeadbeef;
192 hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id );
193 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
194 ok( token_id == (LPWSTR)0xdeadbeef, "got %p\n", token_id );
196 hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL );
197 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
199 hr = ISpObjectTokenCategory_SetId( cat, SPCAT_AUDIOOUT, FALSE );
200 ok( hr == S_OK, "got %08lx\n", hr );
202 hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL );
203 ok( hr == E_POINTER, "got %08lx\n", hr );
205 token_id = (LPWSTR)0xdeadbeef;
206 hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id );
208 /* AudioOutput under windows server returns this error */
209 if (hr == SPERR_NOT_FOUND) {
210 /* also happens if TokenEnums/Tokens is empty or doesn't exist */
211 skip( "AudioOutput category not found for GetDefaultTokenId\n" );
212 return;
215 ok( hr == S_OK, "got %08lx\n", hr );
216 ok( token_id != (LPWSTR)0xdeadbeef && token_id != NULL, "got %p\n", token_id );
218 regvalue_size = sizeof( regvalue );
219 res = RegGetValueW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Speech\\AudioOutput",
220 L"DefaultDefaultTokenId", RRF_RT_REG_SZ, NULL,
221 (LPVOID)&regvalue, &regvalue_size);
222 if (res == ERROR_FILE_NOT_FOUND) {
223 skip( "DefaultDefaultTokenId not found for AudioOutput category (%s)\n",
224 wine_dbgstr_w(token_id) );
225 } else {
226 ok( res == ERROR_SUCCESS, "got %08lx\n", res );
227 ok( !wcscmp(regvalue, token_id),
228 "GetDefaultTokenId (%s) should be equal to the DefaultDefaultTokenId key (%s)\n",
229 wine_dbgstr_w(token_id), wine_dbgstr_w(regvalue) );
232 CoTaskMemFree( token_id );
233 ISpObjectTokenCategory_Release( cat );
236 static void tests_token_voices(void)
238 ISpObjectTokenCategory *cat;
239 HRESULT hr;
240 IEnumSpObjectTokens *tokens;
241 ISpObjectToken *item;
242 ULONG fetched = 0;
243 ULONG count;
245 hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
246 &IID_ISpObjectTokenCategory, (void **)&cat );
247 ok( hr == S_OK, "got %08lx\n", hr );
249 hr = ISpObjectTokenCategory_SetId( cat, SPCAT_VOICES, FALSE );
250 ok( hr == S_OK, "got %08lx\n", hr );
252 hr = ISpObjectTokenCategory_EnumTokens(cat, NULL, NULL, &tokens);
253 ok( hr == S_OK, "got %08lx\n", hr );
255 hr = IEnumSpObjectTokens_GetCount( tokens, &count );
256 ok( hr == S_OK, "got %08lx\n", hr );
257 ok( count != 0, "got %lu\n", count );
258 ISpObjectTokenCategory_Release( cat );
260 hr = IEnumSpObjectTokens_Item(tokens, 0, &item);
261 ok( hr == S_OK, "got %08lx\n", hr );
262 ISpObjectToken_Release(item);
264 hr = IEnumSpObjectTokens_Next(tokens, 1, &item, &fetched);
265 ok( hr == S_OK, "got %08lx\n", hr );
266 ISpObjectToken_Release(item);
268 IEnumSpObjectTokens_Release(tokens);
272 #define TESTCLASS_CLSID L"{67DD26B6-50BA-3297-253E-619346F177F8}"
273 static const GUID CLSID_TestClass = {0x67DD26B6,0x50BA,0x3297,{0x25,0x3E,0x61,0x93,0x46,0xF1,0x77,0xF8}};
275 static ISpObjectToken *test_class_token;
277 static HRESULT WINAPI test_class_QueryInterface(ISpObjectWithToken *iface, REFIID riid, void **ppv)
279 if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_ISpObjectWithToken ))
281 *ppv = iface;
282 return S_OK;
285 *ppv = NULL;
286 return E_NOINTERFACE;
289 static ULONG WINAPI test_class_AddRef(ISpObjectWithToken *iface)
291 return 2;
294 static ULONG WINAPI test_class_Release(ISpObjectWithToken *iface)
296 return 1;
299 static HRESULT WINAPI test_class_SetObjectToken(ISpObjectWithToken *iface, ISpObjectToken *token)
301 ok( token != NULL, "token == NULL\n" );
302 test_class_token = token;
303 ISpObjectToken_AddRef(test_class_token);
304 return S_OK;
307 static HRESULT WINAPI test_class_GetObjectToken(ISpObjectWithToken *iface, ISpObjectToken **token)
309 ok( 0, "unexpected call\n" );
310 return E_NOTIMPL;
313 static const ISpObjectWithTokenVtbl test_class_vtbl = {
314 test_class_QueryInterface,
315 test_class_AddRef,
316 test_class_Release,
317 test_class_SetObjectToken,
318 test_class_GetObjectToken
321 static ISpObjectWithToken test_class = { &test_class_vtbl };
323 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
325 if (IsEqualGUID( &IID_IUnknown, riid ) || IsEqualGUID( &IID_IClassFactory, riid ))
327 *ppv = iface;
328 return S_OK;
331 *ppv = NULL;
332 return E_NOINTERFACE;
335 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
337 return 2;
340 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
342 return 1;
345 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
346 IUnknown *pUnkOuter, REFIID riid, void **ppv)
348 ok( pUnkOuter == NULL, "pUnkOuter != NULL\n" );
349 ok( IsEqualGUID(riid, &IID_IUnknown), "riid = %s\n", wine_dbgstr_guid(riid) );
351 *ppv = &test_class;
352 return S_OK;
355 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
357 ok( 0, "unexpected call\n" );
358 return E_NOTIMPL;
361 static const IClassFactoryVtbl ClassFactoryVtbl = {
362 ClassFactory_QueryInterface,
363 ClassFactory_AddRef,
364 ClassFactory_Release,
365 ClassFactory_CreateInstance,
366 ClassFactory_LockServer
369 static IClassFactory test_class_cf = { &ClassFactoryVtbl };
371 static void test_object_token(void)
373 static const WCHAR test_token_id[] = L"HKEY_CURRENT_USER\\Software\\Winetest\\sapi\\TestToken";
375 ISpObjectToken *token;
376 ISpDataKey *sub_key;
377 HRESULT hr;
378 LPWSTR tempW, token_id;
379 ISpObjectTokenCategory *cat;
380 DWORD regid;
381 IUnknown *obj;
383 hr = CoCreateInstance( &CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER,
384 &IID_ISpObjectToken, (void **)&token );
385 ok( hr == S_OK, "got %08lx\n", hr );
387 hr = ISpObjectToken_GetId( token, NULL );
388 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
390 tempW = (LPWSTR)0xdeadbeef;
391 hr = ISpObjectToken_GetId( token, &tempW );
392 ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
393 ok( tempW == (LPWSTR)0xdeadbeef, "got %s\n", wine_dbgstr_w(tempW) );
395 hr = ISpObjectToken_GetCategory( token, NULL );
396 todo_wine ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
398 cat = (LPVOID)0xdeadbeef;
399 hr = ISpObjectToken_GetCategory( token, &cat );
400 todo_wine ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
401 ok( cat == (LPVOID)0xdeadbeef, "got %p\n", cat );
403 hr = ISpObjectToken_SetId( token, NULL, NULL, FALSE );
404 ok( hr == E_POINTER, "got %08lx\n", hr );
405 hr = ISpObjectToken_SetId( token, L"bogus", NULL, FALSE );
406 ok( hr == E_POINTER, "got %08lx\n", hr );
408 hr = ISpObjectToken_SetId( token, NULL, L"bogus", FALSE );
409 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
410 hr = ISpObjectToken_SetId( token, NULL, L"HKEY_LOCAL_MACHINE\\SOFTWARE\\winetest bogus", FALSE );
411 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
413 /* SetId succeeds even if the key is invalid, but exists */
414 hr = ISpObjectToken_SetId( token, NULL, L"HKEY_LOCAL_MACHINE\\SOFTWARE", FALSE );
415 ok( hr == S_OK, "got %08lx\n", hr );
417 hr = ISpObjectToken_SetId( token, NULL, NULL, FALSE );
418 ok( hr == SPERR_ALREADY_INITIALIZED, "got %08lx\n", hr );
419 hr = ISpObjectToken_SetId( token, NULL, L"bogus", FALSE );
420 ok( hr == SPERR_ALREADY_INITIALIZED, "got %08lx\n", hr );
422 hr = ISpObjectToken_GetId( token, NULL );
423 ok( hr == E_POINTER, "got %08lx\n", hr );
425 hr = ISpObjectToken_GetCategory( token, NULL );
426 todo_wine ok( hr == E_POINTER, "got %08lx\n", hr );
428 tempW = NULL;
429 hr = ISpObjectToken_GetId( token, &tempW );
430 ok( hr == S_OK, "got %08lx\n", hr );
431 ok( tempW != NULL, "got %p\n", tempW );
432 if (tempW) {
433 ok( !wcscmp(tempW, L"HKEY_LOCAL_MACHINE\\SOFTWARE"), "got %s\n",
434 wine_dbgstr_w(tempW) );
435 CoTaskMemFree( tempW );
438 hr = ISpObjectToken_OpenKey(token, L"Non-exist", &sub_key);
439 ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
441 hr = ISpObjectToken_OpenKey(token, L"Classes", &sub_key);
442 ok( hr == S_OK, "got %08lx\n", hr );
443 ISpDataKey_Release(sub_key);
445 cat = (LPVOID)0xdeadbeef;
446 hr = ISpObjectToken_GetCategory( token, &cat );
447 todo_wine ok( hr == SPERR_INVALID_REGISTRY_KEY, "got %08lx\n", hr );
448 ok( cat == (LPVOID)0xdeadbeef, "got %p\n", cat );
450 /* get the default token id for SPCAT_AUDIOOUT */
451 hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
452 &IID_ISpObjectTokenCategory, (void **)&cat );
453 ok( hr == S_OK, "got %08lx\n", hr );
454 hr = ISpObjectTokenCategory_SetId( cat, SPCAT_AUDIOOUT, FALSE );
455 ok( hr == S_OK, "got %08lx\n", hr );
456 token_id = (LPWSTR)0xdeadbeef;
457 hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id );
458 if (hr == SPERR_NOT_FOUND) {
459 skip( "AudioOutput category not found for GetDefaultTokenId\n" );
460 return;
462 ok( hr == S_OK, "got %08lx\n", hr );
463 ok( token_id != (LPWSTR)0xdeadbeef && token_id != NULL, "got %p\n", token_id );
464 ISpObjectTokenCategory_Release( cat );
466 /* recreate token in order to SetId again */
467 ISpObjectToken_Release( token );
468 hr = CoCreateInstance( &CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER,
469 &IID_ISpObjectToken, (void **)&token );
470 ok( hr == S_OK, "got %08lx\n", hr );
472 /* NULL appears to auto-detect the category */
473 hr = ISpObjectToken_SetId( token, NULL, token_id, FALSE );
474 ok( hr == S_OK, "got %08lx\n", hr );
476 tempW = NULL;
477 hr = ISpObjectToken_GetId( token, &tempW );
478 ok( hr == S_OK, "got %08lx\n", hr );
479 ok( tempW != NULL, "got %p\n", tempW );
480 if (tempW) {
481 ok( !wcsncmp(tempW, token_id, wcslen(token_id)),
482 "got %s (expected %s)\n", wine_dbgstr_w(tempW), wine_dbgstr_w(token_id) );
483 CoTaskMemFree( tempW );
486 cat = (LPVOID)0xdeadbeef;
487 hr = ISpObjectToken_GetCategory( token, &cat );
488 todo_wine ok( hr == S_OK, "got %08lx\n", hr );
489 todo_wine ok( cat != (LPVOID)0xdeadbeef, "got %p\n", cat );
490 if (cat != (LPVOID)0xdeadbeef) {
491 tempW = NULL;
492 hr = ISpObjectTokenCategory_GetId( cat, &tempW );
493 todo_wine ok( hr == S_OK, "got %08lx\n", hr );
494 todo_wine ok( tempW != NULL, "got %p\n", tempW );
495 if (tempW) {
496 ok( !wcscmp(tempW, SPCAT_AUDIOOUT), "got %s\n", wine_dbgstr_w(tempW) );
497 CoTaskMemFree( tempW );
500 /* not freed by ISpObjectToken_Release */
501 ISpObjectTokenCategory_Release( cat );
504 hr = CoRegisterClassObject( &CLSID_TestClass, (IUnknown *)&test_class_cf,
505 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid );
506 ok( hr == S_OK, "got %08lx\n", hr );
508 ISpObjectToken_Release( token );
509 hr = CoCreateInstance( &CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER,
510 &IID_ISpObjectToken, (void **)&token );
511 ok( hr == S_OK, "got %08lx\n", hr );
513 hr = ISpObjectToken_SetId( token, NULL, test_token_id, TRUE );
514 ok( hr == S_OK, "got %08lx\n", hr );
516 hr = ISpObjectToken_CreateKey( token, L"Attributes", &sub_key );
517 ok( hr == S_OK, "got %08lx\n", hr );
518 ISpDataKey_Release( sub_key );
520 hr = ISpObjectToken_SetStringValue( token, L"CLSID", TESTCLASS_CLSID );
521 ok( hr == S_OK, "got %08lx\n", hr );
523 tempW = NULL;
524 hr = ISpObjectToken_GetStringValue( token, L"CLSID", &tempW );
526 ok( hr == S_OK, "got %08lx\n", hr );
527 if ( tempW ) {
528 ok( !wcsncmp( tempW, TESTCLASS_CLSID, wcslen(TESTCLASS_CLSID) ),
529 "got %s (expected %s)\n", wine_dbgstr_w(tempW), wine_dbgstr_w(TESTCLASS_CLSID) );
530 CoTaskMemFree( tempW );
533 test_class_token = NULL;
534 hr = ISpObjectToken_CreateInstance( token, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&obj );
535 if ( hr == E_ACCESSDENIED ) {
536 win_skip( "ISpObjectToken_CreateInstance returned E_ACCESSDENIED\n" );
537 return;
539 ok( hr == S_OK, "got %08lx\n", hr );
540 ok( test_class_token != NULL, "test_class_token not set\n" );
542 tempW = NULL;
543 hr = ISpObjectToken_GetId( test_class_token, &tempW );
544 ok( tempW != NULL, "got %p\n", tempW );
545 if (tempW) {
546 ok( !wcsncmp(tempW, test_token_id, wcslen(test_token_id)),
547 "got %s (expected %s)\n", wine_dbgstr_w(tempW), wine_dbgstr_w(test_token_id) );
548 CoTaskMemFree( tempW );
551 ISpObjectToken_Release( test_class_token );
552 IUnknown_Release( obj );
553 ISpObjectToken_Release( token );
556 START_TEST(token)
558 CoInitialize( NULL );
559 RegDeleteTreeA( HKEY_CURRENT_USER, "Software\\Winetest\\sapi" );
560 test_data_key();
561 test_token_category();
562 test_token_enum();
563 test_default_token_id();
564 test_object_token();
565 tests_token_voices();
566 CoUninitialize();