diff options
author | David Tardon <dtardon@redhat.com> | 2014-03-29 16:27:42 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-03-30 18:46:07 +0200 |
commit | 1bcf528ce74bc9caf32d906f51622c3c0f0083a9 (patch) | |
tree | 04443ebee67381323eb792c3f68e5300ae19953d | |
parent | bc7e714ed6d8b42f0f95bad84b2d20259e12e4f7 (diff) |
add a smoketest for wpftdraw import library
Change-Id: I8433345edb51974856b30acbdb29da29a4ba01b8
21 files changed, 177 insertions, 0 deletions
diff --git a/writerperfect/CppunitTest_writerperfect_draw.mk b/writerperfect/CppunitTest_writerperfect_draw.mk new file mode 100644 index 000000000000..d724a5839577 --- /dev/null +++ b/writerperfect/CppunitTest_writerperfect_draw.mk @@ -0,0 +1,42 @@ +# -*- 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,writerperfect_draw)) + +$(eval $(call gb_CppunitTest_use_externals,writerperfect_draw,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_use_api,writerperfect_draw,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,writerperfect_draw,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + test \ + ucbhelper \ + unotest \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_ure,writerperfect_draw)) + +$(eval $(call gb_CppunitTest_use_rdb,writerperfect_draw,services)) + +$(eval $(call gb_CppunitTest_use_configuration,writerperfect_draw)) + +$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_draw,\ + writerperfect/qa/unit/wpftdraw \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk index a0c877e1e7e9..e020bdcd3426 100644 --- a/writerperfect/Module_writerperfect.mk +++ b/writerperfect/Module_writerperfect.mk @@ -27,6 +27,7 @@ $(eval $(call gb_Module_add_targets,writerperfect,\ )) $(eval $(call gb_Module_add_check_targets,writerperfect,\ + CppunitTest_writerperfect_draw \ CppunitTest_writerperfect_impress \ CppunitTest_writerperfect_stream \ CppunitTest_writerperfect_writer \ diff --git a/writerperfect/qa/unit/data/libcdr-cmx/fail/.gitignore b/writerperfect/qa/unit/data/libcdr-cmx/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr-cmx/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libcdr-cmx/indeterminate/.gitignore b/writerperfect/qa/unit/data/libcdr-cmx/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr-cmx/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libcdr-cmx/pass/.gitignore b/writerperfect/qa/unit/data/libcdr-cmx/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr-cmx/pass/.gitignore diff --git a/writerperfect/qa/unit/data/libcdr/fail/.gitignore b/writerperfect/qa/unit/data/libcdr/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libcdr/indeterminate/.gitignore b/writerperfect/qa/unit/data/libcdr/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libcdr/pass/.gitignore b/writerperfect/qa/unit/data/libcdr/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libcdr/pass/.gitignore diff --git a/writerperfect/qa/unit/data/libfreehand/fail/.gitignore b/writerperfect/qa/unit/data/libfreehand/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libfreehand/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libfreehand/indeterminate/.gitignore b/writerperfect/qa/unit/data/libfreehand/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libfreehand/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libfreehand/pass/.gitignore b/writerperfect/qa/unit/data/libfreehand/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libfreehand/pass/.gitignore diff --git a/writerperfect/qa/unit/data/libmspub/fail/.gitignore b/writerperfect/qa/unit/data/libmspub/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libmspub/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libmspub/indeterminate/.gitignore b/writerperfect/qa/unit/data/libmspub/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libmspub/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libmspub/pass/.gitignore b/writerperfect/qa/unit/data/libmspub/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libmspub/pass/.gitignore diff --git a/writerperfect/qa/unit/data/libvisio/fail/.gitignore b/writerperfect/qa/unit/data/libvisio/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libvisio/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libvisio/indeterminate/.gitignore b/writerperfect/qa/unit/data/libvisio/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libvisio/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libvisio/pass/.gitignore b/writerperfect/qa/unit/data/libvisio/pass/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libvisio/pass/.gitignore diff --git a/writerperfect/qa/unit/data/libwpg/fail/.gitignore b/writerperfect/qa/unit/data/libwpg/fail/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libwpg/fail/.gitignore diff --git a/writerperfect/qa/unit/data/libwpg/indeterminate/.gitignore b/writerperfect/qa/unit/data/libwpg/indeterminate/.gitignore new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/writerperfect/qa/unit/data/libwpg/indeterminate/.gitignore diff --git a/writerperfect/qa/unit/data/libwpg/pass/WPG1.wpg b/writerperfect/qa/unit/data/libwpg/pass/WPG1.wpg Binary files differnew file mode 100644 index 000000000000..273089649c5a --- /dev/null +++ b/writerperfect/qa/unit/data/libwpg/pass/WPG1.wpg diff --git a/writerperfect/qa/unit/wpftdraw.cxx b/writerperfect/qa/unit/wpftdraw.cxx new file mode 100644 index 000000000000..b1711b6bb071 --- /dev/null +++ b/writerperfect/qa/unit/wpftdraw.cxx @@ -0,0 +1,134 @@ +/* -*- 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 <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/frame/theDesktop.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/ucb/SimpleFileAccess.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <test/bootstrapfixture.hxx> + +#include <unotest/filters-test.hxx> + +namespace beans = com::sun::star::beans; +namespace document = com::sun::star::document; +namespace frame = com::sun::star::frame; +namespace io = com::sun::star::io; +namespace lang = com::sun::star::lang; +namespace ucb = com::sun::star::ucb; +namespace uno = com::sun::star::uno; + +namespace +{ + +class WpftDrawFilterTest + : public test::FiltersTest + , public test::BootstrapFixture +{ +public: + virtual void setUp(); + virtual void tearDown(); + + void test(); + + CPPUNIT_TEST_SUITE(WpftDrawFilterTest); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); + +private: + virtual bool load(const OUString &, const OUString &rURL, const OUString &, + unsigned int, unsigned int, unsigned int); + + void doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath); + +private: + uno::Reference<frame::XDesktop2> m_xDesktop; + uno::Reference<ucb::XSimpleFileAccess> m_xFileAccess; + uno::Reference<document::XFilter> m_xFilter; +}; + +void WpftDrawFilterTest::setUp() +{ + test::BootstrapFixture::setUp(); + + m_xDesktop = frame::theDesktop::get(m_xContext); + m_xFileAccess = ucb::SimpleFileAccess::create(m_xContext); +} + +void WpftDrawFilterTest::tearDown() +{ + test::BootstrapFixture::tearDown(); + + m_xDesktop->terminate(); +} + +void WpftDrawFilterTest::test() +{ + doTest("com.sun.star.comp.Draw.CDRImportFilter", "/writerperfect/qa/unit/data/libcdr/"); + doTest("com.sun.star.comp.Draw.CMXImportFilter", "/writerperfect/qa/unit/data/libcdr-cmx/"); + doTest("com.sun.star.comp.Draw.FreehandImportFilter", "/writerperfect/qa/unit/data/libfreehand/"); + doTest("com.sun.star.comp.Draw.MSPUBImportFilter", "/writerperfect/qa/unit/data/libmspub/"); + doTest("com.sun.star.comp.Draw.VisioImportFilter", "/writerperfect/qa/unit/data/libvisio/"); + doTest("com.sun.star.comp.Draw.WPGImportFilter", "/writerperfect/qa/unit/data/libwpg/"); +} + +bool WpftDrawFilterTest::load(const OUString &, const OUString &rURL, const OUString &, + unsigned int, unsigned int, unsigned int) +{ + const uno::Reference<lang::XComponent> xDoc( + m_xDesktop->loadComponentFromURL("private:factory/simpress", "_blank", 0, uno::Sequence<beans::PropertyValue>()), + uno::UNO_QUERY_THROW); + + bool result = false; + + try + { + const uno::Reference<document::XImporter> xImporter(m_xFilter, uno::UNO_QUERY_THROW); + + xImporter->setTargetDocument(xDoc); + + uno::Sequence<beans::PropertyValue> aDescriptor(2); + aDescriptor[0].Name = "URL"; + aDescriptor[0].Value <<= rURL; + + const uno::Reference<io::XInputStream> xInputStream(m_xFileAccess->openFileRead(rURL), uno::UNO_QUERY_THROW); + aDescriptor[1].Name = "InputStream"; + aDescriptor[1].Value <<= xInputStream; + + result = m_xFilter->filter(aDescriptor); + } + catch (const uno::Exception &) + { + xDoc->dispose(); + throw; + } + + xDoc->dispose(); + + return result; +} + +void WpftDrawFilterTest::doTest(const rtl::OUString &rFilter, const rtl::OUString &rPath) +{ + m_xFilter.set(m_xFactory->createInstanceWithContext(rFilter, m_xContext), uno::UNO_QUERY_THROW); + testDir(OUString(), getURLFromSrc(rPath), OUString()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(WpftDrawFilterTest); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |