From 71f562f8f77f14b76fde4329f7238fe2e7d6a054 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 21 Jun 2016 16:49:16 +0200 Subject: uitest: support tree lists Change-Id: Iaa1a49d7e38c8d87bb3cfd749af94a0b92feee0d --- svtools/inc/uitest/uiobject.hxx | 36 ++++++++++++ svtools/source/uitest/uiobject.cxx | 111 ++++++++++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 2 deletions(-) (limited to 'svtools') diff --git a/svtools/inc/uitest/uiobject.hxx b/svtools/inc/uitest/uiobject.hxx index 294942176a64..93cfc156a47b 100644 --- a/svtools/inc/uitest/uiobject.hxx +++ b/svtools/inc/uitest/uiobject.hxx @@ -10,6 +10,7 @@ #include class SvTreeListBox; +class SvTreeListEntry; class TreeListUIObject : public WindowUIObject { @@ -20,9 +21,44 @@ public: static std::unique_ptr create(vcl::Window* pWindow); + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr get_child(const OUString& rID) override; + + virtual std::set get_children() const override; + protected: virtual OUString get_name() const override; + +private: + + VclPtr mxTreeList; +}; + +class TreeListEntryUIObject : public UIObject +{ +public: + + TreeListEntryUIObject(VclPtr xTreeList, SvTreeListEntry* pEntry); + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr get_child(const OUString& rID) override; + + virtual std::set get_children() const override; + + virtual OUString get_type() const override; + +private: + + VclPtr mxTreeList; + + SvTreeListEntry* mpEntry; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uitest/uiobject.cxx b/svtools/source/uitest/uiobject.cxx index 65cd4a7d1cb7..494406a97f04 100644 --- a/svtools/source/uitest/uiobject.cxx +++ b/svtools/source/uitest/uiobject.cxx @@ -12,13 +12,58 @@ #include TreeListUIObject::TreeListUIObject(VclPtr xTreeList): - WindowUIObject(xTreeList) + WindowUIObject(xTreeList), + mxTreeList(xTreeList) { } StringMap TreeListUIObject::get_state() { - return WindowUIObject::get_state(); + StringMap aMap = WindowUIObject::get_state(); + + aMap["SelectionCount"] = OUString::number(mxTreeList->GetSelectionCount()); + aMap["VisibleCount"] = OUString::number(mxTreeList->GetVisibleCount()); + aMap["Children"] = OUString::number(mxTreeList->GetChildCount(nullptr)); + aMap["LevelChildren"] = OUString::number(mxTreeList->GetLevelChildCount(nullptr)); + return aMap; +} + +void TreeListUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "") + { + } + else + WindowUIObject::execute(rAction, rParameters); +} + +std::unique_ptr TreeListUIObject::get_child(const OUString& rID) +{ + sal_Int32 nID = rID.toInt32(); + if (nID >= 0) + { + SvTreeListEntry* pEntry = mxTreeList->GetEntry(nullptr, nID); + if (!pEntry) + return nullptr; + + return std::unique_ptr(new TreeListEntryUIObject(mxTreeList, pEntry)); + } + + return nullptr; +} + +std::set TreeListUIObject::get_children() const +{ + std::set aChildren; + + size_t nChildren = mxTreeList->GetLevelChildCount(nullptr); + for (size_t i = 0; i < nChildren; ++i) + { + aChildren.insert(OUString::number(i)); + } + + return aChildren; } OUString TreeListUIObject::get_name() const @@ -33,4 +78,66 @@ std::unique_ptr TreeListUIObject::create(vcl::Window* pWindow) return std::unique_ptr(new TreeListUIObject(pTreeList)); } +TreeListEntryUIObject::TreeListEntryUIObject(VclPtr xTreeList, SvTreeListEntry* pEntry): + mxTreeList(xTreeList), + mpEntry(pEntry) +{ +} + +StringMap TreeListEntryUIObject::get_state() +{ + StringMap aMap; + + aMap["Text"] = mxTreeList->GetEntryText(mpEntry); + aMap["Children"] = OUString::number(mxTreeList->GetLevelChildCount(mpEntry)); + aMap["VisibleChildCount"] = OUString::number(mxTreeList->GetVisibleChildCount(mpEntry)); + + return aMap; +} + +void TreeListEntryUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + if (rAction == "COLLAPSE") + { + mxTreeList->Collapse(mpEntry); + } + else if (rAction == "EXPAND") + { + mxTreeList->Expand(mpEntry); + } +} + +std::unique_ptr TreeListEntryUIObject::get_child(const OUString& rID) +{ + sal_Int32 nID = rID.toInt32(); + if (nID >= 0) + { + SvTreeListEntry* pEntry = mxTreeList->GetEntry(mpEntry, nID); + if (!pEntry) + return nullptr; + + return std::unique_ptr(new TreeListEntryUIObject(mxTreeList, pEntry)); + } + + return nullptr; +} + +std::set TreeListEntryUIObject::get_children() const +{ + std::set aChildren; + + size_t nChildren = mxTreeList->GetLevelChildCount(mpEntry); + for (size_t i = 0; i < nChildren; ++i) + { + aChildren.insert(OUString::number(i)); + } + + return aChildren; +} + +OUString TreeListEntryUIObject::get_type() const +{ + return OUString("TreeListEntry"); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit