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/dllapi.h>
19 
20 #include <set>
21 
22 class Button;
23 class CheckBox;
24 class ComboBox;
25 class Dialog;
26 class Edit;
27 class ListBox;
28 class RadioButton;
29 class TabControl;
30 class TabPage;
31 class SvTreeListBox;
32 class SvTreeListEntry;
33 class SpinButton;
34 class SpinField;
35 class VerticalTabControl;
36 class VclDrawingArea;
37 class VclMultiLineEdit;
38 class MenuButton;
39 class ToolBox;
40 namespace weld { class CustomWidgetController; }
41 
42 typedef std::map<const OUString, OUString> StringMap;
43 
51 {
52  UIObject(UIObject const &) = delete;
53  UIObject& operator =(UIObject const &) = delete;
54 
55 public:
56  UIObject() = default;
57 
58  virtual ~UIObject();
59 
64  virtual StringMap get_state();
65 
70  virtual void execute(const OUString& rAction,
71  const StringMap& rParameters);
72 
77  virtual OUString get_type() const;
78 
84  virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
85 
89  virtual std::set<OUString> get_children() const;
90 
97  virtual OUString dumpState() const;
98 
105  virtual OUString dumpHierarchy() const;
106 
110  virtual OUString get_action(VclEventId nEvent) const;
111 };
112 
114 {
116 
117 public:
118 
119  WindowUIObject(const VclPtr<vcl::Window>& xWindow);
120 
121  virtual StringMap get_state() override;
122 
123  virtual void execute(const OUString& rAction,
124  const StringMap& rParameters) override;
125 
126  virtual OUString get_type() const override;
127 
128  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
129 
130  virtual std::unique_ptr<UIObject> get_visible_child(const OUString& rID);
131 
132  virtual std::set<OUString> get_children() const override;
133 
134  virtual OUString dumpState() const override;
135 
136  virtual OUString dumpHierarchy() const override;
137 
138  virtual OUString get_action(VclEventId nEvent) const override;
139 
140  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
141 
142 protected:
143 
144  virtual OUString get_name() const;
145 
146 };
147 
148 // TODO: moggi: what about push buttons?
149 class ButtonUIObject final : public WindowUIObject
150 {
152 public:
153 
154  ButtonUIObject(const VclPtr<Button>& xButton);
155  virtual ~ButtonUIObject() override;
156 
157  virtual StringMap get_state() override;
158 
159  virtual void execute(const OUString& rAction,
160  const StringMap& rParameters) override;
161 
162  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
163 
164  virtual OUString get_action(VclEventId nEvent) const override;
165 
166 private:
167 
168  virtual OUString get_name() const override;
169 };
170 
171 class DialogUIObject final : public WindowUIObject
172 {
174 
175 public:
176 
177  DialogUIObject(const VclPtr<Dialog>& xDialog);
178  virtual ~DialogUIObject() override;
179 
180  virtual StringMap get_state() override;
181 
182  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
183 
184 private:
185 
186  virtual OUString get_name() const override;
187 };
188 
190 {
192 
193 public:
194 
195  EditUIObject(const VclPtr<Edit>& xEdit);
196  virtual ~EditUIObject() override;
197 
198  virtual void execute(const OUString& rAction,
199  const StringMap& rParameters) override;
200 
201  virtual StringMap get_state() override;
202 
203  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
204 
205  virtual OUString get_action(VclEventId nEvent) const override;
206 
207 protected:
208 
209  virtual OUString get_name() const override;
210 };
211 
213 {
215 
216 public:
217 
219  virtual ~MultiLineEditUIObject() override;
220 
221  virtual void execute(const OUString& rAction,
222  const StringMap& rParameters) override;
223 
224  virtual StringMap get_state() override;
225 
226  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
227 
228 private:
229 
230  virtual OUString get_name() const override;
231 };
232 
233 // TODO: moggi: maybe let it inherit from the button case
234 class CheckBoxUIObject final : public WindowUIObject
235 {
236 private:
238 
239 public:
240  CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox);
241  virtual ~CheckBoxUIObject() override;
242 
243  virtual void execute(const OUString& rAction,
244  const StringMap& rParameters) override;
245 
246  virtual StringMap get_state() override;
247 
248  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
249 
250  virtual OUString get_action(VclEventId nEvent) const override;
251 
252 private:
253 
254  virtual OUString get_name() const override;
255 };
256 
258 {
259 private:
261 
262 public:
263  RadioButtonUIObject(const VclPtr<RadioButton>& xCheckbox);
264  virtual ~RadioButtonUIObject() override;
265 
266  virtual void execute(const OUString& rAction,
267  const StringMap& rParameters) override;
268 
269  virtual StringMap get_state() override;
270 
271  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
272 
273  virtual OUString get_action(VclEventId nEvent) const override;
274 
275 private:
276 
277  virtual OUString get_name() const override;
278 };
279 
280 class TabPageUIObject final : public WindowUIObject
281 {
282 private:
284 public:
285  TabPageUIObject(const VclPtr<TabPage>& xTabPage);
286  virtual ~TabPageUIObject() override;
287 
288  virtual void execute(const OUString& rAction,
289  const StringMap& rParameters) override;
290 
291  virtual StringMap get_state() override;
292 
293  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
294 
295 private:
296 
297  virtual OUString get_name() const override;
298 };
299 
300 class ListBoxUIObject final : public WindowUIObject
301 {
302 private:
304 
305 public:
306 
307  ListBoxUIObject(const VclPtr<ListBox>& xListBox);
308  virtual ~ListBoxUIObject() override;
309 
310  virtual void execute(const OUString& rAction,
311  const StringMap& rParameters) override;
312 
313  virtual StringMap get_state() override;
314 
315  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
316 
317  virtual OUString get_action(VclEventId nEvent) const override;
318 
319 private:
320 
321  virtual OUString get_name() const override;
322 };
323 
324 // TODO: moggi: should it inherit from EditUIObject?
325 class ComboBoxUIObject final : public WindowUIObject
326 {
327 private:
329 
330 public:
331 
332  ComboBoxUIObject(const VclPtr<ComboBox>& xListBox);
333  virtual ~ComboBoxUIObject() override;
334 
335  virtual void execute(const OUString& rAction,
336  const StringMap& rParameters) override;
337 
338  virtual StringMap get_state() override;
339 
340  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
341 
342  virtual OUString get_action(VclEventId nEvent) const override;
343 
344 private:
345 
346  virtual OUString get_name() const override;
347 };
348 
349 class SpinUIObject final : public WindowUIObject
350 {
351 private:
353 
354 public:
355 
356  SpinUIObject(const VclPtr<SpinButton>& xSpinButton);
357  virtual ~SpinUIObject() override;
358 
359  virtual void execute(const OUString& rAction,
360  const StringMap& rParameters) override;
361 
362  virtual StringMap get_state() override;
363 
364  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
365 
366  virtual OUString get_action(VclEventId nEvent) const override;
367 
368 private:
369 
370  virtual OUString get_name() const override;
371 };
372 
374 {
376 
377 public:
378 
379  SpinFieldUIObject(const VclPtr<SpinField>& xEdit);
380  virtual ~SpinFieldUIObject() override;
381 
382  virtual void execute(const OUString& rAction,
383  const StringMap& rParameters) override;
384 
385  virtual StringMap get_state() override;
386 
387  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
388 
389  virtual OUString get_action(VclEventId nEvent) const override;
390 
391 private:
392 
393  virtual OUString get_name() const override;
394 };
395 
396 class TabControlUIObject final : public WindowUIObject
397 {
398 private:
400 
401 public:
402 
403  TabControlUIObject(const VclPtr<TabControl>& mxTabControl);
404  virtual ~TabControlUIObject() override;
405 
406  virtual void execute(const OUString& rAction,
407  const StringMap& rParameters) override;
408 
409  virtual StringMap get_state() override;
410 
411  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
412 
413  virtual OUString get_action(VclEventId nEvent) const override;
414 
415 private:
416 
417  virtual OUString get_name() const override;
418 };
419 
421 {
422 private:
424 
425 public:
426 
428  virtual ~VerticalTabControlUIObject() override;
429 
430  virtual void execute(const OUString& rAction,
431  const StringMap& rParameters) override;
432 
433  virtual StringMap get_state() override;
434 
435  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
436 
437 private:
438 
439  virtual OUString get_name() const override;
440 };
441 
442 class TreeListUIObject final : public WindowUIObject
443 {
444 public:
445  TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
446 
447  virtual StringMap get_state() override;
448 
449  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
450 
451  virtual void execute(const OUString& rAction,
452  const StringMap& rParameters) override;
453 
454  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
455 
456  virtual std::set<OUString> get_children() const override;
457 
458 private:
459 
460  virtual OUString get_name() const override;
461 
463 };
464 
465 class TreeListEntryUIObject final : public UIObject
466 {
467 public:
468 
470 
471  virtual StringMap get_state() override;
472 
473  virtual void execute(const OUString& rAction,
474  const StringMap& rParameters) override;
475 
476  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
477 
478  virtual std::set<OUString> get_children() const override;
479 
480  virtual OUString get_type() const override;
481 
482 private:
483 
485 
487 };
488 
489 class ToolBoxUIObject final : public WindowUIObject
490 {
491 private:
493 
494 public:
495 
496  ToolBoxUIObject(const VclPtr<ToolBox>& mxToolBox);
497  virtual ~ToolBoxUIObject() override;
498 
499  virtual void execute(const OUString& rAction,
500  const StringMap& rParameters) override;
501 
502  virtual StringMap get_state() override;
503 
504  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
505 
506  virtual OUString get_action(VclEventId nEvent) const override;
507 
508 private:
509 
510  virtual OUString get_name() const override;
511 };
512 
513 class MenuButtonUIObject final : public WindowUIObject
514 {
516 
517 public:
518 
519  MenuButtonUIObject(const VclPtr<MenuButton>& xMenuButton);
520  virtual ~MenuButtonUIObject() override;
521 
522  virtual StringMap get_state() override;
523 
524  virtual void execute(const OUString& rAction,
525  const StringMap& rParameters) override;
526 
527  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
528 
529 private:
530 
531  virtual OUString get_name() const override;
532 };
533 
535 {
536 private:
538 protected:
540 public:
541  DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea);
542  virtual ~DrawingAreaUIObject() override;
543 };
544 
545 #endif
546 
547 /* 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:214
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.
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 ~ToolBoxUIObject() override
virtual std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
virtual OUString get_name() const override
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
VclPtr< ToolBox > mxToolBox
Definition: uiobject.hxx:492
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< SpinButton > mxSpinButton
Definition: uiobject.hxx:352
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
weld::CustomWidgetController * mpController
Definition: uiobject.hxx:539
A widget used to choose from a list of items and which has no entry.
Definition: lstbox.hxx:83
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.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
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:50
VclPtr< VclDrawingArea > mxDrawingArea
Definition: uiobject.hxx:537
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:283
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 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_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)
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 ~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.
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual ~TabControlUIObject() override
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
virtual OUString get_name() const override
VclEventId
Definition: vclevent.hxx:37
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 StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
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:55
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.
virtual void execute(const OUString &rAction, const StringMap &rParameters) override
Executes an action on the wrapped UI object, possibly with some additional parameters.
TreeListEntryUIObject(const VclPtr< SvTreeListBox > &xTreeList, SvTreeListEntry *pEntry)
VclPtr< Edit > mxEdit
Definition: uiobject.hxx:191
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:151
ToolBoxUIObject(const VclPtr< ToolBox > &mxToolBox)
CheckBoxUIObject(const VclPtr< CheckBox > &xCheckbox)
std::map< const OUString, OUString > StringMap
Definition: uiobject.hxx:42
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:462
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:484
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.
VerticalTabControlUIObject(const VclPtr< VerticalTabControl > &mxTabControl)
SvTreeListEntry *const mpEntry
Definition: uiobject.hxx:486
VclPtr< ComboBox > mxComboBox
Definition: uiobject.hxx:328
virtual OUString get_name() const override
VclPtr< VerticalTabControl > mxTabControl
Definition: uiobject.hxx:423
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:173
VclPtr< CheckBox > mxCheckBox
Definition: uiobject.hxx:237
VclPtr< TabControl > mxTabControl
Definition: uiobject.hxx:399
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< RadioButton > mxRadioButton
Definition: uiobject.hxx:260
MenuButtonUIObject(const VclPtr< MenuButton > &xMenuButton)
ComboBoxUIObject(const VclPtr< ComboBox > &xListBox)
std::map< OUString, OUString > StringMap
virtual ~VerticalTabControlUIObject() override
VclPtr< ListBox > mxListBox
Definition: uiobject.hxx:303
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< MenuButton > mxMenuButton
Definition: uiobject.hxx:515
VclPtr< vcl::Window > mxWindow
Definition: uiobject.hxx:115
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:375
virtual ~MenuButtonUIObject() override
A widget used to choose from a list of items and which has an entry.
Definition: combobox.hxx:38
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