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/spin.hxx>
19 #include <vcl/button.hxx>
20 #include <vcl/tabpage.hxx>
21 #include <vcl/lstbox.hxx>
22 #include <vcl/combobox.hxx>
23 #include <vcl/spinfld.hxx>
24 #include <vcl/tabctrl.hxx>
25 #include <vcl/treelistbox.hxx>
26 
27 #include <vcl/dllapi.h>
28 
29 #include <set>
30 
31 class Edit;
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?
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 protected:
156 
157  virtual OUString get_name() const override;
158 };
159 
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 protected:
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 protected:
218 
219  virtual OUString get_name() const override;
220 };
221 
222 // TODO: moggi: maybe let it inherit from the button case
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 protected:
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 protected:
265 
266  virtual OUString get_name() const override;
267 };
268 
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 protected:
285 
286  virtual OUString get_name() const override;
287 };
288 
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 protected:
309 
310  virtual OUString get_name() const override;
311 };
312 
313 // TODO: moggi: should it inherit from EditUIObject?
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 protected:
334 
335  virtual OUString get_name() const override;
336 };
337 
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 protected:
358 
359  virtual OUString get_name() const override;
360 };
361 
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 protected:
381 
382  virtual OUString get_name() const override;
383 };
384 
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 protected:
405 
406  virtual OUString get_name() const override;
407 };
408 
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 protected:
426 
427  virtual OUString get_name() const override;
428 
429 private:
430 
432 };
433 
435 {
436 public:
437 
439 
440  virtual StringMap get_state() override;
441 
442  virtual void execute(const OUString& rAction,
443  const StringMap& rParameters) override;
444 
445  virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
446 
447  virtual std::set<OUString> get_children() const override;
448 
449  virtual OUString get_type() const override;
450 
451 private:
452 
454 
456 };
457 
458 #endif
459 
460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclPtr< VclMultiLineEdit > mxEdit
Definition: uiobject.hxx:203
virtual std::unique_ptr< UIObject > get_child(const OUString &rID)
Returns the child of the current UIObject with the corresponding id.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
VclPtr< SpinButton > mxSpinButton
Definition: uiobject.hxx:341
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 std::set< OUString > get_children() const override
Returns a set containing all descendants of the object.
This class wraps a UI object like vcl::Window and provides an interface for the UI testing...
Definition: uiobject.hxx:41
VclPtr< TabPage > mxTabPage
Definition: uiobject.hxx:272
virtual StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_name() const
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 StringMap get_state() override
Returns the state of the wrapped UI object as a string key value map.
virtual OUString get_action(VclEventId nEvent) const override
Gets the corresponding Action string for the event.
VclEventId
Definition: vclevent.hxx:41
virtual std::set< OUString > get_children() const
Returns a set containing all descendants of the object.
Definition: edit.hxx:58
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)
VclPtr< Edit > mxEdit
Definition: uiobject.hxx:180
virtual OUString dumpHierarchy() const
Currently an internal method to dump the parent-child relationship starting from the current top focu...
virtual OUString get_type() const
Returns the type of the UIObject.
VclPtr< Button > mxButton
Definition: uiobject.hxx:140
std::map< const OUString, OUString > StringMap
Definition: uiobject.hxx:31
virtual void execute(const OUString &rAction, const StringMap &rParameters)
Executes an action on the wrapped UI object, possibly with some additional parameters.
#define UITEST_DLLPUBLIC
Definition: dllapi.h:36
virtual std::unique_ptr< UIObject > get_child(const OUString &rID) override
Returns the child of the current UIObject with the corresponding id.
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:431
VclPtr< SvTreeListBox > mxTreeList
Definition: uiobject.hxx:453
virtual OUString dumpState() const
Currently an internal method to dump the state of the current UIObject as represented by get_state()...
SvTreeListEntry *const mpEntry
Definition: uiobject.hxx:455
VclPtr< ComboBox > mxComboBox
Definition: uiobject.hxx:317
VclPtr< Dialog > mxDialog
Definition: uiobject.hxx:162
VclPtr< CheckBox > mxCheckBox
Definition: uiobject.hxx:226
VclPtr< TabControl > mxTabControl
Definition: uiobject.hxx:388
VclPtr< RadioButton > mxRadioButton
Definition: uiobject.hxx:249
VclPtr< ListBox > mxListBox
Definition: uiobject.hxx:292
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
VclPtr< vcl::Window > mxWindow
Definition: uiobject.hxx:106
VclPtr< SpinField > mxSpinField
Definition: uiobject.hxx:364
virtual StringMap get_state()
Returns the state of the wrapped UI object as a string key value map.