configmgr/qa/unit/test.cxx                           |    9 +++++++++
 test/user-template/registry-common/modifications.xcd |    5 +++++
 2 files changed, 14 insertions(+)

New commits:
commit e2cd6fca2f94885e308e9454a2fc986b0ae5afe8
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Thu Feb 16 07:56:46 2023 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Thu Feb 16 10:05:29 2023 +0000

    Improve testLocalizedProperty
    
    c3bd52f81bf733a0b9b0560794a54b2ac1e0f444 "Use the (first segment of the)
    original locale value for the workaround again" had stated:  "The added test
    code unfortunately doesn't actually test this piece of code, and somewhat
    unexpectedly receives the "default" value from the empty string locale 
default,
    rather than the "en-US" value from the higher precedence "en-US" locale 
default,
    because `aFallbacks` happens to contain an empty string, so we already leave
    Access::getChild early in the 'Find the best match using the LanguageTag
    fallback mechanism, excluding the original tag' block."  But, of course, the
    relevant code can well be tested after all, using a localized property that
    does not have a default no-xml:lang value.
    
    (And add a TODO comment about the unexpected "default" vs. "en-US" in the
    original test code, in case the LanguageTag::getFallbackStrings behavior 
ever
    changes and the test starts to fail.)
    
    Change-Id: I526a830a5929b6b5ad17ba57af5943954b07b86a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147137
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index 7aa2daf6f96d..fa380ab76dbf 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -329,8 +329,17 @@ void Test::testLocalizedProperty() {
         OUString v;
         CPPUNIT_ASSERT(
             
access->getByHierarchicalName("/org.libreoffice.unittest/localized/*-") >>= v);
+        //TODO: "default" instead of "en-US" is presumably due to a bug in
+        // LanguageTag::getFallbackStrings, which returns an empty string:
         CPPUNIT_ASSERT_EQUAL(OUString("default"), v);
     }
+    {
+        // Make sure a degenerate passed-in "-" locale is handled gracefully:
+        OUString v;
+        CPPUNIT_ASSERT(
+            
access->getByHierarchicalName("/org.libreoffice.unittest/noDefaultLang/*-") >>= 
v);
+        CPPUNIT_ASSERT_EQUAL(OUString("en-US"), v);
+    }
 }
 
 void Test::testReadCommands()
diff --git a/test/user-template/registry-common/modifications.xcd 
b/test/user-template/registry-common/modifications.xcd
index 1d31141bb04b..f4698116b932 100644
--- a/test/user-template/registry-common/modifications.xcd
+++ b/test/user-template/registry-common/modifications.xcd
@@ -12,6 +12,8 @@
   <component>
    <prop oor:name="localized" oor:localized="true" oor:type="xs:string">
    </prop>
+   <prop oor:name="noDefaultLang" oor:localized="true" oor:type="xs:string">
+   </prop>
   </component>
  </oor:component-schema>
  <oor:component-data oor:package="org.libreoffice" oor:name="unittest">
@@ -20,6 +22,9 @@
     <value xml:lang="en-US">en-US</value>
     <value xml:lang="pt-PT">pt-PT</value>
   </prop>
+  <prop oor:name="noDefaultLang">
+    <value xml:lang="en-US">en-US</value>
+  </prop>
  </oor:component-data>
  <oor:component-data xmlns:install="http://openoffice.org/2004/installation"; 
oor:name="VCL" oor:package="org.openoffice">
   <node oor:name="DefaultFonts">

Reply via email to