[Libreoffice-commits] .: i18npool/qa

Caolán McNamara caolan at kemper.freedesktop.org
Tue Jan 25 06:45:43 PST 2011


 i18npool/qa/cppunit/makefile.mk            |  107 ++++++++++++++++++++++++++
 i18npool/qa/cppunit/test_breakiterator.cxx |  119 +++++++++++++++++++++++++++++
 i18npool/qa/cppunit/version.map            |   34 ++++++++
 3 files changed, 260 insertions(+)

New commits:
commit c77e30f4eff68922cbc1c70a6596b5a59a0bf4ec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jan 25 14:44:31 2011 +0000

    Related: fdo#31271 create a unit test for the line break iterator

diff --git a/i18npool/qa/cppunit/makefile.mk b/i18npool/qa/cppunit/makefile.mk
new file mode 100644
index 0000000..0f97621
--- /dev/null
+++ b/i18npool/qa/cppunit/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=../..
+PRJNAME=i18npool
+TARGET=qa_cppunit
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE :  settings.mk
+
+#building with stlport, but cppunit was not built with stlport
+.IF "$(USE_SYSTEM_STL)"!="YES"
+.IF "$(SYSTEM_CPPUNIT)"=="YES"
+CFLAGSCXX+=-DADAPT_EXT_STL
+.ENDIF
+.ENDIF
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+DLLPRE = # no leading "lib" on .so files
+
+# --- Libs ---------------------------------------------------------
+
+SHL1OBJS=  \
+    $(SLO)/test_breakiterator.obj
+
+SHL1STDLIBS= \
+     $(CPPUNITLIB) \
+     $(SALLIB) \
+     $(CPPULIB) \
+     $(CPPUHELPERLIB) \
+     $(COMPHELPERLIB)
+
+SHL1TARGET= test_breakiterator
+SHL1RPATH = NONE
+SHL1IMPLIB= i$(SHL1TARGET)
+DEF1NAME=$(SHL1TARGET)
+SHL1VERSIONMAP= version.map
+
+# --- All object files ---------------------------------------------
+
+SLOFILES= \
+    $(SHL1OBJS)
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE :  target.mk
+
+.IF "$(OS)" == "WNT"
+my_file = file:///
+.ELSE
+my_file = file://
+.END
+
+ALLTAR: test
+
+$(MISC)$/$(TARGET)$/types.rdb .ERRREMOVE : $(SOLARBINDIR)$/types.rdb
+    $(MKDIRHIER) $(@:d)
+    $(GNUCOPY) $? $@
+
+$(MISC)/$(TARGET)/udkapi.rdb .ERRREMOVE : $(SOLARBINDIR)$/udkapi.rdb
+    $(MKDIRHIER) $(@:d)
+    $(GNUCOPY) $? $@
+
+#Make a services.rdb with the services we know we need to get up and running
+$(MISC)/$(TARGET)/services.rdb .ERRREMOVE : $(MISC)/$(TARGET)/udkapi.rdb makefile.mk
+    $(MKDIRHIER) $(@:d)
+    $(REGCOMP) -register -br $(MISC)/$(TARGET)/udkapi.rdb -r $@ -wop \
+        -c $(DLLDEST)/i18npool.uno$(DLLPOST)
+
+test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb $(MISC)$/$(TARGET)$/types.rdb $(MISC)/$(TARGET)/udkapi.rdb
+    @echo ----------------------------------------------------------
+    @echo - start unit test \#2 on library $(SHL1TARGETN)
+    @echo ----------------------------------------------------------
+    $(CPPUNITTESTER) $(SHL1TARGETN) -headless -invisible \
+        -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
+        -env:UNO_TYPES="$(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/udkapi.rdb" \
+        -env:OOO_BASE_DIR="$(my_file)$(PWD)/$(MISC)/$(TARGET)" \
+        -env:BRAND_BASE_DIR="$(my_file)$(PWD)/$(MISC)/$(TARGET)" \
+        -env:UNO_USER_PACKAGES_CACHE="$(my_file)$(PWD)/$(MISC)/$(TARGET)"
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
new file mode 100644
index 0000000..d1a6130
--- /dev/null
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -0,0 +1,119 @@
+/* -*- 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. 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
+ *       Caolán McNamara <caolanm at redhat.com>
+ *
+ * Contributor(s):
+ *   Caolán McNamara <caolanm at redhat.com>
+ *
+ * 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 "precompiled_i18npool.hxx"
+
+#include "preextstl.h"
+#include <cppunit/TestSuite.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/TestCase.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include "postextstl.h"
+
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+
+#include <string.h>
+
+using namespace ::com::sun::star;
+
+class TestBreakIterator : public CppUnit::TestFixture
+{
+public:
+    TestBreakIterator();
+    ~TestBreakIterator();
+
+    virtual void setUp();
+    virtual void tearDown();
+
+    void testLineBreaking();
+
+    CPPUNIT_TEST_SUITE(TestBreakIterator);
+    CPPUNIT_TEST(testLineBreaking);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<uno::XComponentContext> m_xContext;
+    uno::Reference<lang::XMultiComponentFactory> m_xFactory;
+    uno::Reference<lang::XMultiServiceFactory> m_xMSF;
+};
+
+//See https://bugs.freedesktop.org/show_bug.cgi?id=31271 for motivation
+void TestBreakIterator::testLineBreaking()
+{
+    uno::Reference< i18n::XBreakIterator > xBreak(m_xMSF->createInstance(
+        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))),uno::UNO_QUERY);
+    CPPUNIT_ASSERT_MESSAGE("Expected Break Iterator", xBreak.is());
+
+    ::rtl::OUString aTest1(RTL_CONSTASCII_USTRINGPARAM("(some text here)"));
+
+    i18n::LineBreakHyphenationOptions aHyphOptions;
+    i18n::LineBreakUserOptions aUserOptions;
+    lang::Locale aLocale;
+
+    aLocale.Language = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
+    aLocale.Country = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("US"));
+
+    {
+        //Here we want the line break to leave text here) on the next line
+        i18n::LineBreakResults aResult = xBreak->getLineBreak(aTest1, strlen("(some tex"), aLocale, 0, aHyphOptions, aUserOptions);
+        CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 6);
+    }
+
+    {
+        //Here we want the line break to leave "here)" on the next line
+        i18n::LineBreakResults aResult = xBreak->getLineBreak(aTest1, strlen("(some text here"), aLocale, 0, aHyphOptions, aUserOptions);
+        CPPUNIT_ASSERT_MESSAGE("Expected a break at the the start of the word", aResult.breakIndex == 11);
+    }
+}
+
+TestBreakIterator::TestBreakIterator()
+{
+    m_xContext = cppu::defaultBootstrap_InitialComponentContext();
+    m_xFactory = m_xContext->getServiceManager();
+    m_xMSF = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
+}
+
+void TestBreakIterator::setUp()
+{
+}
+
+TestBreakIterator::~TestBreakIterator()
+{
+}
+
+void TestBreakIterator::tearDown()
+{
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestBreakIterator);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/i18npool/qa/cppunit/version.map b/i18npool/qa/cppunit/version.map
new file mode 100644
index 0000000..3308588
--- /dev/null
+++ b/i18npool/qa/cppunit/version.map
@@ -0,0 +1,34 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+UDK_3_0_0 {
+    global:
+        cppunitTestPlugIn;
+
+    local:
+        *;
+};


More information about the Libreoffice-commits mailing list