diff options
author | Jens Carl <j.carl43@gmx.de> | 2017-08-05 04:31:57 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-07 00:46:24 +0200 |
commit | 44077dc6104e5eab40414889e7be776767709984 (patch) | |
tree | d91df4e9e9c55b740f4572cad377110741423a61 /test | |
parent | f79258444185f3d6939facb3cab071ad92d873e4 (diff) |
tdf#45904 Move Java _XSpreadsheets tests to C++
Change-Id: If311e2c8ca89528760b14d977bca76e14164e6e3
Reviewed-on: https://gerrit.libreoffice.org/40783
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/sheet/xspreadsheets.cxx | 85 |
2 files changed, 86 insertions, 0 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index fb0e3f42000d..d996d7ddf524 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/xnamedranges \ test/source/sheet/xprintareas \ test/source/sheet/xspreadsheetdocument \ + test/source/sheet/xspreadsheets \ test/source/sheet/xspreadsheets2 \ test/source/sheet/xsheetannotation \ test/source/sheet/xsheetannotations \ diff --git a/test/source/sheet/xspreadsheets.cxx b/test/source/sheet/xspreadsheets.cxx new file mode 100644 index 000000000000..8c59258c1711 --- /dev/null +++ b/test/source/sheet/xspreadsheets.cxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/xspreadsheets.hxx> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/sheet/XSpreadsheets.hpp> + +#include "cppunit/extensions/HelperMacros.h" + +using namespace com::sun::star; +using namespace com::sun::star::uno; + + +namespace apitest { + +void XSpreadsheets::testInsertNewByName() +{ + uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW); + + OUString newSheetName( "SheetToInsert" ); + xSpreadsheets->insertNewByName(newSheetName, 0); + + uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("Sheet was not insert", + xNameAccess->hasByName(newSheetName)); +} + +void XSpreadsheets::testInsertNewByNameBadName() +{ + uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW); + + CPPUNIT_ASSERT_THROW_MESSAGE("No excpetion thrown", + xSpreadsheets->insertNewByName("$%#/?\\", 0), + uno::RuntimeException); +} + +void XSpreadsheets::testMoveByName() +{ + uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW); + + // first insert one that should be moved + xSpreadsheets->insertNewByName("SheetToMove", 0); + uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("Sheet to move was not insert", + xNameAccess->hasByName("SheetToCopySrc")); + + xSpreadsheets->moveByName("SheetToMove", 2); + + // get sheet from the new position + uno::Reference< container::XIndexAccess > oIndexAccess(xSpreadsheets, UNO_QUERY_THROW); + uno::Any aAny = oIndexAccess->getByIndex(1); + uno::Reference< container::XNamed > xNamed; + CPPUNIT_ASSERT(aAny >>= xNamed); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet was not moved", + OUString("SheetToMove"), + xNamed->getName()); +} + +void XSpreadsheets::testCopyByName() +{ + uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW); + + // insert new sheet to copy + xSpreadsheets->insertNewByName("SheetToCopySrc", 0); + uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("Sheet to copy was not insert", + xNameAccess->hasByName("SheetToCopySrc")); + + xSpreadsheets->copyByName("SheetToCopySrc", "SheetToCopyDst", 0); + CPPUNIT_ASSERT_MESSAGE("Sheet was not copied", + xNameAccess->hasByName("SheetToCopyDst")); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |