/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_VCL_UITEST_UIOBJECT_HXX #define INCLUDED_VCL_UITEST_UIOBJECT_HXX #include #include #include #include #include #include #include #include class Button; class CheckBox; class ComboBox; class Dialog; class Edit; class IconView; class ListBox; class RadioButton; class TabControl; class TabPage; class SvTreeListBox; class SvTreeListEntry; class SpinButton; class SpinField; class VerticalTabControl; class VclDrawingArea; class VclMultiLineEdit; class MenuButton; class ToolBox; namespace vcl { class Window; } namespace weld { class CustomWidgetController; } typedef std::map StringMap; /** * This class wraps a UI object like vcl::Window and provides * an interface for the UI testing. * * This class should only have virtual methods. */ class UITEST_DLLPUBLIC UIObject { UIObject(UIObject const &) = delete; UIObject& operator =(UIObject const &) = delete; public: UIObject() = default; virtual ~UIObject(); /** * Returns the state of the wrapped UI object as a * string key value map. */ virtual StringMap get_state(); /** * Executes an action on the wrapped UI object, * possibly with some additional parameters */ virtual void execute(const OUString& rAction, const StringMap& rParameters); /** * Returns the type of the UIObject. Additional information might * be available through UIObject::get_state(). */ virtual OUString get_type() const; /** * Returns the child of the current UIObject with the corresponding id. * If no object with that id is being found returns a nullptr. * */ virtual std::unique_ptr get_child(const OUString& rID); /** * Returns a set containing all descendants of the object. */ virtual std::set get_children() const; /** * Currently an internal method to dump the state of the current UIObject as represented by get_state(). * * This method should not be exposed to the outside world. * */ virtual OUString dumpState() const; /** * Currently an internal method to dump the parent-child relationship starting from the current top focus window. * * This method should not be exposed to the outside world. * */ virtual OUString dumpHierarchy() const; /** * Gets the corresponding Action string for the event. */ virtual OUString get_action(VclEventId nEvent) const; }; class UITEST_DLLPUBLIC WindowUIObject : public UIObject { VclPtr mxWindow; public: WindowUIObject(const VclPtr& xWindow); virtual StringMap get_state() override; virtual void execute(const OUString& rAction, const StringMap& rParameters) override; virtual OUString get_type() const override; virtual std::unique_ptr get_child(const OUString& rID) override; std::unique_ptr get_visible_child(const OUString& rID); virtual std::set get_children() const override; virtual OUString dumpState() const override; virtual OUString dumpHierarchy() const override; virtual OUString get_action(VclEventId nEvent) const override; static std::unique_ptr create(vcl::Window* pWindow); protected: virtual OUString get_name() const; }; // TODO: moggi: what about push buttons? class ButtonUIObject final : public WindowUIObject { VclPtr