[Libreoffice-commits] core.git: sc/qa sc/source
Ahmed ElShreif (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jun 21 20:17:42 UTC 2020
sc/qa/uitest/calc_tests/CellDropDownItems.py | 88 +++++++++++++++++++++++++++
sc/source/ui/uitest/uiobject.cxx | 22 ++++++
2 files changed, 108 insertions(+), 2 deletions(-)
New commits:
commit 058f4f3c3d7204421c3e947b845a84eb8bf54675
Author: Ahmed ElShreif <aelshreif7 at gmail.com>
AuthorDate: Fri Jun 19 04:17:08 2020 +0200
Commit: Ahmed ElShreif <aelshreif7 at gmail.com>
CommitDate: Sun Jun 21 22:17:10 2020 +0200
uitest : Add support for Dropdown items in grid window
This patch add support for test cases that test Dropdown list of cells in Calc that can be created using: Data -> Validity -> List.
You can select items from the list by it's id or it's text .
This may help in tdf#133855 .
Change-Id: I830149fd5520df72f07540fd4eebd3f3bad48616
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96670
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py b/sc/qa/uitest/calc_tests/CellDropDownItems.py
new file mode 100644
index 000000000000..2843181eaaca
--- /dev/null
+++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py
@@ -0,0 +1,88 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class CellDropDownItems(UITestCase):
+
+ def test_dropdownitems(self):
+
+ #This is to test Dropdown items in grid window
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+ xCalcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = xCalcDoc.getChild("grid_window")
+ document = self.ui_test.get_component()
+
+ #select cell C10
+ gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"}))
+
+ #Open Validation Dialog
+ self.ui_test.execute_dialog_through_command(".uno:Validation")
+ xDialog = self.xUITest.getTopFocusWindow()
+
+ #Select List option
+ xallow = xDialog.getChild("allow")
+ xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"}))
+
+ #Add items to the List
+ xminlist = xDialog.getChild("minlist")
+ xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"}))
+
+ #Close the dialog
+ xOk = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOk)
+
+ #Launch the Select Menu to view the list ans select first item in the list
+ gridwin = xCalcDoc.getChild("grid_window")
+ gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
+
+ #Select the TreeList UI Object
+ xWin = self.xUITest.getTopFocusWindow()
+ xlist = xWin.getChild("list")
+
+ xListItem = xlist.getChild('0')
+ xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
+ self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item1")
+
+ #Launch the Select Menu to view the list ans select Third item in the list
+ gridwin = xCalcDoc.getChild("grid_window")
+ gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
+
+ #Select the TreeList UI Object
+ xWin = self.xUITest.getTopFocusWindow()
+ xlist = xWin.getChild("list")
+
+ xListItem = xlist.getChild('2')
+ xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
+ self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item3")
+
+ #Launch the Select Menu to view the list ans select Fifth item in the list
+ gridwin = xCalcDoc.getChild("grid_window")
+ gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
+
+ #Select the TreeList UI Object
+ xWin = self.xUITest.getTopFocusWindow()
+ xlist = xWin.getChild("list")
+
+ xListItem = xlist.getChild('4')
+ xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
+ self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item5")
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file
diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx
index 0782ea500d28..df62ab45881d 100644
--- a/sc/source/ui/uitest/uiobject.cxx
+++ b/sc/source/ui/uitest/uiobject.cxx
@@ -192,8 +192,7 @@ void ScGridWinUIObject::execute(const OUString& rAction,
}
else if (rAction == "LAUNCH")
{
- auto itr = rParameters.find("AUTOFILTER");
- if (itr != rParameters.end())
+ if ( rParameters.find("AUTOFILTER") != rParameters.end())
{
auto itrCol = rParameters.find("COL");
if (itrCol == rParameters.end())
@@ -212,6 +211,25 @@ void ScGridWinUIObject::execute(const OUString& rAction,
SCCOL nCol = itrCol->second.toUInt32();
mxGridWindow->LaunchAutoFilterMenu(nCol, nRow);
}
+ else if ( rParameters.find("SELECTMENU") != rParameters.end())
+ {
+ auto itrCol = rParameters.find("COL");
+ if (itrCol == rParameters.end())
+ {
+ SAL_WARN("sc.uitest", "missing COL parameter");
+ return;
+ }
+
+ auto itrRow = rParameters.find("ROW");
+ if (itrRow == rParameters.end())
+ {
+ SAL_WARN("sc.uitest", "missing ROW parameter");
+ return;
+ }
+ SCROW nRow = itrRow->second.toUInt32();
+ SCCOL nCol = itrCol->second.toUInt32();
+ mxGridWindow->LaunchDataSelectMenu(nCol, nRow);
+ }
}
else if (rAction == "SIDEBAR")
{
More information about the Libreoffice-commits
mailing list