Kaydet (Commit) 2cb3587a authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: add initial implementation for ListBox

Change-Id: I9fcc884afab63a9601c560f733a13551b5036cbe
üst b590736b
...@@ -21,6 +21,7 @@ enum class UIObjectType ...@@ -21,6 +21,7 @@ enum class UIObjectType
BUTTON, BUTTON,
EDIT, EDIT,
CHECKBOX, CHECKBOX,
LISTBOX,
UNKNOWN UNKNOWN
}; };
......
...@@ -117,4 +117,25 @@ protected: ...@@ -117,4 +117,25 @@ protected:
virtual OUString get_name() const override; virtual OUString get_name() const override;
}; };
class ListBoxUIObject : public WindowUIObject
{
private:
VclPtr<ListBox> mxListBox;
public:
ListBoxUIObject(VclPtr<ListBox> xListBox);
virtual void execute(const OUString& rAction,
const StringMap& rParameters) override;
virtual StringMap get_state() override;
virtual UIObjectType get_type() const override;
protected:
virtual OUString get_name() const override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "uitest/factory.hxx" #include "uitest/factory.hxx"
#include "uitest/uiobject_impl.hxx" #include "uitest/uiobject_impl.hxx"
#include <vcl/lstbox.hxx>
std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindow) std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindow)
{ {
if (!pWindow) if (!pWindow)
...@@ -65,6 +67,13 @@ std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindo ...@@ -65,6 +67,13 @@ std::unique_ptr<UIObject> UITestWrapperFactory::createObject(vcl::Window* pWindo
return std::unique_ptr<UIObject>(new CheckBoxUIObject(pCheckBox)); return std::unique_ptr<UIObject>(new CheckBoxUIObject(pCheckBox));
} }
break; break;
case WINDOW_LISTBOX:
{
ListBox* pListBox = dynamic_cast<ListBox*>(pWindow);
assert(pListBox);
return std::unique_ptr<UIObject>(new ListBoxUIObject(pListBox));
}
break;
default: default:
break; break;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "uitest/factory.hxx" #include "uitest/factory.hxx"
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <vcl/lstbox.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
...@@ -422,4 +423,52 @@ OUString CheckBoxUIObject::get_name() const ...@@ -422,4 +423,52 @@ OUString CheckBoxUIObject::get_name() const
return OUString("CheckBoxUIObject"); return OUString("CheckBoxUIObject");
} }
ListBoxUIObject::ListBoxUIObject(VclPtr<ListBox> xListBox):
WindowUIObject(xListBox),
mxListBox(xListBox)
{
}
void ListBoxUIObject::execute(const OUString& rAction,
const StringMap& rParameters)
{
if (rAction == "SELECT")
{
bool bSelect = true;
if (rParameters.find("POS") != rParameters.end())
{
auto itr = rParameters.find("POS");
OUString aVal = itr->second;
sal_Int32 nPos = aVal.toInt32();
mxListBox->SelectEntryPos(nPos, bSelect);
}
else if (rParameters.find("TEXT") != rParameters.end())
{
auto itr = rParameters.find("TEXT");
OUString aText = itr->second;
mxListBox->SelectEntry(aText, bSelect);
}
mxListBox->Select();
}
}
StringMap ListBoxUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
aMap["ReadOnly"] = OUString::boolean(mxListBox->IsReadOnly());
aMap["MultiSelect"] = OUString::boolean(mxListBox->IsMultiSelectionEnabled());
return aMap;
}
UIObjectType ListBoxUIObject::get_type() const
{
return UIObjectType::LISTBOX;
}
OUString ListBoxUIObject::get_name() const
{
return OUString("ListBoxUIObject");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment