[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/qa test/Library_subsequenttest.mk test/source

Jens Carl j.carl43 at gmx.de
Fri Nov 24 17:59:29 UTC 2017


 include/test/sheet/xsheetannotationanchor.hxx              |   34 +++
 qadevOOo/Jar_OOoRunner.mk                                  |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv  |    1 
 qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java |  121 -------------
 sc/qa/extras/sccellobj.cxx                                 |   31 ++-
 test/Library_subsequenttest.mk                             |    1 
 test/source/sheet/xcelladdressable.cxx                     |    2 
 test/source/sheet/xsheetannotationanchor.cxx               |   44 ++++
 8 files changed, 102 insertions(+), 133 deletions(-)

New commits:
commit befef6ff30f4eb6d3c61c1542839661d7f823dc4
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Sat Nov 11 01:34:27 2017 +0000

    tdf#45904 Move _XSheetAnnotationAnchor Java test to C++
    
    Fixes #i109517 for sc.ScCellObj by adding a note/comment during
    the set up of the test in sccellobj.cxx and allows to re-enabled
    the test.
    
    Change-Id: Ic7aa6bcb2606f555a76612a6f50c200d738674db
    Reviewed-on: https://gerrit.libreoffice.org/44617
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/include/test/sheet/xsheetannotationanchor.hxx b/include/test/sheet/xsheetannotationanchor.hxx
new file mode 100644
index 000000000000..a0c6fc58d494
--- /dev/null
+++ b/include/test/sheet/xsheetannotationanchor.hxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_TEST_SHEET_XSHEETANNOTATIONANCHOR_HXX
+#define INCLUDED_TEST_SHEET_XSHEETANNOTATIONANCHOR_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest
+{
+class OOO_DLLPUBLIC_TEST XSheetAnnotationAnchor
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testGetAnnotation();
+
+protected:
+    ~XSheetAnnotationAnchor() {}
+};
+}
+
+#endif // INCLUDED_TEST_SHEET_XSHEETANNOTATIONANCHOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 4ee5633c5650..0064c67a5dcf 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -609,7 +609,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XRangeSelection \
     qadevOOo/tests/java/ifc/sheet/_XRecentFunctions \
     qadevOOo/tests/java/ifc/sheet/_XScenario \
-    qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor \
     qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor \
     qadevOOo/tests/java/ifc/style/_CharacterProperties \
     qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
index ef1c845ab31b..a844cd884d23 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv
@@ -152,7 +152,6 @@
 "ScCellObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getDirectPropertyValuesTolerant()"
 "ScCellObj";"com::sun::star::text::XTextFieldsSupplier";"getTextFields()"
 "ScCellObj";"com::sun::star::text::XTextFieldsSupplier";"getTextFieldMasters()"
-"ScCellObj";"com::sun::star::sheet::XSheetAnnotationAnchor";"getAnnotation()"
 "ScCellObj";"com::sun::star::style::CharacterProperties";"CharFontName"
 "ScCellObj";"com::sun::star::style::CharacterProperties";"CharFontStyleName"
 "ScCellObj";"com::sun::star::style::CharacterProperties";"CharFontFamily"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java
