Branch libreoffice-5-0-4
[LibreOffice.git] / test / source / util / xsearchable.cxx
blob91006e18118a1d4c556863dd6ca51529f2bbdc98
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
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"
15 #include <test/util/xsearchable.hxx>
17 using namespace css;
18 using namespace css::uno;
20 namespace apitest {
22 void XSearchable::testFindAll()
24 uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
25 uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
26 xSearchDescr->setSearchString(maSearchString);
28 uno::Reference< container::XIndexAccess > xIndex = xSearchable->findAll(xSearchDescr);
29 CPPUNIT_ASSERT(xIndex.is());
30 CPPUNIT_ASSERT(xIndex->getCount() == mnCount);
33 void XSearchable::testFindFirst()
35 uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
36 uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
37 xSearchDescr->setSearchString(maSearchString);
39 uno::Reference< uno::XInterface > xElement = xSearchable->findFirst(xSearchDescr);
40 CPPUNIT_ASSERT(xElement.is());
43 void XSearchable::testFindNext()
45 uno::Reference< util::XSearchable > xSearchable(init(), UNO_QUERY_THROW);
46 uno::Reference< util::XSearchDescriptor> xSearchDescr = xSearchable->createSearchDescriptor();
47 xSearchDescr->setSearchString(maSearchString);
49 uno::Reference< uno::XInterface > xElement = xSearchable->findFirst(xSearchDescr);
50 CPPUNIT_ASSERT(xElement.is());
52 if (mnCount > 1)
54 uno::Reference< uno::XInterface > xElement2 = xSearchable->findNext(xElement, xSearchDescr);
55 CPPUNIT_ASSERT(xElement2.is());
59 XSearchable::~XSearchable()
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */