summaryrefslogtreecommitdiffstats
path: root/include/vcl/uitest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/vcl/uitest
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--include/vcl/uitest/eventdescription.hxx24
-rw-r--r--include/vcl/uitest/factory.hxx28
-rw-r--r--include/vcl/uitest/formattedfielduiobject.hxx37
-rw-r--r--include/vcl/uitest/logger.hxx81
-rw-r--r--include/vcl/uitest/metricfielduiobject.hxx37
-rw-r--r--include/vcl/uitest/uiobject.hxx462
-rw-r--r--include/vcl/uitest/uitest.hxx42
7 files changed, 711 insertions, 0 deletions
diff --git a/include/vcl/uitest/eventdescription.hxx b/include/vcl/uitest/eventdescription.hxx
new file mode 100644
index 000000000..47bf9e117
--- /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 <rtl/ustring.hxx>
+#include <map>
+
+struct EventDescription
+{
+ OUString aKeyWord, aAction, aID, aParent;
+ std::map<OUString, OUString> 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 000000000..3319c5e18
--- /dev/null
+++ b/include/vcl/uitest/factory.hxx
@@ -0,0 +1,28 @@
+/* -*- 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 <memory>
+#include <functional>
+
+namespace vcl {
+
+class Window;
+
+}
+
+class UIObject;
+
+typedef std::function<std::unique_ptr<UIObject>(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 000000000..2408fe753
--- /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 <vcl/uitest/uiobject.hxx>
+
+class FormattedField;
+
+class UITEST_DLLPUBLIC FormattedFieldUIObject : public SpinFieldUIObject
+{
+ VclPtr<FormattedField> mxFormattedField;
+
+public:
+ FormattedFieldUIObject(const VclPtr<FormattedField>& xEdit);
+ virtual ~FormattedFieldUIObject() override;
+
+ virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+ 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 000000000..8bda35488
--- /dev/null
+++ b/include/vcl/uitest/logger.hxx
@@ -0,0 +1,81 @@
+/* -*- 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 <vcl/dllapi.h>
+
+#include <tools/stream.hxx>
+#include <vcl/vclevent.hxx>
+
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace beans
+{
+struct PropertyValue;
+}
+}
+}
+}
+namespace com
+{
+namespace sun
+{
+namespace star
+{
+namespace uno
+{
+template <class E> class Sequence;
+}
+}
+}
+}
+
+struct EventDescription;
+class Control;
+class KeyEvent;
+
+class UITEST_DLLPUBLIC UITestLogger
+{
+private:
+ SvFileStream maStream;
+
+ bool mbValid;
+
+ OUString app_name;
+
+public:
+ UITestLogger();
+
+ void logCommand(const OUString& rAction,
+ const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
+
+ void logAction(VclPtr<Control> const& xUIElement, VclEventId nEvent);
+
+ void log(const OUString& rString);
+
+ void logKeyInput(VclPtr<vcl::Window> const& xUIElement, const KeyEvent& rEvent);
+
+ void logEvent(const EventDescription& rDescription);
+
+ static UITestLogger& getInstance();
+
+ void setAppName(OUString name) { app_name = name; }
+
+ 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 000000000..21ff7ac88
--- /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 <vcl/uitest/uiobject.hxx>
+
+class MetricField;
+
+class UITEST_DLLPUBLIC MetricFieldUIObject : public SpinFieldUIObject
+{
+ VclPtr<MetricField> mxMetricField;
+
+public:
+ MetricFieldUIObject(const VclPtr<MetricField>& xEdit);
+ virtual ~MetricFieldUIObject() override;
+
+ virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+ 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 000000000..2c9a3e36c
--- /dev/null
+++ b/include/vcl/uitest/uiobject.hxx
@@ -0,0 +1,462 @@
+/* -*- 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 <rtl/ustring.hxx>
+#include <map>
+#include <memory>
+
+#include <vcl/window.hxx>
+#include <vcl/dllapi.h>
+
+#include <set>
+
+class Button;
+class CheckBox;
+class ComboBox;
+class Dialog;
+class Edit;
+class ListBox;
+class RadioButton;
+class TabControl;
+class TabPage;
+class SvTreeListBox;
+class SvTreeListEntry;
+class SpinButton;
+class SpinField;
+class VclMultiLineEdit;
+
+typedef std::map<const OUString, OUString> 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<UIObject> get_child(const OUString& rID);
+
+ /**
+ * Returns a set containing all descendants of the object.
+ */
+ virtual std::set<OUString> 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<vcl::Window> mxWindow;
+
+public:
+
+ WindowUIObject(const VclPtr<vcl::Window>& 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<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> 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<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ virtual OUString get_name() const;
+
+};
+
+// TODO: moggi: what about push buttons?
+class ButtonUIObject final : public WindowUIObject
+{
+ VclPtr<Button> mxButton;
+public:
+
+ ButtonUIObject(const VclPtr<Button>& xButton);
+ virtual ~ButtonUIObject() override;
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class DialogUIObject final : public WindowUIObject
+{
+ VclPtr<Dialog> mxDialog;
+
+public:
+
+ DialogUIObject(const VclPtr<Dialog>& xDialog);
+ virtual ~DialogUIObject() override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class EditUIObject : public WindowUIObject
+{
+ VclPtr<Edit> mxEdit;
+
+public:
+
+ EditUIObject(const VclPtr<Edit>& xEdit);
+ virtual ~EditUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+protected:
+
+ virtual OUString get_name() const override;
+};
+
+class MultiLineEditUIObject final : public WindowUIObject
+{
+ VclPtr<VclMultiLineEdit> mxEdit;
+
+public:
+
+ MultiLineEditUIObject(const VclPtr<VclMultiLineEdit>& xEdit);
+ virtual ~MultiLineEditUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+// TODO: moggi: maybe let it inherit from the button case
+class CheckBoxUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<CheckBox> mxCheckBox;
+
+public:
+ CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox);
+ virtual ~CheckBoxUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class RadioButtonUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<RadioButton> mxRadioButton;
+
+public:
+ RadioButtonUIObject(const VclPtr<RadioButton>& xCheckbox);
+ virtual ~RadioButtonUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class TabPageUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<TabPage> mxTabPage;
+public:
+ TabPageUIObject(const VclPtr<TabPage>& xTabPage);
+ virtual ~TabPageUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class ListBoxUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<ListBox> mxListBox;
+
+public:
+
+ ListBoxUIObject(const VclPtr<ListBox>& xListBox);
+ virtual ~ListBoxUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+// TODO: moggi: should it inherit from EditUIObject?
+class ComboBoxUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<ComboBox> mxComboBox;
+
+public:
+
+ ComboBoxUIObject(const VclPtr<ComboBox>& xListBox);
+ virtual ~ComboBoxUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class SpinUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<SpinButton> mxSpinButton;
+
+public:
+
+ SpinUIObject(const VclPtr<SpinButton>& xSpinButton);
+ virtual ~SpinUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class SpinFieldUIObject : public EditUIObject
+{
+ VclPtr<SpinField> mxSpinField;
+
+public:
+
+ SpinFieldUIObject(const VclPtr<SpinField>& xEdit);
+ virtual ~SpinFieldUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class TabControlUIObject final : public WindowUIObject
+{
+private:
+ VclPtr<TabControl> mxTabControl;
+
+public:
+
+ TabControlUIObject(const VclPtr<TabControl>& mxTabControl);
+ virtual ~TabControlUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual OUString get_action(VclEventId nEvent) const override;
+
+private:
+
+ virtual OUString get_name() const override;
+};
+
+class TreeListUIObject final : public WindowUIObject
+{
+public:
+ TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList);
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+private:
+
+ virtual OUString get_name() const override;
+
+ VclPtr<SvTreeListBox> mxTreeList;
+};
+
+class TreeListEntryUIObject final : public UIObject
+{
+public:
+
+ TreeListEntryUIObject(const VclPtr<SvTreeListBox>& xTreeList, SvTreeListEntry* pEntry);
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+ virtual OUString get_type() const override;
+
+private:
+
+ VclPtr<SvTreeListBox> mxTreeList;
+
+ SvTreeListEntry* const mpEntry;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/uitest/uitest.hxx b/include/vcl/uitest/uitest.hxx
new file mode 100644
index 000000000..4b9ca92f4
--- /dev/null
+++ b/include/vcl/uitest/uitest.hxx
@@ -0,0 +1,42 @@
+/* -*- 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_UITEST_HXX
+#define INCLUDED_VCL_UITEST_UITEST_HXX
+
+#include <rtl/ustring.hxx>
+
+#include <vcl/dllapi.h>
+
+#include <memory>
+
+namespace com::sun::star::beans { struct PropertyValue; }
+namespace com::sun::star::uno { template <typename > class Sequence; }
+
+class UIObject;
+
+class UITest
+{
+public:
+
+ static bool executeCommand(const OUString& rCommand);
+
+ static bool executeCommandWithParameters(const OUString& rCommand,
+ const css::uno::Sequence< css::beans::PropertyValue >& rArgs);
+
+ static bool executeDialog(const OUString& rCommand);
+
+ static std::unique_ptr<UIObject> getFocusTopWindow();
+
+ static std::unique_ptr<UIObject> getFloatWindow();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */