1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest
.framework
import UITestCase
10 from libreoffice
.calc
.document
import get_cell_by_position
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import select_pos
14 class CellDropDownItems(UITestCase
):
16 def test_dropdownitems(self
):
18 #This is to test Dropdown items in grid window
19 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
20 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
21 gridwin
= xCalcDoc
.getChild("grid_window")
24 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "C10"}))
26 #Open Validation Dialog
27 with self
.ui_test
.execute_dialog_through_command(".uno:Validation") as xDialog
:
30 xallow
= xDialog
.getChild("allow")
31 select_pos(xallow
, "6")
33 #Add items to the List
34 xminlist
= xDialog
.getChild("minlist")
35 xminlist
.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"}))
36 xminlist
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
37 xminlist
.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"}))
38 xminlist
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
39 xminlist
.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"}))
40 xminlist
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
41 xminlist
.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"}))
42 xminlist
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
43 xminlist
.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"}))
47 #Launch the Select Menu to view the list ans select first item in the list
48 gridwin
= xCalcDoc
.getChild("grid_window")
49 gridwin
.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
51 #Select the TreeList UI Object
52 xWin
= self
.xUITest
.getTopFocusWindow()
53 xlist
= xWin
.getChild("list")
55 xListItem
= xlist
.getChild('0')
56 xListItem
.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
57 self
.assertEqual(get_cell_by_position(document
, 0, 2, 9).getString(), "Item1")
59 #Launch the Select Menu to view the list ans select Third item in the list
60 gridwin
= xCalcDoc
.getChild("grid_window")
61 gridwin
.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
63 #Select the TreeList UI Object
64 xWin
= self
.xUITest
.getTopFocusWindow()
65 xlist
= xWin
.getChild("list")
67 xListItem
= xlist
.getChild('2')
68 xListItem
.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
69 self
.assertEqual(get_cell_by_position(document
, 0, 2, 9).getString(), "Item3")
71 #Launch the Select Menu to view the list ans select Fifth item in the list
72 gridwin
= xCalcDoc
.getChild("grid_window")
73 gridwin
.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"}))
75 #Select the TreeList UI Object
76 xWin
= self
.xUITest
.getTopFocusWindow()
77 xlist
= xWin
.getChild("list")
79 xListItem
= xlist
.getChild('4')
80 xListItem
.executeAction("DOUBLECLICK" , mkPropertyValues({}) )
81 self
.assertEqual(get_cell_by_position(document
, 0, 2, 9).getString(), "Item5")
84 # vim: set shiftwidth=4 softtabstop=4 expandtab: