diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-04-02 20:13:32 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-04-19 15:06:19 +0200 |
commit | 4a3247f090fc1d254311e7e0a15e2c6e51b915f8 (patch) | |
tree | cdd7fac729f33e4628b510b5636cd62f4d783643 /vcl | |
parent | b46bd60ecc3245d204b57957cea876231a71cd28 (diff) |
jsdialog: uitest: handle click for drawing area
Change-Id: I5ea78697b87f4b2a468f8507470b62031bee4aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113524
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114202
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/uitest/uiobject.cxx | 39 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 8 |
2 files changed, 47 insertions, 0 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx index 92122b54caab..663d7586fc1b 100644 --- a/vcl/source/uitest/uiobject.cxx +++ b/vcl/source/uitest/uiobject.cxx @@ -1732,6 +1732,45 @@ DrawingAreaUIObject::~DrawingAreaUIObject() { } +void DrawingAreaUIObject::execute(const OUString& rAction, const StringMap& rParameters) +{ + if (rAction == "CLICK") + { + // POSX and POSY are percentage of width/height dimensions + if (rParameters.find("POSX") != rParameters.end() && + rParameters.find("POSY") != rParameters.end()) + { + auto aPosX = rParameters.find("POSX"); + auto aPosY = rParameters.find("POSY"); + + OString sPosX2 = OUStringToOString(aPosX->second, RTL_TEXTENCODING_ASCII_US); + OString sPoxY2 = OUStringToOString(aPosY->second, RTL_TEXTENCODING_ASCII_US); + + if (!sPosX2.isEmpty() && !sPoxY2.isEmpty()) + { + double fPosX = std::atof(sPosX2.getStr()); + double fPosY = std::atof(sPoxY2.getStr()); + + fPosX = fPosX * mxDrawingArea->GetOutputWidthPixel(); + fPosY = fPosY * mxDrawingArea->GetOutputHeightPixel(); + + MouseEvent aEvent(Point(fPosX, fPosY), 1, MouseEventModifiers::NONE, MOUSE_LEFT, 0); + mxDrawingArea->MouseButtonDown(aEvent); + mxDrawingArea->MouseButtonUp(aEvent); + } + } + } + else + WindowUIObject::execute(rAction, rParameters); +} + +std::unique_ptr<UIObject> DrawingAreaUIObject::create(vcl::Window* pWindow) +{ + VclDrawingArea* pVclDrawingArea = dynamic_cast<VclDrawingArea*>(pWindow); + assert(pVclDrawingArea); + return std::unique_ptr<UIObject>(new DrawingAreaUIObject(pVclDrawingArea)); +} + IconViewUIObject::IconViewUIObject(const VclPtr<SvTreeListBox>& xIconView): TreeListUIObject(xIconView) { diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 63d5d1536772..9b0ee7452577 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -29,6 +29,7 @@ #include <window.h> #include <boost/multi_array.hpp> #include <vcl/toolkit/vclmedit.hxx> +#include <vcl/uitest/uiobject.hxx> #include <sal/log.hxx> #include <tools/json_writer.hxx> @@ -3005,4 +3006,11 @@ void VclDrawingArea::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) rJsonWriter.put("text", GetQuickHelpText()); } +FactoryFunction VclDrawingArea::GetUITestFactory() const +{ + if (m_pFactoryFunction) + return m_pFactoryFunction; + return DrawingAreaUIObject::create; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |