[Libreoffice-commits] .: sc/CppunitTest_sc_annotationobj.mk sc/Module_sc.mk sc/qa test/inc test/Library_subsequenttest.mk test/Package_inc.mk test/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 17 08:05:40 PST 2013


 sc/CppunitTest_sc_annotationobj.mk             |  129 ++++++++++++++++++++++++
 sc/Module_sc.mk                                |    1 
 sc/qa/extras/scannotationobj.cxx               |  134 +++++++++++++++++++++++++
 sc/qa/extras/testdocuments/ScAnnotationObj.ods |binary
 test/Library_subsequenttest.mk                 |    1 
 test/Package_inc.mk                            |    1 
 test/inc/test/sheet/xsheetannotation.hxx       |   60 +++++++++++
 test/source/sheet/xsheetannotation.cxx         |   88 ++++++++++++++++
 8 files changed, 414 insertions(+)

New commits:
commit 0bf016694e8df63e20e530f9880e87de567dc7e1
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Thu Jan 17 10:17:43 2013 +0100

    sc test for XSheetAnnotation
    
    Change-Id: I1fa77c874c6307ff71ea0aeee653acf1305f2646
    Reviewed-on: https://gerrit.libreoffice.org/1736
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/CppunitTest_sc_annotationobj.mk b/sc/CppunitTest_sc_annotationobj.mk
new file mode 100644
index 0000000..16b2d48
--- /dev/null
+++ b/sc/CppunitTest_sc_annotationobj.mk
@@ -0,0 +1,129 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Initial Developer of the Original Code is
+#	   Copyright (C) 2013 Laurent Godard <lgodard.libre at laposte.net> (initial developer)
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Major Contributor(s):
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_annotationobj))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_annotationobj, \
+    sc/qa/extras/scannotationobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_annotationobj, \
+    avmedia \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    fileacc \
+    for \
+    forui \
+    i18nisolang1 \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sc \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tl \
+    tk \
+    subsequenttest \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_annotationobj,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_annotationobj,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_annotationobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_annotationobj,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    fileaccess/source/fileacc \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+	linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sax/source/fastparser/fastsax \
+    sc/util/sc \
+    sc/util/scd \
+    sc/util/scfilt \
+    $(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
+	    sc/util/vbaobj) \
+    scripting/source/basprov/basprov \
+    scripting/util/scriptframe \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_annotationobj))
+
+$(eval $(call gb_CppunitTest_use_filter_configuration,sc_annotationobj))
+
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_annotationobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index f6c1c62..2b2aa6f 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
 $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
     JunitTest_sc_complex \
     JunitTest_sc_unoapi \
+    CppunitTest_sc_annotationobj \
     CppunitTest_sc_cellrangeobj \
     $(if $(filter-out $(OS),IOS), \
 	    CppunitTest_sc_databaserangeobj) \
diff --git a/sc/qa/extras/scannotationobj.cxx b/sc/qa/extras/scannotationobj.cxx
new file mode 100644
index 0000000..29d9cbf
--- /dev/null
+++ b/sc/qa/extras/scannotationobj.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2013 Laurent Godard <lgodard.libre at laposte.net> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <test/sheet/xsheetannotation.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+
+#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 5
+
+class ScAnnontationObj : public UnoApiTest, apitest::XSheetAnnotation
+{
+public:
+    ScAnnontationObj();
+
+    virtual void setUp();
+    virtual void tearDown();
+
+    virtual uno::Reference< uno::XInterface > init();
+    virtual uno::Reference< sheet::XSheetAnnotation> getAnnotation(table::CellAddress&);
+
+    CPPUNIT_TEST_SUITE(ScAnnontationObj);
+    CPPUNIT_TEST(testGetPosition);
+    CPPUNIT_TEST(testGetAuthor);
+    CPPUNIT_TEST(testGetDate);
+    CPPUNIT_TEST(testGetIsVisible);
+    CPPUNIT_TEST(testSetIsVisible);
+    CPPUNIT_TEST_SUITE_END();
+private:
+
+    static sal_Int32 nTest;
+    static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScAnnontationObj::nTest = 0;
+uno::Reference< lang::XComponent > ScAnnontationObj::mxComponent;
+
+ScAnnontationObj::ScAnnontationObj()
+{
+}
+
+uno::Reference< sheet::XSheetAnnotation> ScAnnontationObj::getAnnotation(table::CellAddress& xCellAddress)
+{
+    // get the sheet
+    uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
+    uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(xCellAddress.Sheet), UNO_QUERY_THROW);
+
+    // get the cell
+    uno::Reference< table::XCell > xCell( xSheet->getCellByPosition(xCellAddress.Column, xCellAddress.Row), UNO_QUERY_THROW);
+
+    // get the annotation from cell
+    uno::Reference< sheet::XSheetAnnotationAnchor > xAnnotationAnchor(xCell, UNO_QUERY_THROW);
+    uno::Reference< sheet::XSheetAnnotation > xSheetAnnotation( xAnnotationAnchor->getAnnotation(), UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT(xSheetAnnotation.is());
+
+    return xSheetAnnotation;
+}
+
+uno::Reference< uno::XInterface > ScAnnontationObj::init()
+{
+
+    // get the test file
+    rtl::OUString aFileURL;
+    createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAnnotationObj.ods")), aFileURL);
+    if(!mxComponent.is())
+        mxComponent = loadFromDesktop(aFileURL);
+    CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
+
+    // tested annotation is in sheet 0 cell C2
+    table::CellAddress xCellAddress;
+    xCellAddress.Sheet = 0;
+    xCellAddress.Row = 1;
+    xCellAddress.Column = 2;
+
+    return getAnnotation(xCellAddress);
+}
+
+void ScAnnontationObj::setUp()
+{
+    nTest++;
+    UnoApiTest::setUp();
+}
+
+void ScAnnontationObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+        closeDocument(mxComponent);
+
+    UnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/testdocuments/ScAnnotationObj.ods b/sc/qa/extras/testdocuments/ScAnnotationObj.ods
new file mode 100644
index 0000000..bed0680
Binary files /dev/null and b/sc/qa/extras/testdocuments/ScAnnotationObj.ods differ
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 0bc9359..77cc573 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -80,6 +80,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
     test/source/sheet/xprintareas \
     test/source/sheet/xspreadsheetdocument \
     test/source/sheet/xspreadsheets2 \
+    test/source/sheet/xsheetannotation \
     test/source/text/xtext \
     test/source/text/xtextfield \
     test/source/text/xtextcontent \
diff --git a/test/Package_inc.mk b/test/Package_inc.mk
index 3b4b7c3..7e236a7 100644
--- a/test/Package_inc.mk
+++ b/test/Package_inc.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/datapilotfield.hxx,tes
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xprintareas.hxx,test/sheet/xprintareas.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheetdocument.hxx,test/sheet/xspreadsheetdocument.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheets2.hxx,test/sheet/xspreadsheets2.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xsheetannotation.hxx,test/sheet/xsheetannotation.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtext.hxx,test/text/xtext.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtextfield.hxx,test/text/xtextfield.hxx))
 $(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtextcontent.hxx,test/text/xtextcontent.hxx))
