Author: akhaldi
Date: Thu May 17 16:52:25 2012
New Revision: 56603
URL:
http://svn.reactos.org/svn/reactos?rev=56603&view=rev
Log:
[RICHED20_WINETEST]
* Sync to Wine 1.5.4.
Modified:
trunk/rostests/winetests/riched20/editor.c
trunk/rostests/winetests/riched20/txtsrv.c
Modified: trunk/rostests/winetests/riched20/editor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/editor…
==============================================================================
--- trunk/rostests/winetests/riched20/editor.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/riched20/editor.c [iso-8859-1] Thu May 17 16:52:25 2012
@@ -6366,7 +6366,7 @@
/* Reset to default rect and check how the format rect adjusts to window
* resize and how it copes with very small windows */
- SendMessageA(hwnd, EM_SETRECT, 0, (LPARAM)NULL);
+ SendMessageA(hwnd, EM_SETRECT, 0, 0);
MoveWindow(hwnd, 0, 0, 100, 30, FALSE);
GetClientRect(hwnd, &clientRect);
@@ -7170,6 +7170,114 @@
delimiter_tests[i].c, delimiter_tests[i].isdelimiter, result);
}
DestroyWindow(hwndRichEdit);
+}
+
+/*
+ * This test attempts to show the effect of enter on a richedit
+ * control v1.0 inserts CRLF whereas for higher versions it only
+ * inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
+ * and also shows that GT_USECRLF has no effect in richedit 1.0, but
+ * does for higher. The same test is cloned in riched32 and riched20.
+ */
+static void test_enter(void)
+{
+ static const struct {
+ const char *initialtext;
+ const int cursor;
+ const char *expectedwmtext;
+ const char *expectedemtext;
+ const char *expectedemtextcrlf;
+ } testenteritems[] = {
+ { "aaabbb\r\n", 3, "aaa\r\nbbb\r\n", "aaa\rbbb\r",
"aaa\r\nbbb\r\n"},
+ { "aaabbb\r\n", 6, "aaabbb\r\n\r\n", "aaabbb\r\r",
"aaabbb\r\n\r\n"},
+ { "aa\rabbb\r\n", 7, "aa\r\nabbb\r\n\r\n",
"aa\rabbb\r\r", "aa\r\nabbb\r\n\r\n"},
+ { "aa\rabbb\r\n", 3, "aa\r\n\r\nabbb\r\n",
"aa\r\rabbb\r", "aa\r\n\r\nabbb\r\n"},
+ { "aa\rabbb\r\n", 2, "aa\r\n\r\nabbb\r\n",
"aa\r\rabbb\r", "aa\r\n\r\nabbb\r\n"}
+ };
+
+ char expectedbuf[1024];
+ char resultbuf[1024];
+ HWND hwndRichEdit = new_richedit(NULL);
+ UINT i,j;
+
+ for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) {
+
+ char buf[1024] = {0};
+ LRESULT result;
+ GETTEXTEX getText;
+ const char *expected;
+
+ /* Set the text to the initial text */
+ result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)
testenteritems[i].initialtext);
+ ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i,
result);
+
+ /* Send Enter */
+ SendMessage(hwndRichEdit, EM_SETSEL, testenteritems[i].cursor,
testenteritems[i].cursor);
+ simulate_typing_characters(hwndRichEdit, "\r");
+
+ /* 1. Retrieve with WM_GETTEXT */
+ buf[0] = 0x00;
+ result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buf);
+ expected = testenteritems[i].expectedwmtext;
+
+ resultbuf[0]=0x00;
+ for (j = 0; j < (UINT)result; j++)
+ sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
+ expectedbuf[0] = '\0';
+ for (j = 0; j < strlen(expected); j++)
+ sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] &
0xFF);
+
+ result = strcmp(expected, buf);
+ ok (result == 0,
+ "[%d] WM_GETTEXT unexpected '%s' expected '%s'\n",
+ i, resultbuf, expectedbuf);
+
+ /* 2. Retrieve with EM_GETTEXTEX, GT_DEFAULT */
+ getText.cb = sizeof(buf);
+ getText.flags = GT_DEFAULT;
+ getText.codepage = CP_ACP;
+ getText.lpDefaultChar = NULL;
+ getText.lpUsedDefChar = NULL;
+ buf[0] = 0x00;
+ result = SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)
buf);
+ expected = testenteritems[i].expectedemtext;
+
+ resultbuf[0]=0x00;
+ for (j = 0; j < (UINT)result; j++)
+ sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
+ expectedbuf[0] = '\0';
+ for (j = 0; j < strlen(expected); j++)
+ sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] &
0xFF);
+
+ result = strcmp(expected, buf);
+ ok (result == 0,
+ "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected
'%s'\n",
+ i, resultbuf, expectedbuf);
+
+ /* 3. Retrieve with EM_GETTEXTEX, GT_USECRLF */
+ getText.cb = sizeof(buf);
+ getText.flags = GT_USECRLF;
+ getText.codepage = CP_ACP;
+ getText.lpDefaultChar = NULL;
+ getText.lpUsedDefChar = NULL;
+ buf[0] = 0x00;
+ result = SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)
buf);
+ expected = testenteritems[i].expectedemtextcrlf;
+
+ resultbuf[0]=0x00;
+ for (j = 0; j < (UINT)result; j++)
+ sprintf(resultbuf+strlen(resultbuf), "%02x", buf[j] & 0xFF);
+ expectedbuf[0] = '\0';
+ for (j = 0; j < strlen(expected); j++)
+ sprintf(expectedbuf+strlen(expectedbuf), "%02x", expected[j] &
0xFF);
+
+ result = strcmp(expected, buf);
+ ok (result == 0,
+ "[%d] EM_GETTEXTEX, GT_USECRLF unexpected '%s', expected
'%s'\n",
+ i, resultbuf, expectedbuf);
+ }
+
+ DestroyWindow(hwndRichEdit);
}
START_TEST( editor )
@@ -7230,6 +7338,7 @@
test_dialogmode();
test_EM_FINDWORDBREAK_W();
test_EM_FINDWORDBREAK_A();
+ test_enter();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
Modified: trunk/rostests/winetests/riched20/txtsrv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/riched20/txtsrv…
==============================================================================
--- trunk/rostests/winetests/riched20/txtsrv.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/riched20/txtsrv.c [iso-8859-1] Thu May 17 16:52:25 2012
@@ -21,6 +21,7 @@
*/
#define COBJMACROS
+#define CONST_VTABLE
#include <stdio.h>
#include <stdarg.h>
@@ -38,6 +39,7 @@
static IID *pIID_ITextServices;
static IID *pIID_ITextHost;
static IID *pIID_ITextHost2;
+static PCreateTextServices pCreateTextServices;
static const char *debugstr_guid(REFIID riid)
{
@@ -620,7 +622,6 @@
{
IUnknown *init;
HRESULT result;
- PCreateTextServices pCreateTextServices;
dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost));
if (dummyTextHost == NULL) {
@@ -633,7 +634,6 @@
/* MSDN states that an IUnknown object is returned by
CreateTextServices which is then queried to obtain a
ITextServices object. */
- pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit,
"CreateTextServices");
result = (*pCreateTextServices)(NULL, &dummyTextHost->ITextHost_iface,
&init);
ok(result == S_OK, "Did not return S_OK when created (result = %x)\n",
result);
if (result != S_OK) {
@@ -812,6 +812,69 @@
"unexpected value for IID_ITextHost2: %s\n",
debugstr_guid(pIID_ITextHost2));
}
+/* Outer IUnknown for COM aggregation tests */
+struct unk_impl {
+ IUnknown IUnknown_iface;
+ LONG ref;
+ IUnknown *inner_unk;
+};
+
+static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface)
+{
+ return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface);
+}
+
+static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
+{
+ struct unk_impl *This = impl_from_IUnknown(iface);
+
+ return IUnknown_QueryInterface(This->inner_unk, riid, ppv);
+}
+
+static ULONG WINAPI unk_AddRef(IUnknown *iface)
+{
+ struct unk_impl *This = impl_from_IUnknown(iface);
+
+ return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI unk_Release(IUnknown *iface)
+{
+ struct unk_impl *This = impl_from_IUnknown(iface);
+
+ return InterlockedDecrement(&This->ref);
+}
+
+static const IUnknownVtbl unk_vtbl =
+{
+ unk_QueryInterface,
+ unk_AddRef,
+ unk_Release
+};
+
+static void test_COM(void)
+{
+ struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
+ struct ITextHostTestImpl texthost = {{&itextHostVtbl}, 1};
+ ITextServices *textsrv;
+ ULONG refcount;
+ HRESULT hr;
+
+ /* COM aggregation */
+ hr = pCreateTextServices(&unk_obj.IUnknown_iface, &texthost.ITextHost_iface,
+ &unk_obj.inner_unk);
+ ok(hr == S_OK, "CreateTextServices failed: %08x\n", hr);
+ hr = IUnknown_QueryInterface(unk_obj.inner_unk, pIID_ITextServices,
(void**)&textsrv);
+ ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08x\n", hr);
+ refcount = ITextServices_AddRef(textsrv);
+ ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM
aggregation\n");
+ refcount = ITextServices_Release(textsrv);
+ ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM
aggregation\n");
+ refcount = ITextServices_Release(textsrv);
+ ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount);
+
+ IUnknown_Release(unk_obj.inner_unk);
+}
START_TEST( txtsrv )
{
@@ -825,7 +888,10 @@
pIID_ITextServices = (IID*)GetProcAddress(hmoduleRichEdit,
"IID_ITextServices");
pIID_ITextHost = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost");
pIID_ITextHost2 = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost2");
+ pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit,
"CreateTextServices");
+
test_IIDs();
+ test_COM();
if (init_texthost())
{