From d97120c6f35e4c14a71df63b91dcbf67d9f310cc Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Sun, 18 Mar 2018 09:10:47 +0000 Subject: tdf#45904 Move _Spreadsheet Java tests to C++ Change-Id: Ic540d06899def77313d6dc7e0a5241e1f9eeea54 Reviewed-on: https://gerrit.libreoffice.org/51491 Tested-by: Jenkins Reviewed-by: Jens Carl --- include/test/sheet/spreadsheet.hxx | 35 +++++++++ qadevOOo/Jar_OOoRunner.mk | 1 - .../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(-) create mode 100644 include/test/sheet/spreadsheet.hxx delete mode 100644 qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java create mode 100644 test/source/sheet/spreadsheet.cxx 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 +#include + +#include + +namespace apitest +{ +class OOO_DLLPUBLIC_TEST Spreadsheet +{ +public: + virtual css::uno::Reference init() = 0; + virtual css::uno::Reference 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 com.sun.star.sheet.Spreadsheet -* service properties : -*
    -*
  • IsVisible
  • -*
  • PageStyle
  • -*

-* Properties testing is automated by lib.MultiPropertyTest. -* @see com.sun.star.sheet.Spreadsheet -*/ -public class _Spreadsheet extends MultiPropertyTest { - - /** - *This class is destined to custom test of property PageStyle. - */ - 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 PageStyle using custom PropertyTest. - */ - 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 #include #include +#include #include #include #include @@ -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 ScTableSheetObj::getXSpreadsheetDocument() +{ + uno::Reference xDoc(mxComponent, UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + return xDoc; +} + uno::Reference ScTableSheetObj::getScenarioSpreadsheet() { uno::Reference 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest +{ +void Spreadsheet::testSpreadsheetProperties() +{ + uno::Reference 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 xConditionalFormatsGet; + uno::Reference xConditionalFormatsSet; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ConditionalFormats", + xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsGet); + + uno::Reference xDoc(getXSpreadsheetDocument(), UNO_QUERY_THROW); + uno::Reference xIA(xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference xSheet(xIA->getByIndex(0), UNO_QUERY_THROW); + + uno::Reference xMSF(xDoc, UNO_QUERY_THROW); + uno::Reference xRanges( + xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), UNO_QUERY_THROW); + uno::Reference 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: */ -- cgit