LibreOffice Module vcl (master)  1
uiobject.hxx
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 #ifndef INCLUDED_VCL_UITEST_UIOBJECT_HXX
11 #define INCLUDED_VCL_UITEST_UIOBJECT_HXX
12 
13 #include <rtl/ustring.hxx>
14 #include <map>
15 #include <memory>
16 
17 #include <vcl/window.hxx>
18 #include <vcl/button.hxx>
19 #include <vcl/tabpage.hxx>
20 #include <vcl/lstbox.hxx>
21 #include <vcl/combobox.hxx>
22 #include <vcl/tabctrl.hxx>
23 #include <vcl/treelistbox.hxx>
24 
25 #include <vcl/dllapi.h>
26 
27 #include <set>
28 
29 class Edit;
30 class SpinButton;
31 class SpinField;
32 
33 typedef std::map<const OUString, OUString> StringMap;
34 
42 {
43  UIObject(UIObject const &) = delete;
44  UIObject& operator =(UIObject const &) = delete;
45 
46 public:
47  UIObject() = default;
48 
49  virtual ~UIObject();
50 
55  virtual StringMap get_state();
56 
61  virtual void execute(const OUString& rAction,
62  const StringMap& rParameters);
63 
68  virtual OUString get_type() const;
69 
75  virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
76 
80  virtual std::set<OUString> get_children() const;
81 
88  virtual OUString dumpState() const;
89 
96  virtual OUString dumpHierarchy() const;
97 
101  virtual OUString get_action(VclEventId nEvent) const;
102 };
103 
105 {
107 
108 public:
109 
110  WindowUIObject(const VclPtr<vcl::Window>& xWindow);
111 
112  virtual StringMap get_state() override;
113 
114  virtual void execute(const OUString& rAction,
115  const StringMap& rParameters) override;
116 
117  virtual OUString get_type() const override;
118 
119  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
120 
121  virtual std::set<OUString> get_children() const override;
122 
123  virtual OUString dumpState() const override;
124 
125  virtual OUString dumpHierarchy() const override;
126 
127  virtual OUString get_action(VclEventId nEvent) const override;
128 
129  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
130 
131 protected:
132 
133  virtual OUString get_name() const;
134 
135 };
136 
137 // TODO: moggi: what about push buttons?
138 class ButtonUIObject final : public WindowUIObject
139 {
141 public:
142 
143  ButtonUIObject(const VclPtr<Button>& xButton);
144  virtual ~ButtonUIObject() override;
145 
146  virtual StringMap get_state() override;
147 
148  virtual void execute(const OUString& rAction,
149  const StringMap& rParameters) override;
150 
151  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
152 
153  virtual OUString get_action(VclEventId nEvent) const override;
154 
155 private:
156 
157  virtual OUString get_name() const override;
158 };
159 
160 class DialogUIObject final : public WindowUIObject
161 {
163 
164 public:
165 
166  DialogUIObject(const VclPtr<Dialog>& xDialog);
167  virtual ~DialogUIObject() override;
168 
169  virtual StringMap get_state() override;
170 
171  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
172 
173 private:
174 
175  virtual OUString get_name() const override;
176 };
177 
179 {
181 
182 public:
183 
184  EditUIObject(const VclPtr<Edit>& xEdit);
185  virtual ~EditUIObject() override;
186 
187  virtual void execute(const OUString& rAction,
188  const StringMap& rParameters) override;
189 
190  virtual StringMap get_state() override;
191 
192  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
193 
194  virtual OUString get_action(VclEventId nEvent) const override;
195 
196 protected:
197 
198  virtual OUString get_name() const override;
199 };
200 
202 {
204 
205 public:
206 
208  virtual ~MultiLineEditUIObject() override;
209 
210  virtual void execute(const OUString& rAction,
211  const StringMap& rParameters) override;
212 
213  virtual StringMap get_state() override;
214 
215  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
216 
217 private:
218 
219  virtual OUString get_name() const override;
220 };
221 
222 // TODO: moggi: maybe let it inherit from the button case
223 class CheckBoxUIObject final : public WindowUIObject
224 {
225 private:
227 
228 public:
229  CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox);
230  virtual ~CheckBoxUIObject() override;
231 
232  virtual void execute(const OUString& rAction,
233  const StringMap& rParameters) override;
234 
235  virtual StringMap get_state() override;
236 
237  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
238 
239  virtual OUString get_action(VclEventId nEvent) const override;
240 
241 private:
242 
243  virtual OUString get_name() const override;
244 };
245 
247 {
248 private:
250 
251 public:
252  RadioButtonUIObject(const VclPtr<RadioButton>& xCheckbox);
253  virtual ~RadioButtonUIObject() override;
254 
255  virtual void execute(const OUString& rAction,
256  const StringMap& rParameters) override;
257 
258  virtual StringMap get_state() override;
259 
260  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
261 
262  virtual OUString get_action(VclEventId nEvent) const override;
263 
264 private:
265 
266  virtual OUString get_name() const override;
267 };
268 
269 class TabPageUIObject final : public WindowUIObject
270 {
271 private:
273 public:
274  TabPageUIObject(const VclPtr<TabPage>& xTabPage);
275  virtual ~TabPageUIObject() override;
276 
277  virtual void execute(const OUString& rAction,
278  const StringMap& rParameters) override;
279 
280  virtual StringMap get_state() override;
281 
282  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
283 
284 private:
285 
286  virtual OUString get_name() const override;
287 };
288 
289 class ListBoxUIObject final : public WindowUIObject
290 {
291 private:
293 
294 public:
295 
296  ListBoxUIObject(const VclPtr<ListBox>& xListBox);
297  virtual ~ListBoxUIObject() override;
298 
299  virtual void execute(const OUString& rAction,
300  const StringMap& rParameters) override;
301 
302  virtual StringMap get_state() override;
303 
304  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
305 
306  virtual OUString get_action(VclEventId nEvent) const override;
307 
308 private:
309 
310  virtual OUString get_name() const override;
311 };
312 
313 // TODO: moggi: should it inherit from EditUIObject?
314 class ComboBoxUIObject final : public WindowUIObject
315 {
316 private:
318 
319 public:
320 
321  ComboBoxUIObject(const VclPtr<ComboBox>& xListBox);
322  virtual ~ComboBoxUIObject() override;
323 
324  virtual void execute(const OUString& rAction,
325  const StringMap& rParameters) override;
326 
327  virtual StringMap get_state() override;
328 
329  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
330 
331  virtual OUString get_action(VclEventId nEvent) const override;
332 
333 private:
334 
335  virtual OUString get_name() const override;
336 };
337 
338 class SpinUIObject final : public WindowUIObject
339 {
340 private:
342 
343 public:
344 
345  SpinUIObject(const VclPtr<SpinButton>& xSpinButton);
346  virtual ~SpinUIObject() override;
347 
348  virtual void execute(const OUString& rAction,
349  const StringMap& rParameters) override;
350 
351  virtual StringMap get_state() override;
352 
353  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
354 
355  virtual OUString get_action(VclEventId nEvent) const override;
356 
357 private:
358 
359  virtual OUString get_name() const override;
360 };
361 
362 class SpinFieldUIObject final : public EditUIObject
363 {
365 
366 public:
367 
368  SpinFieldUIObject(const VclPtr<SpinField>& xEdit);
369  virtual ~SpinFieldUIObject() override;
370 
371  virtual void execute(const OUString& rAction,
372  const StringMap& rParameters) override;
373 
374  virtual StringMap get_state() override;
375 
376  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
377 
378  virtual OUString get_action(VclEventId nEvent) const override;
379 
380 private:
381 
382  virtual OUString get_name() const override;
383 };
384 
385 class TabControlUIObject final : public WindowUIObject
386 {
387 private:
389 
390 public:
391 
392  TabControlUIObject(const VclPtr<TabControl>& mxTabControl);
393  virtual ~TabControlUIObject() override;
394 
395  virtual void execute(const OUString& rAction,
396  const StringMap& rParameters) override;
397 
398  virtual StringMap get_state() override;
399 
400  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
401 
402  virtual OUString get_action(VclEventId nEvent) const override;
403 
404 private:
405 
406  virtual OUString get_name() const override;
407 };
408 
409 class TreeListUIObject final : public WindowUIObject
410 {
411 public:
412  TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
413 
414  virtual StringMap get_state() override;
415 
416  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
417 
418  virtual void execute(const OUString& rAction,
419  const StringMap& rParameters) override;
420 
421  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
422 
423  virtual std::set<OUString> get_children() const override;
424 
425 private:
426 
427  virtual OUString get_name() const override;
428 
430 };
431 
432 class TreeListEntryUIObject final : public UIObject
433 {
434 public:
435 
437 
438  virtual StringMap get_state() override;
439 
440  virtual void execute(const OUString& rAction,
441  const StringMap& rParameters) override;
442 
443  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
444 
445  virtual std::set<OUString> get_children() const override;
446 
447  virtual OUString get_type() const override;
448 
449 private:
450 
452 
454 };
455 
456 #endif
457 
458 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~MultiLineEditUIObject() override
VclPtr< VclMultiLineEdit > mxEdit
Definition: uiobject.hxx:203
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
RadioButtonUIObject(const VclPtr< RadioButton > &xCheckbox)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
TreeListUIObject(const VclPtr< SvTreeListBox > &xTreeList)
ButtonUIObject(const VclPtr< Button > &xButton)
virtual std::unique_ptr< UIObject > get_child(const OUString &rID)
Returns the child of the current UIObject with the corresponding id.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< SpinButton > mxSpinButton
Definition: uiobject.hxx:341
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_action(VclEventId nEvent) const
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
This class wraps a UI object like vcl::Window and provides an interface for the UI testing...
Definition: uiobject.hxx:41
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_type() const override
Returns the type of the UIObject.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
VclPtr< TabPage > mxTabPage
Definition: uiobject.hxx:272
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual ~DialogUIObject() override
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual ~RadioButtonUIObject() override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual ~TabControlUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
VclEventId
Definition: vclevent.hxx:41
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString get_name() const override
virtual OUString get_name() const override
virtual OUString get_name() const override
virtual std::set< OUString > get_children() const
Returns a set containing all descendants of the object.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual OUString get_name() const override
Definition: edit.hxx:57
virtual OUString get_name() const override
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
SpinFieldUIObject(const VclPtr< SpinField > &xEdit)
virtual std::unique_ptr< UIObject > get_child(const OUString &rID) override
Returns the child of the current UIObject with the corresponding id.
TreeListEntryUIObject(const VclPtr< SvTreeListBox > &xTreeList, SvTreeListEntry *pEntry)
VclPtr< Edit > mxEdit
Definition: uiobject.hxx:180
MultiLineEditUIObject(const VclPtr< VclMultiLineEdit > &xEdit)
DialogUIObject(const VclPtr< Dialog > &xDialog)
virtual OUString dumpHierarchy() const
Currently an internal method to dump the parent-child relationship starting from the current top focu...
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual ~ButtonUIObject() override
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_type() const
Returns the type of the UIObject.
ListBoxUIObject(const VclPtr< ListBox > &xListBox)
TabPageUIObject(const VclPtr< TabPage > &xTabPage)
VclPtr< Button > mxButton
Definition: uiobject.hxx:140
CheckBoxUIObject(const VclPtr< CheckBox > &xCheckbox)
std::map< const OUString, OUString > StringMap
Definition: uiobject.hxx:31
virtual OUString get_name() const override
virtual void execute(const OUString &rAction, const StringMap &rParameters)
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual ~ComboBoxUIObject() override
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
#define UITEST_DLLPUBLIC
Definition: dllapi.h:36
virtual OUString get_name() const override
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:429
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:451
virtual ~SpinUIObject() override
virtual OUString dumpState() const
Currently an internal method to dump the state of the current UIObject as represented by get_state()...
virtual ~SpinFieldUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
SvTreeListEntry *const mpEntry
Definition: uiobject.hxx:453
VclPtr< ComboBox > mxComboBox
Definition: uiobject.hxx:317
virtual OUString get_name() const override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< Dialog > mxDialog
Definition: uiobject.hxx:162
VclPtr< CheckBox > mxCheckBox
Definition: uiobject.hxx:226
VclPtr< TabControl > mxTabControl
Definition: uiobject.hxx:388
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< RadioButton > mxRadioButton
Definition: uiobject.hxx:249
ComboBoxUIObject(const VclPtr< ComboBox > &xListBox)
VclPtr< ListBox > mxListBox
Definition: uiobject.hxx:292
virtual ~CheckBoxUIObject() override
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual std::unique_ptr< UIObject > get_child(const OUString &rID) override
Returns the child of the current UIObject with the corresponding id.
SpinUIObject(const VclPtr< SpinButton > &xSpinButton)
VclPtr< vcl::Window > mxWindow
Definition: uiobject.hxx:106
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
TabControlUIObject(const VclPtr< TabControl > &mxTabControl)
VclPtr< SpinField > mxSpinField
Definition: uiobject.hxx:364
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~TabPageUIObject() override
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
EditUIObject(const VclPtr< Edit > &xEdit)
virtual OUString get_name() const override
virtual StringMap get_state()
Returns the state of the wrapped UI object as a string key value map.
virtual ~EditUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual ~ListBoxUIObject() override