diff options
author | Paul Trojahn <paul.trojahn@gmail.com> | 2017-06-08 16:30:08 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-06-20 19:52:10 +0200 |
commit | 2516285d2a9b6b992f24867d39402ca5c29cd71d (patch) | |
tree | ddae5004e3869124c3d16a2e3d54d350043fb756 /test | |
parent | e89e3ca2a6ab1773a7221eac11cb60812c002005 (diff) |
tdf#45904 Move remaining XCellSeries test code to C++
Change-Id: Ie4ee1e52157dd38ac0defee2e9d5cfa822763183
Reviewed-on: https://gerrit.libreoffice.org/38807
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/sheet/xcellrangesquery.cxx | 26 | ||||
-rw-r--r-- | test/source/sheet/xcellseries.cxx | 84 |
2 files changed, 75 insertions, 35 deletions
diff --git a/test/source/sheet/xcellrangesquery.cxx b/test/source/sheet/xcellrangesquery.cxx index 16ca44f94b8a..4838c65746de 100644 --- a/test/source/sheet/xcellrangesquery.cxx +++ b/test/source/sheet/xcellrangesquery.cxx @@ -29,67 +29,67 @@ void XCellRangesQuery::testQueryColumnDifference() uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1)); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryColumnDifference: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aExpected, aResult); } void XCellRangesQuery::testQueryContentDifference() { - OUString aExpected( "Sheet1.B2:B3" ); + OUString aExpected( "Sheet1.B3,Sheet1.C2" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryContentDifference: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aExpected, aResult); } void XCellRangesQuery::testQueryEmptyCells() { - OUString aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5" ); + OUString aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:E5" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells(); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryEmptyCells: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aExpected, aResult); } void XCellRangesQuery::testQueryFormulaCells() { - OUString aExpected( "Sheet1.C2" ); + OUString aExpected( "Sheet1.B2" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryFormulaCells: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aExpected, aResult); } void XCellRangesQuery::testQueryIntersection() { - OUString aExpected( "Sheet1.D4:D5" ); + OUString aExpected( "Sheet1.D4:E5" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7)); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryIntersection: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aExpected, aResult); } void XCellRangesQuery::testQueryRowDifference() { - OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:D4" ); + OUString aExpected( "Sheet1.A2:A4,Sheet1.C2:E4" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1)); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryRowDifference: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aExpected, aResult); } void XCellRangesQuery::testQueryVisibleCells() { - OUString aExpected( "Sheet1.A1:D5" ); + OUString aExpected( "Sheet1.A1:E5" ); uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW); uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells(); OUString aResult = xRanges->getRangeAddressesAsString(); std::cout << "testQueryVisibleCells: Result: " << aResult << std::endl; - CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aResult, aExpected); + CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aExpected, aResult); } } diff --git a/test/source/sheet/xcellseries.cxx b/test/source/sheet/xcellseries.cxx index a1ccd87c3235..61dbcecdc751 100644 --- a/test/source/sheet/xcellseries.cxx +++ b/test/source/sheet/xcellseries.cxx @@ -22,53 +22,93 @@ namespace apitest { void XCellSeries::testFillAuto() { uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); - uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW); xCellSeriesH->fillAuto(sheet::FillDirection_TO_RIGHT, 1); - uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(5, 0), UNO_QUERY_THROW); - xCellResultH->setFormula("=SUM(B1:E1)"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_RIGHT", 14., xCellResultH->getValue()); + sal_Int32 sumH = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW); + sumH += xCellResultH->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_RIGHT", maValue * 3 + 3, sumH); - uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_QUERY_THROW); uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW); xCellSeriesV->fillAuto(sheet::FillDirection_TO_BOTTOM, 1); - uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(1, 4), UNO_QUERY_THROW); - xCellResultV->setFormula("=SUM(B1:B4)"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_BOTTOM", 14., xCellResultV->getValue()); + sal_Int32 sumV = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW); + sumV += xCellResultV->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_BOTTOM", maValue * 3 + 3, sumV); + + for(sal_Int32 i = 1; i < 3; i++) { + uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW); + xCellResultH->setFormula(""); + uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW); + xCellResultV->setFormula(""); + } } void XCellSeries::testFillSeries() { uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW); + sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue(); - uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(1, 0, 4, 0), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_QUERY_THROW); uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW); xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT, sheet::FillMode_LINEAR, - sheet::FillDateMode_FILL_DATE_DAY, 2, 8); - uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(5, 0), UNO_QUERY_THROW); - xCellResultH->setFormula("=SUM(B1:E1)"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and LINEAR", 20., xCellResultH->getValue()); + sheet::FillDateMode_FILL_DATE_DAY, 2, 1000); + sal_Int32 sumH = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW); + sumH += xCellResultH->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and LINEAR", maValue * 3 + 6, sumH); xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT, sheet::FillMode_GROWTH, - sheet::FillDateMode_FILL_DATE_DAY, 2, 16); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and GROWTH", 30., xCellResultH->getValue()); + sheet::FillDateMode_FILL_DATE_DAY, 2, 1000); + sumH = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW); + sumH += xCellResultH->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and GROWTH", maValue + maValue * 2 + maValue * 4, sumH); - uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(1, 0, 1, 3), UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_QUERY_THROW); uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW); xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM, sheet::FillMode_LINEAR, - sheet::FillDateMode_FILL_DATE_DAY, 2, 8); - uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(1, 4), UNO_QUERY_THROW); - xCellResultV->setFormula("=SUM(B1:B4)"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and LINEAR", 20., xCellResultV->getValue()); + sheet::FillDateMode_FILL_DATE_DAY, 2, 1000); + sal_Int32 sumV = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW); + sumV += xCellResultV->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and LINEAR", maValue * 3 + 6, sumV); xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM, sheet::FillMode_GROWTH, - sheet::FillDateMode_FILL_DATE_DAY, 2, 16); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and GROWTH", 30., xCellResultV->getValue()); + sheet::FillDateMode_FILL_DATE_DAY, 2, 1000); + sumV = 0; + for(sal_Int32 i = 0; i < 3; i++) { + uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW); + sumV += xCellResultV->getValue(); + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and GROWTH", maValue + maValue * 2 + maValue * 4, sumV); + + for(sal_Int32 i = 1; i < 3; i++) { + uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_QUERY_THROW); + xCellResultH->setFormula(""); + uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_QUERY_THROW); + xCellResultV->setFormula(""); + } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |