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 test_tdf137617(self
):
20 with self
.ui_test
.create_doc_in_start_center("calc"):
22 calcDoc
= self
.xUITest
.getTopFocusWindow()
23 gridwin
= calcDoc
.getChild("grid_window")
25 enter_text_to_cell(gridwin
, "A1", "Result1")
26 enter_text_to_cell(gridwin
, "A2", "Result2")
28 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B2"}))
30 with self
.ui_test
.execute_dialog_through_command(".uno:CreateNames") as xDialog
:
33 # Only left is selected
34 self
.assertEqual('true', get_state_as_dict(xDialog
.getChild('left'))['Selected'])
35 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('right'))['Selected'])
36 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('bottom'))['Selected'])
37 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('top'))['Selected'])
40 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
42 xPosWindow
= calcDoc
.getChild('pos_window')
43 self
.assertEqual('Result1', get_state_as_dict(xPosWindow
)['Text'])
45 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
47 self
.assertEqual('Result2', get_state_as_dict(xPosWindow
)['Text'])
49 # Change formula syntax to "Excel R1C1"
50 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
52 xPages
= xDialogOpt
.getChild("pages")
53 xCalcEntry
= xPages
.getChild('3')
54 xCalcEntry
.executeAction("EXPAND", tuple())
55 xCalcFormulaEntry
= xCalcEntry
.getChild('4')
56 xCalcFormulaEntry
.executeAction("SELECT", tuple())
58 xFormulaSyntax
= xDialogOpt
.getChild('formulasyntax')
59 select_by_text(xFormulaSyntax
, "Excel R1C1")
62 enter_text_to_cell(gridwin
, "C1", "Result3")
63 enter_text_to_cell(gridwin
, "D1", "Result4")
65 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:D2"}))
67 with self
.ui_test
.execute_dialog_through_command(".uno:CreateNames") as xDialog
:
70 # Only top is selected
71 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('left'))['Selected'])
72 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('right'))['Selected'])
73 self
.assertEqual('false', get_state_as_dict(xDialog
.getChild('bottom'))['Selected'])
74 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'])
87 # Change formula syntax back to "Calc A1"
88 with self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt
:
90 xPages
= xDialogOpt
.getChild("pages")
91 xCalcEntry
= xPages
.getChild('3')
92 xCalcEntry
.executeAction("EXPAND", tuple())
93 xCalcFormulaEntry
= xCalcEntry
.getChild('4')
94 xCalcFormulaEntry
.executeAction("SELECT", tuple())
96 xFormulaSyntax
= xDialogOpt
.getChild('formulasyntax')
97 select_by_text(xFormulaSyntax
, "Calc A1")
101 # vim: set shiftwidth=4 softtabstop=4 expandtab: