[Libreoffice-commits] .: sw/CppunitTest_sw_subsequent_rtftok.mk sw/Module_sw.mk sw/qa
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon Feb 13 05:22:41 PST 2012
sw/CppunitTest_sw_subsequent_rtftok.mk | 83 +++++++++++++++++++
sw/Module_sw.mk | 4
sw/qa/extras/rtftok/data/fdo45553.rtf | 2
sw/qa/extras/rtftok/data/n192129.rtf | 3
sw/qa/extras/rtftok/rtftok.cxx | 143 +++++++++++++++++++++++++++++++++
5 files changed, 235 insertions(+)
New commits:
commit 3cd8d8c27d7c4a13f58c4930ee14b1d862e73ea1
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sat Feb 11 17:06:42 2012 +0100
sw: add rtf slowcheck test that checks the resulting document model
Having it as a subsequent test in wrifterfilter would be less useful;
having it as a unit test in writerfilter is not possible, since
writerfilter does not depend on sw.
diff --git a/sw/CppunitTest_sw_subsequent_rtftok.mk b/sw/CppunitTest_sw_subsequent_rtftok.mk
new file mode 100644
index 0000000..1de0d64
--- /dev/null
+++ b/sw/CppunitTest_sw_subsequent_rtftok.mk
@@ -0,0 +1,83 @@
+# -*- 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
+# Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+# Portions created by the Initial Developer are Copyright (C) 2012 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,sw_subsequent_rtftok))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_subsequent_rtftok, \
+ sw/qa/extras/rtftok/rtftok \
+))
+
+$(eval $(call gb_CppunitTest_add_linked_libs,sw_subsequent_rtftok, \
+ cppu \
+ sal \
+ test \
+ unotest \
+ vcl \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_CppunitTest_add_api,sw_subsequent_rtftok,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_uses_ure,sw_subsequent_rtftok))
+
+$(eval $(call gb_CppunitTest_add_type_rdbs,sw_subsequent_rtftok,\
+ types \
+))
+
+$(eval $(call gb_CppunitTest_add_components,sw_subsequent_rtftok,\
+ configmgr/source/configmgr \
+ fileaccess/source/fileacc \
+ filter/source/config/cache/filterconfig1 \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ package/util/package2 \
+ sw/util/sw \
+ sw/util/swd \
+ sfx2/util/sfx \
+ svl/source/fsstor/fsstorage \
+ svtools/util/svt \
+ toolkit/util/tk \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ unotools/util/utl \
+ unoxml/source/service/unoxml \
+ writerfilter/util/writerfilter \
+))
+
+$(eval $(call gb_CppunitTest_set_args,sw_subsequent_rtftok,\
+ --headless \
+ --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
+ "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 7f48bc3..d9477e9 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -53,6 +53,10 @@ $(eval $(call gb_Module_add_check_targets,sw,\
CppunitTest_sw_swdoc_test \
))
+$(eval $(call gb_Module_add_slowcheck_targets,sw,\
+ CppunitTest_sw_subsequent_rtftok \
+))
+
$(eval $(call gb_Module_add_subsequentcheck_targets,sw,\
JunitTest_sw_complex \
JunitTest_sw_unoapi \
diff --git a/sw/qa/extras/rtftok/data/fdo45553.rtf b/sw/qa/extras/rtftok/data/fdo45553.rtf
new file mode 100644
index 0000000..38b9d36
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo45553.rtf
@@ -0,0 +1,2 @@
+{\rtf1 \sa240 space-after\par\pard
+\sb120 space-before\par}
diff --git a/sw/qa/extras/rtftok/data/n192129.rtf b/sw/qa/extras/rtftok/data/n192129.rtf
new file mode 100644
index 0000000..1451b36
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/n192129.rtf
@@ -0,0 +1,3 @@
+{\rtf1
+{\pict \pngblip \picw-64 \pich-1061137057 \picwgoal0 \pichgoal0 47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b}
+\par }
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
new file mode 100644
index 0000000..2c2252e
--- /dev/null
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -0,0 +1,143 @@
+/*
+ * 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. 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
+ * Miklos Vajna <vmiklos at suse.cz> (SUSE, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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 <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/svapp.hxx>
+
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+
+using rtl::OString;
+using rtl::OUString;
+using rtl::OUStringBuffer;
+using namespace com::sun::star;
+
+class RtfModelTest : public test::BootstrapFixture, public unotest::MacrosTest
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+ void testFdo45553();
+ void testN192129();
+
+ CPPUNIT_TEST_SUITE(RtfModelTest);
+#if !defined(MACOSX) && !defined(WNT)
+ CPPUNIT_TEST(testFdo45553);
+ CPPUNIT_TEST(testN192129);
+#endif
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ void load(const OUString& rURL);
+ uno::Reference<lang::XComponent> mxComponent;
+};
+
+void RtfModelTest::load(const OUString& rFilename)
+{
+ mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/rtftok/data/") + rFilename);
+}
+
+void RtfModelTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(getMultiServiceFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(mxDesktop.is());
+}
+
+void RtfModelTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void RtfModelTest::testFdo45553()
+{
+ load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo45553.rtf")));
+
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ while (xParaEnum->hasMoreElements())
+ {
+ uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration();
+ while (xRangeEnum->hasMoreElements())
+ {
+ uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY);
+ OUString aStr = xRange->getString();
+ if (aStr.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("space-before")))
+ {
+ sal_Int32 nMargin = 0;
+ uno::Reference<beans::XPropertySet> xPropertySet(xRange, uno::UNO_QUERY);
+ uno::Any aValue = xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaTopMargin")));
+ aValue >>= nMargin;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(120)), nMargin);
+ }
+ else if (aStr.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("space-after")))
+ {
+ sal_Int32 nMargin = 0;
+ uno::Reference<beans::XPropertySet> xPropertySet(xRange, uno::UNO_QUERY);
+ uno::Any aValue = xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBottomMargin")));
+ aValue >>= nMargin;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(240)), nMargin);
+ }
+ }
+ }
+}
+
+void RtfModelTest::testN192129()
+{
+ load(OUString(RTL_CONSTASCII_USTRINGPARAM("n192129.rtf")));
+
+ // We expect that the result will be 16x16px.
+ Size aExpectedSize(16, 16);
+ MapMode aMap(MAP_100TH_MM);
+ aExpectedSize = Application::GetDefaultDevice()->PixelToLogic( aExpectedSize, aMap );
+
+ uno::Reference<text::XTextGraphicObjectsSupplier> xTextGraphicObjectsSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextGraphicObjectsSupplier->getGraphicObjects(), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ awt::Size aActualSize(xShape->getSize());
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Width()), aActualSize.Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(aExpectedSize.Height()), aActualSize.Height);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list