sapi: Improve GetDefaultTokenId stub.

Signed-off-by: Myah Caron <qsniyg@protonmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Myah Caron 2020-09-11 19:42:50 +00:00 committed by Alexandre Julliard
parent 3f3c0086cb
commit 2e11e2f33f
2 changed files with 91 additions and 2 deletions

View File

@ -116,11 +116,70 @@ static void test_token_enum(void)
ISpObjectTokenEnumBuilder_Release( token_enum );
}
static void test_default_token_id(void)
{
ISpObjectTokenCategory *cat;
HRESULT hr;
LPWSTR token_id = NULL;
LONG res;
WCHAR regvalue[512];
DWORD regvalue_size;
hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpObjectTokenCategory, (void **)&cat );
ok( hr == S_OK, "got %08x\n", hr );
token_id = (LPWSTR)0xdeadbeef;
hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id );
ok( hr == SPERR_UNINITIALIZED, "got %08x\n", hr );
ok( token_id == (LPWSTR)0xdeadbeef, "got %p\n", token_id );
hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL );
ok( hr == SPERR_UNINITIALIZED, "got %08x\n", hr );
hr = ISpObjectTokenCategory_SetId( cat, SPCAT_AUDIOOUT, FALSE );
ok( hr == S_OK, "got %08x\n", hr );
hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL );
ok( hr == E_POINTER, "got %08x\n", hr );
token_id = (LPWSTR)0xdeadbeef;
hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id );
/* AudioOutput under windows server returns this error */
if (hr == SPERR_NOT_FOUND) {
/* also happens if TokenEnums/Tokens is empty or doesn't exist */
skip( "AudioOutput category not found for GetDefaultTokenId\n" );
return;
}
ok( hr == S_OK, "got %08x\n", hr );
ok( token_id != (LPWSTR)0xdeadbeef && token_id != NULL, "got %p\n", token_id );
regvalue_size = sizeof( regvalue );
res = RegGetValueW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Speech\\AudioOutput",
L"DefaultDefaultTokenId", RRF_RT_REG_SZ, NULL,
(LPVOID)&regvalue, &regvalue_size);
if (res == ERROR_FILE_NOT_FOUND) {
skip( "DefaultDefaultTokenId not found for AudioOutput category (%s)\n",
wine_dbgstr_w(token_id) );
} else {
ok( res == ERROR_SUCCESS, "got %08x\n", res );
ok( !wcscmp(regvalue, token_id),
"GetDefaultTokenId (%s) should be equal to the DefaultDefaultTokenId key (%s)\n",
wine_dbgstr_w(token_id), wine_dbgstr_w(regvalue) );
}
CoTaskMemFree( token_id );
ISpObjectTokenCategory_Release( cat );
}
START_TEST(token)
{
CoInitialize( NULL );
test_data_key();
test_token_category();
test_token_enum();
test_default_token_id();
CoUninitialize();
}

View File

@ -489,8 +489,38 @@ static HRESULT WINAPI token_category_SetDefaultTokenId( ISpObjectTokenCategory *
static HRESULT WINAPI token_category_GetDefaultTokenId( ISpObjectTokenCategory *iface,
LPWSTR *id )
{
FIXME( "stub\n" );
return E_NOTIMPL;
struct token_category *This = impl_from_ISpObjectTokenCategory( iface );
struct data_key *this_data_key;
LONG res;
WCHAR regvalue[512];
DWORD regvalue_size = sizeof( regvalue );
FIXME( "(%p)->(%p): semi-stub\n", iface, id );
if (!This->data_key)
return SPERR_UNINITIALIZED;
if (!id)
return E_POINTER;
/* todo: check HKCU's DefaultTokenId before */
this_data_key = impl_from_ISpRegDataKey( This->data_key );
res = RegGetValueW( this_data_key->key, NULL, L"DefaultDefaultTokenId", RRF_RT_REG_SZ,
NULL, &regvalue, &regvalue_size);
if (res == ERROR_FILE_NOT_FOUND) {
return SPERR_NOT_FOUND;
} else if (res != ERROR_SUCCESS) {
/* probably not the correct return value */
FIXME( "returning %08x\n", res );
return res;
}
*id = CoTaskMemAlloc( regvalue_size );
wcscpy( *id, regvalue );
return S_OK;
}
const struct ISpObjectTokenCategoryVtbl token_category_vtbl =