From 2e635d22cdbfcfe163b46427d04ebce9fe21a61e Mon Sep 17 00:00:00 2001 From: Ahmed ElShreif Date: Fri, 28 Aug 2020 03:11:44 +0200 Subject: uilogger : Add support in the Logger and DSL for Writer-Comments For example the DSL syntax will be: >>Delete Comment1 >>Leave Comment1 >>Show Comment1 >>Hide Comment1 >>Resolve Comment1 Change-Id: Ibdd52f3a12f1679f80e9f3290868c77fbf942d6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101513 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- sw/source/uibase/docvw/AnnotationWin.cxx | 19 ++++++++ sw/source/uibase/docvw/AnnotationWin2.cxx | 16 +++++++ uitest/ui_logger_dsl/Special_commands.tx | 34 +++++++++++++- uitest/ui_logger_dsl/dsl_core.py | 75 +++++++++++++++++++++++++++++++ vcl/source/uitest/logger.cxx | 18 ++++++++ 5 files changed, 161 insertions(+), 1 deletion(-) diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 579323fd40ef..db719948df8b 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -67,6 +69,21 @@ #include +namespace{ + +void collectUIInformation( const OUString& aevent , const OUString& aID ) +{ + EventDescription aDescription; + aDescription.aID = aID; + aDescription.aParameters = {{"" , ""}}; + aDescription.aAction = aevent; + aDescription.aParent = "MainWindow"; + aDescription.aKeyWord = "SwEditWinUIObject"; + UITestLogger::getInstance().logEvent(aDescription); +} + +} + namespace sw::annotation { SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin, @@ -245,6 +262,7 @@ void SwAnnotationWin::SetResolved(bool resolved) mbResolvedStateUpdated = true; UpdateData(); Invalidate(); + collectUIInformation("SETRESOLVED",get_id()); } void SwAnnotationWin::ToggleResolved() @@ -307,6 +325,7 @@ void SwAnnotationWin::UpdateData() void SwAnnotationWin::Delete() { + collectUIInformation("DELETE",get_id()); if (!mrView.GetWrtShellPtr()->GotoField(*mpFormatField)) return; diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 633b8ebe00d8..10493e45a04a 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -58,6 +58,8 @@ #include #include #include +#include +#include #include #include @@ -80,6 +82,17 @@ using namespace sw::sidebarwindows; namespace { +void collectUIInformation( const OUString& aevent , const OUString& aID ) +{ + EventDescription aDescription; + aDescription.aID = aID; + aDescription.aParameters = {{"" , ""}}; + aDescription.aAction = aevent; + aDescription.aParent = "MainWindow"; + aDescription.aKeyWord = "SwEditWinUIObject"; + UITestLogger::getInstance().logEvent(aDescription); +} + /// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input. void lcl_translateTwips(vcl::Window const & rParent, vcl::Window& rChild, MouseEvent* pMouseEvent) { @@ -1126,6 +1139,7 @@ void SwAnnotationWin::ShowNote() // Invalidate. InvalidateControl(); + collectUIInformation("SHOW",get_id()); } void SwAnnotationWin::HideNote() @@ -1141,6 +1155,7 @@ void SwAnnotationWin::HideNote() } if (mpShadow && mpShadow->isVisible()) mpShadow->setVisible(false); + collectUIInformation("HIDE",get_id()); } void SwAnnotationWin::InvalidateControl() @@ -1510,6 +1525,7 @@ void SwAnnotationWin::SwitchToFieldPos() if (aCount) mrView.GetDocShell()->GetWrtShell()->SwCursorShell::Right(aCount, 0); GrabFocusToDocument(); + collectUIInformation("LEAVE",get_id()); } void SwAnnotationWin::SetChangeTracking( const SwPostItHelper::SwLayoutStatus aLayoutStatus, diff --git a/uitest/ui_logger_dsl/Special_commands.tx b/uitest/ui_logger_dsl/Special_commands.tx index 9a8dc4cff6c4..9d37029a5e95 100644 --- a/uitest/ui_logger_dsl/Special_commands.tx +++ b/uitest/ui_logger_dsl/Special_commands.tx @@ -26,7 +26,7 @@ SpecialCommand: writer_command: writer_Type_command | writer_Select_command | writer_GOTO_command | writer_Create_table | writer_Copy_Text | writer_Cut_Text | - writer_Paste_Text | writer_Insert_BreakPage + writer_Paste_Text | writer_Insert_BreakPage | writer_Comment_command ; writer_Type_command: 'Type on writer' what_to_type=Type_options @@ -220,4 +220,36 @@ draw_Delete_Page: ; draw_Rename_Page: 'Rename The Selected Page from ' old_name=STRING 'to' new_name=STRING +; + +//=================================================================// +/* + This part for all the Writer Comment statements: + + 1) Leave + 2) Hide + 3) Show + 4) Delete + 5) Set Resolved + + then we can add whatever we need in the future +*/ +writer_Comment_command: + writer_Comment_leave | writer_Comment_show | writer_Comment_hide | + writer_Comment_delete | writer_Comment_setresolved +; +writer_Comment_leave: + 'Leave ' comment_id=STRING +; +writer_Comment_show: + 'Show ' comment_id=STRING +; +writer_Comment_hide: + 'Hide ' comment_id=STRING +; +writer_Comment_delete: + 'Delete ' comment_id=STRING +; +writer_Comment_setresolved: + 'Resolve' comment_id=STRING ; \ No newline at end of file diff --git a/uitest/ui_logger_dsl/dsl_core.py b/uitest/ui_logger_dsl/dsl_core.py index 062415f00fb1..fa17391eafa7 100644 --- a/uitest/ui_logger_dsl/dsl_core.py +++ b/uitest/ui_logger_dsl/dsl_core.py @@ -121,6 +121,11 @@ class ul_Compiler: "setZoom_command": self.handle_setZoom_command, "draw_Type_command": self.handle_draw_Type_command, "SideBar": self.handle_SideBar, + "writer_Comment_leave":self.handle_writer_Comment_leave, + "writer_Comment_show":self.handle_writer_Comment_show, + "writer_Comment_hide":self.handle_writer_Comment_hide, + "writer_Comment_delete":self.handle_writer_Comment_delete, + "writer_Comment_setresolved":self.handle_writer_Comment_setresolved, "writer_Copy_Text": self.do_nothing, "writer_Cut_Text": self.do_nothing, "writer_Paste_Text": self.do_nothing, @@ -916,6 +921,76 @@ class ul_Compiler: self.prev_command = math_element_selector + def handle_writer_Comment_leave(self,writer_Comment_leave): + + self.init_app() + + self.init_Object( + writer_Comment_leave.comment_id, writer_Comment_leave.comment_id, "MainWindow" + ) + + self.write_line_with_one_parameters( + writer_Comment_leave.comment_id, "LEAVE", "", "" + ) + + self.prev_command = writer_Comment_leave + + def handle_writer_Comment_show(self,writer_Comment_show): + + self.init_app() + + self.init_Object( + writer_Comment_show.comment_id, writer_Comment_show.comment_id, "MainWindow" + ) + + self.write_line_with_one_parameters( + writer_Comment_show.comment_id, "SHOW", "", "" + ) + + self.prev_command = writer_Comment_show + + def handle_writer_Comment_hide(self,writer_Comment_hide): + + self.init_app() + + self.init_Object( + writer_Comment_hide.comment_id, writer_Comment_hide.comment_id, "MainWindow" + ) + + self.write_line_with_one_parameters( + writer_Comment_hide.comment_id, "HIDE", "", "" + ) + + self.prev_command = writer_Comment_hide + + def handle_writer_Comment_delete(self,writer_Comment_delete): + + self.init_app() + + self.init_Object( + writer_Comment_delete.comment_id, writer_Comment_delete.comment_id, "MainWindow" + ) + + self.write_line_with_one_parameters( + writer_Comment_delete.comment_id, "DELETE", "", "" + ) + + self.prev_command = writer_Comment_delete + + def handle_writer_Comment_setresolved(self,writer_Comment_setresolved): + + self.init_app() + + self.init_Object( + writer_Comment_setresolved.comment_id, writer_Comment_setresolved.comment_id, "MainWindow" + ) + + self.write_line_with_one_parameters( + writer_Comment_setresolved.comment_id, "RESOLVE", "", "" + ) + + self.prev_command = writer_Comment_setresolved + def handle_setZoom_command(self, setZoom_command): self.init_app() diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx index a1927d44b2eb..5b3847a6cb3f 100644 --- a/vcl/source/uitest/logger.cxx +++ b/vcl/source/uitest/logger.cxx @@ -559,6 +559,24 @@ void UITestLogger::logEvent(const EventDescription& rDescription) } } } + else if (rDescription.aKeyWord == "SwEditWinUIObject") + { + if(rDescription.aAction=="LEAVE"){ + aLogLine = "Leave '" + rDescription.aID + "'"; + } + else if(rDescription.aAction=="SHOW"){ + aLogLine = "Show '" + rDescription.aID + "'"; + } + else if(rDescription.aAction=="HIDE"){ + aLogLine = "Hide '" + rDescription.aID + "'"; + } + else if(rDescription.aAction=="DELETE"){ + aLogLine = "Delete '" + rDescription.aID + "'"; + } + else if(rDescription.aAction=="SETRESOLVED"){ + aLogLine = "Resolve '" + rDescription.aID + "'"; + } + } else if (rDescription.aParent == "element_selector") { aLogLine = "Select element no " + rDescription.aID + " From " + rDescription.aParent; -- cgit