From 1841426616d97356c725a79fd9cce90231082f8f Mon Sep 17 00:00:00 2001 From: Jactry Zeng Date: Tue, 11 Feb 2014 19:05:33 +0800 Subject: [PATCH] riched20/tests: Add tests to check the content open by ITextDocument_fnOpen. --- dlls/riched20/tests/richole.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 63208eeb10..3781e68f34 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -159,6 +159,16 @@ static void test_ITextDocument_Open(void) HANDLE hFile; VARIANT testfile; WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0}; + int result; + DWORD dw; + static const CHAR chACP[] = "TestSomeText"; + static const CHAR chUTF8[] = "\xef\xbb\xbfTextWithUTF8BOM"; + static const WCHAR chUTF16[] = {0xfeff, 'T', 'e', 's', 't', 'S', 'o', 'm', + 'e', 'T', 'e', 'x', 't', 0}; + +#define MAX_BUF_LEN 1024 + CHAR bufACP[MAX_BUF_LEN]; + WCHAR bufUnicode[MAX_BUF_LEN]; static const int tomConstantsSingle[] = { @@ -328,6 +338,46 @@ static void test_ITextDocument_Open(void) CloseHandle(hFile); release_interfaces(&w, &reOle, &txtDoc, &txtSel); DeleteFileW(filename); + + /* tests to check the content */ + hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + WriteFile(hFile, chACP, sizeof(chACP)-sizeof(CHAR), &dw, NULL); + CloseHandle(hFile); + create_interfaces(&w, &reOle, &txtDoc, &txtSel); + ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_ACP); + result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP); + todo_wine ok(result == 12, "ITextDocument_Open: Test ASCII returned %d, expected 12\n", result); + result = strcmp(bufACP, chACP); + todo_wine ok(result == 0, "ITextDocument_Open: Test ASCII set wrong text: Result: %s\n", bufACP); + release_interfaces(&w, &reOle, &txtDoc, &txtSel); + DeleteFileW(filename); + + hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + WriteFile(hFile, chUTF8, sizeof(chUTF8)-sizeof(CHAR), &dw, NULL); + CloseHandle(hFile); + create_interfaces(&w, &reOle, &txtDoc, &txtSel); + ITextDocument_Open(txtDoc, &testfile, tomReadOnly, CP_UTF8); + result = SendMessageA(w, WM_GETTEXT, 1024, (LPARAM)bufACP); + todo_wine ok(result == 15, "ITextDocument_Open: Test UTF-8 returned %d, expected 15\n", result); + result = strcmp(bufACP, &chUTF8[3]); + todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-8 set wrong text: Result: %s\n", bufACP); + release_interfaces(&w, &reOle, &txtDoc, &txtSel); + DeleteFileW(filename); + + hFile = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + WriteFile(hFile, chUTF16, sizeof(chUTF16)-sizeof(WCHAR), &dw, NULL); + CloseHandle(hFile); + create_interfaces(&w, &reOle, &txtDoc, &txtSel); + ITextDocument_Open(txtDoc, &testfile, tomReadOnly, 1200); + result = SendMessageW(w, WM_GETTEXT, 1024, (LPARAM)bufUnicode); + todo_wine ok(result == 12, "ITextDocument_Open: Test UTF-16 returned %d, expected 12\n", result); + result = lstrcmpW(bufUnicode, &chUTF16[1]); + todo_wine ok(result == 0, "ITextDocument_Open: Test UTF-16 set wrong text: Result: %s\n", wine_dbgstr_w(bufUnicode)); + release_interfaces(&w, &reOle, &txtDoc, &txtSel); + DeleteFileW(filename); } START_TEST(richole)