diff options
author | Shiko <aelshreif7@gmail.com> | 2020-06-14 22:24:13 +0200 |
---|---|---|
committer | Ahmed ElShreif <aelshreif7@gmail.com> | 2020-07-03 11:49:20 +0200 |
commit | 626c6ca43f1c20db261dff0108f89e62853953e7 (patch) | |
tree | 61980ea0623f0db2fa85b7107619ed9f3be37b4e /svx | |
parent | 287adbce9a6e5d045a1d6873ac312370630a922d (diff) |
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@googlemail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/uiobject.hxx | 24 | ||||
-rw-r--r-- | svx/source/dialog/svxbmpnumvalueset.cxx | 7 | ||||
-rw-r--r-- | svx/source/uitest/uiobject.cxx | 49 |
3 files changed, 80 insertions, 0 deletions
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: */ |