[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source

Jens Carl j.carl43 at gmx.de
Sun Mar 18 22:32:26 UTC 2018


 include/test/sheet/spreadsheet.hxx                              |   35 +++
 qadevOOo/Jar_OOoRunner.mk                                       |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv |    3 
 qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java                 |   55 ------
 sc/qa/extras/sctablesheetobj.cxx                                |   13 +
 test/Library_subsequenttest.mk                                  |    1 
 test/source/sheet/spreadsheet.cxx                               |   90 ++++++++++
 7 files changed, 139 insertions(+), 59 deletions(-)

New commits:
commit d97120c6f35e4c14a71df63b91dcbf67d9f310cc
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Sun Mar 18 09:10:47 2018 +0000

    tdf#45904 Move _Spreadsheet Java tests to C++
    
    Change-Id: Ic540d06899def77313d6dc7e0a5241e1f9eeea54
    Reviewed-on: https://gerrit.libreoffice.org/51491
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/sheet/spreadsheet.hxx b/include/test/sheet/spreadsheet.hxx
new file mode 100644
index 000000000000..597790a8e9c3
--- /dev/null
+++ b/include/test/sheet/spreadsheet.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_TEST_SHEET_SPREADSHEET_HXX
+#define INCLUDED_TEST_SHEET_SPREADSHEET_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST Spreadsheet
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+    virtual css::uno::Reference<css::uno::XInterface> getXSpreadsheetDocument() = 0;
+
+    void testSpreadsheetProperties();
+
+protected:
+    ~Spreadsheet() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_SPREADSHEET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 4c4b28b8fd7a..26231e68ee5a 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -565,7 +565,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
     qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
     qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
-    qadevOOo/tests/java/ifc/sheet/_Spreadsheet \
     qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
     qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocumentSettings \
     qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
index a28faa13a253..61d9411bb9f9 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
@@ -121,9 +121,6 @@
 "ScTableSheetObj";"com::sun::star::util::XIndent";"decrementIndent()"
 "ScTableSheetObj";"com::sun::star::util::XIndent";"incrementIndent()"
 "ScTableSheetObj";"com::sun::star::table::XAutoFormattable";"autoFormat()"
-"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"IsVisible"
-"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"PageStyle"
-"ScTableSheetObj";"com::sun::star::sheet::Spreadsheet";"AutomaticPrintArea#optional"
 "ScTableSheetObj";"com::sun::star::table::XTableChartsSupplier";"getCharts()"
 "ScTableSheetObj";"com::sun::star::sheet::XCellRangesQuery";"queryVisibleCells()"
 "ScTableSheetObj";"com::sun::star::sheet::XCellRangesQuery";"queryEmptyCells()"
diff --git a/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java b/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java
deleted file mode 100644
index 369c592a1bcd..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package ifc.sheet;
-
-import lib.MultiPropertyTest;
-
-/**
-* Testing <code>com.sun.star.sheet.Spreadsheet</code>
-* service properties :
-* <ul>
-*  <li><code> IsVisible</code></li>
-*  <li><code> PageStyle</code></li>
-* </ul> <p>
-* Properties testing is automated by <code>lib.MultiPropertyTest</code>.
-* @see com.sun.star.sheet.Spreadsheet
-*/
-public class _Spreadsheet extends MultiPropertyTest {
-
-    /**
-     *This class is destined to custom test of property <code>PageStyle</code>.
-     */
-    protected PropertyTester styleTester = new PropertyTester() {
-        @Override
-        protected Object getNewValue(String propName, Object oldValue) {
-            String str = "Default";
-            String str2= "Report";
-            return str.equals(oldValue) ? str2 : str;
-        }
-    };
-
-    /**
-     * Test property <code>PageStyle</code> using custom <code>PropertyTest</code>.
-     */
-    public void _PageStyle() {
-        testProperty("PageStyle", styleTester);
-    }
-} // finish class _Spreadsheet
-
-
diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index 4a10553ea774..bf72b594ba25 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -10,6 +10,7 @@
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/scenario.hxx>
 #include <test/sheet/sheetcellrange.hxx>
+#include <test/sheet/spreadsheet.hxx>
 #include <test/sheet/xcellformatrangessupplier.hxx>
 #include <test/sheet/xcellrangeaddressable.hxx>
 #include <test/sheet/xcellseries.hxx>
@@ -45,6 +46,7 @@ namespace sc_apitest
 
 class ScTableSheetObj : public CalcUnoApiTest, public apitest::Scenario,
                                                public apitest::SheetCellRange,
+                                               public apitest::Spreadsheet,
                                                public apitest::XCellFormatRangesSupplier,
                                                public apitest::XCellRangeAddressable,
                                                public apitest::XCellSeries,
@@ -76,6 +78,7 @@ public:
     virtual OUString getFileURL() override;
 
     virtual uno::Reference< uno::XInterface > init() override;
+    virtual uno::Reference< uno::XInterface > getXSpreadsheetDocument() override;
     virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
     virtual uno::Reference< uno::XInterface > getScenarioSpreadsheet() override;
 
@@ -87,6 +90,9 @@ public:
     // SheetCellRange
     CPPUNIT_TEST(testSheetCellRangeProperties);
 
+    // Spreadsheet
+    CPPUNIT_TEST(testSpreadsheetProperties);
+
     // XCellFormatRangesSupplier
     CPPUNIT_TEST(testGetCellFormatRanges);
 
@@ -211,6 +217,13 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
     return xSheet;
 }
 
