Kaydet (Commit) 4eff4061 authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move XTableColumns Java tests to C++

Move XTableColumns Java tests to C++ for ScTableColumnsObj.

Change-Id: Iead7ca3d7c07820086f75d86833b7bfc97978751
Reviewed-on: https://gerrit.libreoffice.org/69286
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 16cf63a6
...@@ -82,7 +82,6 @@ job99=sc.ScHeaderFieldsObj ...@@ -82,7 +82,6 @@ job99=sc.ScHeaderFieldsObj
job126=sc.ScSheetLinkObj job126=sc.ScSheetLinkObj
job132=sc.ScStyleObj job132=sc.ScStyleObj
job134=sc.ScTableColumnObj job134=sc.ScTableColumnObj
job135=sc.ScTableColumnsObj
job138=sc.ScTableRowObj job138=sc.ScTableRowObj
job140=sc.XMLContentExporter job140=sc.XMLContentExporter
job141=sc.XMLContentImporter job141=sc.XMLContentImporter
......
/* -*- 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_XTABLECOLUMNS_HXX
#define INCLUDED_TEST_TABLE_XTABLECOLUMNS_HXX
#include <rtl/string.hxx>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XTableColumns
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void setXSpreadsheet(css::uno::Reference<css::sheet::XSpreadsheet>& r_xSheet)
{
m_xSheet = r_xSheet;
}
void testInsertByIndex();
void testInsertByIndexWithNegativeIndex();
// only use with ScTableColumnsObj
void testInsertByIndexWithNoColumn();
void testInsertByIndexWithOutOfBoundIndex();
void testRemoveByIndex();
void testRemoveByIndexWithNegativeIndex();
// only use with ScTableColumnsObj
void testRemoveByIndexWithNoColumn();
void testRemoveByIndexWithOutOfBoundIndex();
protected:
~XTableColumns() {}
private:
css::uno::Reference<css::sheet::XSpreadsheet> m_xSheet;
static const OUString getCellText(const css::uno::Reference<css::table::XCell>& r_xCell);
};
} // namespace apitest
#endif // INCLUDED_TEST_TABLE_XTABLECOLUMNS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -973,7 +973,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ ...@@ -973,7 +973,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScStyleObj \ qadevOOo/tests/java/mod/_sc/ScStyleObj \
qadevOOo/tests/java/mod/_sc/ScSubTotalDescriptorBase \ qadevOOo/tests/java/mod/_sc/ScSubTotalDescriptorBase \
qadevOOo/tests/java/mod/_sc/ScTableColumnObj \ qadevOOo/tests/java/mod/_sc/ScTableColumnObj \
qadevOOo/tests/java/mod/_sc/ScTableColumnsObj \
qadevOOo/tests/java/mod/_sc/ScTableRowObj \ qadevOOo/tests/java/mod/_sc/ScTableRowObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetObj \
qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \
......
"ScTableColumnsObj";"com::sun::star::table::XTableColumns";"insertByIndex()"
"ScTableColumnsObj";"com::sun::star::table::XTableColumns";"removeByIndex()"
/*
* 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.XTableColumns;
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.TableColumns</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::container::XNameAccess</code></li>
* <li> <code>com::sun::star::table::XTableColumns</code></li>
* </ul>
* @see com.sun.star.table.TableColumns
* @see com.sun.star.container.XIndexAccess
* @see com.sun.star.container.XElementAccess
* @see com.sun.star.container.XNameAccess
* @see com.sun.star.table.XTableColumns
* @see ifc.container._XIndexAccess
* @see ifc.container._XElementAccess
* @see ifc.container._XNameAccess
* @see ifc.table._XTableColumns
*/
public class ScTableColumnsObj extends TestCase {
private XSpreadsheetDocument xSheetDoc = null;
/**
* Creates Spreadsheet document.
*/
@Override
protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
// get a soffice factory object
SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
log.println( "creating a sheetdocument" );
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 columns in the range using the interface
* <code>XColumnRowRange</code>. This collection is the instance of the
* service <code>com.sun.star.table.TableColumns</code>.
* @see com.sun.star.table.XColumnRowRange
* @see com.sun.star.table.TableColumns
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
XInterface oObj = null;
// creation of the testobject here
// first we write what we are intend to do to log file
log.println("creating a test environment");
log.println("getting column");
XSpreadsheets xSpreadsheets = xSheetDoc.getSheets();
XNameAccess oNames = UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets );
XSpreadsheet xSpreadsheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),
oNames.getByName(oNames.getElementNames()[0]));
XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet);
XTableColumns oColumns = oColumnRowRange.getColumns();
oObj = oColumns;
log.println("creating a new environment for object");
TestEnvironment tEnv = new TestEnvironment(oObj);
// adding relation for XTableColumns
tEnv.addObjRelation("XTableColumns.XCellRange",
UnoRuntime.queryInterface(XCellRange.class, xSpreadsheet));
return tEnv;
}
} // finish class ScTableColumnsObj
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <test/container/xenumerationaccess.hxx> #include <test/container/xenumerationaccess.hxx>
#include <test/container/xindexaccess.hxx> #include <test/container/xindexaccess.hxx>
#include <test/container/xnameaccess.hxx> #include <test/container/xnameaccess.hxx>
#include <test/table/xtablecolumns.hxx>
#include <cppu/unotype.hxx> #include <cppu/unotype.hxx>
#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp>
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
#include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/XColumnRowRange.hpp> #include <com/sun/star/table/XColumnRowRange.hpp>
#include <com/sun/star/table/XTableColumns.hpp> #include <com/sun/star/table/XTableColumns.hpp>
#include <com/sun/star/text/XSimpleText.hpp>
#include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
...@@ -34,7 +36,8 @@ class ScTableColumnsObj : public CalcUnoApiTest, ...@@ -34,7 +36,8 @@ class ScTableColumnsObj : public CalcUnoApiTest,
public apitest::XElementAccess, public apitest::XElementAccess,
public apitest::XEnumerationAccess, public apitest::XEnumerationAccess,
public apitest::XIndexAccess, public apitest::XIndexAccess,
public apitest::XNameAccess public apitest::XNameAccess,
public apitest::XTableColumns
{ {
public: public:
ScTableColumnsObj(); ScTableColumnsObj();
...@@ -61,6 +64,16 @@ public: ...@@ -61,6 +64,16 @@ public:
CPPUNIT_TEST(testGetElementNames); CPPUNIT_TEST(testGetElementNames);
CPPUNIT_TEST(testHasByName); CPPUNIT_TEST(testHasByName);
// XTableColumns
CPPUNIT_TEST(testInsertByIndex);
CPPUNIT_TEST(testInsertByIndexWithNegativeIndex);
CPPUNIT_TEST(testInsertByIndexWithNoColumn);
CPPUNIT_TEST(testInsertByIndexWithOutOfBoundIndex);
CPPUNIT_TEST(testRemoveByIndex);
CPPUNIT_TEST(testRemoveByIndexWithNegativeIndex);
CPPUNIT_TEST(testRemoveByIndexWithNoColumn);
CPPUNIT_TEST(testRemoveByIndexWithOutOfBoundIndex);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -84,7 +97,23 @@ uno::Reference<uno::XInterface> ScTableColumnsObj::init() ...@@ -84,7 +97,23 @@ uno::Reference<uno::XInterface> ScTableColumnsObj::init()
uno::Reference<table::XColumnRowRange> xCRR(xSheet0, uno::UNO_QUERY_THROW); uno::Reference<table::XColumnRowRange> xCRR(xSheet0, uno::UNO_QUERY_THROW);
uno::Reference<table::XTableColumns> xTC(xCRR->getColumns(), uno::UNO_QUERY_THROW); uno::Reference<table::XTableColumns> xTC(xCRR->getColumns(), uno::UNO_QUERY_THROW);
setXSpreadsheet(xSheet0);
uno::Reference<table::XCellRange> xCR(xSheet0, uno::UNO_QUERY_THROW);
for (auto i = 0; i < xTC->getCount() - 1 && i < 3; ++i)
{
uno::Reference<text::XSimpleText> xST0(xCR->getCellByPosition(i, 0), uno::UNO_QUERY_THROW);
xST0->setString(OUString::number(i) + "a");
uno::Reference<text::XSimpleText> xST1(xCR->getCellByPosition(i, 1), uno::UNO_QUERY_THROW);
xST1->setString(OUString::number(i) + "b");
}
for (auto i = 3; i < xTC->getCount() - 1 && i < 10; ++i)
{
uno::Reference<text::XSimpleText> xST0(xCR->getCellByPosition(i, 0), uno::UNO_QUERY_THROW);
xST0->setString("");
uno::Reference<text::XSimpleText> xST1(xCR->getCellByPosition(i, 1), uno::UNO_QUERY_THROW);
xST1->setString("");
}
return xTC; return xTC;
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
-o sc.ScSubTotalDescriptorBase -o sc.ScSubTotalDescriptorBase
# # i84656 -o sc.ScTabViewObj # # i84656 -o sc.ScTabViewObj
# -o sc.ScTableColumnObj # -o sc.ScTableColumnObj
-o sc.ScTableColumnsObj
# -o sc.ScTableRowObj # -o sc.ScTableRowObj
# -o sc.ScTableSheetObj # -o sc.ScTableSheetObj
# -o sc.ScTableSheetsObj # -o sc.ScTableSheetsObj
......
...@@ -166,6 +166,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ ...@@ -166,6 +166,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/table/xtablechart \ test/source/table/xtablechart \
test/source/table/xtablecharts \ test/source/table/xtablecharts \
test/source/table/xtablechartssupplier \ test/source/table/xtablechartssupplier \
test/source/table/xtablecolumns \
test/source/table/xtablerows \ test/source/table/xtablerows \
test/source/text/xsimpletext \ test/source/text/xsimpletext \
test/source/text/xtext \ test/source/text/xtext \
......
/* -*- 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/xtablecolumns.hxx>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/table/XTableColumns.hpp>
#include <com/sun/star/text/XSimpleText.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
namespace apitest
{
void XTableColumns::testInsertByIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCR(m_xSheet, uno::UNO_QUERY_THROW);
// insert one column at position one
xTC->insertByIndex(1, 1);
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(3, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1)));
// insert one column at position zero
xTC->insertByIndex(0, 1);
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(3, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(4, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(4, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 1)));
// insert two columns at position zero
xTC->insertByIndex(0, 2);
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(3, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(5, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(5, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(6, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(6, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(7, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(7, 1)));
}
void XTableColumns::testInsertByIndexWithNegativeIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->insertByIndex(-1, 1), uno::RuntimeException);
}
void XTableColumns::testInsertByIndexWithNoColumn()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->insertByIndex(0, 0), uno::RuntimeException);
}
void XTableColumns::testInsertByIndexWithOutOfBoundIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->insertByIndex(xTC->getCount(), 1), uno::RuntimeException);
}
void XTableColumns::testRemoveByIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
uno::Reference<table::XCellRange> xCR(m_xSheet, uno::UNO_QUERY_THROW);
xTC->insertByIndex(1, 1); // insert one column at position one
xTC->insertByIndex(0, 1); // insert one column at position zero
xTC->insertByIndex(0, 2); // insert two columns at position zero
// remove two columns at position zero
xTC->removeByIndex(0, 2);
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(3, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(4, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(4, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 1)));
// remove one column at position zero
xTC->removeByIndex(0, 1);
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(3, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1)));
// remove one column at position one
xTC->removeByIndex(1, 1);
CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(1, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(1, 1)));
CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(2, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(2, 1)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(3, 0)));
CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(3, 1)));
}
void XTableColumns::testRemoveByIndexWithNegativeIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->removeByIndex(-1, 1), uno::RuntimeException);
}
void XTableColumns::testRemoveByIndexWithNoColumn()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->removeByIndex(0, 0), uno::RuntimeException);
}
void XTableColumns::testRemoveByIndexWithOutOfBoundIndex()
{
uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_THROW(xTC->removeByIndex(xTC->getCount(), 1), uno::RuntimeException);
}
const OUString XTableColumns::getCellText(const uno::Reference<table::XCell>& r_xCell)
{
uno::Reference<text::XSimpleText> xST(r_xCell, uno::UNO_QUERY_THROW);
return xST->getString();
}
} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment