diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-07-16 18:07:36 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-07-16 18:27:14 +0200 |
commit | d2b2278aaba7f78afb1d8d3bf8fdb199f5a8cdbb (patch) | |
tree | d01cc44ca49fb1f704077d9acee727c574310ea0 /chart2/source/controller/uitest | |
parent | 1a20e663322d0c37e985df1b9cefdb4827ed74ef (diff) |
uitest: provide wrapper for chart objects
This allows now to operate on chart objects and call commands on them.
Change-Id: I399b275c563deb507aaf4f3f49373871e733af91
Diffstat (limited to 'chart2/source/controller/uitest')
-rw-r--r-- | chart2/source/controller/uitest/uiobject.cxx | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/chart2/source/controller/uitest/uiobject.cxx b/chart2/source/controller/uitest/uiobject.cxx index d686d89aa9d8..51e33bf4d1fd 100644 --- a/chart2/source/controller/uitest/uiobject.cxx +++ b/chart2/source/controller/uitest/uiobject.cxx @@ -14,8 +14,82 @@ #include "ObjectHierarchy.hxx" #include "chartview/ExplicitValueProvider.hxx" +#include <vcl/svapp.hxx> + #include <algorithm> +ChartUIObject::ChartUIObject(VclPtr<chart::ChartWindow> xChartWindow, + const OUString& rCID): + maCID(rCID), + mxChartWindow(xChartWindow) +{ +} + +StringMap ChartUIObject::get_state() +{ + StringMap aMap; + aMap["CID"] = maCID; + + return aMap; +} + +void ChartUIObject::execute(const OUString& rAction, + const StringMap& rParameters) +{ + if (rAction == "SELECT") + { + std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); + + StringMap aParams; + aParams["NAME"] = maCID; + pWindow->execute(rAction, aParams); + } + else if (rAction == "COMMAND") + { + // first select object + std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); + + StringMap aParams; + aParams["NAME"] = maCID; + pWindow->execute("SELECT", aParams); + + auto itr = rParameters.find("COMMAND"); + if (itr == rParameters.end()) + throw css::uno::RuntimeException("missing COMMAND parameter"); + + maCommands.emplace_back(new OUString(itr->second)); + OUString* pCommand = maCommands.rbegin()->get(); + + Application::PostUserEvent(LINK(this, ChartUIObject, PostCommand), pCommand); + } +} + +IMPL_LINK_TYPED(ChartUIObject, PostCommand, void*, pCommand, void) +{ + css::util::URL aURL; + aURL.Path = *static_cast<OUString*>(pCommand); + mxChartWindow->GetController()->dispatch(aURL, css::uno::Sequence<css::beans::PropertyValue>()); +} + +std::unique_ptr<UIObject> ChartUIObject::get_child(const OUString& rID) +{ + std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); + + return pWindow->get_child(rID); +} + +std::set<OUString> ChartUIObject::get_children() const +{ + std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); + + return pWindow->get_children(); +} + +OUString ChartUIObject::get_type() const +{ + return OUString("ChartUIObject for type: "); +} + ChartWindowUIObject::ChartWindowUIObject(VclPtr<chart::ChartWindow> xChartWindow): WindowUIObject(xChartWindow), mxChartWindow(xChartWindow) @@ -59,9 +133,12 @@ void ChartWindowUIObject::execute(const OUString& rAction, WindowUIObject::execute(rAction, rParameters); } -std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& /*rID*/) +std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& rID) { - return nullptr; + if (chart::ObjectIdentifier::isCID(rID)) + return std::unique_ptr<UIObject>(new ChartUIObject(mxChartWindow, rID)); + + throw css::uno::RuntimeException("unknown child"); } namespace { |