[Libreoffice-commits] core.git: sfx2/source vcl/source

Ahmed ElShreif (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 29 16:33:09 UTC 2019


 sfx2/source/control/unoctitm.cxx |    2 
 vcl/source/uitest/logger.cxx     |   82 ++++++++++++++++++++++++++++++++++++---
 vcl/source/uitest/uiobject.cxx   |   68 +++++++++++++++++++++-----------
 vcl/source/window/dialog.cxx     |    6 +-
 4 files changed, 127 insertions(+), 31 deletions(-)

New commits:
commit 624530549f30572cb7fb137cbadecfab9a75fc8c
Author:     Ahmed ElShreif <aelshreif7 at gmail.com>
AuthorDate: Mon Jun 10 01:20:59 2019 +0200
Commit:     Ahmed ElShreif <aelshreif7 at gmail.com>
CommitDate: Sat Jun 29 18:28:14 2019 +0200

    Rewrite all the logger statements with the new grammar syntax
    
    Finished parts from old logger:
            1) UNOCommands
            2) StarterCommands
            3) UIObjectCommand
            4) DialogCommand
            5) SpecialCommand
    
    Change-Id: Ia521efef0abe1a351b9a4fcabaab6dbf20e8fc89

diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index aba1357b0ddc..71cccb05d4e2 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -601,7 +601,7 @@ void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css::
     if (!pFile)
         return;
 
-    UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete, rArgs);
+    UITestLogger::getInstance().logCommand("Send UNO Command (\"" + rURL.Complete + "\") ", rArgs);
 }
 
 }
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx
index d100d1bbf125..742d8f4ab63a 100644
--- a/vcl/source/uitest/logger.cxx
+++ b/vcl/source/uitest/logger.cxx
@@ -213,8 +213,21 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
 
     OUString aParentID = pParent->get_id();
 
-    OUString aContent = pUIObject->get_type() + " Action:TYPE Id:" +
-            rID + " Parent:"+ aParentID +" " + aKeyCode;
+    OUString aContent;
+
+    if(pUIObject->get_type()=="EditUIObject"){
+        aContent =  "Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+    }
+    else if(pUIObject->get_type()=="SwEditWinUIObject" && rID=="writer_edit"){
+        aContent = "Type on writer " + aKeyCode ;
+    }
+    else if(pUIObject->get_type()=="ScGridWinUIObject" && rID=="grid_window"){
+        aContent = "Type on current cell " + aKeyCode ;
+    }
+    else{
+        aContent= pUIObject->get_type() + " Action:TYPE Id:" +
+                rID + " Parent:"+ aParentID +" " + aKeyCode;
+    }
     maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
 }
 
@@ -240,16 +253,75 @@ OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
     return aParameterString.makeStringAndClear();
 }
 
