summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRahul Gurung <gurungrahul2@gmail.com>2018-08-26 20:26:17 +0530
committerJens Carl <j.carl43@gmx.de>2018-08-30 07:38:08 +0200
commit9e1df712d6e247f4dc9391c0a006b3da2df40403 (patch)
tree398ddef328d8bf08deebcd69a80368d69a986028 /test
parentc446df46df21472d3465be69603473a4ddad9b82 (diff)
tdf#45904 Move _XCellCursor Java tests to C++
Change-Id: Iebada370e4fa58c5e21dd724789b5f05357a0faa Reviewed-on: https://gerrit.libreoffice.org/59610 Tested-by: Jenkins Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test')
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/table/xcellcursor.cxx128
2 files changed, 129 insertions, 0 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index e31f44bdfb41..1697a4639273 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -146,6 +146,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xviewsplitable \
test/source/sheet/xsubtotalcalculatable \
test/source/sheet/xsubtotaldescriptor \
+ test/source/table/xcellcursor \
test/source/text/xtext \
test/source/text/xtextfield \
test/source/text/xtextcontent \
diff --git a/test/source/table/xcellcursor.cxx b/test/source/table/xcellcursor.cxx
new file mode 100644
index 000000000000..40e70b6ec352
--- /dev/null
+++ b/test/source/table/xcellcursor.cxx
@@ -0,0 +1,128 @@
+/* -*- 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/cppunitasserthelper.hxx>
+
+#include <test/table/xcellcursor.hxx>
+
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCellCursor.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XCellCursor::testGoToNext()
+{
+ uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
+ UNO_QUERY_THROW);
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startCol = aCellRangeAddr.StartColumn;
+
+ xCellCursor->gotoNext();
+
+ aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
+
+ CPPUNIT_ASSERT_MESSAGE("Sucessfully able to go to Next", startCol != startCol2);
+}
+
+void XCellCursor::testGoToOffset()
+{
+ uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
+ UNO_QUERY_THROW);
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startRow = aCellRangeAddr.StartRow;
+ const sal_Int32 startCol = aCellRangeAddr.StartColumn;
+
+ xCellCursor->gotoOffset(4, 4);
+
+ aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startRow2 = aCellRangeAddr.StartRow;
+ const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
+
+ CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Offset",
+ (startCol != startCol2) || (startRow == startRow2));
+}
+
+void XCellCursor::testGoToPrevious()
+{
+ uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
+ UNO_QUERY_THROW);
+ xCellCursor->gotoOffset(4, 4);
+
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startCol = aCellRangeAddr.StartColumn;
+
+ xCellCursor->gotoPrevious();
+
+ aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startCol2 = aCellRangeAddr.StartColumn;
+ CPPUNIT_ASSERT_MESSAGE("Successfully able to go to Previous", startCol != startCol2);
+}
+
+void XCellCursor::testGoToStart()
+{
+ uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
+ UNO_QUERY_THROW);
+ xCellCursor->gotoStart();
+
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+
+ const sal_Int32 startRow = aCellRangeAddr.StartRow;
+ const sal_Int32 startCol = aCellRangeAddr.StartColumn;
+ const sal_Int32 endRow = aCellRangeAddr.EndRow;
+ const sal_Int32 endCol = aCellRangeAddr.EndColumn;
+ CPPUNIT_ASSERT_MESSAGE("Successfully able to got to Start",
+ (startCol == endCol) && (endRow == startRow));
+}
+
+void XCellCursor::testGoToEnd()
+{
+ uno::Reference<table::XCellCursor> xCellCursor(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSpreadsheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference<table::XCellRange> xCellRange(xCellCursor, UNO_QUERY_THROW);
+ xCellRange = xSpreadsheet->getCellRangeByName("$A$1:$g$7");
+ uno::Reference<sheet::XSheetCellRange> xSheetCellRange(xCellCursor, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(xCellCursor, UNO_QUERY_THROW);
+ xSheetCellCursor = xSpreadsheet->createCursorByRange(xSheetCellRange);
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xCellCursor,
+ UNO_QUERY_THROW);
+
+ xCellCursor->gotoEnd();
+
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 startRow = aCellRangeAddr.StartRow;
+ const sal_Int32 startCol = aCellRangeAddr.StartColumn;
+ const sal_Int32 endRow = aCellRangeAddr.EndRow;
+ const sal_Int32 endCol = aCellRangeAddr.EndColumn;
+ CPPUNIT_ASSERT_MESSAGE("Successfully able to go to End",
+ (startCol == endCol) && (endRow == startRow));
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */