LCOV - code coverage report
Current view: top level - test/source/util - xreplaceable.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 35 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <test/util/xreplaceable.hxx>
      11             : 
      12             : #include <com/sun/star/util/XReplaceable.hpp>
      13             : #include <com/sun/star/util/XReplaceDescriptor.hpp>
      14             : #include <com/sun/star/util/XSearchDescriptor.hpp>
      15             : #include "cppunit/extensions/HelperMacros.h"
      16             : 
      17             : #include <iostream>
      18             : 
      19             : using namespace css;
      20             : using namespace css::uno;
      21             : 
      22             : namespace apitest {
      23             : 
      24           0 : void XReplaceable::testCreateReplaceDescriptor()
      25             : {
      26           0 :     uno::Reference< util::XReplaceable > xReplaceable(init(), UNO_QUERY_THROW);
      27           0 :     uno::Reference< util::XReplaceDescriptor> xReplaceDescr = xReplaceable->createReplaceDescriptor();
      28           0 :     CPPUNIT_ASSERT(xReplaceDescr.is());
      29           0 : }
      30             : 
      31           0 : void XReplaceable::testReplaceAll()
      32             : {
      33           0 :     std::cout << "testReplaceAll" << std::endl;
      34           0 :     uno::Reference< util::XReplaceable > xReplaceable(init(), UNO_QUERY_THROW);
      35           0 :     uno::Reference< util::XReplaceDescriptor> xReplaceDescr = xReplaceable->createReplaceDescriptor();
      36           0 :     CPPUNIT_ASSERT(xReplaceDescr.is());
      37             : 
      38           0 :     uno::Reference< util::XSearchDescriptor > xSearchDescr = xReplaceable->createSearchDescriptor();
      39           0 :     xSearchDescr->setSearchString(maSearchString);
      40             : 
      41             :     //check that at least one object is there that will be replaced
      42           0 :     uno::Reference< uno::XInterface > xElement = xReplaceable->findFirst(xSearchDescr);
      43           0 :     CPPUNIT_ASSERT(xElement.is());
      44             : 
      45             :     //check that there is none object with the replace string
      46           0 :     xSearchDescr->setSearchString(maReplaceString);
      47           0 :     xElement = xReplaceable->findFirst(xSearchDescr);
      48           0 :     CPPUNIT_ASSERT(!xElement.is());
      49             : 
      50           0 :     xReplaceDescr->setSearchString(maSearchString);
      51           0 :     xReplaceDescr->setReplaceString(maReplaceString);
      52             : 
      53           0 :     xReplaceable->replaceAll(uno::Reference< util::XSearchDescriptor >(xReplaceDescr, UNO_QUERY_THROW));
      54             : 
      55             :     //check that now at least one element is found
      56           0 :     xElement = xReplaceable->findFirst(xSearchDescr);
      57           0 :     CPPUNIT_ASSERT(xElement.is());
      58             : 
      59           0 :     xSearchDescr->setSearchString(maSearchString);
      60           0 :     xElement = xReplaceable->findFirst(xSearchDescr);
      61           0 :     CPPUNIT_ASSERT(!xElement.is());
      62             : 
      63             :     //redo the whole thing
      64           0 :     xReplaceDescr->setSearchString(maReplaceString);
      65           0 :     xReplaceDescr->setReplaceString(maSearchString);
      66             : 
      67           0 :     xReplaceable->replaceAll(uno::Reference< util::XSearchDescriptor >(xReplaceDescr, UNO_QUERY_THROW));
      68             : 
      69             :     //check that it works
      70           0 :     xElement = xReplaceable->findFirst(xSearchDescr);
      71           0 :     CPPUNIT_ASSERT(xElement.is());
      72             : 
      73             :     //check that there is none object with the replace string
      74           0 :     xSearchDescr->setSearchString(maReplaceString);
      75           0 :     xElement = xReplaceable->findFirst(xSearchDescr);
      76           0 :     CPPUNIT_ASSERT(!xElement.is());
      77           0 : }
      78             : 
      79           0 : }
      80             : 
      81             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10