sc/qa/uitest/calc_tests/formatCells.py          |    8 ---
 sc/qa/uitest/calc_tests6/tdf107267.py           |   12 -----
 sc/qa/uitest/calc_tests8/tdf126248.py           |    1 
 sd/qa/uitest/impress_tests/customSlideShow.py   |    1 
 sw/qa/uitest/findReplace/findReplace.py         |    1 
 sw/qa/uitest/writer_tests2/deleteAllComments.py |    1 
 sw/qa/uitest/writer_tests2/formatParagraph.py   |    1 
 uitest/demo_ui/listbox.py                       |    9 ----
 uitest/demo_ui/spinfield.py                     |    6 --
 uitest/demo_ui/tabdialog.py                     |    6 --
 vcl/source/uitest/uiobject.cxx                  |   50 ++++++++++++------------
 11 files changed, 25 insertions(+), 71 deletions(-)

New commits:
commit f1cc5d2229956e3698fd40a4d900fe45e7f8e160
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Mar 14 14:37:19 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Mar 17 12:30:41 2021 +0100

    throw exception for errors in uitest actions
    
    so we abort early when a uitest goes wrong,
    instead of letting tests become fragile
    because it looks like its passing, but the code
    is just accidentally working
    
    Remove code in python uitests that was not actually
    doing anything (and now crashes because we throw an exception
    for actions that don't mean anything)
    
    Change-Id: I9c52f9fdc06f1c01e9b93b58a5200f9c3684db1f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112471
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/qa/uitest/calc_tests/formatCells.py 
b/sc/qa/uitest/calc_tests/formatCells.py
index 3bb78348fac2..62c1e55c7e9c 100644
--- a/sc/qa/uitest/calc_tests/formatCells.py
+++ b/sc/qa/uitest/calc_tests/formatCells.py
@@ -41,14 +41,6 @@ class formatCell(UITestCase):
         props3 = {"TEXT": "English (USA)"}
         actionProps3 = mkPropertyValues(props3)
         xlanguagelb.executeAction("SELECT", actionProps3)
-        #set Number
-        props = {"TEXT": "Number"}
-        actionProps = mkPropertyValues(props)
-        xliststore1.executeAction("SELECT", actionProps)
-        #set Standard
-        props2 = {"TEXT": "Standard"}
-        actionProps2 = mkPropertyValues(props2)
-        xliststore2.executeAction("SELECT", actionProps2)
         #other properties
         xdecimalsed.executeAction("UP", tuple())
         xleadzerosed.executeAction("UP", tuple())
diff --git a/sc/qa/uitest/calc_tests6/tdf107267.py 
b/sc/qa/uitest/calc_tests6/tdf107267.py
index ec39c7b4b366..70350a15e127 100644
--- a/sc/qa/uitest/calc_tests6/tdf107267.py
+++ b/sc/qa/uitest/calc_tests6/tdf107267.py
@@ -40,10 +40,6 @@ class Subtotals(UITestCase):
 #        x6Entry = xTreeList.getChild("5")
 #        xFirstEntry.executeAction("CLICK", tuple())
         #use the Max function
-        xfunctions = xDialog.getChild("functions")
-        propsF = {"TEXT": "Max"}
-        actionPropsF = mkPropertyValues(propsF)
-        xfunctions.executeAction("SELECT", actionPropsF)
 
         #= 2nd group =5. Group by "Person Number", select "shipping time" and 
use the Min function.
         select_pos(xTabs, "1")
@@ -57,10 +53,6 @@ class Subtotals(UITestCase):
 #        x6Entry = xTreeList.getChild("5")
 #        xFirstEntry.executeAction("CLICK", tuple())
         #use the Min function
-        xfunctions = xDialog.getChild("functions")
-        propsF2 = {"TEXT": "Min"}
-        actionPropsF2 = mkPropertyValues(propsF2)
-        xfunctions.executeAction("SELECT", actionPropsF2)
 
         #= 3rd group = Group by "Person Number", select "shipping time" and 
use the Average function.
         select_pos(xTabs, "2")
@@ -74,10 +66,6 @@ class Subtotals(UITestCase):
 #        x6Entry = xTreeList.getChild("5")
 #        xFirstEntry.executeAction("CLICK", tuple())
         #use the Average function
-        xfunctions = xDialog.getChild("functions")
-        propsF3 = {"TEXT": "Average"}
-        actionPropsF3 = mkPropertyValues(propsF3)
-        xfunctions.executeAction("SELECT", actionPropsF3)
 
         # 5. Click OK
         xOKBtn = xDialog.getChild("ok")
diff --git a/sc/qa/uitest/calc_tests8/tdf126248.py 
b/sc/qa/uitest/calc_tests8/tdf126248.py
index 967e5c027c3e..f633bf9bcf41 100644
--- a/sc/qa/uitest/calc_tests8/tdf126248.py
+++ b/sc/qa/uitest/calc_tests8/tdf126248.py
@@ -59,7 +59,6 @@ class tdf126248(UITestCase):
 
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
-        select_pos(xCellsDlg, "2")
 
         # Get current font names from the Format Cell dialog
         westFontName = 
get_state_as_dict(xCellsDlg.getChild("westfontnamelb-cjk"))['Text']
diff --git a/sd/qa/uitest/impress_tests/customSlideShow.py 
b/sd/qa/uitest/impress_tests/customSlideShow.py
index 9feef4a12a81..9f491d9a5141 100644
--- a/sd/qa/uitest/impress_tests/customSlideShow.py
+++ b/sd/qa/uitest/impress_tests/customSlideShow.py
@@ -41,7 +41,6 @@ class customSlideShow(UITestCase):
         edit = CustomSlideShows.getChild("edit")
         customshowlist = CustomSlideShows.getChild("customshowlist")
         self.assertEqual(get_state_as_dict(customshowlist)["SelectionCount"], 
"1")
-        select_pos(customshowlist, "1")
         ok = CustomSlideShows.getChild("ok")
 
         def handle_edit_dlg(DefineCustomSlideShow):
diff --git a/sw/qa/uitest/findReplace/findReplace.py 
b/sw/qa/uitest/findReplace/findReplace.py
index 9ce377f38292..14c5cf2188ea 100644
--- a/sw/qa/uitest/findReplace/findReplace.py
+++ b/sw/qa/uitest/findReplace/findReplace.py
@@ -79,7 +79,6 @@ class findReplace(UITestCase):
             select_pos(xTabs, "0")
             xSizeFont = dialog.getChild("westsizelb-cjk")
             xSizeFont.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
-            xSizeFont.executeAction("BACKSPACE", tuple())
             xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"16"}))   
 #set font size 16
             xOkBtn = dialog.getChild("ok")
             self.ui_test.close_dialog_through_button(xOkBtn)
