LCOV - code coverage report
Current view: top level - test/source/util - xsearchable.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 29 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 7 85.7 %
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 <com/sun/star/util/XSearchable.hpp>
      11             : #include <com/sun/star/util/XSearchDescriptor.hpp>
      12             : #include <com/sun/star/container/XIndexAccess.hpp>
      13             : #include "cppunit/extensions/HelperMacros.h"
      14             : 
      15             : #include <test/util/xsearchable.hxx>
      16             : 
      17             : using namespace css;
      18             : using namespace css::uno;
      19             : 
      20             : namespace apitest {
      21             : 
      22           2 : void XSearchable::testFindAll()
      23             : {
      24           2 :     uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
      25           4 :     uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
      26           2 :     xSearchDescr->setSearchString(maSearchString);
      27             : 
      28           4 :     uno::Reference< container::XIndexAccess > xIndex = xSearchable->findAll(xSearchDescr);
      29           2 :     CPPUNIT_ASSERT(xIndex.is());
      30           4 :     CPPUNIT_ASSERT(xIndex->getCount() == mnCount);
      31           2 : }
      32             : 
      33           2 : void XSearchable::testFindFirst()
      34             : {
      35           2 :     uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
      36           4 :     uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
      37           2 :     xSearchDescr->setSearchString(maSearchString);
      38             : 
      39           4 :     uno::Reference< uno::XInterface > xElement = xSearchable->findFirst(xSearchDescr);
      40           4 :     CPPUNIT_ASSERT(xElement.is());
      41           2 : }
      42             : 
      43           1 : void XSearchable::testFindNext()
      44             : {
      45           1 :     uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
      46           2 :     uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
      47           1 :     xSearchDescr->setSearchString(maSearchString);
      48             : 
      49           2 :     uno::Reference< uno::XInterface > xElement = xSearchable->findFirst(xSearchDescr);
      50           1 :     CPPUNIT_ASSERT(xElement.is());
      51             : 
      52           1 :     if (mnCount > 1)
      53             :     {
      54           1 :         uno::Reference< uno::XInterface > xElement2 = xSearchable->findNext(xElement, xSearchDescr);
      55           1 :         CPPUNIT_ASSERT(xElement2.is());
      56           1 :     }
      57           1 : }
      58             : 
      59          21 : XSearchable::~XSearchable()
      60             : {
      61          21 : }
      62             : 
      63          90 : }
      64             : 
      65             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11