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;
37 
38 typedef std::map<const OUString, OUString> StringMap;
39 
47 {
48  UIObject(UIObject const &) = delete;
49  UIObject& operator =(UIObject const &) = delete;
50 
51 public:
52  UIObject() = default;
53 
54  virtual ~UIObject();
55 
60  virtual StringMap get_state();
61 
66  virtual void execute(const OUString& rAction,
67  const StringMap& rParameters);
68 
73  virtual OUString get_type() const;
74 
80  virtual std::unique_ptr<UIObject> get_child(const OUString& rID);
81 
85  virtual std::set<OUString> get_children() const;
86 
93  virtual OUString dumpState() const;
94 
101  virtual OUString dumpHierarchy() const;
102 
106  virtual OUString get_action(VclEventId nEvent) const;
107 };
108 
110 {
112 
113 public:
114 
115  WindowUIObject(const VclPtr<vcl::Window>& xWindow);
116 
117  virtual StringMap get_state() override;
118 
119  virtual void execute(const OUString& rAction,
120  const StringMap& rParameters) override;
121 
122  virtual OUString get_type() const override;
123 
124  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
125 
126  virtual std::set<OUString> get_children() const override;
127 
128  virtual OUString dumpState() const override;
129 
130  virtual OUString dumpHierarchy() const override;
131 
132  virtual OUString get_action(VclEventId nEvent) const override;
133 
134  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
135 
136 protected:
137 
138  virtual OUString get_name() const;
139 
140 };
141 
142 // TODO: moggi: what about push buttons?
143 class ButtonUIObject final : public WindowUIObject
144 {
146 public:
147 
148  ButtonUIObject(const VclPtr<Button>& xButton);
149  virtual ~ButtonUIObject() override;
150 
151  virtual StringMap get_state() override;
152 
153  virtual void execute(const OUString& rAction,
154  const StringMap& rParameters) override;
155 
156  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
157 
158  virtual OUString get_action(VclEventId nEvent) const override;
159 
160 private:
161 
162  virtual OUString get_name() const override;
163 };
164 
165 class DialogUIObject final : public WindowUIObject
166 {
168 
169 public:
170 
171  DialogUIObject(const VclPtr<Dialog>& xDialog);
172  virtual ~DialogUIObject() override;
173 
174  virtual StringMap get_state() override;
175 
176  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
177 
178 private:
179 
180  virtual OUString get_name() const override;
181 };
182 
184 {
186 
187 public:
188 
189  EditUIObject(const VclPtr<Edit>& xEdit);
190  virtual ~EditUIObject() override;
191 
192  virtual void execute(const OUString& rAction,
193  const StringMap& rParameters) override;
194 
195  virtual StringMap get_state() override;
196 
197  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
198 
199  virtual OUString get_action(VclEventId nEvent) const override;
200 
201 protected:
202 
203  virtual OUString get_name() const override;
204 };
205 
207 {
209 
210 public:
211 
213  virtual ~MultiLineEditUIObject() override;
214 
215  virtual void execute(const OUString& rAction,
216  const StringMap& rParameters) override;
217 
218  virtual StringMap get_state() override;
219 
220  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
221 
222 private:
223 
224  virtual OUString get_name() const override;
225 };
226 
227 // TODO: moggi: maybe let it inherit from the button case
228 class CheckBoxUIObject final : public WindowUIObject
229 {
230 private:
232 
233 public:
234  CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox);
235  virtual ~CheckBoxUIObject() override;
236 
237  virtual void execute(const OUString& rAction,
238  const StringMap& rParameters) override;
239 
240  virtual StringMap get_state() override;
241 
242  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
243 
244  virtual OUString get_action(VclEventId nEvent) const override;
245 
246 private:
247 
248  virtual OUString get_name() const override;
249 };
250 
252 {
253 private:
255 
256 public:
257  RadioButtonUIObject(const VclPtr<RadioButton>& xCheckbox);
258  virtual ~RadioButtonUIObject() override;
259 
260  virtual void execute(const OUString& rAction,
261  const StringMap& rParameters) override;
262 
263  virtual StringMap get_state() override;
264 
265  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
266 
267  virtual OUString get_action(VclEventId nEvent) const override;
268 
269 private:
270 
271  virtual OUString get_name() const override;
272 };
273 
274 class TabPageUIObject final : public WindowUIObject
275 {
276 private:
278 public:
279  TabPageUIObject(const VclPtr<TabPage>& xTabPage);
280  virtual ~TabPageUIObject() override;
281 
282  virtual void execute(const OUString& rAction,
283  const StringMap& rParameters) override;
284 
285  virtual StringMap get_state() override;
286 
287  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
288 
289 private:
290 
291  virtual OUString get_name() const override;
292 };
293 
294 class ListBoxUIObject final : public WindowUIObject
295 {
296 private:
298 
299 public:
300 
301  ListBoxUIObject(const VclPtr<ListBox>& xListBox);
302  virtual ~ListBoxUIObject() override;
303 
304  virtual void execute(const OUString& rAction,
305  const StringMap& rParameters) override;
306 
307  virtual StringMap get_state() override;
308 
309  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
310 
311  virtual OUString get_action(VclEventId nEvent) const override;
312 
313 private:
314 
315  virtual OUString get_name() const override;
316 };
317 
318 // TODO: moggi: should it inherit from EditUIObject?
319 class ComboBoxUIObject final : public WindowUIObject
320 {
321 private:
323 
324 public:
325 
326  ComboBoxUIObject(const VclPtr<ComboBox>& xListBox);
327  virtual ~ComboBoxUIObject() override;
328 
329  virtual void execute(const OUString& rAction,
330  const StringMap& rParameters) override;
331 
332  virtual StringMap get_state() override;
333 
334  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
335 
336  virtual OUString get_action(VclEventId nEvent) const override;
337 
338 private:
339 
340  virtual OUString get_name() const override;
341 };
342 
343 class SpinUIObject final : public WindowUIObject
344 {
345 private:
347 
348 public:
349 
350  SpinUIObject(const VclPtr<SpinButton>& xSpinButton);
351  virtual ~SpinUIObject() override;
352 
353  virtual void execute(const OUString& rAction,
354  const StringMap& rParameters) override;
355 
356  virtual StringMap get_state() override;
357 
358  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
359 
360  virtual OUString get_action(VclEventId nEvent) const override;
361 
362 private:
363 
364  virtual OUString get_name() const override;
365 };
366 
368 {
370 
371 public:
372 
373  SpinFieldUIObject(const VclPtr<SpinField>& xEdit);
374  virtual ~SpinFieldUIObject() override;
375 
376  virtual void execute(const OUString& rAction,
377  const StringMap& rParameters) override;
378 
379  virtual StringMap get_state() override;
380 
381  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
382 
383  virtual OUString get_action(VclEventId nEvent) const override;
384 
385 private:
386 
387  virtual OUString get_name() const override;
388 };
389 
390 class TabControlUIObject final : public WindowUIObject
391 {
392 private:
394 
395 public:
396 
397  TabControlUIObject(const VclPtr<TabControl>& mxTabControl);
398  virtual ~TabControlUIObject() override;
399 
400  virtual void execute(const OUString& rAction,
401  const StringMap& rParameters) override;
402 
403  virtual StringMap get_state() override;
404 
405  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
406 
407  virtual OUString get_action(VclEventId nEvent) const override;
408 
409 private:
410 
411  virtual OUString get_name() const override;
412 };
413 
415 {
416 private:
418 
419 public:
420 
422  virtual ~VerticalTabControlUIObject() override;
423 
424  virtual void execute(const OUString& rAction,
425  const StringMap& rParameters) override;
426 
427  virtual StringMap get_state() override;
428 
429  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
430 
431 private:
432 
433  virtual OUString get_name() const override;
434 };
435 
436 class TreeListUIObject final : public WindowUIObject
437 {
438 public:
439  TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
440 
441  virtual StringMap get_state() override;
442 
443  static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
444 
445  virtual void execute(const OUString& rAction,
446  const StringMap& rParameters) override;
447 
448  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
449 
450  virtual std::set<OUString> get_children() const override;
451 
452 private:
453 
454  virtual OUString get_name() const override;
455 
457 };
458 
459 class TreeListEntryUIObject final : public UIObject
460 {
461 public:
462 
464 
465  virtual StringMap get_state() override;
466 
467  virtual void execute(const OUString& rAction,
468  const StringMap& rParameters) override;
469 
470  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
471 
472  virtual std::set<OUString> get_children() const override;
473 
474  virtual OUString get_type() const override;
475 
476 private:
477 
479 
481 };
482 
483 #endif
484 
485 /* 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:208
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:346
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
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)
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:46
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:277
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 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.
virtual OUString get_name() const override
VclEventId
Definition: vclevent.hxx:39
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 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:56
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:185
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:145
CheckBoxUIObject(const VclPtr< CheckBox > &xCheckbox)
std::map< const OUString, OUString > StringMap
Definition: uiobject.hxx:36
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:456
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:478
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:480
VclPtr< ComboBox > mxComboBox
Definition: uiobject.hxx:322
virtual OUString get_name() const override
VclPtr< VerticalTabControl > mxTabControl
Definition: uiobject.hxx:417
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:167
VclPtr< CheckBox > mxCheckBox
Definition: uiobject.hxx:231
VclPtr< TabControl > mxTabControl
Definition: uiobject.hxx:393
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< RadioButton > mxRadioButton
Definition: uiobject.hxx:254
ComboBoxUIObject(const VclPtr< ComboBox > &xListBox)
std::map< OUString, OUString > StringMap
virtual ~VerticalTabControlUIObject() override
VclPtr< ListBox > mxListBox
Definition: uiobject.hxx:297
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:111
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:369
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