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/.
10 from uitest
.framework
import UITestCase
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import get_state_as_dict
13 from uitest
.uihelper
.common
import select_by_text
14 from uitest
.uihelper
.calc
import enter_text_to_cell
16 class tdf137617(UITestCase
):
18 def change_formula_syntax(self
, syntax
):
19 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
21 xPages
= xDialogOpt
.getChild("pages")
22 xCalcEntry
= xPages
.getChild('3')
23 xCalcEntry
.executeAction("EXPAND", tuple())
24 xCalcFormulaEntry
= xCalcEntry
.getChild('4')
25 xCalcFormulaEntry
.executeAction("SELECT", tuple())
27 xFormulaSyntax
= xDialogOpt
.getChild('formulasyntax')
28 select_by_text(xFormulaSyntax
, syntax
)
30 def test_tdf137617(self
):
32 with self
.ui_test
.create_doc_in_start_center("calc"):
34 calcDoc
= self
.xUITest
.getTopFocusWindow()
35 gridwin
= calcDoc
.getChild("grid_window")
37 enter_text_to_cell(gridwin
, "A1", "Result1")
38 enter_text_to_cell(gridwin
, "A2", "Result2")
40 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B2"}))
42 with self
.ui_test
.execute_dialog_through_command(".uno:CreateNames") as xDialog
:
45 # Only left is selected
46 self
.assertEqual('true', get_state_as_dict(xDialog
.getChild('left'))['Selected'])
47 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('right'))['Selected'])
48 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('bottom'))['Selected'])
49 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('top'))['Selected'])
51 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
53 xPosWindow
= calcDoc
.getChild('pos_window')
54 self
.assertEqual('Result1', get_state_as_dict(xPosWindow
)['Text'])
56 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
58 self
.assertEqual('Result2', get_state_as_dict(xPosWindow
)['Text'])
61 self
.change_formula_syntax("Excel R1C1")
63 enter_text_to_cell(gridwin
, "C1", "Result3")
64 enter_text_to_cell(gridwin
, "D1", "Result4")
66 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:D2"}))
68 with self
.ui_test
.execute_dialog_through_command(".uno:CreateNames") as xDialog
:
71 # Only top is selected
72 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('left'))['Selected'])
73 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('right'))['Selected'])
74 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('bottom'))['Selected'])
75 self
.assertEqual('true', get_state_as_dict(xDialog
.getChild('top'))['Selected'])
77 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "C2"}))
79 # Without the fix in place, this test would have failed with
80 # AssertionError: 'Result3' != 'R2C3'
81 self
.assertEqual('Result3', get_state_as_dict(xPosWindow
)['Text'])
83 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "D2"}))
85 self
.assertEqual('Result4', get_state_as_dict(xPosWindow
)['Text'])
88 self
.change_formula_syntax("Calc A1")
90 # vim: set shiftwidth=4 softtabstop=4 expandtab: