diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-08-07 00:23:25 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-08 07:25:33 +0200 |
commit | 27cbca2c8dccbbb299621b49e5ffd836188202f0 (patch) | |
tree | fd6eec5f648286c0f4463b41891b759013571fc5 | |
parent | 0bd57d62d0f15eced0e99097d9f46a86f177e9a1 (diff) |
tdf#45904 Move Java _XUsedAreaCursor tests to C++
Change-Id: I6a288fa333d6805540156f63040468f07967c0c6
Reviewed-on: https://gerrit.libreoffice.org/40817
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | include/test/sheet/xusedareacursor.hxx | 36 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java | 126 | ||||
-rw-r--r-- | sc/qa/extras/sccellcursorobj.cxx | 16 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/ScCellCursorObj.ods | bin | 7451 -> 7639 bytes | |||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xcellseries.cxx | 7 | ||||
-rw-r--r-- | test/source/sheet/xusedareacursor.cxx | 97 |
9 files changed, 150 insertions, 136 deletions
diff --git a/include/test/sheet/xusedareacursor.hxx b/include/test/sheet/xusedareacursor.hxx new file mode 100644 index 000000000000..9e98aa3ae25b --- /dev/null +++ b/include/test/sheet/xusedareacursor.hxx @@ -0,0 +1,36 @@ +/* -*- 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_XUSEDAREACURSOR_HXX +#define INCLUDED_TEST_SHEET_XUSEDAREACURSOR_HXX + +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <test/testdllapi.hxx> + +using namespace css; +using namespace css::uno; + +namespace apitest { + +class OOO_DLLPUBLIC_TEST XUsedAreaCursor +{ +public: + virtual uno::Reference< uno::XInterface > init() = 0; + virtual ~XUsedAreaCursor(){} + + void testGotoStartOfUsedArea(); + void testGotoEndOfUsedArea(); +}; + +} + +#endif // INCLUDED_TEST_SHEET_XUSEDAREACURSOR_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 dfb164ffa102..f52618514bcd 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -651,7 +651,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_XSubTotalDescriptor \ qadevOOo/tests/java/ifc/sheet/_XSubTotalField \ qadevOOo/tests/java/ifc/sheet/_XUniqueCellFormatRangesSupplier \ - qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor \ qadevOOo/tests/java/ifc/sheet/_XViewFreezable \ qadevOOo/tests/java/ifc/style/_CharacterProperties \ qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv index 475086fddb03..b8a24da282db 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv @@ -55,8 +55,6 @@ "ScCellCursorObj";"com::sun::star::chart::XChartData";"removeChartDataChangeEventListener()" "ScCellCursorObj";"com::sun::star::chart::XChartData";"getNotANumber()" "ScCellCursorObj";"com::sun::star::chart::XChartData";"isNotANumber()" -"ScCellCursorObj";"com::sun::star::sheet::XUsedAreaCursor";"gotoStartOfUsedArea()" -"ScCellCursorObj";"com::sun::star::sheet::XUsedAreaCursor";"gotoEndOfUsedArea()" "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaAdjust" "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaLineSpacing#optional" "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaBackColor#optional" diff --git a/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java b/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java deleted file mode 100644 index 19079b7507df..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java +++ /dev/null @@ -1,126 +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.MultiMethodTest; - -import com.sun.star.sheet.XCellRangeAddressable; -import com.sun.star.sheet.XUsedAreaCursor; -import com.sun.star.table.CellRangeAddress; -import com.sun.star.uno.UnoRuntime; - -/** -* Testing <code>com.sun.star.sheet.XUsedAreaCursor</code> -* interface methods : -* <ul> -* <li><code> gotoStartOfUsedArea()</code></li> -* <li><code> gotoEndOfUsedArea()</code></li> -* </ul> <p> -* Component must also implement the following interfaces : -* <ul> -* <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current -* position of the cursor </li> -* <ul> <p> -* @see com.sun.star.sheet.XUsedAreaCursor -*/ -public class _XUsedAreaCursor extends MultiMethodTest { - - public XUsedAreaCursor oObj = null; - CellRangeAddress sAddr = null; - - /** - * Test points the cursor to the start of used area, expands cursor to the - * end of the used area, gets and checks current range address, then - * points the cursor to the end of the used area, gets and checks current - * range address again. <p> - * Has <b> OK </b> status if the range address expands at all used area - * in first case and if the range address just points to the cell at the end - * of the used area in second case. <p> - */ - public void _gotoEndOfUsedArea() { - boolean result = true ; - - XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; - - // first with true argument - oObj.gotoStartOfUsedArea(false); - oObj.gotoEndOfUsedArea(true); - sAddr = oAddr.getRangeAddress(); - - result &= (sAddr.StartColumn == 1); - result &= (sAddr.StartRow == 1); - result &= (sAddr.EndColumn == 4); - result &= (sAddr.EndRow == 5); - - oObj.gotoEndOfUsedArea(false); - sAddr = oAddr.getRangeAddress(); - - result &= (sAddr.StartColumn == 4); - result &= (sAddr.StartRow == 5); - result &= (sAddr.EndColumn == 4); - result &= (sAddr.EndRow == 5); - - tRes.tested("gotoEndOfUsedArea()", result) ; - } - - /** - * Test points the cursor to the end of used area, expands cursor to the - * start of the used area, gets and checks current range address, then - * points the cursor to the start of the used area, gets and checks current - * range address again. <p> - * Has <b> OK </b> status if the range address expands at all used area - * in first case and if the range address just points to the cell at the - * start of the used area in second case. <p> - */ - public void _gotoStartOfUsedArea() { - XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; - - boolean result = true ; - - // with true parameter first - oObj.gotoEndOfUsedArea(false); - oObj.gotoStartOfUsedArea(true); - sAddr = oAddr.getRangeAddress(); - - result &= (sAddr.StartColumn == 1); - result &= (sAddr.StartRow == 1); - result &= (sAddr.EndColumn == 4); - result &= (sAddr.EndRow == 5); - - // now testing with false parameter - oObj.gotoStartOfUsedArea(false); - sAddr = oAddr.getRangeAddress(); - - result &= (sAddr.StartColumn == 1); - result &= (sAddr.StartRow == 1); - result &= (sAddr.EndColumn == 1); - result &= (sAddr.EndRow == 1); - - tRes.tested("gotoStartOfUsedArea()", result) ; - } // finished gotoStartOfUsedArea - - /** - * Forces object environment recreation. - */ - @Override - protected void after() { - this.disposeEnvironment(); - } -} // finished class _XUsedAreaCursor - diff --git a/sc/qa/extras/sccellcursorobj.cxx b/sc/qa/extras/sccellcursorobj.cxx index ade41a77e375..7450034b7705 100644 --- a/sc/qa/extras/sccellcursorobj.cxx +++ b/sc/qa/extras/sccellcursorobj.cxx @@ -9,8 +9,8 @@ #include <test/calc_unoapi_test.hxx> #include <test/sheet/xcellseries.hxx> +#include <test/sheet/xusedareacursor.hxx> -#include <com/sun/star/table/XCellCursor.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -19,9 +19,9 @@ using namespace css::uno; namespace sc_apitest { -#define NUMBER_OF_TESTS 2 +#define NUMBER_OF_TESTS 4 -class ScCellCursorObj : public CalcUnoApiTest, private apitest::XCellSeries +class ScCellCursorObj : public CalcUnoApiTest, private apitest::XCellSeries, public apitest::XUsedAreaCursor { public: ScCellCursorObj(); @@ -31,8 +31,15 @@ public: virtual uno::Reference< uno::XInterface > init() override; CPPUNIT_TEST_SUITE(ScCellCursorObj); + + // XUsedAreaCursor + CPPUNIT_TEST(testGotoStartOfUsedArea); + CPPUNIT_TEST(testGotoEndOfUsedArea); + + // XCellSeries CPPUNIT_TEST(testFillAuto); CPPUNIT_TEST(testFillSeries); + CPPUNIT_TEST_SUITE_END(); private: @@ -60,9 +67,8 @@ uno::Reference< uno::XInterface > ScCellCursorObj::init() uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - uno::Reference< table::XCellCursor > xCellCursor( xSheet->createCursor(), UNO_QUERY_THROW); - return xCellCursor; + return xSheet; } void ScCellCursorObj::setUp() diff --git a/sc/qa/extras/testdocuments/ScCellCursorObj.ods b/sc/qa/extras/testdocuments/ScCellCursorObj.ods Binary files differindex fbb054f59f2e..46d8090ec5d2 100644 --- a/sc/qa/extras/testdocuments/ScCellCursorObj.ods +++ b/sc/qa/extras/testdocuments/ScCellCursorObj.ods diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index e69afd4d2a38..f2c6af8fe34e 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xsheetannotationshapesupplier \ test/source/sheet/xsheetoutline \ test/source/sheet/xstyleloader \ + test/source/sheet/xusedareacursor \ test/source/sheet/xviewpane \ test/source/sheet/xviewsplitable \ test/source/text/xtext \ diff --git a/test/source/sheet/xcellseries.cxx b/test/source/sheet/xcellseries.cxx index 61dbcecdc751..222fce29ef7e 100644 --- a/test/source/sheet/xcellseries.cxx +++ b/test/source/sheet/xcellseries.cxx @@ -10,6 +10,7 @@ #include <test/sheet/xcellseries.hxx> #include <com/sun/star/sheet/XCellSeries.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/XCellRange.hpp> #include "cppunit/extensions/HelperMacros.h" @@ -21,7 +22,8 @@ namespace apitest { void XCellSeries::testFillAuto() { - uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW); sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); @@ -54,7 +56,8 @@ void XCellSeries::testFillAuto() void XCellSeries::testFillSeries() { - uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRange(xSheet->createCursor(), UNO_QUERY_THROW); sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); diff --git a/test/source/sheet/xusedareacursor.cxx b/test/source/sheet/xusedareacursor.cxx new file mode 100644 index 000000000000..fdde5f6cd52f --- /dev/null +++ b/test/source/sheet/xusedareacursor.cxx @@ -0,0 +1,97 @@ +/* -*- 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/xusedareacursor.hxx> + +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XSheetCellCursor.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/sheet/XUsedAreaCursor.hpp> + +#include <com/sun/star/table/CellRangeAddress.hpp> + +#include "cppunit/extensions/HelperMacros.h" + +using namespace com::sun::star; +using namespace com::sun::star::uno; + + +namespace apitest { + +void XUsedAreaCursor::testGotoStartOfUsedArea() +{ + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW); + uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW); + + uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW); + + xUsedAreaCursor->gotoStartOfUsedArea(false); + xUsedAreaCursor->gotoEndOfUsedArea(true); + table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); + + xUsedAreaCursor->gotoEndOfUsedArea(false); + cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(2), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); +} + +void XUsedAreaCursor::testGotoEndOfUsedArea() +{ + uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_QUERY_THROW); + uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW); + + uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW); + + xUsedAreaCursor->gotoEndOfUsedArea(false); + xUsedAreaCursor->gotoStartOfUsedArea(true); + table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(2), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); + + xUsedAreaCursor->gotoStartOfUsedArea(false); + cellRangeAddress = xCellRangeAddressable->getRangeAddress(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column", + sal_Int32(0), cellRangeAddress.StartColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndColumn); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row", + sal_Int32(0), cellRangeAddress.StartRow); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column", + sal_Int32(0), cellRangeAddress.EndRow); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |