riched20/tests: Add Conformance test for EM_FINDWORKBREAK
James McKenzie
jjmckenzie51 at gmail.com
Sun May 8 11:24:51 CDT 2011
try 3: Remove unused but initialized variable.
try 2: Remove bypass code for initial testing.
Conformance tests for bugs 14401 and 23292.
This patch is released in to the public domain without reservation for any
lawful purpose.
---
dlls/riched20/tests/editor.c | 277 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 277 insertions(+), 0 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index c0ad42f..baa9296 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -7034,6 +7034,282 @@ static void test_dialogmode(void)
DestroyWindow(hwParent);
}
+static void test_EM_FINDWORDBREAK(void)
+{
+ HWND hwndRichEdit = new_richedit(NULL);
+ long result, class;
+ char text[] = "Text for wordbreak proc!!! test.member ...";
+ /* 0123456789012345678901234567890123456789012345
+ * 10 20 30 40 {0}
+ */
+ /* Unicode representation of above */
+ WCHAR in_text[] = {'T','e','x','t',' ','f','o','r',' ','w','o','r','d','b','r',
+ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
+ 'e','a','k',' ','p','r','o','c','!','!','!',' ',' ',' ',' ',
+ /*15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 */
+ 't','e','s','t','.','m','e','m','b','e','r',' ','.','.','.', 0};
+ /*30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 */
+ static const struct {
+ const char newchar;
+ int location;
+ BOOL isdelimiter;
+ WORD class;
+ } fmtstrings[] = {
+ {'<', 4, 0, 1},
+ {'>', 4, 0, 1},
+ {'{', 5, 0, 1},
+ {'}', 5, 0, 1},
+ {'(', 6, 0, 1},
+ {')', 6, 0, 1},
+ {'[', 4, 0, 1},
+ {']', 4, 0, 1},
+ {'\t', 5, 0, 0x13},
+ {'$', 5, 0, 1},
+ {'!', 6, 0, 1},
+ {'%', 6, 0, 1},
+ {'-', 4, 0, 0x41},
+ {'?', 4, 0, 1},
+ {'\\', 5, 0, 1},
+ {0x20, 5, TRUE, 0x32},
+ {0x0a, 6, FALSE, 0x14}, /* newline */
+ {0x0b, 6, FALSE, 0x14}, /* vertical tab mark */
+ {0x0c, 4, FALSE, 0x14}, /* form feed */
+ {0x0d, 4, FALSE, 0x14}, /* carriage return */
+ {'A', 6, 0, 0}
+ };
+ static const struct {
+ const WCHAR newchar;
+ int location;
+ BOOL isdelimiter;
+ WORD class;
+ } Widestrings[] = {
+ {0xf020, 4, TRUE, 0x32},
+ {0x00a0, 4, FALSE, 0x12},
+ {0x3000, 5, FALSE, 0x12},
+ {WCH_EMBEDDING, 5, FALSE, 0x42},
+ {0x85, 6, FALSE, 0x14}, /* detected as Class 0 for Windows NT 4.0 and Windows 2K SP4 */
+ {0x1680, 6, FALSE, 0x14}, /* detected as Class 0 for Windows NT 4.0 and Windows 2K SP4 */
+ {0x180e, 4, FALSE, 0x14}, /* detected as Class 0 for Windows NT 4.0, Windows 2K SP4, WinXP SP3 and Windows 2K3 SE SP2 */
+ {0x2000, 4, FALSE, 0x14},
+ {0x2002, 5, FALSE, 0x14},
+ {0x2003, 5, FALSE, 0x14},
+ {0x2004, 6, FALSE, 0x14},
+ {0x2005, 6, FALSE, 0x14},
+ {0x2006, 4, FALSE, 0x14},
+ {0x2008, 4, FALSE, 0x14},
+ {0x2009, 5, FALSE, 0x14},
+ {0x200a, 5, FALSE, 0x14},
+ {0x2028, 6, FALSE, 0x14}, /* secondary UNICODE */
+ {0x2029, 6, FALSE, 0x14},
+ {0x202f, 4, FALSE, 0x14}, /* detected as Class 0 for Windows NT 4.0 and Windows 2K SP4 */
+ {0x205f, 4, FALSE, 0x14}, /* detected as Class 0 for Windows NT 4.0, Windows 2K SP4, WinXP SP3 and Windows 2K3 SE SP2 */
+ {0xf061, 6, FALSE, 0}, /* High order UNICODE Capital letter A */
+ {0x1100, 6, FALSE, 0x0}, /* Hangul Choseong Kiyeok (G sound) Ordinary Letter*/
+ {0x11ff, 6, FALSE, 0x0}, /* Hangul Jongseoung Kiyeok-Hieuh (Hard N sound) Ordinary Letter*/
+ {0x115f, 6, FALSE, 0x0}, /* Hangul Choseong Filler (no sound, used with two letter Hangul words) Ordinary Letter */
+ {0xac00, 6, FALSE, 0x80}, /* Hangul character GA*/
+ {0xd7af, 6, FALSE, 0x80} /*End of Hangul character chart */
+ };
+
+ static const struct {
+ int start;
+ int left_location;
+ int leftword_location;
+ int leftbreak_location;
+ int right_location;
+ int rightword_location;
+ int rightbreak_location;
+ } postest[] ={
+ { -2, 0, 0, 0, 0, 5, 0 }, /* test for underflow, all cases should point to beginning of text */
+ { 0, 0, 0, 0, 0, 5, 0 }, /* start at beginning of text, all left cases should return zero */
+ { 3, 0, 0, 0, 5, 5, 4 }, /* Set to s in Test */
+ { 5, 4, 0, 4, 5, 9, 5 }, /* Set to first letter in for */
+ { 6, 5, 5, 4, 9, 9, 8 }, /* Set to second letter in for */
+ { 21, 19, 19, 18, 30, 23, 26 }, /* set to 'o' in proc */
+ { 27, 26, 23, 26, 30, 30, 30 }, /* Middle of spaces after triple exclamation points */
+ { 31, 30, 30, 26, 42, 34, 41 }, /* e in the word test in test.member */
+ { 36, 30, 35, 26, 42, 42, 41 }, /* e in the work member in test.member */
+ { 43, 41, 42, 41, 45, 45, 45 }, /* middle of ellipsis at end of text line */
+ { 47, 46, 45, 46, 46, 46, 46 } /* overflow test. MOVEWORD_LEFT finds NULL at end of string */
+ };
+
+ GETTEXTLENGTHEX gtl;
+ int i, j, len;
+ int length = sizeof(in_text);
+
+ EDITSTREAM es;
+ struct {
+ WORD buf_size;
+ char out_text[4096];
+ } buffer;
+ struct StringWithLength cookie;
+ buffer.buf_size = sizeof(buffer.out_text);
+
+ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+
+ gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
+ gtl.codepage = CP_ACP;
+ len = SendMessageA(hwndRichEdit, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0);
+
+ for (i = 0; i < sizeof(postest)/sizeof(postest[0]); i++)
+ {
+ /* Test executes Send Message for WB_LEFT */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_LEFT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].left_location,"EM_FINDWORDBREAK WB_LEFT ANSI %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].left_location, result);
+ }
+
+ /* Test executes Send Message for WB_MOVEWORDLEFT */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_MOVEWORDLEFT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].leftword_location,"EM_FINDWORDBREAK WB_MOVEWORDLEFT %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].leftword_location, result);
+ }
+
+ /* Test executes Send Message for WB_LEFT/PREVBREAK */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_LEFTBREAK, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].leftbreak_location,"EM_FINDWORDBREAK WB_LEFTBREAK %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].leftbreak_location, result);
+ }
+
+ /* Test executes Send Message for WB_RIGHT */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_RIGHT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].right_location, "EM_FINDWORDBREAK WB_RIGHT %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].right_location, result);
+ }
+
+ /* Test executes SendMessage for WB_MOVEWORDRIGHT */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_MOVEWORDRIGHT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].rightword_location, "EM_FINDWORDBREAK WB_MOVEWORDRIGHT %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].rightword_location, result);
+ }
+
+ /* Test executes SendMessage for WB_RIGHT/NEXTBREAK */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_RIGHTBREAK, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].rightbreak_location, "EM_FINDWORDBREAK WB_RIGHTBREAK %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].rightbreak_location, result);
+ }
+
+ }
+
+ for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++)
+ {
+ j = fmtstrings[i].location;
+ text[j] = fmtstrings[i].newchar;
+ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
+
+ /* Test WB_ISDELIMITER Case */
+ result = SendMessageA(hwndRichEdit, EM_FINDWORDBREAK, WB_ISDELIMITER, j);
+ todo_wine {
+ ok(result == fmtstrings[i].isdelimiter, "%c at %d not detected as a delimiter\n", text[j], j);
+ }
+
+ /* Add tests for WB_CLASSIFY */
+
+ class = SendMessageA(hwndRichEdit, EM_FINDWORDBREAK, WB_CLASSIFY, j);
+ todo_wine {
+ ok(class == fmtstrings[i].class, "%c at %d detected as class %x\n", text[j], j, class);
+ }
+ }
+
+ SendMessageW(hwndRichEdit, WM_SETTEXT, SF_TEXT|SF_UNICODE, (LPARAM) in_text);
+
+ for (i = 0; i < sizeof(postest)/sizeof(postest[0]); i++)
+ {
+ /* Test executes Send Message for WB_LEFT */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_LEFT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].left_location,"EM_FINDWORDBREAK WB_LEFT Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].left_location, result);
+ }
+
+ /* Test executes Send Message for WB_MOVEWORDLEFT */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_MOVEWORDLEFT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].leftword_location,"EM_FINDWORDBREAK WB_MOVEWORDLEFT Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].leftword_location, result);
+ }
+
+ /* Test executes Send Message for WB_LEFT/PREVBREAK */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_LEFTBREAK, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].leftbreak_location,"EM_FINDWORDBREAK WB_LEFTBREAK Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].leftbreak_location, result);
+ }
+
+ /* Test executes Send Message for WB_RIGHT */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_RIGHT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].right_location, "EM_FINDWORDBREAK WB_RIGHT Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].right_location, result);
+ }
+
+ /* Test executes SendMessage for WB_MOVEWORDRIGHT */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_MOVEWORDRIGHT, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].rightword_location, "EM_FINDWORDBREAK WB_MOVEWORDRIGHT Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].rightword_location, result);
+ }
+
+ /* Test executes SendMessage for WB_RIGHT/NEXTBREAK */
+ result = SendMessageW(hwndRichEdit, EM_FINDWORDBREAK, WB_RIGHTBREAK, postest[i].start);
+ todo_wine {
+ ok(result == postest[i].rightbreak_location, "EM_FINDWORDBREAK WB_RIGHTBREAK Unicode %d: "
+ "expected: %d actual: %ld\n", postest[i].start, postest[i].rightbreak_location, result);
+ }
+
+ }
+
+ /* WB_CLASSIFY and WB_DELIMITER Tests using Widestrings [] */
+ for (i = 0; i < sizeof(Widestrings)/sizeof(Widestrings[0]); i++)
+ {
+ j = Widestrings[i].location;
+ in_text[j] = Widestrings[i].newchar;
+ length = sizeof(in_text);
+ es.dwError = 0;
+ cookie.buffer = (char *)in_text;
+ cookie.length = length;
+ es.dwCookie = (DWORD_PTR)&cookie;
+ es.pfnCallback = test_EM_STREAMIN_esCallback2;
+ /* use EM_STREAMIN so that we can insert NULL bytes */
+ SendMessageW(hwndRichEdit, EM_STREAMIN, SF_TEXT|SF_UNICODE, (LPARAM)&es);
+
+ /* Test WB_ISDELIMITER Case */
+ result = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_ISDELIMITER, j);
+ todo_wine {
+ ok(result == Widestrings[i].isdelimiter, "%x at %d not detected as a delimiter\n", in_text[j], j);
+ }
+
+ /* Add tests for WB_CLASSIFY */
+
+ class = SendMessage(hwndRichEdit, EM_FINDWORDBREAK, WB_CLASSIFY, j);
+ todo_wine {
+ switch (Widestrings[i].newchar) {
+ case 0x85:
+ case 0x1680:
+ case 0x202f:
+ ok (class == Widestrings[i].class || broken (class == 0), /* WINNT/WIN2K */ "UNICODE Char %x detected as class %x, should be class %x",
+ Widestrings[i].newchar, class, Widestrings[i].class);
+ break;
+ case 0x180e:
+ case 0x205f:
+ ok (class == Widestrings[i].class || broken (class == 0), /*WINNT/WIN2K/WINXP/WIN2K3 */ "UNICODE char %x detected as class %x, "
+ "should be class %x", Widestrings[i], class, Widestrings[i].class);
+ break;
+ default:
+ ok(class == Widestrings[i].class, "%x detected as class %x, should be %x\n", in_text[j], class, Widestrings[i].class);
+ }
+ }
+ }
+
+ DestroyWindow(hwndRichEdit);
+}
+
START_TEST( editor )
{
BOOL ret;
@@ -7090,6 +7366,7 @@ START_TEST( editor )
test_WM_GETDLGCODE();
test_zoom();
test_dialogmode();
+ test_EM_FINDWORDBREAK();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
--
1.7.5
--------------070907020701030903060303--
More information about the wine-patches
mailing list