include/vcl/layout.hxx          |    1 
 include/vcl/uitest/uiobject.hxx |   22 ++++++++++++++++++++
 vcl/source/uitest/uiobject.cxx  |   43 ++++++++++++++++++++++++++++++++++++++++
 vcl/source/window/layout.cxx    |    5 ++++
 4 files changed, 71 insertions(+)

New commits:
commit 1403a335b43089af7ed25fc67bd44df932dc9611
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Apr 1 11:57:31 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Apr 1 14:12:05 2022 +0200

    uitest: add wrapper for VclExpander
    
    Change-Id: I725c51fdddea9da9aa79d166d747261e80ca9376
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132416
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 19eca5b5cf40..2296f8097a4a 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -470,6 +470,7 @@ public:
     virtual void StateChanged(StateChangedType nType) override;
     void  SetExpandedHdl( const Link<VclExpander&,void>& rLink ) { 
maExpandedHdl = rLink; }
     virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
+    virtual FactoryFunction GetUITestFactory() const override;
 private:
     virtual Size calculateRequisition() const override;
     virtual void setAllocation(const Size &rAllocation) override;
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index c46218d68423..c9a932ec672f 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -36,6 +36,7 @@ class SvTreeListEntry;
 class SpinButton;
 class SpinField;
 class VerticalTabControl;
+class VclExpander;
 class VclDrawingArea;
 class VclMultiLineEdit;
 class MenuButton;
@@ -234,6 +235,27 @@ private:
     virtual OUString get_name() const override;
 };
 
+class ExpanderUIObject : public WindowUIObject
+{
+    VclPtr<VclExpander> mxExpander;
+
+public:
+
+    ExpanderUIObject(const VclPtr<VclExpander>& xExpander);
+    virtual ~ExpanderUIObject() 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
 {
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index da71b7d3e41d..d44134cb7996 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -894,6 +894,49 @@ std::unique_ptr<UIObject> 
MultiLineEditUIObject::create(vcl::Window* pWindow)
     return std::unique_ptr<UIObject>(new MultiLineEditUIObject(pEdit));
 }
 
+ExpanderUIObject::ExpanderUIObject(const VclPtr<VclExpander>& xExpander)
+    : WindowUIObject(xExpander)
+    , mxExpander(xExpander)
+{
+}
+
+ExpanderUIObject::~ExpanderUIObject()
+{
+}
+
+void ExpanderUIObject::execute(const OUString& rAction, const StringMap& 
rParameters)
+{
+    if (rAction == "EXPAND")
+    {
+        mxExpander->set_expanded(true);
+    }
+    else if (rAction == "COLLAPSE")
+    {
+        mxExpander->set_expanded(false);
+    }
+    else
+        WindowUIObject::execute(rAction, rParameters);
+}
+
+StringMap ExpanderUIObject::get_state()
+{
+    StringMap aMap = WindowUIObject::get_state();
+    aMap["Expanded"] = OUString::boolean(mxExpander->get_expanded());
+    return aMap;
+}
+
+OUString ExpanderUIObject::get_name() const
+{
+    return "ExpanderUIObject";
+}
+
+std::unique_ptr<UIObject> ExpanderUIObject::create(vcl::Window* pWindow)
+{
+    VclExpander* pVclExpander = dynamic_cast<VclExpander*>(pWindow);
+    assert(pVclExpander);
+    return std::unique_ptr<UIObject>(new ExpanderUIObject(pVclExpander));
+}
+
 CheckBoxUIObject::CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox):
     WindowUIObject(xCheckbox),
     mxCheckBox(xCheckbox)
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 5cd885ed2556..99b60673b7c0 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1798,6 +1798,11 @@ void VclExpander::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
     rJsonWriter.put("type", "expander");
 }
 
+FactoryFunction VclExpander::GetUITestFactory() const
+{
+    return ExpanderUIObject::create;
+}
+
 IMPL_LINK( VclExpander, ClickHdl, CheckBox&, rBtn, void )
 {
     vcl::Window *pChild = get_child();

Reply via email to