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
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
13 from libreoffice
.calc
.document
import get_cell_by_position
16 class keyF4(UITestCase
):
18 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 gridwin
= xCalcDoc
.getChild("grid_window")
22 enter_text_to_cell(gridwin
, "A1", "1")
23 enter_text_to_cell(gridwin
, "A2", "2")
24 enter_text_to_cell(gridwin
, "A3", "3")
25 enter_text_to_cell(gridwin
, "B1", "=A1")
26 enter_text_to_cell(gridwin
, "B2", "=A2")
27 enter_text_to_cell(gridwin
, "B3", "=A3")
29 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
31 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
33 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 1)
34 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getFormula(), "=$A$1")
36 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
38 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 1)
39 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getFormula(), "=A$1")
41 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
43 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getValue(), 1)
44 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getFormula(), "=$A1")
46 #non continuous select
48 enter_text_to_cell(gridwin
, "C1", "=A1")
49 enter_text_to_cell(gridwin
, "C2", "=A2")
50 enter_text_to_cell(gridwin
, "C3", "=A3")
53 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
54 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "C3", "EXTEND":"1"}))
56 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
58 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 1)
59 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getFormula(), "=$A$1")
60 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
61 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getFormula(), "=$A$3")
63 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
65 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 1)
66 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getFormula(), "=A$1")
67 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
68 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getFormula(), "=A$3")
70 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"}))
72 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getValue(), 1)
73 self
.assertEqual(get_cell_by_position(document
, 0, 2, 0).getFormula(), "=$A1")
74 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getValue(), 3)
75 self
.assertEqual(get_cell_by_position(document
, 0, 2, 2).getFormula(), "=$A3")
77 # vim: set shiftwidth=4 softtabstop=4 expandtab: