diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2014-06-27 15:35:32 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-02 12:21:34 +0000 |
commit | 17d0d12b8d2cc92f6e83dbea467f7d00a97795bb (patch) | |
tree | e3ba77bd4ce5da099f581b3cf153d3c58a61ae44 | |
parent | 3a25b45122c374bee92bca5c417e47a27a9e57d2 (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>
-rw-r--r-- | include/test/sheet/xsheetannotations.hxx | 1 | ||||
-rw-r--r-- | sc/qa/extras/scannotationsobj.cxx | 3 | ||||
-rw-r--r-- | test/source/sheet/xsheetannotations.cxx | 49 |
3 files changed, 52 insertions, 1 deletions
diff --git a/include/test/sheet/xsheetannotations.hxx b/include/test/sheet/xsheetannotations.hxx index 09a29b575b46..ff44f655e007 100644 --- a/include/test/sheet/xsheetannotations.hxx +++ b/include/test/sheet/xsheetannotations.hxx @@ -21,6 +21,7 @@ public: virtual css::uno::Reference< css::uno::XInterface > init() = 0; // XSheetAnnotations + void testGetByIndex(); void testInsertNew(); void testRemoveByIndex(); void testCount(); diff --git a/sc/qa/extras/scannotationsobj.cxx b/sc/qa/extras/scannotationsobj.cxx index 49874b13feed..9bcd60eacefc 100644 --- a/sc/qa/extras/scannotationsobj.cxx +++ b/sc/qa/extras/scannotationsobj.cxx @@ -20,7 +20,7 @@ using namespace css::uno; namespace sc_apitest { -#define NUMBER_OF_TESTS 3 +#define NUMBER_OF_TESTS 4 class ScAnnontationsObj : public CalcUnoApiTest, apitest::XSheetAnnotations { @@ -37,6 +37,7 @@ public: CPPUNIT_TEST(testInsertNew); CPPUNIT_TEST(testRemoveByIndex); CPPUNIT_TEST(testCount); + CPPUNIT_TEST(testGetByIndex); CPPUNIT_TEST_SUITE_END(); private: 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); } |