+OUString GetValueInMapWithIndex(const std::map<OUString, OUString>& rParameters,sal_Int32 index)
+{
+    sal_Int32 j=0;
+
+    std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
+
+    for ( ; itr != rParameters.end() && j<index ; ++itr,++j);
+
+    return itr->second;
+}
+
+
+OUString GetKeyInMapWithIndex(const std::map<OUString, OUString>& rParameters,sal_Int32 index)
+{
+    sal_Int32 j=0;
+
+    std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
+
+    for ( ; itr != rParameters.end() && j<index ; ++itr,++j);
+
+    return itr->first;
+}
+
 }
 
 void UITestLogger::logEvent(const EventDescription& rDescription)
 {
     OUString aParameterString = StringMapToOUString(rDescription.aParameters);
 
-    OUString aLogLine = rDescription.aKeyWord + " Action:" +
-        rDescription.aAction + " Id:" + rDescription.aID +
-        " Parent:" + rDescription.aParent + aParameterString;
+    //here we will customize our statments depending on the caller of this function
+    OUString aLogLine ;
+
+    if(rDescription.aID=="writer_edit"){
+
+        if(rDescription.aAction=="GOTO"){
+            aLogLine = "GOTO page number " + GetValueInMapWithIndex(rDescription.aParameters,0);
+        }
+        else if(rDescription.aAction=="SET"){
+            aLogLine =  "Set Zoom to be "  + GetValueInMapWithIndex(rDescription.aParameters,0);
+        }
+        else if(rDescription.aAction=="SELECT"){
+            OUString to = GetValueInMapWithIndex(rDescription.aParameters,0);
+            OUString from =   GetValueInMapWithIndex(rDescription.aParameters,1);
+            aLogLine =  "Select from Pos "  +  from + " to " + to ;
+        }
+    }
+    else if(rDescription.aID=="grid_window"){
 
+        if(rDescription.aAction=="SELECT"){
+            OUString type = GetKeyInMapWithIndex(rDescription.aParameters,0);
+            if(type=="CELL" || type=="RANGE"){
+                aLogLine = "Select from calc" + aParameterString ;
+            }
+            else if(type=="TABLE")
+            {
+                aLogLine = "Switch to sheet number " + GetValueInMapWithIndex(rDescription.aParameters,0) ;
+            }
+        }
+        else if(rDescription.aAction=="LAUNCH"){
+            aLogLine = "Lanuch AutoFilter from Col "+
+            GetValueInMapWithIndex(rDescription.aParameters,2) +
+            " and Row " + GetValueInMapWithIndex(rDescription.aParameters,1);
+        }
+    }
+    else{
+        aLogLine = rDescription.aKeyWord + " Action:" +
+            rDescription.aAction + " Id:" + rDescription.aID +
+            " Parent:" + rDescription.aParent + aParameterString;
+    }
     log(aLogLine);
 }
 
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index b8932913cf53..583c4ac38659 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -584,8 +584,34 @@ OUString ButtonUIObject::get_action(VclEventId nEvent) const
 {
     if (nEvent == VclEventId::ButtonClick)
     {
-        return this->get_type() + " Action:CLICK Id:" + mxButton->get_id() + " Parent:" +
-            get_top_parent(mxButton)->get_id();
+        if(mxButton->get_id()=="writer_all")
+        {
+            return "Start writer" ;
+        }
+        else if(mxButton->get_id()=="calc_all")
+        {
+            return "Start calc" ;
+        }
+        else if(mxButton->get_id()=="impress_all")
+        {
+            return "Start impress" ;
+        }
+        else if(mxButton->get_id()=="draw_all")
+        {
+            return "Start draw" ;
+        }
+        else if(mxButton->get_id()=="math_all")
+        {
+            return "Start math" ;
+        }
+        else if(mxButton->get_id()=="database_all")
+        {
+            return "Start database" ;
+        }
+        else{
+            return "Click on '" + mxButton->get_id() + "' from "+
+                get_top_parent(mxButton)->get_id();
+        }
     }
     else
         return WindowUIObject::get_action(nEvent);
@@ -708,11 +734,12 @@ OUString EditUIObject::get_action(VclEventId nEvent) const
         const Selection& rSelection  = mxEdit->GetSelection();
         long nMin = rSelection.Min();
         long nMax = rSelection.Max();
-        return this->get_type() + " Action:SELECT Id:" +
+        return  "Select in '" +
                 mxEdit->get_id() +
-                " Parent:" + get_top_parent(mxEdit)->get_id() +
-                " {\"FROM\": \"" + OUString::number(nMin) + "\", \"TO\": \"" +
-                OUString::number(nMax) + "\"}";
+                "' {\"FROM\": \"" + OUString::number(nMin) + "\", \"TO\": \"" +
+                OUString::number(nMax) + "\"} from "
+                + get_top_parent(mxEdit)->get_id()
+                ;
     }
     else
         return WindowUIObject::get_action(nEvent);
