tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / qa / uitest / range_name / tdf148072.py
bloba923136b81668025bdb82ba6301bfa9db4ea0f3f
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, type_text, select_by_text
13 from libreoffice.calc.document import get_cell_by_position
14 from uitest.uihelper.calc import enter_text_to_cell
16 class Tdf148072(UITestCase):
18 def test_tdf148072(self):
19 with self.ui_test.create_doc_in_start_center("calc") as calc_doc:
21 xCalcDoc = self.xUITest.getTopFocusWindow()
22 gridwin = xCalcDoc.getChild("grid_window")
23 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
25 with self.ui_test.execute_modeless_dialog_through_command(".uno:AddName", close_button="add") as xAddNameDlg:
26 xEdit = xAddNameDlg.getChild("edit")
27 type_text(xEdit, "testfield_1")
29 xRange = xAddNameDlg.getChild("range")
30 self.assertEqual("$Sheet1.$B$2", get_state_as_dict(xRange)['Text'])
32 xScope = xAddNameDlg.getChild("scope")
33 select_by_text(xScope, "Sheet1")
35 enter_text_to_cell(gridwin, "B2", "1")
36 enter_text_to_cell(gridwin, "B3", "=testfield_1")
38 self.assertEqual("1", get_cell_by_position(calc_doc, 0, 1, 1).getString())
39 self.assertEqual("1", get_cell_by_position(calc_doc, 0, 1, 2).getString())
41 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B2:B3"}))
43 self.xUITest.executeCommand(".uno:Cut")
45 # Insert a new sheet
46 with self.ui_test.execute_dialog_through_command(".uno:Add") as xDialog:
47 xName = xDialog.getChild('name_entry')
48 self.assertEqual( 'Sheet2', get_state_as_dict(xName)["Text"])
50 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "$Sheet2.B2"}))
52 self.xUITest.executeCommand(".uno:Paste")
54 self.assertEqual("", get_cell_by_position(calc_doc, 0, 1, 1).getString())
55 self.assertEqual("", get_cell_by_position(calc_doc, 0, 1, 2).getString())
56 self.assertEqual("1", get_cell_by_position(calc_doc, 1, 1, 1).getString())
57 self.assertEqual("1", get_cell_by_position(calc_doc, 1, 1, 2).getString())
59 with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog:
60 xNamesList = xDialog.getChild('names')
61 self.assertEqual(1, len(xNamesList.getChildren()))
63 xName = xDialog.getChild('name')
64 self.assertEqual( 'testfield_1', get_state_as_dict(xName)["Text"])
66 xRange = xDialog.getChild("range")
67 self.assertEqual("$Sheet2.$B$2", get_state_as_dict(xRange)['Text'])
69 xScope = xDialog.getChild("scope")
70 self.assertEqual("$Sheet2.$B$2", get_state_as_dict(xRange)['Text'])
72 self.xUITest.executeCommand(".uno:Undo")
73 self.xUITest.executeCommand(".uno:Undo")
74 self.xUITest.executeCommand(".uno:Undo")
76 self.assertEqual("1", get_cell_by_position(calc_doc, 0, 1, 1).getString())
78 # Without the fix in place, this test would have failed with
79 # AssertionError: '1' != '#REF!'
80 self.assertEqual("1", get_cell_by_position(calc_doc, 0, 1, 2).getString())
82 with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog:
83 xNamesList = xDialog.getChild('names')
84 self.assertEqual(1, len(xNamesList.getChildren()))
86 xName = xDialog.getChild('name')
87 self.assertEqual( 'testfield_1', get_state_as_dict(xName)["Text"])
89 xRange = xDialog.getChild("range")
90 self.assertEqual("$Sheet1.$B$2", get_state_as_dict(xRange)['Text'])
92 xScope = xDialog.getChild("scope")
93 self.assertEqual("$Sheet1.$B$2", get_state_as_dict(xRange)['Text'])
95 # vim: set shiftwidth=4 softtabstop=4 expandtab: