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 uitest
.uihelper
.calc
import enter_text_to_cell
11 from libreoffice
.calc
.document
import get_cell_by_position
12 from uitest
.uihelper
.common
import select_by_text
, select_pos
14 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
17 class EvaluateFormulaInputs(UITestCase
):
19 def test_inputs_with_formula(self
):
20 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
21 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
22 gridwin
= xCalcDoc
.getChild("grid_window")
23 enter_text_to_cell(gridwin
, "A1", "5")
24 enter_text_to_cell(gridwin
, "A2", "7")
25 enter_text_to_cell(gridwin
, "A3", "12")
27 #Select the cells to be validated
28 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "A4"}))
29 #Apply Data > Validity ... > Integer
30 with self
.ui_test
.execute_dialog_through_command(".uno:Validation") as xDialog
:
31 xTabs
= xDialog
.getChild("tabcontrol")
32 select_pos(xTabs
, "0")
33 xallow
= xDialog
.getChild("allow")
34 xallowempty
= xDialog
.getChild("allowempty")
35 xdata
= xDialog
.getChild("data")
36 xmin
= xDialog
.getChild("min")
38 select_by_text(xallow
, "Integer")
39 xallowempty
.executeAction("CLICK", tuple())
40 select_by_text(xdata
, "equal")
41 xmin
.executeAction("TYPE", mkPropertyValues({"TEXT":"A3"}))
43 enter_text_to_cell(gridwin
, "A4", "=SUM(A1:A2)")
44 # without the fix in place, an error message would have appeared
45 self
.assertEqual(get_cell_by_position(document
, 0, 0, 3).getValue(), 12.0)
47 # vim: set shiftwidth=4 softtabstop=4 expandtab: