[Libreoffice-commits] core.git: include/svx svx/inc svx/source

Shiko (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 3 09:50:10 UTC 2020


 include/svx/numvset.hxx                 |    3 +
 svx/inc/uiobject.hxx                    |   24 +++++++++++++++
 svx/source/dialog/svxbmpnumvalueset.cxx |    7 ++++
 svx/source/uitest/uiobject.cxx          |   49 ++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+)

New commits:
commit 626c6ca43f1c20db261dff0108f89e62853953e7
Author:     Shiko <aelshreif7 at gmail.com>
AuthorDate: Sun Jun 14 22:24:13 2020 +0200
Commit:     Ahmed ElShreif <aelshreif7 at gmail.com>
CommitDate: Fri Jul 3 11:49:20 2020 +0200

    uitest : Add Support for SvxNumValueSet
    
    We need to add support for the SvxNumValueSet to use it in testing this item:
            Writer Format-Bullets and numbering dialog
    
    You can now test any SvxNumValueSet with this lines:
            >> obj_name.executeAction("CHOOSE", mkPropertyValues({"POS": "pos_num"}))
    
    I will provide another patch with test case fo Writer Format-Bullets and numbering dialog
    
    Change-Id: I4e3835c34bd3509929ee2d5e832991aa95ed3bba
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97271
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/svx/numvset.hxx b/include/svx/numvset.hxx
index 2b58fb6dd4ab..7cbf6d8dc761 100644
--- a/include/svx/numvset.hxx
+++ b/include/svx/numvset.hxx
@@ -81,6 +81,9 @@ public:
                 css::uno::Reference<css::container::XIndexAccess> > const & rOutline,
             css::uno::Reference<css::text::XNumberingFormatter> const & xFormatter,
             const css::lang::Locale& rLocale);
+
+    virtual FactoryFunction GetUITestFactory() const override;
+
 };
 
 
diff --git a/svx/inc/uiobject.hxx b/svx/inc/uiobject.hxx
index c07b90cbf074..405b854e1f06 100644
--- a/svx/inc/uiobject.hxx
+++ b/svx/inc/uiobject.hxx
@@ -12,8 +12,10 @@
 
 #include <memory>
 #include <vcl/uitest/uiobject.hxx>
+#include <svx/numvset.hxx>
 
 class SvxShowCharSet;
+class SvxNumValueSet;
 
 class SvxShowCharSetUIObject final : public WindowUIObject
 {
@@ -32,6 +34,28 @@ private:
     OUString get_name() const override;
 };
 
+
+class SvxNumValueSetUIObject final : public WindowUIObject
+{
+    SvxNumValueSet* mpNumValueSet;
+
+public:
+
+    SvxNumValueSetUIObject(vcl::Window*  xNumValueSetWin, SvxNumValueSet* pNumValueSet);
+
+    virtual void execute(const OUString& rAction,
+            const StringMap& rParameters) override;
+
+    static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+    virtual StringMap get_state() override;
+
+private:
+
+    OUString get_name() const override;
+
+};
+
 #endif // INCLUDED_SVX_INC_UIOBJECT_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
index 44bae49ff416..998132c7a578 100644
--- a/svx/source/dialog/svxbmpnumvalueset.cxx
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -35,6 +35,8 @@
 
 #include <algorithm>
 
+#include <uiobject.hxx>
+
 using namespace com::sun::star::uno;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::lang;
@@ -397,6 +399,11 @@ SvxNumValueSet::SvxNumValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWi
 {
 }
 
+FactoryFunction SvxNumValueSet::GetUITestFactory() const
+{
+    return SvxNumValueSetUIObject::create;
+}
+
 void SvxNumValueSet::init(NumberingPageType eType)
 {
     ePageType = eType;
diff --git a/svx/source/uitest/uiobject.cxx b/svx/source/uitest/uiobject.cxx
index c791dc068395..5204688c4975 100644
--- a/svx/source/uitest/uiobject.cxx
+++ b/svx/source/uitest/uiobject.cxx
@@ -12,6 +12,10 @@
 #include <svx/charmap.hxx>
 #include <vcl/layout.hxx>
 
+#include <memory>
+#include <svx/numvset.hxx>
+#include <vcl/layout.hxx>
+
 SvxShowCharSetUIObject::SvxShowCharSetUIObject(const VclPtr<vcl::Window>& xCharSetWin, SvxShowCharSet* pCharSet):
     WindowUIObject(xCharSetWin),
     mpCharSet(pCharSet)
@@ -59,4 +63,49 @@ OUString SvxShowCharSetUIObject::get_name() const
     return "SvxShowCharSetUIObject";
 }
 
+
+SvxNumValueSetUIObject::SvxNumValueSetUIObject(vcl::Window*  xNumValueSetWin , SvxNumValueSet* pNumValueSet):
+    WindowUIObject(xNumValueSetWin),
+    mpNumValueSet(pNumValueSet)
+{
+}
+
+void SvxNumValueSetUIObject::execute(const OUString& rAction,
+        const StringMap& rParameters)
+{
+    if (rAction == "CHOOSE")
+    {
+        if (rParameters.find("POS") != rParameters.end())
+        {
+            OUString aIndexStr = rParameters.find("POS")->second;
+            sal_Int32 nIndex = aIndexStr.toInt32();
+            mpNumValueSet->SelectItem(nIndex);
+            mpNumValueSet->Select();
+        }
+    }
+    else
+       WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> SvxNumValueSetUIObject::create(vcl::Window* pWindow)
+{
+    VclDrawingArea* pNumValueSetWin = dynamic_cast<VclDrawingArea*>(pWindow);
+    assert(pNumValueSetWin);
+    return std::unique_ptr<UIObject>(new SvxNumValueSetUIObject(pNumValueSetWin, static_cast<SvxNumValueSet*>(pNumValueSetWin->GetUserData())));
+}
+
+OUString SvxNumValueSetUIObject::get_name() const
+{
+    return "SvxNumValueSetUIObject";
+}
+
+StringMap SvxNumValueSetUIObject::get_state()
+{
+    StringMap aMap = WindowUIObject::get_state();
+    aMap["SelectedItemId"] = OUString::number( mpNumValueSet->GetSelectedItemId() );
+    aMap["SelectedItemPos"] = OUString::number( mpNumValueSet->GetSelectItemPos() );
+    aMap["ItemsCount"] = OUString::number(mpNumValueSet->GetItemCount());
+    aMap["ItemText"] = mpNumValueSet->GetItemText(mpNumValueSet->GetSelectedItemId());
+    return aMap;
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list