uitest: provide wrapper for chart objects
This allows now to operate on chart objects and call commands on them. Change-Id: I399b275c563deb507aaf4f3f49373871e733af91
This commit is contained in:
@@ -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
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user