Huw Davies : inetcomm/tests: Add tests for IMimeInternational_GetCharsetInfo.

Alexandre Julliard julliard at winehq.org
Thu Sep 11 08:01:15 CDT 2008


Module: wine
Branch: master
Commit: 3dd46c3606a9cc4a2dee298e54c5639bd42eb373
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3dd46c3606a9cc4a2dee298e54c5639bd42eb373

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Sep 10 14:12:07 2008 +0100

inetcomm/tests: Add tests for IMimeInternational_GetCharsetInfo.

---

 dlls/inetcomm/tests/Makefile.in |    2 +-
 dlls/inetcomm/tests/mimeintl.c  |   45 +++++++++++++++++++++++++++++++++++++++
 dlls/inetcomm/tests/mimeole.c   |    1 -
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/dlls/inetcomm/tests/Makefile.in b/dlls/inetcomm/tests/Makefile.in
index 8e302db..83b0b77 100644
--- a/dlls/inetcomm/tests/Makefile.in
+++ b/dlls/inetcomm/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = inetcomm.dll
-IMPORTS   = inetcomm ole32 kernel32
+IMPORTS   = inetcomm oleaut32 ole32 kernel32
 
 CTESTS = \
 	mimeintl.c \
diff --git a/dlls/inetcomm/tests/mimeintl.c b/dlls/inetcomm/tests/mimeintl.c
index 0075cb5..eae871e 100644
--- a/dlls/inetcomm/tests/mimeintl.c
+++ b/dlls/inetcomm/tests/mimeintl.c
@@ -27,6 +27,9 @@
 
 #include "mimeole.h"
 
+#include "initguid.h"
+#include "mlang.h"
+
 #include <stdio.h>
 #include <assert.h>
 
@@ -52,11 +55,41 @@ static void test_create(void)
     IMimeInternational_Release(internat);
 }
 
+static inline HRESULT get_mlang(IMultiLanguage **ml)
+{
+    return CoCreateInstance(&CLSID_CMultiLanguage, NULL,  CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
+                            &IID_IMultiLanguage, (void **)ml);
+}
+
+static HRESULT mlang_getcsetinfo(const char *charset, MIMECSETINFO *mlang_info)
+{
+    DWORD len = MultiByteToWideChar(CP_ACP, 0, charset, -1, NULL, 0);
+    BSTR bstr = SysAllocStringLen(NULL, len - 1);
+    HRESULT hr;
+    IMultiLanguage *ml;
+
+    MultiByteToWideChar(CP_ACP, 0, charset, -1, bstr, len);
+
+    hr = get_mlang(&ml);
+
+    if(SUCCEEDED(hr))
+    {
+        hr = IMultiLanguage_GetCharsetInfo(ml, bstr, mlang_info);
+        IMultiLanguage_Release(ml);
+    }
+    SysFreeString(bstr);
+    if(FAILED(hr)) hr = MIME_E_NOT_FOUND;
+    return hr;
+}
+
+
 static void test_charset(void)
 {
     IMimeInternational *internat;
     HRESULT hr;
     HCHARSET hcs, hcs_windows_1252, hcs_windows_1251;
+    INETCSETINFO cs_info;
+    MIMECSETINFO mlang_cs_info;
 
     hr = MimeOleGetInternat(&internat);
     ok(hr == S_OK, "ret %08x\n", hr);
@@ -74,6 +107,18 @@ static void test_charset(void)
     ok(hr == S_OK, "got %08x\n", hr);
     ok(hcs_windows_1252 != hcs_windows_1251, "got the same hcharset for the different names\n");
 
+    hr = IMimeInternational_GetCharsetInfo(internat, hcs_windows_1252, &cs_info);
+    ok(hr == S_OK, "got %08x\n", hr);
+
+    hr = mlang_getcsetinfo("windows-1252", &mlang_cs_info);
+    ok(hr == S_OK, "got %08x\n", hr);
+    ok(cs_info.cpiWindows == mlang_cs_info.uiCodePage, "cpiWindows %d while mlang uiCodePage %d\n",
+       cs_info.cpiWindows, mlang_cs_info.uiCodePage);
+    ok(cs_info.cpiInternet == mlang_cs_info.uiInternetEncoding, "cpiInternet %d while mlang uiInternetEncoding %d\n",
+       cs_info.cpiInternet, mlang_cs_info.uiInternetEncoding);
+    ok(cs_info.hCharset == hcs_windows_1252, "hCharset doesn't match requested\n");
+    ok(!strcmp(cs_info.szName, "windows-1252"), "szName doesn't match requested\n");
+
     IMimeInternational_Release(internat);
 }
 
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index eaba225..8200400 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -26,7 +26,6 @@
 #include "ole2.h"
 #include "ocidl.h"
 
-#include "initguid.h"
 #include "mimeole.h"
 
 #include <stdio.h>




More information about the wine-cvs mailing list