deleted file mode 100644
index 8c33d9f4542e..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package ifc.sheet;
-
-import lib.MultiMethodTest;
-
-import com.sun.star.sheet.XSheetAnnotation;
-import com.sun.star.sheet.XSheetAnnotationAnchor;
-import com.sun.star.table.CellAddress;
-import com.sun.star.text.XSimpleText;
-import com.sun.star.uno.UnoRuntime;
-
-/**
-* Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code>
-* interface methods :
-* <ul>
-*  <li><code> getAnnotation()</code></li>
-* </ul>
-* @see com.sun.star.sheet.XSheetAnnotationAnchor
-*/
-public class _XSheetAnnotationAnchor extends MultiMethodTest {
-
-    public XSheetAnnotationAnchor oObj = null;
-    protected XSheetAnnotation anno = null;
-
-    public void _getAnnotation() {
-        anno = oObj.getAnnotation();
-        tRes.tested("getAnnotation()",checkAnnotation());
-    }
-
-    protected boolean checkAnnotation() {
-        boolean res = true;
-        res &= check_getAuthor();
-        res &= check_getDate();
-        res &= check_getIsVisible();
-        res &= check_getPosition();
-        res &= check_setIsVisible();
-        return res;
-    }
-
-    /**
-    * Gets the author of annotation. <p>
-    * Returns <b>true</b> if not null value returned.
-    */
-    protected boolean check_getAuthor() {
-      String author = anno.getAuthor();
-      return (author != null);
-    }
-
-    /**
-    * Gets the modification date of annotation. <p>
-    * Returns <b>true</b> if not null value returned.
-    */
-    protected boolean check_getDate() {
-      String date = anno.getDate();
-      return (date != null);
-    }
-
-    /**
-    * Sets the string of annotation, then makes it visible and
-    * checks the value returned by <code>getIsVisible</code> method. <p>
-    * Returns <b>true</b> if the method returns <code>true</code>.
-    */
-    protected boolean check_getIsVisible() {
-      XSimpleText oText  = UnoRuntime.queryInterface(XSimpleText.class, anno);
-      oText.setString("XSheetAnnotation");
-      anno.setIsVisible(true);
-      boolean bVis = anno.getIsVisible();
-      return bVis;
-    }
-
-    /**
-    * Gets the position of annotated cell
-    * Returns <b>true</b> if this position is not null.
-    */
-    protected boolean check_getPosition() {
-      CellAddress oCAddr = anno.getPosition();
-      return  (oCAddr != null);
-    }
-
-    /**
-    * Sets the string of annotation, makes it hidden and then
-    * visible. Visibility is checked in both cases. <p>
-    * Returns <b>true</b> if the <code>getIsVisible</code> method
-    * returns <code>false</code> in the first case and <code>true</code>
-    * in the second.
-    */
-    protected boolean check_setIsVisible() {
-      boolean bResult = true;
-      XSimpleText oText  = UnoRuntime.queryInterface(XSimpleText.class, anno);
-      oText.setString("XSheetAnnotation");
-      anno.setIsVisible(false);
-      boolean bVis = anno.getIsVisible();
-      if (!bVis) {
-          anno.setIsVisible(true);
-          bVis = anno.getIsVisible();
-          if (bVis) {
-              bResult = true;
-          }
-      }
-
-      return bResult;
-    }
-
-}
\ No newline at end of file
diff --git a/sc/qa/extras/sccellobj.cxx b/sc/qa/extras/sccellobj.cxx
index 6d0f90c1f732..dd9ab6fe633a 100644
--- a/sc/qa/extras/sccellobj.cxx
+++ b/sc/qa/extras/sccellobj.cxx
@@ -9,10 +9,15 @@
 
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/xcelladdressable.hxx>
+#include <test/sheet/xsheetannotationanchor.hxx>
 
 #include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+#include <com/sun/star/sheet/XSheetAnnotations.hpp>
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
 #include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
 #include <com/sun/star/table/XCellRange.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 
@@ -21,9 +26,10 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 1
+#define NUMBER_OF_TESTS 2
 
