sc/CppunitTest_sc_theme_import_export_test.mk                    |    2 
 sc/qa/unit/ThemeImportExportTest.cxx                             |   56 
+++++++---
 sc/qa/unit/data/xlsx/Test_ThemeColor_Text_Background_Border.xlsx |binary
 3 files changed, 45 insertions(+), 13 deletions(-)

New commits:
commit e836e69eb6f2f01a475c5679fb338dda7936643f
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Jun 23 21:57:14 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Jun 29 04:57:45 2023 +0200

    sc: Add import tests for text, background, border theme colors
    
    Change-Id: I03f0ddb42e6491618e56ba98f5bd8befc9ba47a5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153506
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/CppunitTest_sc_theme_import_export_test.mk 
b/sc/CppunitTest_sc_theme_import_export_test.mk
index 52f9736e36b9..22b0a2eea6a2 100644
--- a/sc/CppunitTest_sc_theme_import_export_test.mk
+++ b/sc/CppunitTest_sc_theme_import_export_test.mk
@@ -25,6 +25,7 @@ $(eval $(call 
gb_CppunitTest_use_externals,sc_theme_import_export_test, \
 
 $(eval $(call gb_CppunitTest_use_libraries,sc_theme_import_export_test, \
     basegfx \
+    docmodel \
     comphelper \
     cppu \
     cppuhelper \
@@ -34,6 +35,7 @@ $(eval $(call 
gb_CppunitTest_use_libraries,sc_theme_import_export_test, \
     sc \
     scqahelper \
     sfx \
+    svl \
     subsequenttest \
     test \
     tl \
diff --git a/sc/qa/unit/ThemeImportExportTest.cxx 
b/sc/qa/unit/ThemeImportExportTest.cxx
index ae1653837f36..45d29bf7a088 100644
--- a/sc/qa/unit/ThemeImportExportTest.cxx
+++ b/sc/qa/unit/ThemeImportExportTest.cxx
@@ -7,30 +7,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <test/unoapixml_test.hxx>
+#include "helper/qahelper.hxx"
 
-#include <com/sun/star/lang/XComponent.hpp>
-#include <comphelper/servicehelper.hxx>
 #include <docsh.hxx>
+#include <scitems.hxx>
+#include <editeng/brushitem.hxx>
 
 using namespace css;
 
-class ThemeImportExportTest : public UnoApiXmlTest
+class ThemeImportExportTest : public ScModelTestBase
 {
 public:
     ThemeImportExportTest()
-        : UnoApiXmlTest("sc/qa/unit/data")
+        : ScModelTestBase("sc/qa/unit/data")
     {
     }
-
-    void test();
-
-    CPPUNIT_TEST_SUITE(ThemeImportExportTest);
-    CPPUNIT_TEST(test);
-    CPPUNIT_TEST_SUITE_END();
 };
 
-void ThemeImportExportTest::test()
+CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExport)
 {
     loadFromURL(u"xlsx/CalcThemeTest.xlsx");
 
@@ -64,7 +58,43 @@ void ThemeImportExportTest::test()
     assertXPath(pXmlDoc, 
"/x:styleSheet/x:fills/x:fill[4]/x:patternFill/x:fgColor", "theme", "4");
 }
 
-CPPUNIT_TEST_SUITE_REGISTRATION(ThemeImportExportTest);
+CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testCellBackgroundThemeColor)
+{
+    loadFromURL(u"xlsx/Test_ThemeColor_Text_Background_Border.xlsx");
+
+    ScDocument* pDoc = getScDoc();
+
+    {
+        const ScPatternAttr* pPattern = pDoc->GetPattern(0, 0, 0);
+        const SfxPoolItem* pItem = nullptr;
+        pPattern->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
+        CPPUNIT_ASSERT(pItem);
+
+        auto* pBrushItem = static_cast<const SvxBrushItem*>(pItem);
+        CPPUNIT_ASSERT_EQUAL(Color(0x27ced7), pBrushItem->GetColor());
+        auto aComplexColor = pBrushItem->getComplexColor();
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, 
aComplexColor.getSchemeType());
+        CPPUNIT_ASSERT_EQUAL(size_t(0), 
aComplexColor.getTransformations().size());
+    }
+
+    {
+        const ScPatternAttr* pPattern = pDoc->GetPattern(0, 1, 0);
+        const SfxPoolItem* pItem = nullptr;
+        pPattern->GetItemSet().HasItem(ATTR_BACKGROUND, &pItem);
+        CPPUNIT_ASSERT(pItem);
+
+        auto* pBrushItem = static_cast<const SvxBrushItem*>(pItem);
+        CPPUNIT_ASSERT_EQUAL(Color(0xd4f5f7), pBrushItem->GetColor());
+        auto aComplexColor = pBrushItem->getComplexColor();
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent3, 
aComplexColor.getSchemeType());
+        auto& rTransformations = aComplexColor.getTransformations();
+        CPPUNIT_ASSERT_EQUAL(size_t(2), rTransformations.size());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTransformations[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, 
rTransformations[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(7999), rTransformations[1].mnValue);
+    }
+}
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sc/qa/unit/data/xlsx/Test_ThemeColor_Text_Background_Border.xlsx 
b/sc/qa/unit/data/xlsx/Test_ThemeColor_Text_Background_Border.xlsx
new file mode 100644
index 000000000000..339d7539ecfb
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/Test_ThemeColor_Text_Background_Border.xlsx differ

Reply via email to