[1/2] comdlg32/tests: Add some font dialog tests.

Kusanagi Kouichi slash at ac.auone-net.jp
Thu Dec 29 06:49:13 CST 2011


Signed-off-by: Kusanagi Kouichi <slash at ac.auone-net.jp>
---
 dlls/comdlg32/tests/fontdlg.c |   65 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/dlls/comdlg32/tests/fontdlg.c b/dlls/comdlg32/tests/fontdlg.c
index 0900535..c16fcf3 100644
--- a/dlls/comdlg32/tests/fontdlg.c
+++ b/dlls/comdlg32/tests/fontdlg.c
@@ -69,12 +69,49 @@ static HDC get_printer_ic(void)
     return result;
 }
 
-static UINT_PTR CALLBACK CFHookProcOK(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+static INT CALLBACK novert_proc(const LOGFONTA *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lparam)
 {
+    const LRESULT ret = SendMessage((HWND)lparam, CB_FINDSTRINGEXACT, -1, (LPARAM)elf->lfFaceName);
+
+    if (elf->lfFaceName[0] == '@')
+        todo_wine
+        ok(ret == CB_ERR, "%s is listed\n", elf->lfFaceName);
+    else
+        ok(ret != CB_ERR, "%s is not listed\n", elf->lfFaceName);
+
+    return 1;
+}
+
+static UINT_PTR CALLBACK CFHookProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    LOGFONTA lf;
+    HWND ctl;
+    HDC hdc;
+
     switch (msg)
     {
     case WM_INITDIALOG:
-        PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
+        switch (((CHOOSEFONT *)lparam)->lCustData)
+        {
+        case IDOK:
+            PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
+            break;
+        case IDCANCEL:
+            PostMessageA(hdlg, WM_COMMAND, IDCANCEL, FALSE);
+            break;
+        case CF_NOVERTFONTS:
+            lf.lfCharSet = DEFAULT_CHARSET;
+            lf.lfPitchAndFamily = 0;
+            lf.lfFaceName[0] = '\0';
+            ctl = GetDlgItem(hdlg, cmb1);
+            hdc = GetDC(NULL);
+            EnumFontFamiliesExA(hdc, &lf, novert_proc, (LPARAM)ctl, 0);
+            ReleaseDC(NULL, hdc);
+            PostMessageA(hdlg, WM_COMMAND, IDOK, FALSE);
+            break;
+        default:
+            break;
+        }
         return 0;
     default:
         return 0;
@@ -85,11 +122,22 @@ static void test_ChooseFontA(void)
 {
     LOGFONTA lfa;
     CHOOSEFONTA cfa;
+    DWORD err;
     BOOL ret;
     int dpiy = get_dpiy();
     int expected_pointsize, expected_lfheight;
     HDC printer_ic;
 
+    cfa.lStructSize = sizeof cfa;
+    cfa.lpLogFont = &lfa;
+    cfa.hwndOwner = NULL;
+    cfa.Flags = CF_ENABLEHOOK | CF_SCREENFONTS;
+    cfa.lCustData = IDCANCEL;
+    cfa.lpfnHook = CFHookProc;
+    ok(!ChooseFontA(&cfa), "ChooseFontA returned TRUE\n");
+    err = CommDlgExtendedError();
+    ok(err == 0, "expected 0, got 0x%x\n", err);
+
     memset(&lfa, 0, sizeof(LOGFONTA));
     lfa.lfHeight = -16;
     lfa.lfWeight = FW_NORMAL;
@@ -99,7 +147,8 @@ static void test_ChooseFontA(void)
     cfa.lStructSize = sizeof(cfa);
     cfa.lpLogFont = &lfa;
     cfa.Flags = CF_ENABLEHOOK|CF_INITTOLOGFONTSTRUCT|CF_SCREENFONTS;
-    cfa.lpfnHook = CFHookProcOK;
+    cfa.lpfnHook = CFHookProc;
+    cfa.lCustData = IDOK;
 
     ret = ChooseFontA(&cfa);
 
@@ -112,6 +161,14 @@ static void test_ChooseFontA(void)
     ok(lfa.lfWeight == FW_NORMAL, "Expected FW_NORMAL, got %i\n", lfa.lfWeight);
     ok(strcmp(lfa.lfFaceName, "Symbol") == 0, "Expected Symbol, got %s\n", lfa.lfFaceName);
 
+    cfa.lStructSize = sizeof cfa;
+    cfa.lpLogFont = &lfa;
+    cfa.hwndOwner = NULL;
+    cfa.Flags = CF_ENABLEHOOK | CF_NOVERTFONTS | CF_SCREENFONTS;
+    cfa.lCustData = CF_NOVERTFONTS;
+    cfa.lpfnHook = CFHookProc;
+    ChooseFontA(&cfa);
+
     printer_ic = get_printer_ic();
     if (!printer_ic)
         skip("can't get a DC for a local printer\n");
@@ -127,7 +184,7 @@ static void test_ChooseFontA(void)
         cfa.lpLogFont = &lfa;
         cfa.Flags = CF_ENABLEHOOK|CF_INITTOLOGFONTSTRUCT|CF_PRINTERFONTS;
         cfa.hDC = printer_ic;
-        cfa.lpfnHook = CFHookProcOK;
+        cfa.lpfnHook = CFHookProc;
 
         ret = ChooseFontA(&cfa);
 
-- 
1.7.7.3




More information about the wine-patches mailing list