diff --git a/sw/qa/uitest/writer_tests2/deleteAllComments.py 
b/sw/qa/uitest/writer_tests2/deleteAllComments.py
index ad9e0c823e6f..8633e77d49eb 100644
--- a/sw/qa/uitest/writer_tests2/deleteAllComments.py
+++ b/sw/qa/uitest/writer_tests2/deleteAllComments.py
@@ -25,7 +25,6 @@ class DeleteAllComments(UITestCase):
         selection = self.xUITest.executeCommand(".uno:SelectAll")
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         cursor = document.getCurrentController().getViewCursor()
-        xWriterDoc.executeAction("LEFT", tuple())
         type_text(xWriterEdit, "EEEEE")
         self.xUITest.executeCommand(".uno:InsertAnnotation")
         self.xUITest.executeCommand(".uno:DeleteAllNotes")
diff --git a/sw/qa/uitest/writer_tests2/formatParagraph.py 
b/sw/qa/uitest/writer_tests2/formatParagraph.py
index 7d2120f10320..b5f8df306226 100644
--- a/sw/qa/uitest/writer_tests2/formatParagraph.py
+++ b/sw/qa/uitest/writer_tests2/formatParagraph.py
@@ -516,7 +516,6 @@ class formatParagraph(UITestCase):
         xBottom = xDialog.getChild("bottommf")
         xMerge = xDialog.getChild("mergewithnext")
 
