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 <cppuhelper/implbase.hxx>
11 #include <test/bootstrapfixture.hxx>
12 #include <unotest/macros_test.hxx>
14 #include <com/sun/star/awt/UnoControlDialog.hpp>
15 #include <com/sun/star/awt/XUnoControlDialog.hpp>
16 #include <com/sun/star/awt/XControlModel.hpp>
17 #include <com/sun/star/beans/XPropertySet.hpp>
18 #include <com/sun/star/frame/Desktop.hpp>
19 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
21 #include <comphelper/processfactory.hxx>
22 #include <toolkit/awt/vclxwindow.hxx>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <vcl/vclptr.hxx>
25 #include <vcl/window.hxx>
31 /// Test dialogs constructed via UNO
32 class DialogTest
: public test::BootstrapFixture
, public unotest::MacrosTest
35 uno::Reference
<uno::XComponentContext
> mxContext
;
38 virtual void setUp() override
;
41 void DialogTest::setUp()
43 test::BootstrapFixture::setUp();
45 mxContext
.set(comphelper::getComponentContext(getMultiServiceFactory()));
48 CPPUNIT_TEST_FIXTURE(DialogTest
, testDialogSizeable
)
50 uno::Reference
<awt::XDialog
> xDialog
;
51 uno::Reference
<lang::XMultiComponentFactory
> xFactory(mxContext
->getServiceManager(),
53 uno::Reference
<awt::XControlModel
> xControlModel(
54 xFactory
->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext
),
55 uno::UNO_QUERY_THROW
);
57 uno::Reference
<beans::XPropertySet
> xPropSet(xControlModel
, uno::UNO_QUERY_THROW
);
58 xPropSet
->setPropertyValue("Sizeable", uno::Any(true));
60 uno::Reference
<awt::XUnoControlDialog
> xControl
= awt::UnoControlDialog::create(mxContext
);
61 xControl
->setModel(xControlModel
);
62 uno::Reference
<awt::XWindow
> xWindow(xControl
, uno::UNO_QUERY
);
63 xWindow
->setVisible(true);
64 xDialog
.set(xControl
, uno::UNO_QUERY_THROW
);
67 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow(xControl
->getPeer());
68 CPPUNIT_ASSERT(pWindow
);
69 CPPUNIT_ASSERT(pWindow
->GetStyle() & WB_SIZEABLE
);
71 xDialog
->endExecute();
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */