Francois Gouget : mlang/tests: Fix the check for non-English locales in test_GetCodePageInfo().

Alexandre Julliard julliard at winehq.org
Tue Jul 6 18:09:36 CDT 2021


Module: wine
Branch: master
Commit: 237befbe4d69fb275ad77e1907d2f06821c7850e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=237befbe4d69fb275ad77e1907d2f06821c7850e

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Jul  6 16:56:23 2021 +0200

mlang/tests: Fix the check for non-English locales in test_GetCodePageInfo().

The strings returned by GetCodePageInfo() depend on the thread's UI
language, not the system locale or the thread's standards and formats
settings.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mlang/tests/mlang.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c
index d3a71e935d6..1486a643604 100644
--- a/dlls/mlang/tests/mlang.c
+++ b/dlls/mlang/tests/mlang.c
@@ -2511,6 +2511,29 @@ static void test_DetectOutboundCodePageInIStream(IMultiLanguage3 *ml)
     todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
 }
 
+/* Returns true if the user interface is in English. Note that this does not
+ * presume of the formatting of dates, numbers, etc.
+ */
+static BOOL is_lang_english(void)
+{
+    static HMODULE hkernel32 = NULL;
+    static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
+    static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
+
+    if (!hkernel32)
+    {
+        hkernel32 = GetModuleHandleA("kernel32.dll");
+        pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
+        pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
+    }
+    if (pGetThreadUILanguage)
+        return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
+    if (pGetUserDefaultUILanguage)
+        return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
+
+    return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
+}
+
 static void test_GetCodePageInfo(IMultiLanguage2 *iML2)
 {
     static const DWORD VALID_MASK = (DWORD)(~(MIMECONTF_VALID_NLS | MIMECONTF_VALID));
@@ -2560,10 +2583,9 @@ static void test_GetCodePageInfo(IMultiLanguage2 *iML2)
                    "%d: got wrong wszBodyCharset expected %s return %s.\n",
                i, wine_dbgstr_w(cpinfo_cmp.wszBodyCharset), wine_dbgstr_w(cpinfo.wszBodyCharset));
 
-            if ((PRIMARYLANGID(LANGIDFROMLCID(GetSystemDefaultLCID())) != LANG_ENGLISH) ||
-                (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH))
+            if (!is_lang_english())
             {
-                /* FIXME: Windows returns description and font name in system's language */
+                /* FIXME: Cannot test non-English descriptions and font names */
                 skip("Non-English locale\n");
             }
             else




More information about the wine-cvs mailing list