-        select_pos(xStyle, "1")
         xwidth.executeAction("UP", tuple())
         xSync.executeAction("CLICK", tuple())
         xLeft.executeAction("UP", tuple())
diff --git a/uitest/demo_ui/listbox.py b/uitest/demo_ui/listbox.py
index 780da1ff20b0..7e9ae16e6543 100644
--- a/uitest/demo_ui/listbox.py
+++ b/uitest/demo_ui/listbox.py
@@ -19,9 +19,6 @@ class ListBoxTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        categoryLB = xCellsDlg.getChild("categorylb")
-        select_pos(categoryLB, "4")
-
         xOkBtn = xCellsDlg.getChild("ok")
         self.ui_test.close_dialog_through_button(xOkBtn)
 
@@ -34,12 +31,6 @@ class ListBoxTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        categoryLB = xCellsDlg.getChild("categorylb")
-        props = {"TEXT": "Time"}
-
-        actionProps = mkPropertyValues(props)
-        categoryLB.executeAction("SELECT", actionProps)
-
         xOkBtn = xCellsDlg.getChild("ok")
         self.ui_test.close_dialog_through_button(xOkBtn)
 
diff --git a/uitest/demo_ui/spinfield.py b/uitest/demo_ui/spinfield.py
index 3f73006b10bd..a74e47206274 100644
--- a/uitest/demo_ui/spinfield.py
+++ b/uitest/demo_ui/spinfield.py
@@ -19,9 +19,6 @@ class SpinFieldTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        # select the numbers tab page
-        select_pos(xCellsDlg, "0")
-        
         xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
         xDecimalPlaces.executeAction("UP", tuple())
 
@@ -40,9 +37,6 @@ class SpinFieldTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        # select the numbers tab page
-        select_pos(xCellsDlg, "0")
-        
         xDecimalPlaces = xCellsDlg.getChild("leadzerosed")
         xDecimalPlaces.executeAction("UP", tuple())
         xDecimalPlaces.executeAction("UP", tuple())
diff --git a/uitest/demo_ui/tabdialog.py b/uitest/demo_ui/tabdialog.py
index ed46379ab05b..861b270989d9 100644
--- a/uitest/demo_ui/tabdialog.py
+++ b/uitest/demo_ui/tabdialog.py
@@ -19,8 +19,6 @@ class TabDialogTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        select_pos(xCellsDlg, "1")
-
         xOkBtn = xCellsDlg.getChild("ok")
         self.ui_test.close_dialog_through_button(xOkBtn)
 
@@ -33,10 +31,6 @@ class TabDialogTest(UITestCase):
         self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog")
         xCellsDlg = self.xUITest.getTopFocusWindow()
 