@@ -828,7 +855,7 @@ OUString CheckBoxUIObject::get_action(VclEventId nEvent) const
 {
     if (nEvent == VclEventId::CheckboxToggle)
     {
-        return this->get_type() + " Action:CLICK Id:" + mxCheckBox->get_id() + " Parent:" +
+        return "Toggle '" + mxCheckBox->get_id() + "' CheckBox from " +
             get_top_parent(mxCheckBox)->get_id();
     }
     else
@@ -878,7 +905,7 @@ OUString RadioButtonUIObject::get_action(VclEventId nEvent) const
 {
     if (nEvent == VclEventId::RadiobuttonToggle)
     {
-        return this->get_type() + " Action:CLICK Id:" + mxRadioButton->get_id() + " Parent:" +
+        return "Select '" + mxRadioButton->get_id() + "' RadioButton from " +
             get_top_parent(mxRadioButton)->get_id();
     }
     else
@@ -984,9 +1011,8 @@ OUString ListBoxUIObject::get_action(VclEventId nEvent) const
     if (nEvent == VclEventId::ListboxSelect)
     {
         sal_Int32 nPos = mxListBox->GetSelectedEntryPos();
-        return this->get_type() + " Action:SELECT Id:" + mxListBox->get_id() +
-            " Parent:" + get_top_parent(mxListBox)->get_id() +
-            " {\"POS\": \"" + OUString::number(nPos) + "\"}";
+        return "Select element with position " + OUString::number(nPos) +
+                 " in '" + mxListBox->get_id() +"' from" + get_top_parent(mxListBox)->get_id() ;
     }
     else if (nEvent == VclEventId::ListboxFocus)
     {
@@ -1060,10 +1086,9 @@ OUString ComboBoxUIObject::get_action(VclEventId nEvent) const
     if (nEvent == VclEventId::ComboboxSelect)
     {
         sal_Int32 nPos = mxComboBox->GetSelectedEntryPos();
-        return this->get_type() + " Action:SELECT Id:" +
-                mxComboBox->get_id() +
-                " Parent:" + get_top_parent(mxComboBox)->get_id() +
-                " {\"POS\": \"" + OUString::number(nPos) + "\"}";
+        return "select in '" + mxComboBox->get_id() +
+                "' ComboBox item number " + OUString::number(nPos) +
+                " from " + get_top_parent(mxComboBox)->get_id();
     }
     else
         return WindowUIObject::get_action(nEvent);
@@ -1176,13 +1201,13 @@ OUString SpinFieldUIObject::get_action(VclEventId nEvent) const
 {
     if (nEvent == VclEventId::SpinfieldUp)
     {
-        return this->get_type() + " Action:UP Id:" + mxSpinField->get_id() +
-            " Parent:" + get_top_parent(mxSpinField)->get_id();
+        return "Increase '" + mxSpinField->get_id() +
+            "' from " + get_top_parent(mxSpinField)->get_id();
     }
     else if (nEvent == VclEventId::SpinfieldDown)
     {
-        return this->get_type() + " Action:DOWN Id:" + mxSpinField->get_id() +
-            " Parent:" + get_top_parent(mxSpinField)->get_id();
+        return "Decrease '" + mxSpinField->get_id() +
+            "' from " + get_top_parent(mxSpinField)->get_id();
     }
     else
         return WindowUIObject::get_action(nEvent);
@@ -1244,9 +1269,8 @@ OUString TabControlUIObject::get_action(VclEventId nEvent) const
     if (nEvent == VclEventId::TabpageActivate)
     {
         sal_Int32 nPageId = mxTabControl->GetCurPageId();
-        return this->get_type() + " Action:SELECT Id:" + mxTabControl->get_id() +
-            " Parent:" + get_top_parent(mxTabControl)->get_id() +
-            " {\"POS\": \"" + OUString::number(mxTabControl->GetPagePos(nPageId)) + "\"}";
+        return "Choose Tab number " + OUString::number(mxTabControl->GetPagePos(nPageId)) +
+                " from '" + mxTabControl->get_id() + "'" ;
     }
     else
         return WindowUIObject::get_action(nEvent);
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 9d60b796b035..dd5a7f05c779 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -640,7 +640,7 @@ void Dialog::dispose()
     css::document::DocumentEvent aObject;
     aObject.EventName = "DialogClosed";
     xEventBroadcaster->documentEventOccured(aObject);
-    UITestLogger::getInstance().log("DialogClosed");
+    UITestLogger::getInstance().log("Close Dialog");
 
     if (comphelper::LibreOfficeKit::isActive())
     {
@@ -988,9 +988,9 @@ bool Dialog::ImplStartExecute()
     aObject.EventName = "DialogExecute";
     xEventBroadcaster->documentEventOccured(aObject);
     if (bModal)
-        UITestLogger::getInstance().log("ModalDialogExecuted Id:" + get_id());
+        UITestLogger::getInstance().log("Open " + get_id());
     else
-        UITestLogger::getInstance().log("ModelessDialogExecuted Id:" + get_id());
+        UITestLogger::getInstance().log("Open " + get_id());
 
     return true;
 }


More information about the Libreoffice-commits mailing list