summaryrefslogtreecommitdiff
path: root/sc/qa/extras
diff options
context:
space:
mode:
authorLaurent Godard <lgodard.libre@laposte.net>2014-08-05 17:02:49 +0200
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-08-08 00:38:10 +0200
commit949279c8013022ff2935d73276cd57c9af069b97 (patch)
treeed769534cd74e77bce5235041c54d0d740ad2a60 /sc/qa/extras
parent41e05f48dd3bf08552db3675f5285276095ba0bf (diff)
XStyleLoader2 loadStylesFromDocument - unit tests
Change-Id: Id143689f573e6f8585db9bc48a252e311ff0e721
Diffstat (limited to 'sc/qa/extras')
-rw-r--r--sc/qa/extras/scstyleloaderobj.cxx125
-rw-r--r--sc/qa/extras/testdocuments/ScStyleLoaderObj.odsbin0 -> 18045 bytes
2 files changed, 125 insertions, 0 deletions
diff --git a/sc/qa/extras/scstyleloaderobj.cxx b/sc/qa/extras/scstyleloaderobj.cxx
new file mode 100644
index 000000000000..06f7c9e2ca5a
--- /dev/null
+++ b/sc/qa/extras/scstyleloaderobj.cxx
@@ -0,0 +1,125 @@
+/* -*- 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/xstyleloader.hxx>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 2
+
+class ScStyleLoaderObj : public CalcUnoApiTest, apitest::XStyleLoader
+{
+public:
+ ScStyleLoaderObj();
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ virtual uno::Reference< uno::XInterface > init();
+ virtual uno::Reference< lang::XComponent > getTargetComponent();
+ virtual uno::Reference< lang::XComponent > getSourceComponent();
+ virtual OUString getTestURL();
+
+ CPPUNIT_TEST_SUITE(ScStyleLoaderObj);
+ CPPUNIT_TEST(testLoadStylesFromURL);
+ CPPUNIT_TEST(testLoadStylesFromDocument);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxSourceComponent;
+ static uno::Reference< lang::XComponent > mxTargetComponent;
+
+
+};
+
+sal_Int32 ScStyleLoaderObj::nTest = 0;
+uno::Reference< lang::XComponent > ScStyleLoaderObj::mxSourceComponent;
+uno::Reference< lang::XComponent > ScStyleLoaderObj::mxTargetComponent;
+
+
+ScStyleLoaderObj::ScStyleLoaderObj()
+ : CalcUnoApiTest("sc/qa/extras/testdocuments")
+{
+}
+
+
+uno::Reference< uno::XInterface > ScStyleLoaderObj::init()
+{
+ return getTargetComponent();
+}
+
+
+uno::Reference< lang::XComponent > ScStyleLoaderObj::getTargetComponent(){
+ // target is always an empty document
+
+ if (mxTargetComponent.is())
+ closeDocument(mxTargetComponent);
+
+ mxTargetComponent = loadFromDesktop("private:factory/scalc");
+
+ return mxTargetComponent;
+}
+
+uno::Reference< lang::XComponent > ScStyleLoaderObj::getSourceComponent(){
+
+ if (mxSourceComponent.is())
+ closeDocument(mxSourceComponent);
+
+ // get the test file url
+ OUString aFileURL = getTestURL();
+
+ if(!mxSourceComponent.is())
+ mxSourceComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxSourceComponent.is());
+
+ return mxSourceComponent;
+}
+
+OUString ScStyleLoaderObj::getTestURL(){
+
+ OUString aFileURL;
+ createFileURL(OUString("ScStyleLoaderObj.ods"), aFileURL);
+
+ return aFileURL;
+}
+
+void ScStyleLoaderObj::setUp()
+{
+ nTest++;
+ CalcUnoApiTest::setUp();
+}
+
+void ScStyleLoaderObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ if (mxSourceComponent.is())
+ closeDocument(mxSourceComponent);
+ if (mxTargetComponent.is())
+ closeDocument(mxTargetComponent);
+ }
+ CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScStyleLoaderObj);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods b/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
new file mode 100644
index 000000000000..3cfb3bac62ef
--- /dev/null
+++ b/sc/qa/extras/testdocuments/ScStyleLoaderObj.ods
Binary files differ