Nikolay Sivov : dwrite: Added basic test for IDWriteFont created from LOGFONTW.

Alexandre Julliard julliard at winehq.org
Tue Jul 31 12:04:15 CDT 2012


Module: wine
Branch: master
Commit: bd7db0a9a4af1c2d3d31cd80c47c1bb011b68da1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bd7db0a9a4af1c2d3d31cd80c47c1bb011b68da1

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Jul 31 08:18:02 2012 +0400

dwrite: Added basic test for IDWriteFont created from LOGFONTW.

---

 configure                     |    3 +-
 configure.ac                  |    3 +-
 dlls/dwrite/Makefile.in       |    3 +-
 dlls/dwrite/gdiinterop.c      |    3 +
 dlls/dwrite/tests/Makefile.in |    7 +++
 dlls/dwrite/tests/font.c      |  100 +++++++++++++++++++++++++++++++++++++++++
 include/dwrite.idl            |    2 +
 7 files changed, 118 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 512f7e4..e0984d2 100755
--- a/configure
+++ b/configure
@@ -15280,7 +15280,8 @@ wine_fn_config_dll dssenh enable_dssenh
 wine_fn_config_test dlls/dssenh/tests dssenh_test
 wine_fn_config_dll dswave enable_dswave
 wine_fn_config_dll dwmapi enable_dwmapi implib
-wine_fn_config_dll dwrite enable_dwrite
+wine_fn_config_dll dwrite enable_dwrite implib
+wine_fn_config_test dlls/dwrite/tests dwrite_test
 wine_fn_config_dll dxdiagn enable_dxdiagn po
 wine_fn_config_test dlls/dxdiagn/tests dxdiagn_test
 wine_fn_config_lib dxerr8
diff --git a/configure.ac b/configure.ac
index 35c0e6c..4bd43d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2624,7 +2624,8 @@ WINE_CONFIG_DLL(dssenh)
 WINE_CONFIG_TEST(dlls/dssenh/tests)
 WINE_CONFIG_DLL(dswave)
 WINE_CONFIG_DLL(dwmapi,,[implib])
-WINE_CONFIG_DLL(dwrite)
+WINE_CONFIG_DLL(dwrite,,[implib])
+WINE_CONFIG_TEST(dlls/dwrite/tests)
 WINE_CONFIG_DLL(dxdiagn,,[po])
 WINE_CONFIG_TEST(dlls/dxdiagn/tests)
 WINE_CONFIG_LIB(dxerr8)
diff --git a/dlls/dwrite/Makefile.in b/dlls/dwrite/Makefile.in
index 7d88e77..03220d1 100644
--- a/dlls/dwrite/Makefile.in
+++ b/dlls/dwrite/Makefile.in
@@ -1,4 +1,5 @@
-MODULE = dwrite.dll
+MODULE    = dwrite.dll
+IMPORTLIB = dwrite
 
 C_SRCS = \
 	gdiinterop.c \
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index 7b3c589..8215185 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -57,6 +57,9 @@ static HRESULT WINAPI gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop *iface,
     LOGFONTW const *logfont, IDWriteFont **font)
 {
     FIXME("(%p %p): stub\n", logfont, font);
+
+    if (!logfont) return E_INVALIDARG;
+
     return E_NOTIMPL;
 }
 
diff --git a/dlls/dwrite/tests/Makefile.in b/dlls/dwrite/tests/Makefile.in
new file mode 100644
index 0000000..f00d0e7
--- /dev/null
+++ b/dlls/dwrite/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL = dwrite.dll
+IMPORTS = dwrite
+
+C_SRCS = \
+	font.c
+
+ at MAKE_TEST_RULES@
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
new file mode 100644
index 0000000..fa345e3
--- /dev/null
+++ b/dlls/dwrite/tests/font.c
@@ -0,0 +1,100 @@
+/*
+ *    Font related tests
+ *
+ * Copyright 2012 Nikolay Sivov for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "windows.h"
+
+#include "initguid.h"
+#include "dwrite.h"
+
+#include "wine/test.h"
+
+#define EXPECT_HR(hr,hr_exp) \
+    ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
+
+IDWriteFactory *factory;
+
+static void test_CreateFontFromLOGFONT(void)
+{
+    static const WCHAR arialW[] = {'A','r','i','a','l',0};
+    IDWriteGdiInterop *interop;
+    DWRITE_FONT_WEIGHT weight;
+    DWRITE_FONT_STYLE style;
+    IDWriteFont *font;
+    LOGFONTW logfont;
+    HRESULT hr;
+    BOOL ret;
+
+    hr = IDWriteFactory_GetGdiInterop(factory, &interop);
+    EXPECT_HR(hr, S_OK);
+
+if (0)
+    /* null out parameter crashes this call */
+    hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, NULL);
+
+    hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, NULL, &font);
+    EXPECT_HR(hr, E_INVALIDARG);
+
+    memset(&logfont, 0, sizeof(logfont));
+    logfont.lfHeight = 12;
+    logfont.lfWidth  = 12;
+    logfont.lfWeight = FW_NORMAL;
+    logfont.lfItalic = 1;
+    lstrcpyW(logfont.lfFaceName, arialW);
+
+    hr = IDWriteGdiInterop_CreateFontFromLOGFONT(interop, &logfont, &font);
+todo_wine
+    EXPECT_HR(hr, S_OK);
+
+if (hr == S_OK)
+{
+    /* now check properties */
+    weight = IDWriteFont_GetWeight(font);
+    ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight);
+
+    style = IDWriteFont_GetStyle(font);
+    ok(style == DWRITE_FONT_STYLE_ITALIC, "got %d\n", style);
+
+    ret = IDWriteFont_IsSymbolFont(font);
+    ok(!ret, "got %d\n", ret);
+
+    IDWriteFont_Release(font);
+}
+
+    IDWriteGdiInterop_Release(interop);
+}
+
+START_TEST(font)
+{
+    HRESULT hr;
+
+    hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IDWriteFactory, (IUnknown**)&factory);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    if (hr != S_OK)
+    {
+        win_skip("failed to create factory\n");
+        return;
+    }
+
+    test_CreateFontFromLOGFONT();
+
+    IDWriteFactory_Release(factory);
+}
diff --git a/include/dwrite.idl b/include/dwrite.idl
index dc0e135..aff529a 100644
--- a/include/dwrite.idl
+++ b/include/dwrite.idl
@@ -1392,3 +1392,5 @@ interface IDWriteFactory : IUnknown
         FLOAT baseline_y,
         IDWriteGlyphRunAnalysis **analysis);
 }
+
+cpp_quote("HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE,REFIID,IUnknown**);")




More information about the wine-cvs mailing list