LCOV - code coverage report
Current view: top level - editeng/qa/unit - core-test.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 84 100.0 %
Date: 2012-08-25 Functions: 14 15 93.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 208 418 49.8 %

           Branch data     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         [ -  + ]:         12 : 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 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE(Test);
         [ +  - ][ +  - ]
                 [ #  # ]
      65 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testConstruction);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      66 [ +  - ][ +  - ]:          3 :     CPPUNIT_TEST(testUnoTextFields);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      67 [ +  - ][ +  - ]:          6 :     CPPUNIT_TEST_SUITE_END();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      68                 :            : 
      69                 :            : private:
      70                 :            :     EditEngineItemPool* mpItemPool;
      71                 :            : };
      72                 :            : 
      73                 :          6 : Test::Test() : mpItemPool(NULL) {}
      74                 :            : 
      75                 :          6 : void Test::setUp()
      76                 :            : {
      77                 :          6 :     test::BootstrapFixture::setUp();
      78                 :            : 
      79         [ +  - ]:          6 :     mpItemPool = new EditEngineItemPool(true);
      80                 :          6 : }
      81                 :            : 
      82                 :          6 : void Test::tearDown()
      83                 :            : {
      84                 :          6 :     SfxItemPool::Free(mpItemPool);
      85                 :          6 :     test::BootstrapFixture::tearDown();
      86                 :          6 : }
      87                 :            : 
      88                 :          3 : void Test::testConstruction()
      89                 :            : {
      90         [ +  - ]:          3 :     EditEngine aEngine(mpItemPool);
      91                 :            : 
      92                 :          3 :     rtl::OUString aParaText = "I am Edit Engine.";
      93 [ +  - ][ +  - ]:          3 :     aEngine.SetText(aParaText);
         [ +  - ][ +  - ]
      94                 :          3 : }
      95                 :            : 
      96                 :            : namespace {
      97                 :            : 
      98                 :         42 : bool includes(const uno::Sequence<rtl::OUString>& rSeq, const rtl::OUString& rVal)
      99                 :            : {
     100         [ +  - ]:        168 :     for (sal_Int32 i = 0, n = rSeq.getLength(); i < n; ++i)
     101         [ +  + ]:        168 :         if (rSeq[i] == rVal)
     102                 :         42 :             return true;
     103                 :            : 
     104                 :         42 :     return false;
     105                 :            : }
     106                 :            : 
     107                 :            : }
     108                 :            : 
     109                 :          3 : void Test::testUnoTextFields()
     110                 :            : {
     111                 :            :     {
     112                 :            :         // DATE
     113                 :          3 :         SvxUnoTextField aField(text::textfield::Type::DATE);
     114         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     115         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     116 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     117                 :            :     }
     118                 :            : 
     119                 :            :     {
     120                 :            :         // URL
     121                 :          3 :         SvxUnoTextField aField(text::textfield::Type::URL);
     122         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     123         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.URL");
     124 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     125                 :            :     }
     126                 :            : 
     127                 :            :     {
     128                 :            :         // PAGE
     129                 :          3 :         SvxUnoTextField aField(text::textfield::Type::PAGE);
     130         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     131         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageNumber");
     132 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     133                 :            :     }
     134                 :            : 
     135                 :            :     {
     136                 :            :         // PAGES
     137                 :          3 :         SvxUnoTextField aField(text::textfield::Type::PAGES);
     138         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     139         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.PageCount");
     140 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     141                 :            :     }
     142                 :            : 
     143                 :            :     {
     144                 :            :         // TIME
     145                 :          3 :         SvxUnoTextField aField(text::textfield::Type::TIME);
     146         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     147         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     148 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     149                 :            :     }
     150                 :            : 
     151                 :            :     {
     152                 :            :         // FILE
     153                 :          3 :         SvxUnoTextField aField(text::textfield::Type::DOCINFO_TITLE);
     154         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     155         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.docinfo.Title");
     156 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     157                 :            :     }
     158                 :            : 
     159                 :            :     {
     160                 :            :         // TABLE
     161                 :          3 :         SvxUnoTextField aField(text::textfield::Type::TABLE);
     162         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     163         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.SheetName");
     164 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     165                 :            :     }
     166                 :            : 
     167                 :            :     {
     168                 :            :         // EXTENDED TIME
     169                 :          3 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_TIME);
     170         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     171         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.DateTime");
     172 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     173                 :            :     }
     174                 :            : 
     175                 :            :     {
     176                 :            :         // EXTENDED FILE
     177                 :          3 :         SvxUnoTextField aField(text::textfield::Type::EXTENDED_FILE);
     178         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     179         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.FileName");
     180 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     181                 :            :     }
     182                 :            : 
     183                 :            :     {
     184                 :            :         // AUTHOR
     185                 :          3 :         SvxUnoTextField aField(text::textfield::Type::AUTHOR);
     186         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     187         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Author");
     188 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     189                 :            :     }
     190                 :            : 
     191                 :            :     {
     192                 :            :         // MEASURE
     193                 :          3 :         SvxUnoTextField aField(text::textfield::Type::MEASURE);
     194         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     195         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.text.textfield.Measure");
     196 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     197                 :            :     }
     198                 :            : 
     199                 :            :     {
     200                 :            :         // PRESENTATION HEADER
     201                 :          3 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_HEADER);
     202         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     203         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Header");
     204 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     205                 :            :     }
     206                 :            : 
     207                 :            :     {
     208                 :            :         // PRESENTATION FOOTER
     209                 :          3 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_FOOTER);
     210         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     211         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.Footer");
     212 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     213                 :            :     }
     214                 :            : 
     215                 :            :     {
     216                 :            :         // PRESENTATION DATE TIME
     217                 :          3 :         SvxUnoTextField aField(text::textfield::Type::PRESENTATION_DATE_TIME);
     218         [ +  - ]:          3 :         uno::Sequence<rtl::OUString> aSvcs = aField.getSupportedServiceNames();
     219         [ +  - ]:          3 :         bool bGood = includes(aSvcs, "com.sun.star.presentation.textfield.DateTime");
     220 [ +  - ][ +  - ]:          3 :         CPPUNIT_ASSERT_MESSAGE("expected service is not present.", bGood);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     221                 :            :     }
     222                 :          3 : }
     223                 :            : 
     224                 :          3 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
     225                 :            : 
     226                 :            : }
     227                 :            : 
     228 [ +  - ][ +  - ]:         12 : CPPUNIT_PLUGIN_IMPLEMENT();
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
     229                 :            : 
     230                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10