LibreOffice Module vcl (master)  1
uitest.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 
10 #include <memory>
11 #include <vcl/uitest/uitest.hxx>
12 #include <vcl/uitest/uiobject.hxx>
13 
14 #include <vcl/dialog.hxx>
15 
16 #include <svdata.hxx>
17 
19 #include <com/sun/star/beans/PropertyValue.hpp>
20 
21 bool UITest::executeCommand(const OUString& rCommand)
22 {
24  rCommand,
25  {{"SynchronMode", -1, css::uno::Any(true),
26  css::beans::PropertyState_DIRECT_VALUE}});
27 }
28 
29 bool UITest::executeCommandWithParameters(const OUString& rCommand,
30  const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
31 {
32  css::uno::Sequence< css::beans::PropertyValue > lNewArgs =
33  {{"SynchronMode", -1, css::uno::Any(true),
34  css::beans::PropertyState_DIRECT_VALUE}};
35 
36  if ( rArgs.hasElements() )
37  {
38  sal_uInt32 nIndex( lNewArgs.getLength() );
39  lNewArgs.realloc( lNewArgs.getLength()+rArgs.getLength() );
40 
41  std::copy(rArgs.begin(), rArgs.end(), std::next(lNewArgs.begin(), nIndex));
42  }
43  return comphelper::dispatchCommand(rCommand,lNewArgs);
44 }
45 
46 bool UITest::executeDialog(const OUString& rCommand)
47 {
49  rCommand,
50  {{"SynchronMode", -1, css::uno::Any(false),
51  css::beans::PropertyState_DIRECT_VALUE}});
52 }
53 
54 std::unique_ptr<UIObject> UITest::getFocusTopWindow()
55 {
56  ImplSVData* pSVData = ImplGetSVData();
57  ImplSVWinData& rWinData = pSVData->maWinData;
58 
59  if (!rWinData.mpExecuteDialogs.empty())
60  {
61  return rWinData.mpExecuteDialogs.back()->GetUITestFactory()(rWinData.mpExecuteDialogs.back());
62  }
63 
64  return rWinData.mpFirstFrame->GetUITestFactory()(rWinData.mpFirstFrame);
65 }
66 
67 std::unique_ptr<UIObject> UITest::getFloatWindow()
68 {
69  ImplSVData* pSVData = ImplGetSVData();
70  ImplSVWinData& rWinData = pSVData->maWinData;
71 
72  VclPtr<vcl::Window> pFloatWin = rWinData.mpFirstFloat;
73  if (pFloatWin)
74  return pFloatWin->GetUITestFactory()(pFloatWin);
75 
76  return nullptr;
77 }
78 
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3889
static std::unique_ptr< UIObject > getFloatWindow()
Definition: uitest.cxx:67
static bool executeCommand(const OUString &rCommand)
Definition: uitest.cxx:21
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:67
std::vector< VclPtr< Dialog > > mpExecuteDialogs
Stack of dialogs that are Execute()'d - the last one is the top most one.
Definition: svdata.hxx:205
static std::unique_ptr< UIObject > getFocusTopWindow()
Definition: uitest.cxx:54
ImplSVWinData maWinData
Definition: svdata.hxx:349
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:204
VclPtr< vcl::Window > mpFirstFrame
Definition: svdata.hxx:198
static bool executeCommandWithParameters(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: uitest.cxx:29
static bool executeDialog(const OUString &rCommand)
Definition: uitest.cxx:46