[Libreoffice-commits] core.git: include/test sc/CppunitTest_sc_viewpaneobj.mk sc/Module_sc.mk sc/qa test/Library_subsequenttest.mk test/source

Fabio Buso dev.siroibaf at gmail.com
Wed Apr 27 00:28:29 UTC 2016


 include/test/sheet/xviewpane.hxx |   40 ++++++++++++++
 sc/CppunitTest_sc_viewpaneobj.mk |  107 +++++++++++++++++++++++++++++++++++++++
 sc/Module_sc.mk                  |    1 
 sc/qa/extras/scviewpaneobj.cxx   |   97 +++++++++++++++++++++++++++++++++++
 test/Library_subsequenttest.mk   |    1 
 test/source/sheet/xviewpane.cxx  |   54 +++++++++++++++++++
 6 files changed, 300 insertions(+)

New commits:
commit e7f55f15ccd97bc92e1400bc5862171a621da3e2
Author: Fabio Buso <dev.siroibaf at gmail.com>
Date:   Thu Apr 21 22:45:51 2016 +0200

    tdf#45904 Move java XViewPane test to c++
    
    Change-Id: I3c99fb4c611a3b45d31412731c548b59e95d7179
    Reviewed-on: https://gerrit.libreoffice.org/24285
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/test/sheet/xviewpane.hxx b/include/test/sheet/xviewpane.hxx
new file mode 100644
index 0000000..1ab20a1
--- /dev/null
+++ b/include/test/sheet/xviewpane.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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_XVIEWPANE_HXX
+#define INCLUDED_TEST_SHEET_XVIEWPANE_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XViewPane
+{
+public:
+    virtual uno::Reference< uno::XInterface > init() = 0;
+
+    void testFirstVisibleColumn();
+    void testFirstVisibleRow();
+    void testVisibleRange();
+
+protected:
+    virtual ~XViewPane() {}
+
+};
+
+}
+
+#endif // INCLUDED_TEST_SHEET_XVIEWPANE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/CppunitTest_sc_viewpaneobj.mk b/sc/CppunitTest_sc_viewpaneobj.mk
new file mode 100644
index 0000000..33a360c
--- /dev/null
+++ b/sc/CppunitTest_sc_viewpaneobj.mk
@@ -0,0 +1,107 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_viewpaneobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_viewpaneobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_viewpaneobj, \
+    sc/qa/extras/scviewpaneobj \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_viewpaneobj, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sc \
+    sfx \
+    sot \
+    subsequenttest \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tk \
+    tl \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_viewpaneobj,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_viewpaneobj,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_viewpaneobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_viewpaneobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_viewpaneobj,\
+	basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    filter/source/config/cache/filterconfig1 \
+    filter/source/storagefilterdetect/storagefd \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    scripting/source/basprov/basprov \
+    scripting/util/scriptframe \
+    sc/util/sc \
+    sc/util/scd \
+    sc/util/scfilt \
+    $(call gb_Helper_optional,SCRIPTING, \
+	    sc/util/vbaobj) \
+    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 \
+    xmloff/util/xo \
+	svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_viewpaneobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index e0cbf5b..3586019 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -94,6 +94,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_check_xcell_ranges_query \
 	CppunitTest_sc_check_data_pilot_field \
 	CppunitTest_sc_check_data_pilot_table \
+	CppunitTest_sc_viewpaneobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/scviewpaneobj.cxx b/sc/qa/extras/scviewpaneobj.cxx
new file mode 100644
index 0000000..c95373f
--- /dev/null
+++ b/sc/qa/extras/scviewpaneobj.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/calc_unoapi_test.hxx>
+#include <test/sheet/xviewpane.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XViewPane.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 3
+
+class ScViewPaneObj : public CalcUnoApiTest, public apitest::XViewPane
+{
+public:
+    ScViewPaneObj();
+
+    virtual uno::Reference< uno::XInterface > init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScViewPaneObj);
+    CPPUNIT_TEST(testFirstVisibleColumn);
+    CPPUNIT_TEST(testFirstVisibleRow);
+    CPPUNIT_TEST(testVisibleRange);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+
+    static sal_Int32 nTest;
+    static uno::Reference<lang::XComponent> mxComponent;
+
+};
+
+sal_Int32 ScViewPaneObj::nTest = 0;
+uno::Reference< lang::XComponent > ScViewPaneObj::mxComponent;
+
+ScViewPaneObj::ScViewPaneObj()
+        : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference< uno::XInterface > ScViewPaneObj::init()
+{
+    // create a calc document
+    if (!mxComponent.is())
+        mxComponent = loadFromDesktop("private:factory/scalc");
+
+    uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document!", xSheetDoc.is());
+
+    uno::Reference< frame::XModel > xModel(xSheetDoc, uno::UNO_QUERY_THROW);
+    uno::Reference< frame::XController > xController = xModel->getCurrentController();
+    uno::Reference< container::XIndexAccess > xIndexAccess(xController, uno::UNO_QUERY_THROW);
+    uno::Reference< sheet::XViewPane > xViewPane (xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
+    return xViewPane;
+}
+
+void ScViewPaneObj::setUp()
+{
+    nTest++;
+    CalcUnoApiTest::setUp();
+}
+
+void ScViewPaneObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScViewPaneObj);
+
+} // End Namespace
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index f9b4b93..5bfe527 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
     test/source/sheet/xsheetannotations \
     test/source/sheet/xsheetoutline \
     test/source/sheet/xstyleloader \
+    test/source/sheet/xviewpane \
     test/source/text/xtext \
     test/source/text/xtextfield \
     test/source/text/xtextcontent \
diff --git a/test/source/sheet/xviewpane.cxx b/test/source/sheet/xviewpane.cxx
new file mode 100644
index 0000000..7595310
--- /dev/null
+++ b/test/source/sheet/xviewpane.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/xviewpane.hxx>
+#include <com/sun/star/sheet/XViewPane.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include "cppunit/TestAssert.h"
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XViewPane::testFirstVisibleColumn()
+{
+    sal_Int32 nCol = 5;
+    uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+    xViewPane->setFirstVisibleColumn(nCol);
+    CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleColumn(), nCol);
+}
+
+void XViewPane::testFirstVisibleRow()
+{
+    sal_Int32 nRow = 3;
+    uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+    xViewPane->setFirstVisibleRow(nRow);
+    CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleRow(), nRow);
+}
+
+void XViewPane::testVisibleRange()
+{
+    sal_Int16 nSheet = 0;
+    sal_Int32 nCol = 5;
+    sal_Int32 nRow = 3;
+    uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+    xViewPane->setFirstVisibleColumn(nCol);
+    xViewPane->setFirstVisibleRow(nRow);
+
+    table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
+    CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.Sheet, nSheet);
+    CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartRow, nRow);
+    CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartColumn, nCol);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list