Francois Gouget : shlwapi/tests: Some tests require that the user interface be in English.

Alexandre Julliard julliard at winehq.org
Thu Sep 15 12:34:53 CDT 2011


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

Author: Francois Gouget <fgouget at free.fr>
Date:   Thu Sep 15 09:36:43 2011 +0200

shlwapi/tests: Some tests require that the user interface be in English.

With MUI versions of Windows checking for the default user language id or locale is insufficient.

---

 dlls/shlwapi/tests/string.c |   44 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c
index 4b984ce..5522137 100644
--- a/dlls/shlwapi/tests/string.c
+++ b/dlls/shlwapi/tests/string.c
@@ -197,6 +197,39 @@ static const StrFromTimeIntervalResult StrFromTimeInterval_results[] = {
   { 0, 0, NULL }
 };
 
+
+/* 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;
+}
+
+/* Returns true if the dates, numbers, etc. are formatted using English
+ * conventions.
+ */
+static BOOL is_locale_english(void)
+{
+    /* Surprisingly GetThreadLocale() is irrelevant here */
+    return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
+}
+
 static void test_StrChrA(void)
 {
   char string[129];
@@ -1405,15 +1438,18 @@ START_TEST(string)
   test_StrDupA();
 
   /* language-dependent test */
-  if (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH)
-    skip("English is required for StrFromTimeInterval and StrFormat*Size tests\n");
-  else
+  if (is_lang_english() && is_locale_english())
   {
     test_StrFormatByteSize64A();
     test_StrFormatKBSizeA();
     test_StrFormatKBSizeW();
-    test_StrFromTimeIntervalA();
   }
+  else
+    skip("An English UI and locale is required for the StrFormat*Size tests\n");
+  if (is_lang_english())
+    test_StrFromTimeIntervalA();
+  else
+    skip("An English UI is required for the StrFromTimeInterval tests\n");
 
   test_StrCmpA();
   test_StrCmpW();




More information about the wine-cvs mailing list