From 2279208fa0570ef5fa2d49c14a721b7d59be069d Mon Sep 17 00:00:00 2001 From: Laurent Godard Date: Fri, 6 Dec 2013 12:36:41 +0100 Subject: count notes - GetNotesInRange now include last tab - refactor tests - add unit test on counting notes on a sheet Change-Id: I6762a0e791a745b828800645effdfc044ac33710 Reviewed-on: https://gerrit.libreoffice.org/6954 Reviewed-by: Markus Mohrhard Tested-by: Markus Mohrhard --- test/source/sheet/xsheetannotations.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/source/sheet/xsheetannotations.cxx b/test/source/sheet/xsheetannotations.cxx index 66715938163a..a56fc6ba581c 100644 --- a/test/source/sheet/xsheetannotations.cxx +++ b/test/source/sheet/xsheetannotations.cxx @@ -22,6 +22,27 @@ using namespace css::uno; namespace apitest { +void XSheetAnnotations::testCount() +{ + uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW); + + // count on sheet 1 before inserting + uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW); + sal_Int32 nBefore = xAnnotationsIndex->getCount(); + + // get Sheet 2 annotations + uno::Reference< sheet::XSheetAnnotations > xSheet2Annotations( getAnnotations(1), UNO_QUERY_THROW); + + // insert a note on sheet 2 + table::CellAddress xTargetCellAddress (1,0,0); + xSheet2Annotations->insertNew(xTargetCellAddress, "an inserted annotation on sheet 2"); + + // count again on sheet 1 + sal_Int32 nAfter = xAnnotationsIndex->getCount(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Annotations count should not change on sheet 1", nBefore, nAfter); +} + void XSheetAnnotations::testInsertNew() { uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW); @@ -30,6 +51,9 @@ void XSheetAnnotations::testInsertNew() uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW); sal_Int32 nBefore = xAnnotationsIndex->getCount(); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "There should already be one note", 1, nBefore ); + // insert the annotation table::CellAddress xTargetCellAddress (0,3,4); aSheetAnnotations->insertNew(xTargetCellAddress, "an inserted annotation"); -- cgit