-class ScCellObj : public CalcUnoApiTest, public apitest::XCellAddressable
+class ScCellObj : public CalcUnoApiTest, public apitest::XCellAddressable,
+                                         public apitest::XSheetAnnotationAnchor
 {
 public:
     ScCellObj();
@@ -33,8 +39,13 @@ public:
     virtual void tearDown() override;
 
     CPPUNIT_TEST_SUITE(ScCellObj);
+
     // XCellAddressable
     CPPUNIT_TEST(testGetCellAddress);
+
+    // XSheetAnnotationAnchor
+    CPPUNIT_TEST(testGetAnnotation);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -61,14 +72,16 @@ uno::Reference< uno::XInterface > ScCellObj::init()
     uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
     CPPUNIT_ASSERT_MESSAGE("no calc document", xSheetDoc.is());
 
-    // get getSheets
-    uno::Reference< sheet::XSpreadsheets > xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW);
-    uno::Any rSheet = xSheets->getByName("Sheet1");
-    // query for the XCellRange interface
-    uno::Reference< table::XCellRange > rCellRange(rSheet, UNO_QUERY);
-    uno::Reference< table::XCellRange > xCellRange = rCellRange->getCellRangeByName("A1");
+    uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
+
+    uno::Reference<sheet::XSheetAnnotationsSupplier> xSheetAnnosSupplier(xSheet, UNO_QUERY_THROW);
+    uno::Reference<sheet::XSheetAnnotations> xSheetAnnos(xSheetAnnosSupplier->getAnnotations(),
+                                                         UNO_QUERY_THROW);
+    xSheetAnnos->insertNew(table::CellAddress(0, 2, 3), "xSheetAnnotation");
 
-    return xCellRange->getCellByPosition(0, 0);
+    return xSheet->getCellByPosition(2, 3);
 }
 
 void ScCellObj::setUp()
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index a2bee04955d0..e70ee12970f3 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/xspreadsheets2 \
 	test/source/sheet/xspreadsheetview \
 	test/source/sheet/xsheetannotation \
+	test/source/sheet/xsheetannotationanchor \
 	test/source/sheet/xsheetannotations \
 	test/source/sheet/xsheetannotationssupplier \
 	test/source/sheet/xsheetannotationshapesupplier \
diff --git a/test/source/sheet/xcelladdressable.cxx b/test/source/sheet/xcelladdressable.cxx
index 5fad50858af5..eeb7ea85f5de 100644
--- a/test/source/sheet/xcelladdressable.cxx
+++ b/test/source/sheet/xcelladdressable.cxx
@@ -24,7 +24,7 @@ void XCellAddressable::testGetCellAddress()
 {
     uno::Reference< sheet::XCellAddressable > xCellAddressable(init(), UNO_QUERY_THROW);
     table::CellAddress xCellAddress = xCellAddressable->getCellAddress();
-    table::CellAddress defaultCellAddress;
+    table::CellAddress defaultCellAddress(0, 2, 3);
 
     CPPUNIT_ASSERT_EQUAL_MESSAGE("getCellAddress() didn't returned default cell address",
                                  defaultCellAddress, xCellAddress);
diff --git a/test/source/sheet/xsheetannotationanchor.cxx b/test/source/sheet/xsheetannotationanchor.cxx
new file mode 100644
index 000000000000..cf0894a7e83d
--- /dev/null
+++ b/test/source/sheet/xsheetannotationanchor.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotationanchor.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetAnnotationAnchor::testGetAnnotation()
+{
+    uno::Reference<sheet::XSheetAnnotationAnchor> xAnchor(init(), UNO_QUERY_THROW);
+    uno::Reference<sheet::XSheetAnnotation> xAnnotation(xAnchor->getAnnotation(), UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("Unable to get XSheetAnnotation", xAnnotation.is());
+
+    CPPUNIT_ASSERT_MESSAGE("Unable to check: getAuthor()", xAnnotation->getAuthor().isEmpty());
+    CPPUNIT_ASSERT_MESSAGE("Unable to check: getDate()", !xAnnotation->getDate().isEmpty());
+    CPPUNIT_ASSERT_MESSAGE("Unable to check: getIsVisible()", !xAnnotation->getIsVisible());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to check: getPosition()", table::CellAddress(0, 2, 3),
+                                 xAnnotation->getPosition());
+
+    xAnnotation->setIsVisible(false);
+    CPPUNIT_ASSERT_MESSAGE("Unable to setIsVisible() to false", !xAnnotation->getIsVisible());
+    xAnnotation->setIsVisible(true);
+    CPPUNIT_ASSERT_MESSAGE("Unable to setIsVisible() to true", xAnnotation->getIsVisible());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list