dwrite/tests: Use separate factory for each test in layout tests.

This commit is contained in:
Nikolay Sivov 2015-03-15 01:00:48 +03:00 committed by Alexandre Julliard
parent 947f8e64d5
commit bd3069c0c1
1 changed files with 69 additions and 8 deletions

View File

@ -28,8 +28,6 @@
#include "wine/test.h" #include "wine/test.h"
static IDWriteFactory *factory;
static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0}; static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
static const WCHAR enusW[] = {'e','n','-','u','s',0}; static const WCHAR enusW[] = {'e','n','-','u','s',0};
@ -41,6 +39,14 @@ static void _expect_ref(IUnknown* obj, ULONG ref, int line)
ok_(__FILE__,line)(rc-1 == ref, "expected refcount %d, got %d\n", ref, rc-1); ok_(__FILE__,line)(rc-1 == ref, "expected refcount %d, got %d\n", ref, rc-1);
} }
static IDWriteFactory *create_factory(void)
{
IDWriteFactory *factory;
HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory);
ok(hr == S_OK, "got 0x%08x\n", hr);
return factory;
}
enum drawcall_kind { enum drawcall_kind {
DRAW_GLYPHRUN = 0, DRAW_GLYPHRUN = 0,
DRAW_UNDERLINE, DRAW_UNDERLINE,
@ -312,8 +318,11 @@ static void test_CreateTextLayout(void)
IDWriteTextLayout2 *layout2; IDWriteTextLayout2 *layout2;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, &layout); hr = IDWriteFactory_CreateTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, &layout);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
@ -364,6 +373,7 @@ if (hr == S_OK)
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_CreateGdiCompatibleTextLayout(void) static void test_CreateGdiCompatibleTextLayout(void)
@ -371,9 +381,12 @@ static void test_CreateGdiCompatibleTextLayout(void)
static const WCHAR strW[] = {'s','t','r','i','n','g',0}; static const WCHAR strW[] = {'s','t','r','i','n','g',0};
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteFactory *factory;
FLOAT dimension; FLOAT dimension;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout); hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
@ -418,6 +431,7 @@ static void test_CreateGdiCompatibleTextLayout(void)
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_CreateTextFormat(void) static void test_CreateTextFormat(void)
@ -433,8 +447,11 @@ static void test_CreateTextFormat(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
FLOAT spacing, baseline; FLOAT spacing, baseline;
IDWriteInlineObject *trimmingsign; IDWriteInlineObject *trimmingsign;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -509,6 +526,7 @@ if (0) /* crashes on native */
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_GetLocaleName(void) static void test_GetLocaleName(void)
@ -517,10 +535,13 @@ static void test_GetLocaleName(void)
static const WCHAR ruW[] = {'r','u',0}; static const WCHAR ruW[] = {'r','u',0};
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
IDWriteTextFormat *format, *format2; IDWriteTextFormat *format, *format2;
IDWriteFactory *factory;
WCHAR buff[10]; WCHAR buff[10];
UINT32 len; UINT32 len;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -549,6 +570,7 @@ static void test_GetLocaleName(void)
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteTextFormat_Release(format2); IDWriteTextFormat_Release(format2);
IDWriteFactory_Release(factory);
} }
static void test_CreateEllipsisTrimmingSign(void) static void test_CreateEllipsisTrimmingSign(void)
@ -556,8 +578,11 @@ static void test_CreateEllipsisTrimmingSign(void)
DWRITE_BREAK_CONDITION before, after; DWRITE_BREAK_CONDITION before, after;
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteInlineObject *sign; IDWriteInlineObject *sign;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -578,6 +603,7 @@ if (0) /* crashes on native */
IDWriteInlineObject_Release(sign); IDWriteInlineObject_Release(sign);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_fontweight(void) static void test_fontweight(void)
@ -588,9 +614,12 @@ static void test_fontweight(void)
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_FONT_WEIGHT weight; DWRITE_FONT_WEIGHT weight;
DWRITE_TEXT_RANGE range; DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
FLOAT size; FLOAT size;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -665,6 +694,7 @@ static void test_fontweight(void)
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(fmt2); IDWriteTextFormat_Release(fmt2);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_SetInlineObject(void) static void test_SetInlineObject(void)
@ -676,8 +706,11 @@ static void test_SetInlineObject(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range, r2; DWRITE_TEXT_RANGE range, r2;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -796,6 +829,7 @@ static void test_SetInlineObject(void)
IDWriteInlineObject_Release(inlineobj); IDWriteInlineObject_Release(inlineobj);
IDWriteInlineObject_Release(inlineobj2); IDWriteInlineObject_Release(inlineobj2);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
/* drawing calls sequence doesn't depend on run order, instead all runs are /* drawing calls sequence doesn't depend on run order, instead all runs are
@ -830,8 +864,11 @@ static void test_Draw(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range; DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, ruW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -879,17 +916,20 @@ todo_wine
ok_sequence(sequences, RENDERER_ID, draw_seq2, "draw test 2", TRUE); ok_sequence(sequences, RENDERER_ID, draw_seq2, "draw test 2", TRUE);
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_typography(void) static void test_typography(void)
{ {
DWRITE_FONT_FEATURE feature; DWRITE_FONT_FEATURE feature;
IDWriteTypography *typography; IDWriteTypography *typography;
IDWriteFactory *factory;
UINT32 count; UINT32 count;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTypography(factory, &typography); hr = IDWriteFactory_CreateTypography(factory, &typography);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -926,6 +966,7 @@ static void test_typography(void)
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
IDWriteTypography_Release(typography); IDWriteTypography_Release(typography);
IDWriteFactory_Release(factory);
} }
static void test_GetClusterMetrics(void) static void test_GetClusterMetrics(void)
@ -935,9 +976,12 @@ static void test_GetClusterMetrics(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range; DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
UINT32 count; UINT32 count;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -968,6 +1012,7 @@ todo_wine
IDWriteInlineObject_Release(trimm); IDWriteInlineObject_Release(trimm);
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_SetLocaleName(void) static void test_SetLocaleName(void)
@ -977,8 +1022,11 @@ static void test_SetLocaleName(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range; DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -1032,6 +1080,7 @@ if (0) /* crashes on native */
IDWriteTextLayout_Release(layout); IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory);
} }
static void test_SetPairKerning(void) static void test_SetPairKerning(void)
@ -1041,9 +1090,12 @@ static void test_SetPairKerning(void)
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range; DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
BOOL kerning; BOOL kerning;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -1057,6 +1109,7 @@ static void test_SetPairKerning(void)
if (hr != S_OK) { if (hr != S_OK) {
win_skip("SetPairKerning() is not supported.\n"); win_skip("SetPairKerning() is not supported.\n");
IDWriteFactory_Release(factory);
return; return;
} }
@ -1086,6 +1139,7 @@ if (0) { /* crashes on native */
ok(kerning == TRUE, "got %d\n", kerning); ok(kerning == TRUE, "got %d\n", kerning);
IDWriteTextLayout1_Release(layout1); IDWriteTextLayout1_Release(layout1);
IDWriteFactory_Release(factory);
} }
static void test_SetVerticalGlyphOrientation(void) static void test_SetVerticalGlyphOrientation(void)
@ -1095,8 +1149,11 @@ static void test_SetVerticalGlyphOrientation(void)
IDWriteTextLayout2 *layout2; IDWriteTextLayout2 *layout2;
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -1110,6 +1167,7 @@ static void test_SetVerticalGlyphOrientation(void)
if (hr != S_OK) { if (hr != S_OK) {
win_skip("SetVerticalGlyphOrientation() is not supported.\n"); win_skip("SetVerticalGlyphOrientation() is not supported.\n");
IDWriteFactory_Release(factory);
return; return;
} }
@ -1120,6 +1178,7 @@ static void test_SetVerticalGlyphOrientation(void)
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
IDWriteTextLayout2_Release(layout2); IDWriteTextLayout2_Release(layout2);
IDWriteFactory_Release(factory);
} }
static void test_fallback(void) static void test_fallback(void)
@ -1129,8 +1188,11 @@ static void test_fallback(void)
IDWriteTextLayout2 *layout2; IDWriteTextLayout2 *layout2;
IDWriteTextFormat *format; IDWriteTextFormat *format;
IDWriteTextLayout *layout; IDWriteTextLayout *layout;
IDWriteFactory *factory;
HRESULT hr; HRESULT hr;
factory = create_factory();
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
@ -1144,6 +1206,7 @@ static void test_fallback(void)
if (hr != S_OK) { if (hr != S_OK) {
win_skip("GetFontFallback() is not supported.\n"); win_skip("GetFontFallback() is not supported.\n");
IDWriteFactory_Release(factory);
return; return;
} }
@ -1156,16 +1219,14 @@ if (0) /* crashes on native */
ok(fallback == NULL, "got %p\n", fallback); ok(fallback == NULL, "got %p\n", fallback);
IDWriteTextLayout2_Release(layout2); IDWriteTextLayout2_Release(layout2);
IDWriteFactory_Release(factory);
} }
START_TEST(layout) START_TEST(layout)
{ {
HRESULT hr; IDWriteFactory *factory;
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory); if (!(factory = create_factory())) {
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr != S_OK)
{
win_skip("failed to create factory\n"); win_skip("failed to create factory\n");
return; return;
} }