diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-11-17 00:37:18 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2016-11-17 00:27:27 +0000 |
commit | c03c77ef4f46b81cd000ea26c4ef154044322535 (patch) | |
tree | 0a3338853dddf41f26e1340c0c7e7ae00c4dcb7b /test | |
parent | b223028d65d24ffcd8e27974c29c2744a5df6227 (diff) |
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@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/README.vars | 3 | ||||
-rw-r--r-- | test/source/setupvcl.cxx | 19 |
2 files changed, 16 insertions, 6 deletions
diff --git a/test/README.vars b/test/README.vars new file mode 100644 index 000000000000..2157d9497db8 --- /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 bd5401b2f059..49bdf7364865 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); |