LibreOffice Module test (master) 1
xnameaccess.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
11
12#include <com/sun/star/container/NoSuchElementException.hpp>
13#include <com/sun/star/container/XNameAccess.hpp>
14
15#include <com/sun/star/uno/Reference.hxx>
16#include <com/sun/star/uno/Sequence.hxx>
17
18#include <cppunit/TestAssert.h>
19
20using namespace css;
21using namespace css::uno;
22
23namespace apitest
24{
26{
27 uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
28
29 // test with existing name
30 CPPUNIT_ASSERT_NO_THROW(xNA->getByName(m_aName));
31 // test with non-existing name
32 CPPUNIT_ASSERT_THROW(xNA->getByName(m_aName + "UnitTest"), container::NoSuchElementException);
33}
34
36{
37 uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
38 uno::Sequence<OUString> aNames = xNA->getElementNames();
39
40 CPPUNIT_ASSERT(aNames.hasElements());
41}
42
44{
45 uno::Reference<container::XNameAccess> xNA(init(), uno::UNO_QUERY_THROW);
46
47 // test with existing name
48 CPPUNIT_ASSERT(xNA->hasByName(m_aName));
49 // test with non-existing name
50 CPPUNIT_ASSERT(!xNA->hasByName(m_aName + "UnitTest"));
51}
52
53} // namespace apitest
54
55/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
OUString const m_aName
Definition: xnameaccess.hxx:40
virtual css::uno::Reference< css::uno::XInterface > init()=0