summaryrefslogtreecommitdiff
path: root/test/source/sheet
diff options
context:
space:
mode:
authorLaurent Godard <lgodard.libre@laposte.net>2014-06-27 15:35:32 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-07-02 12:21:34 +0000
commit17d0d12b8d2cc92f6e83dbea467f7d00a97795bb (patch)
treee3ba77bd4ce5da099f581b3cf153d3c58a61ae44 /test/source/sheet
parent3a25b45122c374bee92bca5c417e47a27a9e57d2 (diff)
unit test XSheetAnnotations GetByIndex for #fdo80551
Change-Id: I89ebc3d5ac257f3c754a050caf3776959b81d8b3 Reviewed-on: https://gerrit.libreoffice.org/9933 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'test/source/sheet')
-rw-r--r--test/source/sheet/xsheetannotations.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/source/sheet/xsheetannotations.cxx b/test/source/sheet/xsheetannotations.cxx
index cf4b82a8e879..66a7b8dd1876 100644
--- a/test/source/sheet/xsheetannotations.cxx
+++ b/test/source/sheet/xsheetannotations.cxx
@@ -155,6 +155,55 @@ void XSheetAnnotations::testRemoveByIndex()
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Remove Annotation - Wrong string",
OUString("an inserted annotation 1"), aPreviousString);
+}
+
+void XSheetAnnotations::testGetByIndex()
+{
+
+ // testing #fdo80551 - getByIndex not on the first sheet
+
+ // insert annotations in first sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheet0Annotations (init(), UNO_QUERY_THROW);
+ table::CellAddress xTargetCellAddress0 (0,0,1);
+ aSheet0Annotations->insertNew(xTargetCellAddress0, "an inserted annotation 1 on sheet 1");
+ table::CellAddress xSecondTargetCellAddress0 (0,0,2);
+ aSheet0Annotations->insertNew(xSecondTargetCellAddress0, "an inserted annotation 2 on sheet 1");
+ table::CellAddress xThirdCellAddress0 (0,0,3);
+ aSheet0Annotations->insertNew(xThirdCellAddress0, "an inserted annotation 3 on sheet 1");
+
+ // insert annotations in second sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheet1Annotations (getAnnotations(1), UNO_QUERY_THROW);
+ table::CellAddress xTargetCellAddress1 (1,4,5);
+ aSheet1Annotations->insertNew(xTargetCellAddress1, "an inserted annotation 1 on sheet 2");
+ table::CellAddress xSecondTargetCellAddress1 (1,5,6);
+ aSheet1Annotations->insertNew(xSecondTargetCellAddress1, "an inserted annotation 2 on sheet 2");
+ table::CellAddress xThirdCellAddress1 (1,7,8);
+ aSheet1Annotations->insertNew(xThirdCellAddress1, "an inserted annotation 3 on sheet 2");
+
+ // get second annotation for second sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (getAnnotations(1), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetAnnotation > aAnnotation (xAnnotationsIndex->getByIndex(1), UNO_QUERY_THROW);
+
+ table::CellAddress xToBeAnalyzedCellAddress = aAnnotation->getPosition();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong SHEET reference position",
+ xSecondTargetCellAddress1.Sheet, xToBeAnalyzedCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong COLUMN reference position",
+ xSecondTargetCellAddress1.Column, xToBeAnalyzedCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong ROW reference position",
+ xSecondTargetCellAddress1.Row, xToBeAnalyzedCellAddress.Row);
+
+ // is the string ok ?
+ uno::Reference< text::XTextRange > aTextSheetAnnotation(aAnnotation, UNO_QUERY_THROW);
+ OUString aString = aTextSheetAnnotation->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong string",
+ OUString("an inserted annotation 2 on sheet 2"), aString);
}