diff options
-rw-r--r-- | include/svtools/valueset.hxx | 2 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/inc/uiobject.hxx | 38 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 7 | ||||
-rw-r--r-- | svtools/source/uitest/uiobject.cxx | 57 |
5 files changed, 105 insertions, 0 deletions
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index 410003e97d72..128ffcb8daf6 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -407,6 +407,8 @@ public: int nItemId = IsNoSelection() ? -1 : GetSelectedItemId(); return mnSavedItemId != nItemId; } + + virtual FactoryFunction GetUITestFactory() const override; }; diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 456a7ae568a0..b7ed7657d691 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -182,6 +182,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/uno/wizard/unowizard \ svtools/source/uno/wizard/wizardpagecontroller \ svtools/source/uno/wizard/wizardshell \ + svtools/source/uitest/uiobject \ )) ifeq ($(OS),WNT) diff --git a/svtools/inc/uiobject.hxx b/svtools/inc/uiobject.hxx new file mode 100644 index 000000000000..a27b6d68fdad --- /dev/null +++ b/svtools/inc/uiobject.hxx @@ -0,0 +1,38 @@ +/* -*- 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_SVTOOLS_INC_UIOBJECT_HXX +#define INCLUDED_SVTOOLS_INC_UIOBJECT_HXX + +#include <memory> +#include <vcl/uitest/uiobject.hxx> +#include <svtools/valueset.hxx> + +class ValueSet; + +class ValueSetUIObject final : public WindowUIObject +{ + ValueSet* mpSet; + +public: + ValueSetUIObject(const VclPtr<vcl::Window>& xSetWin, ValueSet* pSet); + + 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: */
\ No newline at end of file diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 74a09e613d26..e56f3e7e2d43 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -43,6 +43,8 @@ #include <svtools/valueset.hxx> #include <boost/property_tree/ptree.hpp> +#include <uiobject.hxx> + using namespace css::uno; using namespace css::lang; using namespace css::accessibility; @@ -1909,4 +1911,9 @@ void ValueSet::Hide() mxScrolledWindow->hide(); } +FactoryFunction ValueSet::GetUITestFactory() const +{ + return ValueSetUIObject::create; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx new file mode 100644 index 000000000000..904a81be1bb6 --- /dev/null +++ b/svtools/source/uitest/uiobject.cxx @@ -0,0 +1,57 @@ +/* -*- 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/. + */ + +#include <memory> +#include <uiobject.hxx> +#include <svtools/valueset.hxx> +#include <vcl/layout.hxx> + +ValueSetUIObject::ValueSetUIObject(const VclPtr<vcl::Window>& xSetWin, ValueSet* pSet) + : WindowUIObject(xSetWin) + , mpSet(pSet) +{ +} + +void ValueSetUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + if (rAction == "SELECT") + { + if (rParameters.find("POS") != rParameters.end()) + { + OUString aIndexStr = rParameters.find("POS")->second; + + sal_Int32 nIndex = aIndexStr.toInt32(); + mpSet->SelectItem(nIndex); + mpSet->Select(); + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +std::unique_ptr<UIObject> ValueSetUIObject::create(vcl::Window* pWindow) +{ + VclDrawingArea* pSetWin = dynamic_cast<VclDrawingArea*>(pWindow); + assert(pSetWin); + return std::unique_ptr<UIObject>( + new ValueSetUIObject(pSetWin, static_cast<ValueSet*>(pSetWin->GetUserData()))); +} + +OUString ValueSetUIObject::get_name() const { return "ValueSetUIObject"; } + +StringMap ValueSetUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + aMap["SelectedItemId"] = OUString::number(mpSet->GetSelectedItemId()); + aMap["SelectedItemPos"] = OUString::number(mpSet->GetSelectItemPos()); + aMap["ItemsCount"] = OUString::number(mpSet->GetItemCount()); + return aMap; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file |