diff --git a/test/inc/test/sheet/xsheetannotation.hxx b/test/inc/test/sheet/xsheetannotation.hxx
new file mode 100644
index 0000000..9dd552d
--- /dev/null
+++ b/test/inc/test/sheet/xsheetannotation.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2013 Laurent Godard lgodard.libre at laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+#include <test/testdllapi.hxx>
+
+#include <com/sun/star/table/CellAddress.hpp>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XSheetAnnotation
+{
+public:
+    virtual uno::Reference< uno::XInterface > init() = 0;
+
+    // XSheetAnnotation
+    void testGetPosition();
+    void testGetAuthor();
+    void testGetDate();
+    void testGetIsVisible();
+    void testSetIsVisible();
+
+protected:
+    ~XSheetAnnotation() {}
+
+    virtual uno::Reference< sheet::XSheetAnnotation> getAnnotation(table::CellAddress&) = 0;
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetannotation.cxx b/test/source/sheet/xsheetannotation.cxx
new file mode 100644
index 0000000..ec76804
--- /dev/null
+++ b/test/source/sheet/xsheetannotation.cxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre at laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xsheetannotation.hxx>
+
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+#include <rtl/ustring.hxx>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XSheetAnnotation::testGetPosition()
+{
+    uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+    table::CellAddress xResultCellAddress = aSheetAnnotation->getPosition();
+
+    //expected result
+    table::CellAddress xExpectedCellAddress;
+    xExpectedCellAddress.Sheet = 0;
+    xExpectedCellAddress.Row = 1;
+    xExpectedCellAddress.Column = 2;
+
+    CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xResultCellAddress.Sheet == xExpectedCellAddress.Sheet);
+    CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xResultCellAddress.Column == xExpectedCellAddress.Column);
+    CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xResultCellAddress.Row == xExpectedCellAddress.Row);
+}
+
+void XSheetAnnotation::testGetAuthor()
+{
+    uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+    rtl::OUString aAuthor = aSheetAnnotation->getAuthor();
+
+    CPPUNIT_ASSERT_MESSAGE("Wrong author", aAuthor.equals("LG"));
+}
+void XSheetAnnotation::testGetDate()
+{
+    uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+    rtl::OUString aDate = aSheetAnnotation->getDate();
+
+    CPPUNIT_ASSERT_MESSAGE("Wrong date", aDate.equals("01/17/2013"));
+}
+void XSheetAnnotation::testGetIsVisible()
+{
+    uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+    bool isVisible = aSheetAnnotation->getIsVisible();
+
+    CPPUNIT_ASSERT_MESSAGE("Wrong visible state", isVisible == true);
+}
+void XSheetAnnotation::testSetIsVisible()
+{
+    uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+    aSheetAnnotation->setIsVisible(false);
+    bool isVisible = aSheetAnnotation->getIsVisible();
+
+    CPPUNIT_ASSERT_MESSAGE("Visible state not changed", isVisible == false);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list