riched20: Added tests for ITextDocument::Open

Jactry Zeng jactry92 at gmail.com
Tue May 21 07:45:04 CDT 2013


-------------- next part --------------
From abc3f05efa6c2e7eaad0928b0c8e9c9519c9b59a Mon Sep 17 00:00:00 2001
From: Jactry Zeng <jactry92 at gmail.com>
Date: Tue, 21 May 2013 19:31:32 +0800
Subject: riched20: Added tests for ITextDocument::Open.

---
 dlls/riched20/tests/richole.c |   67 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 dlls/riched20/tests/test.txt

diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index d22904a..c3980e3 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -60,6 +60,46 @@ START_TEST(richole)
   HRESULT hres;
   LRESULT res;
   HWND w;
+  VARIANT testfile;
+  WCHAR filename[] = {'t', 'e', 's', 't','.','t','x','t', 0};
+  static const struct tomConstants
+  {
+    char tomConName[64];
+    int value;
+  }
+  tomConstantsSingle[] =
+    {
+      { "tomReadOnly", tomReadOnly },
+      { "tomShareDenyRead", tomShareDenyRead },
+      { "tomShareDenyWrite", tomShareDenyWrite },
+      { "tomPasteFile", tomPasteFile },
+      { "tomCreateAlways", tomCreateAlways },
+      { "tomOpenExisting", tomOpenExisting },
+      { "tomOpenAlways", tomOpenAlways },
+      { "tomTruncateExisting", tomTruncateExisting },
+      { "tomRTF",tomRTF },
+      { "tomText", tomText }
+    },
+  tomConstantsMulti[] =
+    {
+      { "tomReadOnly|tomShareDenyRead", tomReadOnly|tomShareDenyRead },
+      { "tomReadOnly|tomShareDenyWrite", tomReadOnly|tomShareDenyWrite },
+      { "tomReadOnly|tomShareDenyRead|tomShareDenyWrite", tomReadOnly|tomShareDenyRead|tomShareDenyWrite },
+      { "tomShareDenyRead|tomShareDenyWrite", tomShareDenyRead|tomShareDenyWrite },
+      { "tomShareDenyRead|tomPasteFile", tomShareDenyRead|tomPasteFile },
+      { "tomShareDenyRead|tomShareDenyWrite|tomPasteFile", tomShareDenyRead|tomShareDenyWrite|tomPasteFile },
+      { "tomShareDenyWrite|tomPasteFile", tomShareDenyWrite|tomPasteFile },
+      { "tomReadOnly|tomShareDenyRead|tomShareDenyWrite|tomPasteFile", tomShareDenyWrite|tomShareDenyRead|tomShareDenyWrite|tomPasteFile },
+      { "tomReadOnly|tomPasteFile", tomReadOnly|tomPasteFile },
+      { "tomReadOnly|tomShareDenyRead|tomPasteFile", tomReadOnly|tomShareDenyRead|tomPasteFile }
+    };
+
+  int tomNunSingle =  sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]) - 1;
+  int tomNunMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]) -1;
+  VariantInit(&testfile);
+  V_VT(&testfile) = VT_BSTR;
+  V_BSTR(&testfile) = SysAllocString(filename);
+
 
   /* Must explicitly LoadLibrary(). The test has no references to functions in
    * RICHED20.DLL, so the linker doesn't actually link to it. */
@@ -85,6 +125,33 @@ START_TEST(richole)
   ok(hres == S_OK, "ITextDocument_GetSelection\n");
   ok(txtSel != NULL, "ITextDocument_GetSelection\n");
 
+  /* tests for ITextDocument::Open */
+  for(; tomNunSingle >= 0; tomNunSingle--)
+    {
+      SetLastError(0xdeadbeef);
+      hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[tomNunSingle].value, CP_ACP);
+      ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:%s Codepage:CP_ACP hres:0x%x LastError:0x%x\n",
+	 tomConstantsSingle[tomNunSingle].tomConName, hres, GetLastError());
+
+      SetLastError(0xdeadbeef);
+      hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsSingle[tomNunSingle].value, CP_UTF8);
+      ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:%s Codepage:CP_UTF8 hres:0x%x LastError:0x%x\n",
+	 tomConstantsSingle[tomNunSingle].tomConName, hres, GetLastError());
+    }
+
+    for(; tomNunMulti >= 0; tomNunMulti--)
+      {
+	SetLastError(0xdeadbeef);
+	hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[tomNunMulti].value, CP_ACP);
+	ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:%s Codepage:CP_ACP hres:0x%x LastError:0x%x\n",
+	   tomConstantsMulti[tomNunMulti].tomConName, hres, GetLastError());
+
+	SetLastError(0xdeadbeef);
+	hres = ITextDocument_Open(txtDoc, &testfile, tomConstantsMulti[tomNunMulti].value, CP_UTF8);
+	ok(hres == S_OK, "ITextDocument_Open: Filename:test.txt Flags:%s Codepage:CP_UTF8 hres:0x%x LastError:0x%x\n",
+	   tomConstantsMulti[tomNunMulti].tomConName, hres, GetLastError());
+      }
+
   punk = NULL;
   hres = ITextSelection_QueryInterface(txtSel, &IID_ITextSelection, (void **) &punk);
   ok(hres == S_OK, "ITextSelection_QueryInterface\n");
diff --git a/dlls/riched20/tests/test.txt b/dlls/riched20/tests/test.txt
new file mode 100644
index 0000000..e69de29
-- 
1.7.9.5


More information about the wine-patches mailing list