summaryrefslogtreecommitdiffstats
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-07-16 18:07:36 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-07-16 18:27:14 +0200
commitd2b2278aaba7f78afb1d8d3bf8fdb199f5a8cdbb (patch)
treed01cc44ca49fb1f704077d9acee727c574310ea0 /chart2
parentuitest: provide a way to open a dialog through an action on an object (diff)
downloadcore-d2b2278aaba7f78afb1d8d3bf8fdb199f5a8cdbb.tar.gz
core-d2b2278aaba7f78afb1d8d3bf8fdb199f5a8cdbb.zip
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')
-rw-r--r--chart2/source/controller/inc/uiobject.hxx29
-rw-r--r--chart2/source/controller/uitest/uiobject.cxx81
2 files changed, 107 insertions, 3 deletions
diff --git a/chart2/source/controller/inc/uiobject.hxx b/chart2/source/controller/inc/uiobject.hxx
index e458b6d42f33..f5a2ede42ded 100644
--- a/chart2/source/controller/inc/uiobject.hxx
+++ b/chart2/source/controller/inc/uiobject.hxx
@@ -14,6 +14,33 @@
#include "ChartWindow.hxx"
+class ChartUIObject : public UIObject
+{
+public:
+
+ ChartUIObject(VclPtr<chart::ChartWindow> xChartWindow,
+ const OUString& rCID);
+
+ StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override;
+
+ virtual std::set<OUString> get_children() const override;
+
+ virtual OUString get_type() const override;
+
+private:
+
+ OUString maCID;
+ VclPtr<chart::ChartWindow> mxChartWindow;
+ std::vector<std::unique_ptr<OUString>> maCommands;
+
+ DECL_LINK_TYPED(PostCommand, void*, void);
+};
+
class ChartWindowUIObject : public WindowUIObject
{
VclPtr<chart::ChartWindow> mxChartWindow;
@@ -35,7 +62,7 @@ public:
protected:
- virtual OUString get_name() const;
+ virtual OUString get_name() const override;
};
#endif
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 {