dwrite: Implement GetStringLength method.

This commit is contained in:
Nikolay Sivov 2012-10-07 17:25:23 -04:00 committed by Alexandre Julliard
parent 98ce55c148
commit 114ef0688b
2 changed files with 27 additions and 3 deletions

View file

@ -271,8 +271,16 @@ static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *if
static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length) static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
{ {
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface); struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
FIXME("(%p)->(%u %p): stub\n", This, index, length);
return E_NOTIMPL; TRACE("(%p)->(%u %p)\n", This, index, length);
if (index >= This->count) {
*length = (UINT32)-1;
return E_FAIL;
}
*length = strlenW(This->data[index].string);
return S_OK;
} }
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size) static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)

View file

@ -321,6 +321,7 @@ static void test_GetFamilyNames(void)
IDWriteFont *font; IDWriteFont *font;
LOGFONTW logfont; LOGFONTW logfont;
HRESULT hr; HRESULT hr;
UINT32 len;
hr = IDWriteFactory_GetGdiInterop(factory, &interop); hr = IDWriteFactory_GetGdiInterop(factory, &interop);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
@ -350,9 +351,24 @@ if (0) /* crashes on native */
EXPECT_REF(names2, 1); EXPECT_REF(names2, 1);
ok(names != names2, "got %p, was %p\n", names2, names); ok(names != names2, "got %p, was %p\n", names2, names);
IDWriteLocalizedStrings_Release(names);
IDWriteLocalizedStrings_Release(names2); IDWriteLocalizedStrings_Release(names2);
/* GetStringLength */
if (0) /* crashes on native */
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, NULL);
len = 0;
hr = IDWriteLocalizedStrings_GetStringLength(names, 0, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(len > 0, "got %u\n", len);
len = 100;
hr = IDWriteLocalizedStrings_GetStringLength(names, 10, &len);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(len == (UINT32)-1, "got %u\n", len);
IDWriteLocalizedStrings_Release(names);
IDWriteFontFamily_Release(family); IDWriteFontFamily_Release(family);
IDWriteFont_Release(font); IDWriteFont_Release(font);
IDWriteGdiInterop_Release(interop); IDWriteGdiInterop_Release(interop);