Module: wine
Branch: refs/heads/master
Commit: 22bc001c08687eb0654debf27c57e49f3782c3db
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=22bc001c08687eb0654debf…
Author: Matt Finnicum <mattfinn(a)gmail.com>
Date: Wed Aug 9 16:01:47 2006 -0400
riched20: Add conformance tests for WM_SETFONT.
---
dlls/riched20/editor.c | 2 +
dlls/riched20/tests/editor.c | 62 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 1098618..bf406bf 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1875,7 +1875,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 7812f7d..1e378dd 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -1062,6 +1062,67 @@ static void test_EM_GETLIMITTEXT(void)
DestroyWindow(hwndRichEdit);
}
+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);
+
+ 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;
@@ -1085,6 +1146,7 @@ START_TEST( editor )
test_EM_SETTEXTEX();
test_EM_EXLIMITTEXT();
test_EM_GETLIMITTEXT();
+ test_WM_SETFONT();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.