Commit b6c17607 authored by Shaun Ren's avatar Shaun Ren Committed by Alexandre Julliard

sapi: Implement ISpeechObjectToken::GetDescription.

parent 23f360b1
MODULE = sapi.dll
IMPORTS = uuid ole32 user32 advapi32
IMPORTS = uuid ole32 oleaut32 user32 advapi32
DELAYIMPORTS = winmm
SOURCES = \
......
TESTDLL = sapi.dll
IMPORTS = ole32 user32 advapi32 winmm
IMPORTS = ole32 oleaut32 user32 advapi32 winmm
SOURCES = \
automation.c \
......
......@@ -657,7 +657,7 @@ static IClassFactory test_class_cf = { &ClassFactoryVtbl };
static void test_object_token(void)
{
static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Wine\\Winetest\\sapi\\TestToken";
static const WCHAR test_token_id[] = L"HKEY_LOCAL_MACHINE\\Software\\Winetest\\sapi\\TestToken";
ISpObjectToken *token;
IDispatch *disp;
......@@ -665,6 +665,7 @@ static void test_object_token(void)
ISpDataKey *sub_key;
HRESULT hr;
LPWSTR tempW, token_id;
BSTR tempB;
ISpObjectTokenCategory *cat;
DWORD regid;
IUnknown *obj;
......@@ -863,11 +864,64 @@ static void test_object_token(void)
CoTaskMemFree( tempW );
}
hr = ISpObjectToken_SetStringValue( token, L"409", L"409 - TestToken" );
ok( hr == S_OK, "got %08lx\n", hr );
hr = ISpObjectToken_SetStringValue( token, L"407", L"407 - TestToken" );
ok( hr == S_OK, "got %08lx\n", hr );
hr = ISpObjectToken_SetStringValue( token, L"E40C", L"E40C - TestToken" );
ok( hr == S_OK, "got %08lx\n", hr );
hr = ISpObjectToken_QueryInterface( token, &IID_ISpeechObjectToken, (void **)&speech_token );
ok( hr == S_OK, "got %08lx\n", hr );
hr = ISpeechObjectToken_GetDescription( speech_token, 0x409, NULL );
ok( hr == E_POINTER, "got %08lx\n", hr );
tempB = NULL;
hr = ISpeechObjectToken_GetDescription( speech_token, 0x409, &tempB );
ok( hr == S_OK, "got %08lx\n", hr );
ok( tempB && !wcscmp( tempB, L"409 - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB );
tempB = NULL;
hr = ISpeechObjectToken_GetDescription( speech_token, 0x10407, &tempB );
ok( hr == S_OK, "got %08lx\n", hr );
ok( tempB && !wcscmp( tempB, L"407 - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB );
tempB = NULL;
hr = ISpeechObjectToken_GetDescription( speech_token, 0xE40C, &tempB );
ok( hr == S_OK, "got %08lx\n", hr );
ok( tempB && !wcscmp( tempB, L"E40C - TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB );
tempB = (BSTR)0xdeadbeef;
hr = ISpeechObjectToken_GetDescription( speech_token, 0x406, &tempB );
ok( hr == SPERR_NOT_FOUND, "got %08lx\n", hr );
ok( tempB == (BSTR)0xdeadbeef || broken(tempB == NULL) /* < win7 */, "got %p\n", tempB );
hr = ISpObjectToken_SetStringValue( token, NULL, L"TestToken" );
ok( hr == S_OK, "got %08lx\n", hr );
tempB = NULL;
hr = ISpeechObjectToken_GetDescription( speech_token, 0x406, &tempB );
ok( hr == S_OK, "got %08lx\n", hr );
ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB );
tempB = NULL;
hr = ISpeechObjectToken_GetDescription( speech_token, 0x0, &tempB );
ok( hr == S_OK, "got %08lx\n", hr );
ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB );
ISpeechObjectToken_Release( speech_token );
ISpObjectToken_Release( test_class_token );
IUnknown_Release( obj );
ISpObjectToken_Release( token );
RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Winetest\\sapi" );
RegDeleteTreeA( HKEY_LOCAL_MACHINE, "Software\\Winetest\\sapi" );
}
START_TEST(token)
......
......@@ -1829,8 +1829,27 @@ static HRESULT WINAPI speech_token_get_Category( ISpeechObjectToken *iface,
static HRESULT WINAPI speech_token_GetDescription( ISpeechObjectToken *iface,
LONG locale, BSTR *desc )
{
FIXME( "stub\n" );
return E_NOTIMPL;
struct object_token *This = impl_from_ISpeechObjectToken( iface );
WCHAR langid[5];
WCHAR *desc_wstr = NULL;
HRESULT hr;
TRACE( "(%p)->(%#lx %p)\n", This, locale, desc );
if (!desc) return E_POINTER;
swprintf( langid, ARRAY_SIZE( langid ), L"%X", LANGIDFROMLCID( locale ) );
hr = ISpObjectToken_GetStringValue( &This->ISpObjectToken_iface, langid, &desc_wstr );
if (hr == SPERR_NOT_FOUND)
hr = ISpObjectToken_GetStringValue( &This->ISpObjectToken_iface, NULL, &desc_wstr );
if (FAILED(hr))
return hr;
*desc = SysAllocString( desc_wstr );
CoTaskMemFree( desc_wstr );
return *desc ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI speech_token_SetId( ISpeechObjectToken *iface,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment