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/bootstrapfixture.hxx>
11 #include <unotest/macros_test.hxx>
13 #include <com/sun/star/awt/UnoControlDialog.hpp>
14 #include <com/sun/star/awt/XUnoControlDialog.hpp>
15 #include <com/sun/star/awt/XControlModel.hpp>
16 #include <com/sun/star/beans/XPropertySet.hpp>
17 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
19 #include <comphelper/processfactory.hxx>
20 #include <toolkit/helper/vclunohelper.hxx>
21 #include <vcl/vclptr.hxx>
22 #include <vcl/window.hxx>
28 /// Test dialogs constructed via UNO
29 class DialogTest
: public test::BootstrapFixture
, public unotest::MacrosTest
32 uno::Reference
<uno::XComponentContext
> mxContext
;
35 virtual void setUp() override
;
38 void DialogTest::setUp()
40 test::BootstrapFixture::setUp();
42 mxContext
.set(comphelper::getComponentContext(getMultiServiceFactory()));
45 CPPUNIT_TEST_FIXTURE(DialogTest
, testDialogSizeable
)
47 uno::Reference
<awt::XDialog
> xDialog
;
48 uno::Reference
<lang::XMultiComponentFactory
> xFactory(mxContext
->getServiceManager(),
50 uno::Reference
<awt::XControlModel
> xControlModel(
51 xFactory
->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext
),
52 uno::UNO_QUERY_THROW
);
54 uno::Reference
<beans::XPropertySet
> xPropSet(xControlModel
, uno::UNO_QUERY_THROW
);
55 xPropSet
->setPropertyValue("Sizeable", uno::Any(true));
57 uno::Reference
<awt::XUnoControlDialog
> xControl
= awt::UnoControlDialog::create(mxContext
);
58 xControl
->setModel(xControlModel
);
59 xControl
->setVisible(true);
60 xDialog
.set(xControl
, uno::UNO_QUERY_THROW
);
63 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow(xControl
->getPeer());
64 CPPUNIT_ASSERT(pWindow
);
65 CPPUNIT_ASSERT(pWindow
->GetStyle() & WB_SIZEABLE
);
67 xDialog
->endExecute();
68 css::uno::Reference
<css::lang::XComponent
>(xDialog
, css::uno::UNO_QUERY_THROW
)->dispose();
69 css::uno::Reference
<css::lang::XComponent
>(xControlModel
, css::uno::UNO_QUERY_THROW
)->dispose();
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */