diff options
author | Jens Carl <j.carl43@gmx.de> | 2018-12-19 08:22:57 +0000 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2018-12-19 18:45:45 +0100 |
commit | 1a4a78efc7c8bc06de958ce64c6be5f5ef3f1e2d (patch) | |
tree | ace1bfd95cc8e30bba98da80828ee0d686336fdc | |
parent | 5829e8308e40203a83cfb5b91fc81e14e0630258 (diff) |
tdf#45904 Move XTableRows Java tests to C++
Move XTableRows Java tests to C++ for ScTableRowsObj.
Change-Id: I765d213e0a3e95a3925f1fc179a8a3f6c6611739
Reviewed-on: https://gerrit.libreoffice.org/65398
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r-- | include/test/table/xtablerows.hxx | 38 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowsObj.csv | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/mod/_sc/ScTableRowsObj.java | 120 | ||||
-rw-r--r-- | sc/qa/extras/sctablerowsobj.cxx | 23 | ||||
-rw-r--r-- | sc/qa/unoapi/sc_7.sce | 1 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/table/xtablerows.cxx | 55 |
8 files changed, 116 insertions, 125 deletions
diff --git a/include/test/table/xtablerows.hxx b/include/test/table/xtablerows.hxx new file mode 100644 index 000000000000..ac874daac778 --- /dev/null +++ b/include/test/table/xtablerows.hxx @@ -0,0 +1,38 @@ +/* -*- 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_TABLE_XTABLEROWS_HXX +#define INCLUDED_TEST_TABLE_XTABLEROWS_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 XTableRows +{ +public: + virtual css::uno::Reference<css::uno::XInterface> init() = 0; + virtual css::uno::Reference<css::uno::XInterface> getXCellRange() = 0; + + virtual void testInsertByIndex(); + virtual void testRemoveByIndex(); + +protected: + ~XTableRows() {} +}; + +} // namespace apitest + +#endif // INCLUDED_TEST_TABLE_XTABLEROWS_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 204d556676bd..ba9f30fd6e6c 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -1001,7 +1001,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/mod/_sc/ScTableColumnsObj \ qadevOOo/tests/java/mod/_sc/ScTableConditionalFormat \ qadevOOo/tests/java/mod/_sc/ScTableRowObj \ - qadevOOo/tests/java/mod/_sc/ScTableRowsObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \ qadevOOo/tests/java/mod/_sc/ScTableValidationObj \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowsObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowsObj.csv deleted file mode 100644 index 5933ff4c8533..000000000000 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableRowsObj.csv +++ /dev/null @@ -1,2 +0,0 @@ -"ScTableRowsObj";"com::sun::star::table::XTableRows";"insertByIndex()" -"ScTableRowsObj";"com::sun::star::table::XTableRows";"removeByIndex()" diff --git a/qadevOOo/tests/java/mod/_sc/ScTableRowsObj.java b/qadevOOo/tests/java/mod/_sc/ScTableRowsObj.java deleted file mode 100644 index b210f4f6f78d..000000000000 --- a/qadevOOo/tests/java/mod/_sc/ScTableRowsObj.java +++ /dev/null @@ -1,120 +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 mod._sc; - -import java.io.PrintWriter; - -import lib.TestCase; -import lib.TestEnvironment; -import lib.TestParameters; -import util.SOfficeFactory; - -import com.sun.star.container.XNameAccess; -import com.sun.star.lang.XComponent; -import com.sun.star.sheet.XSpreadsheet; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.sheet.XSpreadsheets; -import com.sun.star.table.XCellRange; -import com.sun.star.table.XColumnRowRange; -import com.sun.star.table.XTableRows; -import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.Type; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; - -/** -* Test for object which is represented by service -* <code>com.sun.star.table.TableRows</code>. <p> -* Object implements the following interfaces : -* <ul> -* <li> <code>com::sun::star::container::XIndexAccess</code></li> -* <li> <code>com::sun::star::container::XElementAccess</code></li> -* <li> <code>com::sun::star::table::XTableRows</code></li> -* </ul> -* @see com.sun.star.table.TableRows -* @see com.sun.star.container.XIndexAccess -* @see com.sun.star.container.XElementAccess -* @see com.sun.star.table.XTableRows -* @see ifc.container._XIndexAccess -* @see ifc.container._XElementAccess -* @see ifc.table._XTableRows -*/ -public class ScTableRowsObj extends TestCase { - XSpreadsheetDocument xSheetDoc = null; - - /** - * Creates Spreadsheet document. - */ - @Override - protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { - SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); - - log.println( "creating a Spreadsheet document" ); - xSheetDoc = SOF.createCalcDoc(null); - } - - /** - * Disposes Spreadsheet document. - */ - @Override - protected void cleanup( TestParameters tParam, PrintWriter log ) { - log.println( " disposing xSheetDoc " ); - XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ; - util.DesktopTools.closeDoc(oComp); - } - - /** - * Creating a TestEnvironment for the interfaces to be tested. - * Retrieves a collection of spreadsheets from the document and takes one of - * them. Obtains the collection of rows using the interface - * <code>XColumnRowRange</code>. The obtained collection is the instance of - * the service <code>com.sun.star.table.TableRows</code>. - * @see com.sun.star.table.XColumnRowRange - * @see com.sun.star.table.TableRows - */ - @Override - protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { - - XInterface oObj = null; - - log.println("getting row"); - XSpreadsheet xSpreadsheet = null; - - XSpreadsheets xSpreadsheets = xSheetDoc.getSheets(); - XNameAccess oNames = UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets ); - xSpreadsheet = (XSpreadsheet) AnyConverter.toObject( - new Type(XSpreadsheet.class), - oNames.getByName(oNames.getElementNames()[0])); - - XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet); - - XTableRows oRows = oColumnRowRange.getRows(); - oObj = oRows; - - log.println("creating a new environment for object"); - TestEnvironment tEnv = new TestEnvironment(oObj); - - // adding relation for XTableRows - tEnv.addObjRelation("XTableRows.XCellRange", - UnoRuntime.queryInterface(XCellRange.class, xSpreadsheet)); - - return tEnv; - } -} // finish class ScTableRowsObj - diff --git a/sc/qa/extras/sctablerowsobj.cxx b/sc/qa/extras/sctablerowsobj.cxx index 76c86da52e9b..381f9ee6bf5d 100644 --- a/sc/qa/extras/sctablerowsobj.cxx +++ b/sc/qa/extras/sctablerowsobj.cxx @@ -11,6 +11,7 @@ #include <test/container/xelementaccess.hxx> #include <test/container/xenumerationaccess.hxx> #include <test/container/xindexaccess.hxx> +#include <test/table/xtablerows.hxx> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -34,12 +35,14 @@ namespace sc_apitest class ScTableRowsObj : public CalcUnoApiTest, public apitest::XElementAccess, public apitest::XEnumerationAccess, - public apitest::XIndexAccess + public apitest::XIndexAccess, + public apitest::XTableRows { public: ScTableRowsObj(); virtual uno::Reference<uno::XInterface> init() override; + virtual uno::Reference<uno::XInterface> getXCellRange() override; virtual void setUp() override; virtual void tearDown() override; @@ -56,6 +59,10 @@ public: CPPUNIT_TEST(testGetByIndex); CPPUNIT_TEST(testGetCount); + // XTableRows + CPPUNIT_TEST(testInsertByIndex); + CPPUNIT_TEST(testRemoveByIndex); + CPPUNIT_TEST_SUITE_END(); private: @@ -85,6 +92,20 @@ uno::Reference<uno::XInterface> ScTableRowsObj::init() return xTR; } +uno::Reference<uno::XInterface> ScTableRowsObj::getXCellRange() +{ + uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xCompoment, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is()); + + uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<container::XNameAccess> xNA(xSheets, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet0(xSheets->getByName(xNA->getElementNames()[0]), + uno::UNO_QUERY_THROW); + + uno::Reference<table::XCellRange> xCR(xSheet0, uno::UNO_QUERY_THROW); + return xCR; +} + void ScTableRowsObj::setUp() { CalcUnoApiTest::setUp(); diff --git a/sc/qa/unoapi/sc_7.sce b/sc/qa/unoapi/sc_7.sce index 70a8acdefb43..37ade7cf0499 100644 --- a/sc/qa/unoapi/sc_7.sce +++ b/sc/qa/unoapi/sc_7.sce @@ -22,7 +22,6 @@ -o sc.ScTableColumnsObj -o sc.ScTableConditionalFormat # -o sc.ScTableRowObj --o sc.ScTableRowsObj # -o sc.ScTableSheetObj # -o sc.ScTableSheetsObj -o sc.ScTableValidationObj diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 88edfeed9741..8895df3e24a0 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -157,6 +157,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/table/xcellcursor \ test/source/table/xcolumnrowrange \ test/source/table/xtablechartssupplier \ + test/source/table/xtablerows \ test/source/text/xtext \ test/source/text/xtextcontent \ test/source/text/xtextfield \ diff --git a/test/source/table/xtablerows.cxx b/test/source/table/xtablerows.cxx new file mode 100644 index 000000000000..ba884281f2c5 --- /dev/null +++ b/test/source/table/xtablerows.cxx @@ -0,0 +1,55 @@ +/* -*- 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/table/xtablerows.hxx> + +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace css; +using namespace css::uno; + +namespace apitest +{ +void XTableRows::testInsertByIndex() +{ + uno::Reference<table::XCellRange> xCellRange(getXCellRange(), uno::UNO_QUERY_THROW); + xCellRange->getCellByPosition(0, 0)->setValue(17); + xCellRange->getCellByPosition(0, 1)->setValue(15); + + uno::Reference<table::XTableRows> xTableRows(init(), uno::UNO_QUERY_THROW); + xTableRows->removeByIndex(0, 1); + + xTableRows->insertByIndex(0, 1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(xCellRange->getCellByPosition(0, 1)->getValue(), 15.0, 0.1); + + CPPUNIT_ASSERT_THROW(xTableRows->insertByIndex(-1, 1), uno::RuntimeException); +} + +void XTableRows::testRemoveByIndex() +{ + uno::Reference<table::XCellRange> xCellRange(getXCellRange(), uno::UNO_QUERY_THROW); + xCellRange->getCellByPosition(0, 0)->setValue(17); + xCellRange->getCellByPosition(0, 1)->setValue(15); + + uno::Reference<table::XTableRows> xTableRows(init(), uno::UNO_QUERY_THROW); + xTableRows->removeByIndex(0, 1); + CPPUNIT_ASSERT_DOUBLES_EQUAL(xCellRange->getCellByPosition(0, 0)->getValue(), 15.0, 0.1); + + CPPUNIT_ASSERT_THROW(xTableRows->removeByIndex(-1, 1), uno::RuntimeException); +} + +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |