tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / toolkit / qa / cppunit / EventContainer.cxx
blob8bd4e57c631c18be0c41ccbe79d09328b132cf76
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 <test/bootstrapfixture.hxx>
12 #include <com/sun/star/awt/XControlModel.hpp>
13 #include <com/sun/star/beans/XPropertySet.hpp>
14 #include <com/sun/star/container/XNameContainer.hpp>
15 #include <com/sun/star/lang/XComponent.hpp>
16 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
17 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
18 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
19 #include <com/sun/star/uno/Reference.hxx>
21 #include <comphelper/processfactory.hxx>
23 using namespace css;
24 using namespace css::awt;
25 using namespace css::container;
26 using namespace css::lang;
27 using namespace css::script;
28 using namespace css::uno;
30 namespace
32 /// Test EventContainer class
33 class EventContainerTest : public test::BootstrapFixture
37 // Make sure that EventContainer keeps insertion order, and does not reorder its elements.
38 // Otherwise this would break macro signatures.
39 CPPUNIT_TEST_FIXTURE(EventContainerTest, testInsertOrder)
41 Reference<XMultiComponentFactory> xFactory(m_xContext->getServiceManager(), UNO_SET_THROW);
42 Reference<XControlModel> xControlModel(
43 xFactory->createInstanceWithContext(u"com.sun.star.awt.UnoControlDialogModel"_ustr,
44 m_xContext),
45 UNO_QUERY_THROW);
47 Reference<beans::XPropertySet> xPropSet(xControlModel, UNO_QUERY_THROW);
49 Reference<XScriptEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY_THROW);
50 Reference<XNameContainer> xEvents(xEventsSupplier->getEvents(), UNO_SET_THROW);
51 script::ScriptEventDescriptor descr1;
52 script::ScriptEventDescriptor descr2;
53 script::ScriptEventDescriptor descr3;
54 script::ScriptEventDescriptor descr4;
55 xEvents->insertByName(u"b"_ustr, Any(descr1));
56 xEvents->insertByName(u"a"_ustr, Any(descr2));
57 xEvents->insertByName(u"1"_ustr, Any(descr3));
58 xEvents->insertByName(u"A"_ustr, Any(descr4));
60 Sequence<OUString> aEventNames(xEvents->getElementNames());
61 sal_Int32 nEventCount = aEventNames.getLength();
62 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), nEventCount);
64 CPPUNIT_ASSERT_EQUAL(u"b"_ustr, aEventNames[0]);
65 CPPUNIT_ASSERT_EQUAL(u"a"_ustr, aEventNames[1]);
66 CPPUNIT_ASSERT_EQUAL(u"1"_ustr, aEventNames[2]);
67 CPPUNIT_ASSERT_EQUAL(u"A"_ustr, aEventNames[3]);
69 css::uno::Reference<css::lang::XComponent>(xControlModel, css::uno::UNO_QUERY_THROW)->dispose();
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */