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 #ifndef INCLUDED_VCL_UITEST_UIOBJECT_HXX
11 #define INCLUDED_VCL_UITEST_UIOBJECT_HXX
13 #include <rtl/ustring.hxx>
17 #include <vcl/window.hxx>
18 #include <vcl/spin.hxx>
19 #include <vcl/button.hxx>
20 #include <vcl/edit.hxx>
21 #include <vcl/tabpage.hxx>
22 #include <vcl/lstbox.hxx>
23 #include <vcl/combobox.hxx>
24 #include <vcl/spinfld.hxx>
25 #include <vcl/tabctrl.hxx>
27 #include <vcl/dllapi.h>
31 typedef std::map
<const OUString
, OUString
> StringMap
;
34 * This class wraps a UI object like vcl::Window and provides
35 * an interface for the UI testing.
37 * This class should only have virtual methods.
39 class UITEST_DLLPUBLIC UIObject
41 UIObject(UIObject
&) = delete;
42 void operator =(UIObject
) = delete;
50 * Returns the state of the wrapped UI object as a
51 * string key value map.
53 virtual StringMap
get_state();
56 * Executes an action on the wrapped UI object,
57 * possibly with some additional parameters
59 virtual void execute(const OUString
& rAction
,
60 const StringMap
& rParameters
);
63 * Returns the type of the UIObject. Additional information might
64 * be available through UIObject::get_state().
66 virtual OUString
get_type() const;
69 * Returns the child of the current UIObject with the corresponding id.
70 * If no object with that id is being found returns a nullptr.
73 virtual std::unique_ptr
<UIObject
> get_child(const OUString
& rID
);
76 * Returns a set containing all descendants of the object.
78 virtual std::set
<OUString
> get_children() const;
81 * Currently an internal method to dump the state of the current UIObject as represented by get_state().
83 * This method should not be exposed to the outside world.
86 virtual OUString
dumpState() const;
89 * Currently an internal method to dump the parent-child relationship starting from the current top focus window.
91 * This method should not be exposed to the outside world.
94 virtual OUString
dumpHierarchy() const;
97 * Gets the corresponding Action string for the event.
99 virtual OUString
get_action(VclEventId nEvent
) const;
102 class UITEST_DLLPUBLIC WindowUIObject
: public UIObject
104 VclPtr
<vcl::Window
> mxWindow
;
108 WindowUIObject(VclPtr
<vcl::Window
> xWindow
);
110 virtual StringMap
get_state() override
;
112 virtual void execute(const OUString
& rAction
,
113 const StringMap
& rParameters
) override
;
115 virtual OUString
get_type() const override
;
117 virtual std::unique_ptr
<UIObject
> get_child(const OUString
& rID
) override
;
119 virtual std::set
<OUString
> get_children() const override
;
121 virtual OUString
dumpState() const override
;
123 virtual OUString
dumpHierarchy() const override
;
125 virtual OUString
get_action(VclEventId nEvent
) const override
;
127 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
131 virtual OUString
get_name() const;
135 // TODO: moggi: what about push buttons?
136 class UITEST_DLLPUBLIC ButtonUIObject
: public WindowUIObject
138 VclPtr
<Button
> mxButton
;
141 ButtonUIObject(VclPtr
<Button
> xButton
);
142 virtual ~ButtonUIObject() override
;
144 virtual StringMap
get_state() override
;
146 virtual void execute(const OUString
& rAction
,
147 const StringMap
& rParameters
) override
;
149 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
153 virtual OUString
get_name() const override
;
156 class UITEST_DLLPUBLIC DialogUIObject
: public WindowUIObject
158 VclPtr
<Dialog
> mxDialog
;
162 DialogUIObject(VclPtr
<Dialog
> xDialog
);
163 virtual ~DialogUIObject() override
;
165 virtual StringMap
get_state() override
;
167 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
171 virtual OUString
get_name() const override
;
174 class UITEST_DLLPUBLIC EditUIObject
: public WindowUIObject
180 EditUIObject(VclPtr
<Edit
> xEdit
);
181 virtual ~EditUIObject() override
;
183 virtual void execute(const OUString
& rAction
,
184 const StringMap
& rParameters
) override
;
186 virtual StringMap
get_state() override
;
188 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
192 virtual OUString
get_name() const override
;
195 // TODO: moggi: maybe let it inherit from the button case
196 class UITEST_DLLPUBLIC CheckBoxUIObject
: public WindowUIObject
199 VclPtr
<CheckBox
> mxCheckBox
;
202 CheckBoxUIObject(VclPtr
<CheckBox
> xCheckbox
);
203 virtual ~CheckBoxUIObject() override
;
205 virtual void execute(const OUString
& rAction
,
206 const StringMap
& rParameters
) override
;
208 virtual StringMap
get_state() override
;
210 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
214 virtual OUString
get_name() const override
;
217 class UITEST_DLLPUBLIC RadioButtonUIObject
: public WindowUIObject
220 VclPtr
<RadioButton
> mxRadioButton
;
223 RadioButtonUIObject(VclPtr
<RadioButton
> xCheckbox
);
224 virtual ~RadioButtonUIObject() override
;
226 virtual void execute(const OUString
& rAction
,
227 const StringMap
& rParameters
) override
;
229 virtual StringMap
get_state() override
;
231 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
235 virtual OUString
get_name() const override
;
238 class UITEST_DLLPUBLIC TabPageUIObject
: public WindowUIObject
241 VclPtr
<TabPage
> mxTabPage
;
243 TabPageUIObject(VclPtr
<TabPage
> xTabPage
);
244 virtual ~TabPageUIObject() override
;
246 virtual void execute(const OUString
& rAction
,
247 const StringMap
& rParameters
) override
;
249 virtual StringMap
get_state() override
;
251 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
255 virtual OUString
get_name() const override
;
258 class UITEST_DLLPUBLIC ListBoxUIObject
: public WindowUIObject
261 VclPtr
<ListBox
> mxListBox
;
265 ListBoxUIObject(VclPtr
<ListBox
> xListBox
);
266 virtual ~ListBoxUIObject() override
;
268 virtual void execute(const OUString
& rAction
,
269 const StringMap
& rParameters
) override
;
271 virtual StringMap
get_state() override
;
273 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
275 virtual OUString
get_action(VclEventId nEvent
) const override
;
279 virtual OUString
get_name() const override
;
282 // TODO: moggi: should it inherit from EditUIObject?
283 class UITEST_DLLPUBLIC ComboBoxUIObject
: public WindowUIObject
286 VclPtr
<ComboBox
> mxComboBox
;
290 ComboBoxUIObject(VclPtr
<ComboBox
> xListBox
);
291 virtual ~ComboBoxUIObject() override
;
293 virtual void execute(const OUString
& rAction
,
294 const StringMap
& rParameters
) override
;
296 virtual StringMap
get_state() override
;
298 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
302 virtual OUString
get_name() const override
;
305 class UITEST_DLLPUBLIC SpinUIObject
: public WindowUIObject
308 VclPtr
<SpinButton
> mxSpinButton
;
312 SpinUIObject(VclPtr
<SpinButton
> xSpinButton
);
313 virtual ~SpinUIObject() override
;
315 virtual void execute(const OUString
& rAction
,
316 const StringMap
& rParameters
) override
;
318 virtual StringMap
get_state() override
;
320 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
324 virtual OUString
get_name() const override
;
327 class UITEST_DLLPUBLIC SpinFieldUIObject
: public EditUIObject
329 VclPtr
<SpinField
> mxSpinField
;
333 SpinFieldUIObject(VclPtr
<SpinField
> xEdit
);
334 virtual ~SpinFieldUIObject() override
;
336 virtual void execute(const OUString
& rAction
,
337 const StringMap
& rParameters
) override
;
339 virtual StringMap
get_state() override
;
341 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
345 virtual OUString
get_name() const override
;
348 class UITEST_DLLPUBLIC TabControlUIObject
: public WindowUIObject
351 VclPtr
<TabControl
> mxTabControl
;
355 TabControlUIObject(VclPtr
<TabControl
> mxTabControl
);
356 virtual ~TabControlUIObject() override
;
358 virtual void execute(const OUString
& rAction
,
359 const StringMap
& rParameters
) override
;
361 virtual StringMap
get_state() override
;
363 static std::unique_ptr
<UIObject
> create(vcl::Window
* pWindow
);
367 virtual OUString
get_name() const override
;
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */