diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-09-29 17:08:48 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-09-29 17:26:49 +0200 |
commit | a801155464cf479b3fbf30f27e3f51030d69ba14 (patch) | |
tree | d4c7fe4f8627ef42cfda2266bb8cfe8a9c3e41a5 | |
parent | d4e19a2394f58191b4d60f445988450142650679 (diff) |
add introspection support for SvSimpleTable
This is the second part of the UI test tutorial.
The tutorial shows how to add introspection support to a new
vcl::Window based UI object.
Change-Id: I2b3ed68d313749787869c7e85f2e27c9d01fff4a
-rw-r--r-- | include/svtools/simptabl.hxx | 3 | ||||
-rw-r--r-- | svtools/inc/uitest/uiobject.hxx | 17 | ||||
-rw-r--r-- | svtools/source/contnr/simptabl.cxx | 11 | ||||
-rw-r--r-- | svtools/source/uitest/uiobject.cxx | 28 |
4 files changed, 59 insertions, 0 deletions
diff --git a/include/svtools/simptabl.hxx b/include/svtools/simptabl.hxx index 7e4627552b36..051e991732ff 100644 --- a/include/svtools/simptabl.hxx +++ b/include/svtools/simptabl.hxx @@ -40,10 +40,13 @@ public: virtual void dispose() override; void SetTable(SvSimpleTable* pTable); + SvSimpleTable* GetTable(); virtual void Resize() override; virtual void GetFocus() override; + + virtual FactoryFunction GetUITestFactory() const override; }; class SVT_DLLPUBLIC SvSimpleTable : public SvHeaderTabListBox diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx index 93cfc156a47b..873c3d57dedf 100644 --- a/svtools/inc/uitest/uiobject.hxx +++ b/svtools/inc/uitest/uiobject.hxx @@ -11,6 +11,7 @@ class SvTreeListBox; class SvTreeListEntry; +class SvSimpleTable; class TreeListUIObject : public WindowUIObject { @@ -61,4 +62,20 @@ private: SvTreeListEntry* mpEntry; }; +class SimpleTableUIObject : public TreeListUIObject +{ +public: + SimpleTableUIObject(VclPtr<SvSimpleTable> xTable); + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> createFromContainer(vcl::Window* pWindow); + +protected: + virtual OUString get_type() const override; + +private: + VclPtr<SvSimpleTable> mxTable; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/contnr/simptabl.cxx b/svtools/source/contnr/simptabl.cxx index 8515183e66b6..88a8cb3c11c2 100644 --- a/svtools/source/contnr/simptabl.cxx +++ b/svtools/source/contnr/simptabl.cxx @@ -24,6 +24,7 @@ #include <vcl/builderfactory.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <uitest/uiobject.hxx> SvSimpleTableContainer::SvSimpleTableContainer(vcl::Window* pParent, WinBits nBits) : Control(pParent, nBits) @@ -50,6 +51,11 @@ void SvSimpleTableContainer::SetTable(SvSimpleTable* pTable) m_pTable = pTable; } +SvSimpleTable* SvSimpleTableContainer::GetTable() +{ + return m_pTable.get(); +} + bool SvSimpleTableContainer::PreNotify( NotifyEvent& rNEvt ) { bool bResult = true; @@ -84,6 +90,11 @@ void SvSimpleTableContainer::GetFocus() m_pTable->GrabFocus(); } +FactoryFunction SvSimpleTableContainer::GetUITestFactory() const +{ + return SimpleTableUIObject::createFromContainer; +} + // SvSimpleTable ------------------------------------------------------------ SvSimpleTable::SvSimpleTable(SvSimpleTableContainer& rParent, WinBits nBits): diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx index 6156f4451918..0a4550ff1813 100644 --- a/svtools/source/uitest/uiobject.cxx +++ b/svtools/source/uitest/uiobject.cxx @@ -10,6 +10,7 @@ #include "uitest/uiobject.hxx" #include <svtools/treelistbox.hxx> +#include <svtools/simptabl.hxx> TreeListUIObject::TreeListUIObject(VclPtr<SvTreeListBox> xTreeList): WindowUIObject(xTreeList), @@ -140,4 +141,31 @@ OUString TreeListEntryUIObject::get_type() const return OUString("TreeListEntry"); } +SimpleTableUIObject::SimpleTableUIObject(VclPtr<SvSimpleTable> xTable): + TreeListUIObject(xTable), + mxTable(xTable) +{ +} + +StringMap SimpleTableUIObject::get_state() +{ + StringMap aMap = TreeListUIObject::get_state(); + + aMap["ColumnCount"] = OUString::number(mxTable->TabCount()); + + return aMap; +} + +OUString SimpleTableUIObject::UIObject::get_type() const +{ + return OUString("SimpleTable"); +} + +std::unique_ptr<UIObject> SimpleTableUIObject::createFromContainer(vcl::Window* pWindow) +{ + SvSimpleTableContainer* pTableContainer = dynamic_cast<SvSimpleTableContainer*>(pWindow); + assert(pTableContainer); + return std::unique_ptr<UIObject>(new SimpleTableUIObject(pTableContainer->GetTable())); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |