[Libreoffice-commits] core.git: include/vcl uitest/ui_logger_dsl vcl/source
Ahmed ElShreif (via logerrit)
logerrit at kemper.freedesktop.org
Sun Aug 23 22:26:38 UTC 2020
include/vcl/uitest/logger.hxx | 2 ++
include/vcl/uitest/uiobject.hxx | 2 ++
uitest/ui_logger_dsl/UI_Object_commands.tx | 6 +++++-
uitest/ui_logger_dsl/dsl_core.py | 20 ++++++++++++++++++++
vcl/source/uitest/logger.cxx | 15 +++++++++++++++
vcl/source/uitest/uiobject.cxx | 11 +++++++++++
vcl/source/window/toolbox2.cxx | 2 ++
7 files changed, 57 insertions(+), 1 deletion(-)
New commits:
commit 3ceccd384cb61686a96e73821035c6ac5d0d1604
Author: Ahmed ElShreif <aelshreif7 at gmail.com>
AuthorDate: Sun Aug 16 10:24:20 2020 +0200
Commit: Ahmed ElShreif <aelshreif7 at gmail.com>
CommitDate: Mon Aug 24 00:26:03 2020 +0200
uilogger : Add support in the Logger and DSL for the ToolBox
The support is tested on the FindBar and it works well .
For example the DSL syntax in the FindBar should be like:
>>"Click on item number 3 in FindBar"
Change-Id: I3ec5f5afc260df4b38dc4e420fcc48d9c774c29f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100811
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx
index a2339b8b8e39..927c9cbf38ef 100644
--- a/include/vcl/uitest/logger.hxx
+++ b/include/vcl/uitest/logger.hxx
@@ -44,6 +44,8 @@ public:
void logAction(VclPtr<Control> const& xUIElement, VclEventId nEvent);
+ void logAction(vcl::Window* const& xUIWin, VclEventId nEvent);
+
void log(const OUString& rString);
void logKeyInput(VclPtr<vcl::Window> const& xUIElement, const KeyEvent& rEvent);
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index 50533157e19b..7d709a342eb4 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -499,6 +499,8 @@ public:
static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+ virtual OUString get_action(VclEventId nEvent) const override;
+
private:
virtual OUString get_name() const override;
diff --git a/uitest/ui_logger_dsl/UI_Object_commands.tx b/uitest/ui_logger_dsl/UI_Object_commands.tx
index 2d3724f2d11e..a3fe81b72b2b 100644
--- a/uitest/ui_logger_dsl/UI_Object_commands.tx
+++ b/uitest/ui_logger_dsl/UI_Object_commands.tx
@@ -10,12 +10,13 @@ import type_options
6) ComboBoxUIObject ( Select event )
7) SpinUIObject ( Increase event - Decrease event )
8) TabControlUIObject ( Change tab event )
+ 9) ToolBoxUIObject ( Click on item event )
*/
UIObjectCommand:
ButtonUIObject | CheckBoxUIObject | EditUIObject |
RadioButtonUIObject | ListBoxUIObject | ComboBoxUIObject |
- SpinFieldUIObject | TabControlUIObject
+ SpinFieldUIObject | TabControlUIObject | ToolBoxUIObject
;
ButtonUIObject:
@@ -42,6 +43,9 @@ SpinFieldUIObject:
ListBoxUIObject:
'Select element with position ' POS=INT 'in' list_id=STRING ('from' parent_id=ID)?
;
+ToolBoxUIObject:
+ 'Click on item number' POS=INT 'in' toolbox_id=ID
+;
//=============================================================
//helper grammar for EditUIObject
action_on_UIObject:
diff --git a/uitest/ui_logger_dsl/dsl_core.py b/uitest/ui_logger_dsl/dsl_core.py
index ebe936bba76a..feb69b76a320 100644
--- a/uitest/ui_logger_dsl/dsl_core.py
+++ b/uitest/ui_logger_dsl/dsl_core.py
@@ -103,6 +103,7 @@ class ul_Compiler:
"ListBoxUIObject": self.handle_List_box,
"SpinFieldUIObject": self.handle_spin_field,
"EditUIObject": self.handle_Edit_uiObject,
+ "ToolBoxUIObject": self.handle_ToolBox_uiObject,
"writer_Type_command": self.handle_writer_type,
"writer_Select_command": self.handle_writer_select,
"writer_GOTO_command": self.handle_writer_goto,
@@ -607,6 +608,25 @@ class ul_Compiler:
self.prev_command = EditUIObject
+ def handle_ToolBox_uiObject(self, ToolBoxUIObject):
+ name_of_obj = ""
+ if keyword.iskeyword(ToolBoxUIObject.toolbox_id):
+ name_of_obj = "x" + ToolBoxUIObject.toolbox_id
+ else:
+ name_of_obj = ToolBoxUIObject.toolbox_id
+
+ self.init_Object(
+ name_of_obj,
+ ToolBoxUIObject.toolbox_id,
+ self.last_parent[self.parent_hierarchy_count],
+ )
+
+ self.write_line_with_one_parameters(
+ name_of_obj, "CLICK", "POS", ToolBoxUIObject.POS
+ )
+
+ self.prev_command = ToolBoxUIObject
+
def handle_writer_type(self, writer_Type_command):
self.init_app()
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx
index 8cd0c4b6f15f..b7a9e02ac48a 100644
--- a/vcl/source/uitest/logger.cxx
+++ b/vcl/source/uitest/logger.cxx
@@ -166,6 +166,21 @@ void UITestLogger::logAction(VclPtr<Control> const& xUIElement, VclEventId nEven
maStream.WriteLine(OUStringToOString(aAction, RTL_TEXTENCODING_UTF8));
}
+void UITestLogger::logAction(vcl::Window* const& xUIWin, VclEventId nEvent)
+{
+ if (!mbValid)
+ return;
+
+ if (xUIWin->get_id().isEmpty())
+ return;
+
+ std::unique_ptr<UIObject> pUIObject = xUIWin->GetUITestFactory()(xUIWin);
+ OUString aAction = pUIObject->get_action(nEvent);
+
+ if (!aAction.isEmpty())
+ maStream.WriteLine(OUStringToOString(aAction, RTL_TEXTENCODING_UTF8));
+}
+
void UITestLogger::log(const OUString& rString)
{
if (!mbValid)
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 38007063bd3a..d0dc54274235 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1591,6 +1591,17 @@ void ToolBoxUIObject::execute(const OUString& rAction,
WindowUIObject::execute(rAction, rParameters);
}
+OUString ToolBoxUIObject::get_action(VclEventId nEvent) const
+{
+ if (nEvent == VclEventId::ToolboxClick)
+ {
+ return "Click on item number " + OUString::number(mxToolBox->GetCurItemId()) +
+ " in " + mxToolBox->get_id();
+ }
+ else
+ return WindowUIObject::get_action(nEvent);
+}
+
StringMap ToolBoxUIObject::get_state()
{
StringMap aMap = WindowUIObject::get_state();
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 9538410d5b6d..b7e094447383 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -18,6 +18,7 @@
*/
#include <sal/config.h>
+#include <vcl/uitest/logger.hxx>
#include <sal/log.hxx>
#include <comphelper/processfactory.hxx>
@@ -324,6 +325,7 @@ void ToolBox::Click()
{
CallEventListeners( VclEventId::ToolboxClick );
maClickHdl.Call( this );
+ UITestLogger::getInstance().logAction( this, VclEventId::ToolboxClick);
}
void ToolBox::DoubleClick()
More information about the Libreoffice-commits
mailing list