+uno::Reference<uno::XInterface> ScTableSheetObj::getXSpreadsheetDocument()
+{
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+    return xDoc;
+}
+
 uno::Reference<uno::XInterface> ScTableSheetObj::getScenarioSpreadsheet()
 {
     uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 9aeceaf1e4f4..1e8fdb134770 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/sheetcellranges \
 	test/source/sheet/sheetfilterdescriptor \
 	test/source/sheet/sheetlink \
+	test/source/sheet/spreadsheet \
 	test/source/sheet/tableautoformat \
 	test/source/sheet/tablevalidation \
 	test/source/sheet/xarealink \
diff --git a/test/source/sheet/spreadsheet.cxx b/test/source/sheet/spreadsheet.cxx
new file mode 100644
index 000000000000..6ff83c475e46
--- /dev/null
+++ b/test/source/sheet/spreadsheet.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/spreadsheet.hxx>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XConditionalFormats.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void Spreadsheet::testSpreadsheetProperties()
+{
+    uno::Reference<beans::XPropertySet> xSpreadsheet(init(), UNO_QUERY_THROW);
+    OUString propName;
+    uno::Any aNewValue;
+
+    propName = "IsVisible";
+    testBooleanProperty(xSpreadsheet, propName);
+
+    propName = "PageStyle";
+    testStringProperty(xSpreadsheet, propName, "Report");
+
+    propName = "TableLayout";
+    testShortProperty(xSpreadsheet, propName, text::WritingMode2::RL_TB);
+
+    propName = "AutomaticPrintArea";
+    testBooleanProperty(xSpreadsheet, propName);
+
+    propName = "TabColor";
+    util::Color aColorGet;
+    util::Color aColorSet;
+    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: TabColor",
+                           xSpreadsheet->getPropertyValue(propName) >>= aColorGet);
+
+    aNewValue <<= util::Color(42);
+    xSpreadsheet->setPropertyValue(propName, aNewValue);
+    CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= aColorSet);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: TabColor", util::Color(42),
+                                 aColorSet);
+
+    propName = "ConditionalFormats";
+    uno::Reference<sheet::XConditionalFormats> xConditionalFormatsGet;
+    uno::Reference<sheet::XConditionalFormats> xConditionalFormatsSet;
+    CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ConditionalFormats",
+                           xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsGet);
+
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(getXSpreadsheetDocument(), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
+
+    uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
+    uno::Reference<container::XNameContainer> xRanges(
+        xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), UNO_QUERY_THROW);
+    uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(xRanges, UNO_QUERY_THROW);
+
+    uno::Any xCellRange;
+    xCellRange <<= xSheet->getCellRangeByName("C1:D4");
+    xRanges->insertByName("Range1", xCellRange);
+    xConditionalFormatsGet->createByRange(xSheetCellRanges);
+
+    aNewValue <<= xConditionalFormatsGet;
+    xSpreadsheet->setPropertyValue(propName, aNewValue);
+    CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsSet);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: ConditionalFormats", sal_Int32(1),
+                                 xConditionalFormatsSet->getLength());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list