summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-04-02 20:13:32 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-04-16 14:55:04 +0200
commitebeb1d1ae554e8301d876b19afc05f454acdfc1c (patch)
treee30baa02e46223a07b07e98eb135263f6ad97c2e
parentf38465834acf42b6a6023ea4b1bb7cdd09c77030 (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>
-rw-r--r--desktop/source/lib/init.cxx11
-rw-r--r--include/vcl/layout.hxx7
-rw-r--r--include/vcl/uitest/uiobject.hxx2
-rw-r--r--vcl/source/uitest/uiobject.cxx39
-rw-r--r--vcl/source/window/layout.cxx8
5 files changed, 61 insertions, 6 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e2027ab218ba..cd4b3da2d729 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3809,6 +3809,17 @@ static void lcl_sendDialogEvent(unsigned long long int nWindowId, const char* pA
aMap["VALUE"] = aMap["data"];
pUIWindow->execute(sValue, aMap);
}
+ else if (sAction == "click" && aMap["type"] == "drawingarea")
+ {
+ int separatorPos = aMap["data"].indexOf(';');
+ if (separatorPos > 0)
+ {
+ // x;y
+ aMap["POSX"] = aMap["data"].copy(0, separatorPos);
+ aMap["POSY"] = aMap["data"].copy(separatorPos + 1);
+ }
+ pUIWindow->execute(sClickAction, aMap);
+ }
else
pUIWindow->execute(sClickAction, aMap);
}
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 9a896915b1ed..5a2b7310ea48 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -707,12 +707,7 @@ private:
}
}
virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override;
- virtual FactoryFunction GetUITestFactory() const override
- {
- if (m_pFactoryFunction)
- return m_pFactoryFunction;
- return Control::GetUITestFactory();
- }
+ virtual FactoryFunction GetUITestFactory() const override;
public:
VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 1a2c192a4c63..b4df10a40c9e 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -557,6 +557,8 @@ protected:
public:
DrawingAreaUIObject(const VclPtr<vcl::Window>& rDrawingArea);
virtual ~DrawingAreaUIObject() override;
+ virtual void execute(const OUString& rAction, const StringMap& rParameters) override;
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
};
#endif
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 4d8390e212a2..11c6e7ec7d6e 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1735,6 +1735,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 d5e5839583fd..0a79fb7f78dc 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -30,6 +30,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>
@@ -2954,4 +2955,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: */