Nikolay Sivov : dwrite/tests: Add some tests for reference objects.

Alexandre Julliard julliard at winehq.org
Fri Dec 6 16:06:38 CST 2019


Module: wine
Branch: master
Commit: 725a787f45bbea75b24f501c43cfa2c75e0965e0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=725a787f45bbea75b24f501c43cfa2c75e0965e0

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Dec  6 13:58:05 2019 +0300

dwrite/tests: Add some tests for reference objects.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dwrite/tests/font.c | 110 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 75 insertions(+), 35 deletions(-)

diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 5ab01465b7..a0d36e2f0b 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -7558,12 +7558,12 @@ static void test_CreateFontFaceReference(void)
     static const WCHAR dummyW[] = {'d','u','m','m','y',0};
     IDWriteFontFace3 *fontface, *fontface1;
     IDWriteFontFaceReference *ref, *ref1;
+    IDWriteFontCollection1 *collection;
     IDWriteFontFile *file, *file1;
     IDWriteFactory3 *factory;
+    UINT32 index, count, i;
     IDWriteFont3 *font3;
-    IDWriteFont *font;
     ULONG refcount;
-    UINT32 index;
     WCHAR *path;
     HRESULT hr;
     BOOL ret;
@@ -7672,47 +7672,87 @@ todo_wine
     IDWriteFontFile_Release(file);
     IDWriteFontFile_Release(file1);
 
-    /* references returned from IDWriteFont3 */
-    font = get_tahoma_instance((IDWriteFactory *)factory, DWRITE_FONT_STYLE_NORMAL);
-    hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont3, (void**)&font3);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
-    IDWriteFont_Release(font);
+    /* References returned from IDWriteFont3/IDWriteFontFace3. */
+    hr = IDWriteFactory3_GetSystemFontCollection(factory, FALSE, &collection, FALSE);
+    ok(hr == S_OK, "Failed to get system collection, hr %#x.\n", hr);
 
-    hr = IDWriteFont3_GetFontFaceReference(font3, &ref);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
+    count = IDWriteFontCollection1_GetFontFamilyCount(collection);
+    for (i = 0; i < count; i++)
+    {
+        IDWriteFontFamily1 *family;
+        UINT32 font_count, j;
 
-    hr = IDWriteFont3_GetFontFaceReference(font3, &ref1);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
-    ok(ref != ref1, "got %p, %p\n", ref1, ref);
+        hr = IDWriteFontCollection1_GetFontFamily(collection, i, &family);
+        ok(hr == S_OK, "Failed to get family, hr %#x.\n", hr);
 
-    IDWriteFontFaceReference_Release(ref);
-    IDWriteFontFaceReference_Release(ref1);
+        font_count = IDWriteFontFamily1_GetFontCount(family);
 
-    /* references returned from IDWriteFontFace3 */
-    hr = IDWriteFont3_CreateFontFace(font3, &fontface);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
+        for (j = 0; j < font_count; j++)
+        {
+            IDWriteFontFaceReference1 *ref2;
 
-    hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref);
-todo_wine
-    ok(hr == S_OK, "got 0x%08x\n", hr);
+            hr = IDWriteFontFamily1_GetFont(family, j, &font3);
+            ok(hr == S_OK, "Failed to get font, hr %#x.\n", hr);
 
-    hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref1);
-todo_wine
-    ok(hr == S_OK, "got 0x%08x\n", hr);
-if (hr == S_OK)
-    ok(ref == ref1, "got %p, %p\n", ref1, ref);
+            hr = IDWriteFont3_GetFontFaceReference(font3, &ref);
+            ok(hr == S_OK, "Failed to get reference object, hr %#x.\n", hr);
 
-if (hr == S_OK) {
-    hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface1);
-    ok(hr == S_OK, "got 0x%08x\n", hr);
-    ok(fontface1 == fontface, "got %p, %p\n", fontface1, fontface);
-    IDWriteFontFace3_Release(fontface1);
+            hr = IDWriteFont3_GetFontFaceReference(font3, &ref1);
+            ok(hr == S_OK, "Failed to get reference object, hr %#x.\n", hr);
+            ok(ref != ref1, "Unexpected reference object %p, %p.\n", ref1, ref);
 
-    IDWriteFontFaceReference_Release(ref);
-    IDWriteFontFaceReference_Release(ref1);
-}
-    IDWriteFontFace3_Release(fontface);
-    IDWriteFont3_Release(font3);
+            hr = IDWriteFont3_CreateFontFace(font3, &fontface);
+            ok(hr == S_OK, "Failed to create a fontface, hr %#x.\n", hr);
+
+            /* Fonts present regular properties as axis values, for non-variable fonts too.
+               Normally it would include weight/width/slant/italic, but could also contain optical size axis. */
+            if (SUCCEEDED(hr = IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1,
+                    (void **)&ref2)))
+            {
+                UINT32 axis_count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref2);
+            todo_wine
+                ok(axis_count > 0, "Unexpected axis value count.\n");
+                IDWriteFontFaceReference1_Release(ref2);
+            }
+
+            IDWriteFontFaceReference_Release(ref);
+            IDWriteFontFaceReference_Release(ref1);
+
+            hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref);
+        todo_wine
+            ok(hr == S_OK, "Failed to get a reference, hr %#x.\n", hr);
+
+            hr = IDWriteFontFace3_GetFontFaceReference(fontface, &ref1);
+        todo_wine
+            ok(hr == S_OK, "Failed to get a reference, hr %#x.\n", hr);
+        if (hr == S_OK)
+            ok(ref == ref1, "Unexpected reference %p, %p.\n", ref1, ref);
+
+        if (hr == S_OK) {
+            hr = IDWriteFontFaceReference_CreateFontFace(ref, &fontface1);
+            ok(hr == S_OK, "Failed to create fontface, hr %#x.\n", hr);
+            ok(fontface1 == fontface, "Unexpected fontface %p, %p.\n", fontface1, fontface);
+            IDWriteFontFace3_Release(fontface1);
+
+            if (SUCCEEDED(hr = IDWriteFontFaceReference_QueryInterface(ref, &IID_IDWriteFontFaceReference1,
+                    (void **)&ref2)))
+            {
+                UINT32 axis_count = IDWriteFontFaceReference1_GetFontAxisValueCount(ref2);
+                ok(!axis_count, "Unexpected axis value count.\n");
+                IDWriteFontFaceReference1_Release(ref2);
+            }
+
+            IDWriteFontFaceReference_Release(ref);
+            IDWriteFontFaceReference_Release(ref1);
+        }
+            IDWriteFontFace3_Release(fontface);
+
+            IDWriteFont3_Release(font3);
+        }
+
+        IDWriteFontFamily1_Release(family);
+    }
+    IDWriteFontCollection1_Release(collection);
 
     refcount = IDWriteFactory3_Release(factory);
     ok(refcount == 0, "factory not released, %u\n", refcount);




More information about the wine-cvs mailing list