[Libreoffice-commits] core.git: include/test sc/qa test/source
Laurent Godard
lgodard.libre at laposte.net
Wed Jul 2 05:21:57 PDT 2014
include/test/sheet/xsheetannotations.hxx | 1
sc/qa/extras/scannotationsobj.cxx | 3 +
test/source/sheet/xsheetannotations.cxx | 49 +++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 1 deletion(-)
New commits:
commit 17d0d12b8d2cc92f6e83dbea467f7d00a97795bb
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Fri Jun 27 15:35:32 2014 +0200
unit test XSheetAnnotations GetByIndex for #fdo80551
Change-Id: I89ebc3d5ac257f3c754a050caf3776959b81d8b3
Reviewed-on: https://gerrit.libreoffice.org/9933
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/test/sheet/xsheetannotations.hxx b/include/test/sheet/xsheetannotations.hxx
index 09a29b5..ff44f65 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 49874b1..9bcd60e 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 cf4b82a..66a7b8d 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);
}
More information about the Libreoffice-commits
mailing list