LCOV - code coverage report
Current view: top level - libreoffice/editeng/qa/unit - core-test.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 83 84 98.8 %
Date: 2012-12-27 Functions: 14 15 93.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  *   Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
      17             :  *
      18             :  * All Rights Reserved.
      19             :  *
      20             :  * For minor contributions see the git repository.
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #include "test/bootstrapfixture.hxx"
      30             : 
      31             : #include <cppunit/TestFixture.h>
      32             : #include <cppunit/extensions/HelperMacros.h>
      33             : 
      34             : #include "svl/itempool.hxx"
      35             : #include "editeng/eerdll.hxx"
      36             : #include "editeng/eerdll2.hxx"
      37             : #include "editeng/editeng.hxx"
      38             : #include "editeng/eeitem.hxx"
      39             : #include "editeng/editids.hrc"
      40             : #include "editeng/editdoc.hxx"
      41             : #include "editeng/unofield.hxx"
      42             : 
      43             : #include <com/sun/star/text/textfield/Type.hpp>
      44             : 
      45             : using namespace com::sun::star;
      46             : 
      47             : namespace {
      48             : 
      49           4 : class Test : public test::BootstrapFixture
      50             : {
      51             : public:
      52             :     Test();
      53             : 
      54             :     virtual void setUp();
      55             :     virtual void tearDown();
      56             : 
      57             :     void testConstruction();
      58             : 
      59             :     /**
      60             :      * Test UNO service class that implements text field items.
      61             :      */
      62             :     void testUnoTextFields();
      63             : 
      64           2 :     CPPUNIT_TEST_SUITE(Test);
      65           1 :     CPPUNIT_TEST(testConstruction);
      66           1 :     CPPUNIT_TEST(testUnoTextFields);
      67           2 :     CPPUNIT_TEST_SUITE_END();
      68             : 
      69             : private:
      70             :     EditEngineItemPool* mpItemPool;
      71             : };
      72             : 
      73           2 : Test::Test() : mpItemPool(NULL) {}
      74             : 
      75           2 : void Test::setUp()
      76             : {
      77           2 :     test::BootstrapFixture::setUp();
      78             : 
      79           2 :     mpItemPool = new EditEngineItemPool(true);
      80           2 : }
      81             : 
      82           2 : void Test::tearDown()
      83             : {
      84           2 :     SfxItemPool::Free(mpItemPool);
      85           2 :     test::BootstrapFixture::tearDown();
      86           2 : }
      87             : 
      88           1 : void Test::testConstruction()
      89             : {
      90           1 :     EditEngine aEngine(mpItemPool);
      91             : 
      92           1 :     rtl::OUString aParaText = "I am Edit Engine.";
      93           1 :     aEngine.SetText(aParaText);
      94           1 : }
      95             : 
      96             : namespace {
      97             : 
      98          14 : bool includes(const uno::Sequence<rtl::OUString>& rSeq, const rtl::OUString& rVal)
      99             : {
     100          56 :     for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i)
     101          56 :         if (rSeq[i] == rVal)
     102          14 :             return true;
     103             : 
     104           0 :     return false;
     105             : }
     106             : 
     107             : }
     108             : 
     109           1 : void Test::testUnoTextFields()
     110             : {
     111             :     {
     112             :         // DATE
     113           1 :         SvxUnoTextField aField(text::textfield::Type::DATE);
     114           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     115           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     116           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     117             :     }
     118             : 
     119             :     {
     120             :         // URL
     121           1 :         SvxUnoTextField aField(text::textfield::Type::URL);
     122           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     123           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
     124           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     125             :     }
     126             : 
     127             :     {
     128             :         // PAGE
     129           1 :         SvxUnoTextField aField(text::textfield::Type::PAGE);
     130           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     131           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
     132           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     133             :     }
     134             : 
     135             :     {
     136             :         // PAGES
     137           1 :         SvxUnoTextField aField(text::textfield::Type::PAGES);
     138           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     139           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
     140           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     141             :     }
     142             : 
     143             :     {
     144             :         // TIME
     145           1 :         SvxUnoTextField aField(text::textfield::Type::TIME);
     146           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     147           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     148           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     149             :     }
     150             : 
     151             :     {
     152             :         // FILE
     153           1 :         SvxUnoTextField aField(text::textfield::Type::DOCINFO_TITLE);
     154           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     155           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
     156           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     157             :     }
     158             : 
     159             :     {
     160             :         // TABLE
     161           1 :         SvxUnoTextField aField(text::textfield::Type::TABLE);
     162           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     163           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
     164           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     165             :     }
     166             : 
     167             :     {
     168             :         // EXTENDED TIME
     169           1 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
     170           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     171           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     172           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     173             :     }
     174             : 
     175             :     {
     176             :         // EXTENDED FILE
     177           1 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
     178           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     179           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
     180           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     181             :     }
     182             : 
     183             :     {
     184             :         // AUTHOR
     185           1 :         SvxUnoTextField aField(text::textfield::Type::AUTHOR);
     186           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     187           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
     188           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     189             :     }
     190             : 
     191             :     {
     192             :         // MEASURE
     193           1 :         SvxUnoTextField aField(text::textfield::Type::MEASURE);
     194           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     195           1 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
     196           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     197             :     }
     198             : 
     199             :     {
     200             :         // PRESENTATION HEADER
     201           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
     202           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     203           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
     204           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     205             :     }
     206             : 
     207             :     {
     208             :         // PRESENTATION FOOTER
     209           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
     210           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     211           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
     212           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     213             :     }
     214             : 
     215             :     {
     216             :         // PRESENTATION DATE TIME
     217           1 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
     218           1 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     219           1 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
     220           1 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
     221             :     }
     222           1 : }
     223             : 
     224           1 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     225             : 
     226             : }
     227             : 
     228           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     229             : 
     230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10