riched20: Add conformance tests for WM_SETFONT

Matt Finnicum mattfinn at gmail.com
Wed Aug 9 15:01:47 CDT 2006


Hi,
This patch adds conformance tests for WM_SETFONT to riched20. It also
changes the default font (if null is sent to WM_SETFONT) from
DEFAULT_GUI_FONT to SYSTEM_FONT - you can verify this is correct by
running the included tests against a native riched20.dll

--Matt Finnicum
-------------- next part --------------
From 15230497c83d845f990af1c4132bcac697c2d027 Mon Sep 17 00:00:00 2001
From: Matthew Finnicum <MattFinn at gmail.com>
Date: Wed, 9 Aug 2006 15:53:09 -0400
Subject: [PATCH] riched20: Add conformance tests for WM_SETFONT
---
 dlls/riched20/editor.c       |    2 +
 dlls/riched20/tests/editor.c |   64 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 77bb7a0..b4e1457 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1874,7 +1874,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
     BOOL bRepaint = LOWORD(lParam);
     
     if (!wParam)
-      wParam = (WPARAM)GetStockObject(DEFAULT_GUI_FONT); 
+      wParam = (WPARAM)GetStockObject(SYSTEM_FONT); 
     GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf);
     hDC = GetDC(hWnd);
     ME_CharFormatFromLogFont(hDC, &lf, &fmt); 
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 6153e6e..af51ecd 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -898,6 +898,69 @@ static void test_ES_PASSWORD()
 	"EM_GETPASSWORDCHAR returned %c (%d) when set to 'x', instead of x (120)\n",result,result);
 }
 
+static void test_WM_SETFONT()
+{
+  /* There is no invalid input or error conditions for this function.
+   * NULL wParam and lParam just fall back to their default values 
+   * It should be noted that even if you use a gibberish name for your fonts
+   * here, it will still work because the name is stored. They will display as
+   * System, but will report their name to be whatever they were created as */
+  
+  HWND hwndRichEdit = new_richedit(NULL);
+  HFONT testFont1 = CreateFontA (0,0,0,0,FW_LIGHT, 0, 0, 0, ANSI_CHARSET, 
+    OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | 
+    FF_DONTCARE, "Marlett");
+  HFONT testFont2 = CreateFontA (0,0,0,0,FW_LIGHT, 0, 0, 0, ANSI_CHARSET, 
+    OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | 
+    FF_DONTCARE, "MS Sans Serif");
+  HFONT testFont3 = CreateFontA (0,0,0,0,FW_LIGHT, 0, 0, 0, ANSI_CHARSET, 
+    OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | 
+    FF_DONTCARE, "Courier");
+  LOGFONTA sentLogFont;
+  CHARFORMAT2A returnedCF2A;
+  
+  returnedCF2A.cbSize = sizeof(returnedCF2A);
+  
+  SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "x");
+  SendMessage(hwndRichEdit, WM_SETFONT, (WPARAM)testFont1,(LPARAM) MAKELONG((WORD) TRUE, 0));
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT,   SCF_DEFAULT,  (LPARAM) &returnedCF2A);
+
+  GetObjectA(testFont1, sizeof(LOGFONTA), &sentLogFont);
+  ok (!strcmp(sentLogFont.lfFaceName,returnedCF2A.szFaceName),
+    "EM_GETCHARFOMAT: Returned wrong font on test 1. Sent: %s, Returned: %s\n",
+    sentLogFont.lfFaceName,returnedCF2A.szFaceName);
+    
+  //ok (0,"Test 1 Sent: %s Recieved: %s",sentLogFont.bPitchAndFamily,lfPitchAndFamily);
+  
+  SendMessage(hwndRichEdit, WM_SETFONT, (WPARAM)testFont2,(LPARAM) MAKELONG((WORD) TRUE, 0));
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT,   SCF_DEFAULT,  (LPARAM) &returnedCF2A);
+  GetObjectA(testFont2, sizeof(LOGFONTA), &sentLogFont);
+  ok (!strcmp(sentLogFont.lfFaceName,returnedCF2A.szFaceName),
+    "EM_GETCHARFOMAT: Returned wrong font on test 2. Sent: %s, Returned: %s\n",
+    sentLogFont.lfFaceName,returnedCF2A.szFaceName);
+    
+  SendMessage(hwndRichEdit, WM_SETFONT, (WPARAM)testFont3,(LPARAM) MAKELONG((WORD) TRUE, 0));
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT,   SCF_DEFAULT,  (LPARAM) &returnedCF2A);
+  GetObjectA(testFont3, sizeof(LOGFONTA), &sentLogFont);
+  ok (!strcmp(sentLogFont.lfFaceName,returnedCF2A.szFaceName),
+    "EM_GETCHARFOMAT: Returned wrong font on test 3. Sent: %s, Returned: %s\n",
+    sentLogFont.lfFaceName,returnedCF2A.szFaceName);
+   
+  /* This last test is special since we send in NULL. We clear the variables
+   * and just compare to "System" instead of the sent in font name. */
+  ZeroMemory(&returnedCF2A,sizeof(returnedCF2A));
+  ZeroMemory(&sentLogFont,sizeof(sentLogFont));
+  returnedCF2A.cbSize = sizeof(returnedCF2A);
+  
+  SendMessage(hwndRichEdit, WM_SETFONT, (WPARAM)NULL,(LPARAM) MAKELONG((WORD) TRUE, 0));
+  SendMessage(hwndRichEdit, EM_GETCHARFORMAT,   SCF_DEFAULT,  (LPARAM) &returnedCF2A);
+  GetObjectA(NULL, sizeof(LOGFONTA), &sentLogFont);
+  ok (!strcmp("System",returnedCF2A.szFaceName),
+    "EM_GETCHARFOMAT: Returned wrong font on test 4. Sent: NULL, Returned: %s. Expected \"System\".\n",returnedCF2A.szFaceName);
+  
+  DestroyWindow(hwndRichEdit);
+}
+
 START_TEST( editor )
 {
   MSG msg;
@@ -918,6 +981,7 @@ START_TEST( editor )
   test_EM_AUTOURLDETECT();
   test_EM_SETUNDOLIMIT();
   test_ES_PASSWORD();
+  test_WM_SETFONT();
 
   /* Set the environment variable WINETEST_RICHED20 to keep windows
    * responsive and open for 30 seconds. This is useful for debugging.
-- 
1.4.1.1


More information about the wine-patches mailing list