Kaydet (Commit) 17d0d12b authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Caolán McNamara

unit test XSheetAnnotations GetByIndex for #fdo80551

Change-Id: I89ebc3d5ac257f3c754a050caf3776959b81d8b3
Reviewed-on: https://gerrit.libreoffice.org/9933Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 3a25b451
......@@ -21,6 +21,7 @@ public:
virtual css::uno::Reference< css::uno::XInterface > init() = 0;
// XSheetAnnotations
void testGetByIndex();
void testInsertNew();
void testRemoveByIndex();
void testCount();
......
......@@ -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:
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment