summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-04-02 20:13:32 +0200
committerJan Holesovsky <kendy@collabora.com>2021-04-14 11:06:08 +0200
commit5f18922496ec60255097048d9b00b70fc6ccbba5 (patch)
treefc32a0e0f09d16bf7a6cffd38c6a0f1e386078bf /vcl
parentd8d1b869e8554c0aa1e13114b9fe1fdc236c47d8 (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>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/uitest/uiobject.cxx50
-rw-r--r--vcl/source/window/layout.cxx8
2 files changed, 58 insertions, 0 deletions
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 2c6010dc205d..c10cc5f21d9d 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -11,6 +11,7 @@
#include <vcl/event.hxx>
#include <vcl/tabpage.hxx>
+#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/combobox.hxx>
#include <vcl/toolkit/spin.hxx>
@@ -1485,6 +1486,55 @@ std::unique_ptr<UIObject> TabControlUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new TabControlUIObject(pTabControl));
}
+DrawingAreaUIObject::DrawingAreaUIObject(const VclPtr<VclDrawingArea>& rDrawingArea)
+ : WindowUIObject(rDrawingArea)
+ , mxDrawingArea(rDrawingArea.get())
+{
+ assert(mxDrawingArea);
+}
+
+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));
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 4e2efa065439..110ffa6b4f87 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -17,6 +17,7 @@
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <vcl/messagedialog.hxx>
+#include <vcl/uitest/uiobject.hxx>
#include <window.h>
#include <boost/multi_array.hpp>
#include <boost/property_tree/ptree.hpp>
@@ -2721,4 +2722,11 @@ bool isLayoutEnabled(const vcl::Window *pWindow)
return pChild && isContainerWindow(*pChild) && !pChild->GetWindow(GetWindowType::Next);
}
+FactoryFunction VclDrawingArea::GetUITestFactory() const
+{
+ if (m_pFactoryFunction)
+ return m_pFactoryFunction;
+ return DrawingAreaUIObject::create;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */