1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <test/container/xnamed.hxx>
11 #include <rtl/ustring.hxx>
13 #include <com/sun/star/container/XNamed.hpp>
14 #include <com/sun/star/uno/RuntimeException.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
18 #include <cppunit/TestAssert.h>
21 using namespace css::uno
;
25 void XNamed::testGetName()
27 uno::Reference
<container::XNamed
> xNamed(init(), UNO_QUERY_THROW
);
28 CPPUNIT_ASSERT_EQUAL(m_aTestName
, xNamed
->getName());
31 void XNamed::testSetName()
33 uno::Reference
<container::XNamed
> xNamed(init(), UNO_QUERY_THROW
);
34 OUString
aTestName(u
"NewName"_ustr
);
36 xNamed
->setName(aTestName
);
37 CPPUNIT_ASSERT_EQUAL(aTestName
, xNamed
->getName());
40 xNamed
->setName(m_aTestName
);
41 CPPUNIT_ASSERT_EQUAL(m_aTestName
, xNamed
->getName());
44 void XNamed::testSetNameByScSheetLinkObj()
46 uno::Reference
<container::XNamed
> xNamed(init(), uno::UNO_QUERY_THROW
);
47 OUString
aTestName(m_aTestName
.replaceAll("ScSheetLinkObj", "NewScSheetLinkObj"));
49 xNamed
->setName(aTestName
);
50 CPPUNIT_ASSERT_EQUAL(aTestName
, xNamed
->getName());
53 xNamed
->setName(m_aTestName
);
54 CPPUNIT_ASSERT_EQUAL(m_aTestName
, xNamed
->getName());
57 void XNamed::testSetNameThrowsException()
59 uno::Reference
<container::XNamed
> xNamed(init(), uno::UNO_QUERY_THROW
);
61 CPPUNIT_ASSERT_THROW(xNamed
->setName(u
"NewName"_ustr
), uno::RuntimeException
);
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */