diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/uitest/uiobject.cxx | 52 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 7 |
2 files changed, 59 insertions, 0 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index 477f1ff06af9..9e58f594b158 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -30,6 +30,7 @@ #include <vcl/uitest/logger.hxx> #include <uiobject-internal.hxx> #include <verticaltabctrl.hxx> +#include <vcl/toolbox.hxx> #include <comphelper/string.hxx> #include <comphelper/lok.hxx> @@ -1561,4 +1562,55 @@ std::unique_ptr<UIObject> VerticalTabControlUIObject::create(vcl::Window* pWindo return std::unique_ptr<UIObject>(new VerticalTabControlUIObject(pTabControl)); } + +ToolBoxUIObject::ToolBoxUIObject(const VclPtr<ToolBox>& xToolBox): + WindowUIObject(xToolBox), + mxToolBox(xToolBox) +{ +} + +ToolBoxUIObject::~ToolBoxUIObject() +{ +} + +void ToolBoxUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "CLICK") + { + if (rParameters.find("POS") != rParameters.end()) + { + auto itr = rParameters.find("POS"); + sal_uInt16 nPos = itr->second.toUInt32(); + mxToolBox->SetCurItemId(nPos); + mxToolBox->Click(); + mxToolBox->Select(); + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +StringMap ToolBoxUIObject::get_state() +{ + StringMap aMap = WindowUIObject::get_state(); + aMap["CurrSelectedItemID"] = OUString::number(mxToolBox->GetCurItemId()); + aMap["CurrSelectedItemText"] = mxToolBox->GetItemText(mxToolBox->GetCurItemId()); + aMap["CurrSelectedItemCommand"] = mxToolBox->GetItemCommand(mxToolBox->GetCurItemId()); + aMap["ItemCount"] = OUString::number(mxToolBox->GetItemCount()); + return aMap; +} + +OUString ToolBoxUIObject::get_name() const +{ + return "ToolBoxUIObject"; +} + +std::unique_ptr<UIObject> ToolBoxUIObject::create(vcl::Window* pWindow) +{ + ToolBox* pToolBox = dynamic_cast<ToolBox*>(pWindow); + assert(pToolBox); + return std::unique_ptr<UIObject>(new ToolBoxUIObject(pToolBox)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 6ee94e7b0ae5..b15e97f14dcf 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -41,6 +41,8 @@ #include <unotools/confignode.hxx> #include <tools/json_writer.hxx> +#include <vcl/uitest/uiobject.hxx> + using namespace vcl; #define TB_SEP_SIZE 8 // Separator size @@ -350,6 +352,11 @@ void ToolBox::Highlight() CallEventListeners( VclEventId::ToolboxHighlight ); } +FactoryFunction ToolBox::GetUITestFactory() const +{ + return ToolBoxUIObject::create; +} + void ToolBox::Select() { VclPtr<vcl::Window> xWindow = this; |