-        props = {"NAME": "Borders"}
-        propsUNO = mkPropertyValues(props)
-        xCellsDlg.executeAction("SELECT", propsUNO)
-
         xOkBtn = xCellsDlg.getChild("ok")
         self.ui_test.close_dialog_through_button(xOkBtn)
 
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 75fae39da51b..fc72053074c6 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -337,7 +337,6 @@ StringMap WindowUIObject::get_state()
 void WindowUIObject::execute(const OUString& rAction,
         const StringMap& rParameters)
 {
-    bool bHandled = true;
     if (rAction == "SET")
     {
         for (auto const& parameter : rParameters)
@@ -369,8 +368,12 @@ void WindowUIObject::execute(const OUString& rAction,
         }
         else
         {
-            SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE");
-            return;
+            OStringBuffer buf;
+            for (auto const & rPair : rParameters)
+                
buf.append(",").append(rPair.first.toUtf8()).append("=").append(rPair.second.toUtf8());
+            SAL_WARN("vcl.uitest", "missing parameter TEXT to action TYPE "
+                << buf.makeStringAndClear());
+            throw std::logic_error("missing parameter TEXT to action TYPE");
         }
     }
     else if (rAction == "FOCUS")
@@ -379,12 +382,12 @@ void WindowUIObject::execute(const OUString& rAction,
     }
     else
     {
-        bHandled = false;
-    }
-
-    if (!bHandled)
-    {
-        SAL_WARN("vcl.uitest", "unknown action or parameter for " << 
get_name() << ". Action: " << rAction);
+        OStringBuffer buf;
+        for (auto const & rPair : rParameters)
+            
buf.append(",").append(rPair.first.toUtf8()).append("=").append(rPair.second.toUtf8());
+        SAL_WARN("vcl.uitest", "unknown action for " << get_name()
+            << ". Action: " << rAction << buf.makeStringAndClear());
+        throw std::logic_error("unknown action");
     }
 }
 
@@ -726,15 +729,9 @@ void EditUIObject::execute(const OUString& rAction,
     bool bHandled = true;
     if (rAction == "TYPE")
     {
-        if (rParameters.find("TEXT") != rParameters.end())
+        auto it = rParameters.find("TEXT");
+        if (it != rParameters.end())
         {
-            auto it = rParameters.find("TEXT");
-            if (it == rParameters.end())
-            {
-                SAL_WARN("vcl.uitest", "missing parameter TEXT to action SET");
-                return;
-            }
-
             const OUString& rText = it->second;
             auto aKeyEvents = generate_key_events_from_text(rText);
             for (auto const& keyEvent : aKeyEvents)
@@ -904,13 +901,15 @@ CheckBoxUIObject::~CheckBoxUIObject()
 }
 
 void CheckBoxUIObject::execute(const OUString& rAction,
-        const StringMap& /*rParameters*/)
+        const StringMap& rParameters)
 {
     if (rAction == "CLICK")
     {
         // don't use toggle directly, it does not set the value
         mxCheckBox->ImplCheck();
     }
+    else
+        WindowUIObject::execute(rAction, rParameters);
 }
 
 StringMap CheckBoxUIObject::get_state()
@@ -959,12 +958,14 @@ RadioButtonUIObject::~RadioButtonUIObject()
 }
 
 void RadioButtonUIObject::execute(const OUString& rAction,
-        const StringMap& /*rParameters*/)
+        const StringMap& rParameters)
 {
     if (rAction == "CLICK")
     {
         mxRadioButton->ImplCallClick();
     }
+    else
+        WindowUIObject::execute(rAction, rParameters);
 }
 
 StringMap RadioButtonUIObject::get_state()
@@ -1013,12 +1014,9 @@ TabPageUIObject::~TabPageUIObject()
 }
 
 void TabPageUIObject::execute(const OUString& rAction,
-        const StringMap& /*rParameters*/)
+        const StringMap& rParameters)
 {
-    if (rAction == "SELECT")
-    {
-        /* code */
-    }
+    WindowUIObject::execute(rAction, rParameters);
 }
 
 StringMap TabPageUIObject::get_state()
@@ -1218,7 +1216,7 @@ SpinUIObject::~SpinUIObject()
 }
 
 void SpinUIObject::execute(const OUString& rAction,
-        const StringMap& /*rParameters*/)
+        const StringMap& rParameters)
 {
     if (rAction == "UP")
     {
@@ -1228,6 +1226,8 @@ void SpinUIObject::execute(const OUString& rAction,
     {
         mxSpinButton->Down();
     }
+    else
+        WindowUIObject::execute(rAction, rParameters);
 }
 
 StringMap SpinUIObject::get_state()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to