From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- include/vcl/uitest/eventdescription.hxx | 24 ++ include/vcl/uitest/factory.hxx | 27 ++ include/vcl/uitest/formattedfielduiobject.hxx | 37 ++ include/vcl/uitest/logger.hxx | 68 +++ include/vcl/uitest/metricfielduiobject.hxx | 37 ++ include/vcl/uitest/uiobject.hxx | 591 ++++++++++++++++++++++++++ include/vcl/uitest/uitest.hxx | 38 ++ 7 files changed, 822 insertions(+) create mode 100644 include/vcl/uitest/eventdescription.hxx create mode 100644 include/vcl/uitest/factory.hxx create mode 100644 include/vcl/uitest/formattedfielduiobject.hxx create mode 100644 include/vcl/uitest/logger.hxx create mode 100644 include/vcl/uitest/metricfielduiobject.hxx create mode 100644 include/vcl/uitest/uiobject.hxx create mode 100644 include/vcl/uitest/uitest.hxx (limited to 'include/vcl/uitest') diff --git a/include/vcl/uitest/eventdescription.hxx b/include/vcl/uitest/eventdescription.hxx new file mode 100644 index 0000000000..47bf9e117e --- /dev/null +++ b/include/vcl/uitest/eventdescription.hxx @@ -0,0 +1,24 @@ +/* -*- 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_EVENTDESCRIPTION_HXX +#define INCLUDED_VCL_UITEST_EVENTDESCRIPTION_HXX + +#include +#include + +struct EventDescription +{ + OUString aKeyWord, aAction, aID, aParent; + std::map aParameters; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/factory.hxx b/include/vcl/uitest/factory.hxx new file mode 100644 index 0000000000..e514278766 --- /dev/null +++ b/include/vcl/uitest/factory.hxx @@ -0,0 +1,27 @@ +/* -*- 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_FACTORY_HXX +#define INCLUDED_VCL_UITEST_FACTORY_HXX + +#include +#include + +namespace vcl +{ +class Window; +} + +class UIObject; + +typedef std::function(vcl::Window*)> FactoryFunction; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/formattedfielduiobject.hxx b/include/vcl/uitest/formattedfielduiobject.hxx new file mode 100644 index 0000000000..0bbc95c75e --- /dev/null +++ b/include/vcl/uitest/formattedfielduiobject.hxx @@ -0,0 +1,37 @@ +/* -*- 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_FORMATTEDFIELDUIOBJECT_HXX +#define INCLUDED_VCL_UITEST_FORMATTEDFIELDUIOBJECT_HXX + +#include + +class FormattedField; + +class FormattedFieldUIObject final : public SpinFieldUIObject +{ + VclPtr mxFormattedField; + +public: + FormattedFieldUIObject(const VclPtr& xEdit); + virtual ~FormattedFieldUIObject() override; + + virtual void execute(const OUString& rAction, const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr create(vcl::Window* pWindow); + +private: + virtual OUString get_name() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx new file mode 100644 index 0000000000..bc353ad4ea --- /dev/null +++ b/include/vcl/uitest/logger.hxx @@ -0,0 +1,68 @@ +/* -*- 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_LOGGER_HXX +#define INCLUDED_VCL_UITEST_LOGGER_HXX + +#include + +#include + +#include + +#include +#include + +namespace com::sun::star::beans +{ +struct PropertyValue; +} +namespace com::sun::star::uno +{ +template class Sequence; +} +struct EventDescription; +class Control; +class KeyEvent; + +class UITEST_DLLPUBLIC UITestLogger +{ +private: + SvFileStream maStream; + + bool mbValid; + + OUString app_name; + +public: + UITestLogger(); + + void logCommand(std::u16string_view rAction, + const css::uno::Sequence& rArgs); + + void logAction(VclPtr const& xUIElement, VclEventId nEvent); + + void logAction(vcl::Window* const& xUIWin, VclEventId nEvent); + + void log(std::u16string_view rString); + + void logKeyInput(VclPtr const& xUIElement, const KeyEvent& rEvent); + + void logEvent(const EventDescription& rDescription); + + static UITestLogger& getInstance(); + + void setAppName(const OUString& name) { app_name = name; } + + const OUString& getAppName() const { return app_name; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/metricfielduiobject.hxx b/include/vcl/uitest/metricfielduiobject.hxx new file mode 100644 index 0000000000..f45da77230 --- /dev/null +++ b/include/vcl/uitest/metricfielduiobject.hxx @@ -0,0 +1,37 @@ +/* -*- 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_METRICFIELDUIOBJECT_HXX +#define INCLUDED_VCL_UITEST_METRICFIELDUIOBJECT_HXX + +#include + +class MetricField; + +class MetricFieldUIObject final : public SpinFieldUIObject +{ + VclPtr mxMetricField; + +public: + MetricFieldUIObject(const VclPtr& xEdit); + virtual ~MetricFieldUIObject() override; + + virtual void execute(const OUString& rAction, const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr create(vcl::Window* pWindow); + +private: + virtual OUString get_name() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx new file mode 100644 index 0000000000..d27140b2c2 --- /dev/null +++ b/include/vcl/uitest/uiobject.hxx @@ -0,0 +1,591 @@ +/* -*- 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 VclExpander; +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