riched32: Skeleton of richedit 1.0 test plus WM_SETTEXT test.

This commit is contained in:
Alex Villacís Lasso 2007-10-22 10:47:59 -05:00 committed by Alexandre Julliard
parent 2c742a38c4
commit 74cd5903e2
9 changed files with 170 additions and 0 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -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

3
configure vendored
View File

@ -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" ;;

View File

@ -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])

View File

@ -292,6 +292,7 @@ TESTSUBDIRS = \
psapi/tests \
quartz/tests \
riched20/tests \
riched32/tests \
rpcrt4/tests \
rsabase/tests \
rsaenh/tests \

View File

@ -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

View File

@ -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 <stdarg.h>
#include <assert.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <winnls.h>
#include <ole2.h>
#include <richedit.h>
#include <time.h>
#include <wine/test.h>
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());
}

View File

@ -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)

View File

@ -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"