From 74cd5903e2b3c3ca51989b61781e1aba729d490a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= Date: Mon, 22 Oct 2007 10:47:59 -0500 Subject: [PATCH] riched32: Skeleton of richedit 1.0 test plus WM_SETTEXT test. --- .gitignore | 4 + Makefile.in | 2 + configure | 3 + configure.ac | 1 + dlls/Makefile.in | 1 + dlls/riched32/tests/Makefile.in | 13 +++ dlls/riched32/tests/editor.c | 142 ++++++++++++++++++++++++++++++++ programs/winetest/Makefile.in | 3 + programs/winetest/winetest.rc | 1 + 9 files changed, 170 insertions(+) create mode 100644 dlls/riched32/tests/Makefile.in create mode 100644 dlls/riched32/tests/editor.c diff --git a/.gitignore b/.gitignore index 1bde3846142..e64757cf4b7 100644 --- a/.gitignore +++ b/.gitignore @@ -380,6 +380,9 @@ dlls/riched20/tests/*.ok dlls/riched20/tests/riched20_crosstest.exe dlls/riched20/tests/testlist.c dlls/riched20/version.res +dlls/riched32/tests/*.ok +dlls/riched32/tests/riched32_crosstest.exe +dlls/riched32/tests/testlist.c dlls/riched32/version.res dlls/rpcrt4/librpcrt4.def dlls/rpcrt4/tests/*.ok @@ -732,6 +735,7 @@ programs/winetest/pdh_test.exe programs/winetest/psapi_test.exe programs/winetest/quartz_test.exe programs/winetest/riched20_test.exe +programs/winetest/riched32_test.exe programs/winetest/rpcrt4_test.exe programs/winetest/rsabase_test.exe programs/winetest/rsaenh_test.exe diff --git a/Makefile.in b/Makefile.in index 31bfb087a4c..1de6a53ee76 100644 --- a/Makefile.in +++ b/Makefile.in @@ -359,6 +359,7 @@ ALL_MAKEFILES = \ dlls/riched20/Makefile \ dlls/riched20/tests/Makefile \ dlls/riched32/Makefile \ + dlls/riched32/tests/Makefile \ dlls/rpcrt4/Makefile \ dlls/rpcrt4/tests/Makefile \ dlls/rsabase/Makefile \ @@ -733,6 +734,7 @@ dlls/resutils/Makefile: dlls/resutils/Makefile.in dlls/Makedll.rules dlls/riched20/Makefile: dlls/riched20/Makefile.in dlls/Makedll.rules dlls/riched20/tests/Makefile: dlls/riched20/tests/Makefile.in dlls/Maketest.rules dlls/riched32/Makefile: dlls/riched32/Makefile.in dlls/Makedll.rules +dlls/riched32/tests/Makefile: dlls/riched32/tests/Makefile.in dlls/Maketest.rules dlls/rpcrt4/Makefile: dlls/rpcrt4/Makefile.in dlls/Makedll.rules dlls/rpcrt4/tests/Makefile: dlls/rpcrt4/tests/Makefile.in dlls/Maketest.rules dlls/rsabase/Makefile: dlls/rsabase/Makefile.in dlls/Makedll.rules diff --git a/configure b/configure index 9592bec933e..568c5e9b3b0 100755 --- a/configure +++ b/configure @@ -20916,6 +20916,8 @@ ac_config_files="$ac_config_files dlls/riched20/tests/Makefile" ac_config_files="$ac_config_files dlls/riched32/Makefile" +ac_config_files="$ac_config_files dlls/riched32/tests/Makefile" + ac_config_files="$ac_config_files dlls/rpcrt4/Makefile" ac_config_files="$ac_config_files dlls/rpcrt4/tests/Makefile" @@ -21999,6 +22001,7 @@ do "dlls/riched20/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/riched20/Makefile" ;; "dlls/riched20/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/riched20/tests/Makefile" ;; "dlls/riched32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/riched32/Makefile" ;; + "dlls/riched32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/riched32/tests/Makefile" ;; "dlls/rpcrt4/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/rpcrt4/Makefile" ;; "dlls/rpcrt4/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/rpcrt4/tests/Makefile" ;; "dlls/rsabase/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/rsabase/Makefile" ;; diff --git a/configure.ac b/configure.ac index 586321e40c4..f8265d7507a 100644 --- a/configure.ac +++ b/configure.ac @@ -1775,6 +1775,7 @@ AC_CONFIG_FILES([dlls/resutils/Makefile]) AC_CONFIG_FILES([dlls/riched20/Makefile]) AC_CONFIG_FILES([dlls/riched20/tests/Makefile]) AC_CONFIG_FILES([dlls/riched32/Makefile]) +AC_CONFIG_FILES([dlls/riched32/tests/Makefile]) AC_CONFIG_FILES([dlls/rpcrt4/Makefile]) AC_CONFIG_FILES([dlls/rpcrt4/tests/Makefile]) AC_CONFIG_FILES([dlls/rsabase/Makefile]) diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 4eb4dd8261f..f5819c21d78 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -292,6 +292,7 @@ TESTSUBDIRS = \ psapi/tests \ quartz/tests \ riched20/tests \ + riched32/tests \ rpcrt4/tests \ rsabase/tests \ rsaenh/tests \ diff --git a/dlls/riched32/tests/Makefile.in b/dlls/riched32/tests/Makefile.in new file mode 100644 index 00000000000..06de4daf295 --- /dev/null +++ b/dlls/riched32/tests/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = riched32.dll +IMPORTS = ole32 user32 gdi32 kernel32 + +CTESTS = \ + editor.c + +@MAKE_TEST_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c new file mode 100644 index 00000000000..6d0c04e016e --- /dev/null +++ b/dlls/riched32/tests/editor.c @@ -0,0 +1,142 @@ +/* +* Unit test suite for rich edit control 1.0 +* +* Copyright 2006 Google (Thomas Kho) +* Copyright 2007 Matt Finnicum +* Copyright 2007 Dmitry Timoshkov +* Copyright 2007 Alex VillacĂ­s Lasso +* +* 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 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static HMODULE hmoduleRichEdit; + +static HWND new_window(LPCTSTR lpClassName, DWORD dwStyle, HWND parent) { + HWND hwnd; + hwnd = CreateWindow(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL + |WS_VISIBLE, 0, 0, 200, 60, parent, NULL, + hmoduleRichEdit, NULL); + ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError()); + return hwnd; +} + +static HWND new_richedit(HWND parent) { + return new_window(RICHEDIT_CLASS10A, ES_MULTILINE, parent); +} + +static void test_WM_SETTEXT() +{ + HWND hwndRichEdit = new_richedit(NULL); + const char * TestItem1 = "TestSomeText"; + const char * TestItem2 = "TestSomeText\r"; + const char * TestItem3 = "TestSomeText\rSomeMoreText\r"; + const char * TestItem4 = "TestSomeText\n\nTestSomeText"; + const char * TestItem5 = "TestSomeText\r\r\nTestSomeText"; + const char * TestItem6 = "TestSomeText\r\r\n\rTestSomeText"; + const char * TestItem7 = "TestSomeText\r\n\r\r\n\rTestSomeText"; + const char * TestItem8 = "TestSomeText\r\n"; + const char * TestItem9 = "TestSomeText\r\nSomeMoreText\r\n"; + const char * TestItem10 = "TestSomeText\r\n\r\nTestSomeText"; + const char * TestItem11 = "TestSomeText TestSomeText"; + const char * TestItem12 = "TestSomeText \r\nTestSomeText"; + const char * TestItem13 = "TestSomeText\r\n \r\nTestSomeText"; + char buf[1024] = {0}; + LRESULT result; + + /* This test attempts to show that WM_SETTEXT on a riched32 control does not + attempt to modify the text that is pasted into the control, and should + return it as is. In particular, \r\r\n is NOT converted, unlike riched20. + Currently, builtin riched32 mangles solitary \r or \n when not part of + a \r\n pair. + */ + +#define TEST_SETTEXT(a, b, is_todo) \ + result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) a); \ + ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result); \ + result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buf); \ + ok (result == strlen(buf), \ + "WM_GETTEXT returned %ld instead of expected %u\n", \ + result, strlen(buf)); \ + result = strcmp(b, buf); \ + if (is_todo) todo_wine { \ + ok(result == 0, \ + "WM_SETTEXT round trip: strcmp = %ld\n", result); \ + } else { \ + ok(result == 0, \ + "WM_SETTEXT round trip: strcmp = %ld\n", result); \ + } + + TEST_SETTEXT(TestItem1, TestItem1, 0) + TEST_SETTEXT(TestItem2, TestItem2, 1) + TEST_SETTEXT(TestItem3, TestItem3, 1) + TEST_SETTEXT(TestItem4, TestItem4, 1) + TEST_SETTEXT(TestItem5, TestItem5, 1) + TEST_SETTEXT(TestItem6, TestItem6, 1) + TEST_SETTEXT(TestItem7, TestItem7, 1) + TEST_SETTEXT(TestItem8, TestItem8, 0) + TEST_SETTEXT(TestItem9, TestItem9, 0) + TEST_SETTEXT(TestItem10, TestItem10, 0) + TEST_SETTEXT(TestItem11, TestItem11, 0) + TEST_SETTEXT(TestItem12, TestItem12, 0) + TEST_SETTEXT(TestItem13, TestItem13, 0) + +#undef TEST_SETTEXT + DestroyWindow(hwndRichEdit); +} + +START_TEST( editor ) +{ + MSG msg; + time_t end; + + /* Must explicitly LoadLibrary(). The test has no references to functions in + * RICHED32.DLL, so the linker doesn't actually link to it. */ + hmoduleRichEdit = LoadLibrary("RICHED32.DLL"); + ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); + + test_WM_SETTEXT(); + + /* Set the environment variable WINETEST_RICHED32 to keep windows + * responsive and open for 30 seconds. This is useful for debugging. + * + * The message pump uses PeekMessage() to empty the queue and then sleeps for + * 50ms before retrying the queue. */ + end = time(NULL) + 30; + if (getenv( "WINETEST_RICHED32" )) { + while (time(NULL) < end) { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } else { + Sleep(50); + } + } + } + + OleFlushClipboard(); + ok(FreeLibrary(hmoduleRichEdit) != 0, "error: %d\n", (int) GetLastError()); +} diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in index b1342e0a55e..56197e4c160 100644 --- a/programs/winetest/Makefile.in +++ b/programs/winetest/Makefile.in @@ -68,6 +68,7 @@ TESTBINS = \ psapi_test.exe \ quartz_test.exe \ riched20_test.exe \ + riched32_test.exe \ rpcrt4_test.exe \ rsabase_test.exe \ rsaenh_test.exe \ @@ -187,6 +188,8 @@ quartz_test.exe: $(DLLDIR)/quartz/tests/quartz_test.exe$(DLLEXT) cp $(DLLDIR)/quartz/tests/quartz_test.exe$(DLLEXT) $@ && $(STRIP) $@ riched20_test.exe: $(DLLDIR)/riched20/tests/riched20_test.exe$(DLLEXT) cp $(DLLDIR)/riched20/tests/riched20_test.exe$(DLLEXT) $@ && $(STRIP) $@ +riched32_test.exe: $(DLLDIR)/riched32/tests/riched32_test.exe$(DLLEXT) + cp $(DLLDIR)/riched32/tests/riched32_test.exe$(DLLEXT) $@ && $(STRIP) $@ rpcrt4_test.exe: $(DLLDIR)/rpcrt4/tests/rpcrt4_test.exe$(DLLEXT) cp $(DLLDIR)/rpcrt4/tests/rpcrt4_test.exe$(DLLEXT) $@ && $(STRIP) $@ rsabase_test.exe: $(DLLDIR)/rsabase/tests/rsabase_test.exe$(DLLEXT) diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index 9b8a8ebfc0b..b34931a78ae 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -126,6 +126,7 @@ pdh_test.exe TESTRES "pdh_test.exe" psapi_test.exe TESTRES "psapi_test.exe" quartz_test.exe TESTRES "quartz_test.exe" riched20_test.exe TESTRES "riched20_test.exe" +riched32_test.exe TESTRES "riched32_test.exe" rpcrt4_test.exe TESTRES "rpcrt4_test.exe" rsabase_test.exe TESTRES "rsabase_test.exe" rsaenh_test.exe TESTRES "rsaenh_test.exe"