[Libreoffice-commits] core.git: test/README.vars test/source

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Thu Nov 17 00:27:52 UTC 2016


 test/README.vars         |    3 +++
 test/source/setupvcl.cxx |   19 +++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

New commits:
commit c03c77ef4f46b81cd000ea26c4ef154044322535
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Thu Nov 17 00:37:18 2016 +0100

    test: Allow to force a certain locale during unit tests
    
    So that screenshots can be generated in different languages
    
    Change-Id: I486e48a49d6f3837058ec7ac93b5d7d3094be90e
    Reviewed-on: https://gerrit.libreoffice.org/30914
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/test/README.vars b/test/README.vars
new file mode 100644
index 0000000..2157d94
--- /dev/null
+++ b/test/README.vars
@@ -0,0 +1,3 @@
+Environment variables in VCL:
+
+LO_TEST_LOCALE - the locale to be used during unit tests. Defaults to en-US.
diff --git a/test/source/setupvcl.cxx b/test/source/setupvcl.cxx
index bd5401b..49bdf73 100644
--- a/test/source/setupvcl.cxx
+++ b/test/source/setupvcl.cxx
@@ -58,13 +58,20 @@ IMPL_STATIC_LINK_NOARG(Hook, deinitHook, LinkParamNone *, void) {
 }
 
 void test::setUpVcl() {
-    // Force locale (and resource files loaded) to en-US:
-    ResMgr::SetDefaultLocale(LanguageTag("en-US"));
+    // Force locale (and resource files loaded):
+    OUString locale;
+    if (getenv("LO_TEST_LOCALE") != nullptr)
+        locale = OUString::fromUtf8(getenv("LO_TEST_LOCALE"));
+    else
+        locale = "en-US";
+
+    ResMgr::SetDefaultLocale(LanguageTag(locale));
     SvtSysLocaleOptions localOptions;
-    localOptions.SetLocaleConfigString("en-US");
-    localOptions.SetUILocaleConfigString("en-US");
-    MsLangId::setConfiguredSystemUILanguage(LANGUAGE_ENGLISH_US);
-    LanguageTag::setConfiguredSystemLanguage(LANGUAGE_ENGLISH_US);
+    localOptions.SetLocaleConfigString(locale);
+    localOptions.SetUILocaleConfigString(locale);
+    LanguageTag tag(locale);
+    MsLangId::setConfiguredSystemUILanguage(tag.getLanguageType(false));
+    LanguageTag::setConfiguredSystemLanguage(tag.getLanguageType(false));
     InitVCL();
     if (isHeadless()) {
         Application::EnableHeadlessMode(true);


More information about the Libreoffice-commits mailing list