[Libreoffice-commits] core.git: sw/source uitest/ui_logger_dsl vcl/source

Ahmed ElShreif (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 1 01:37:34 UTC 2020


 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(-)

New commits:
commit 2e635d22cdbfcfe163b46427d04ebce9fe21a61e
Author:     Ahmed ElShreif <aelshreif7 at gmail.com>
AuthorDate: Fri Aug 28 03:11:44 2020 +0200
Commit:     Ahmed ElShreif <aelshreif7 at gmail.com>
CommitDate: Tue Sep 1 03:36:53 2020 +0200

    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 <markus.mohrhard at googlemail.com>

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 <vcl/scrbar.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 #include <svl/undo.hxx>
 #include <unotools/localedatawrapper.hxx>
@@ -67,6 +69,21 @@
 
 #include <memory>
 
+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 <vcl/menubtn.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/ptrstyle.hxx>
+#include <vcl/uitest/logger.hxx>
+#include <vcl/uitest/eventdescription.hxx>
 
 #include <edtwin.hxx>
 #include <view.hxx>
@@ -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;


More information about the Libreoffice-commits mailing list