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
.common
import get_url_for_data_file
, get_state_as_dict
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from libreoffice
.calc
.document
import get_cell_by_position
13 from libreoffice
.calc
.paste_special
import reset_default_values
15 class tdf65856(UITestCase
):
17 def test_tdf65856_paste_special_shift_right(self
):
18 with self
.ui_test
.load_file(get_url_for_data_file("tdf65856.ods")) as calc_doc
:
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 gridwin
= xCalcDoc
.getChild("grid_window")
23 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:E14"}))
24 self
.xUITest
.executeCommand(".uno:Copy")
26 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "D1"}))
27 with self
.ui_test
.execute_dialog_through_command(".uno:PasteSpecial") as xDialog
:
28 reset_default_values(self
, xDialog
)
30 xmove_right
= xDialog
.getChild("move_right")
31 xmove_right
.executeAction("CLICK", tuple())
34 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 0).getString(), "T1")
35 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 1, 0).getString(), "TE1")
36 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 2, 0).getString(), "TES1")
37 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 0).getString(), "TEST1")
38 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 0).getString(), "TEST1")
39 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 0).getString(), "TEST1")
40 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 6, 0).getString(), "TEST1")
41 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 0, 13).getString(), "T14")
42 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 1, 13).getString(), "TE14")
43 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 2, 13).getString(), "TES14")
44 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 13).getString(), "TEST14")
45 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 13).getString(), "TEST14")
46 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 13).getString(), "TEST14")
47 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 6, 13).getString(), "TEST14")
49 def test_tdf65856_paste_special_shift_right_2(self
):
50 with self
.ui_test
.load_file(get_url_for_data_file("tdf65856_2.ods")) as calc_doc
:
51 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
52 gridwin
= xCalcDoc
.getChild("grid_window")
54 #- select range C2:D4; copy
55 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "C2:D4"}))
56 self
.xUITest
.executeCommand(".uno:Copy")
58 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B2"}))
59 with self
.ui_test
.execute_dialog_through_command(".uno:PasteSpecial") as xDialog
:
60 xmove_right
= xDialog
.getChild("move_right")
62 # tdf#69750: Without the fix in place, this test would have failed here
63 self
.assertEqual("true", get_state_as_dict(xmove_right
)["Checked"])
66 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 1, 1).getString(), "1")
67 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 2, 1).getString(), "1")
68 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 1).getString(), "1")
69 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 1).getString(), "1")
70 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 1).getString(), "1")
71 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 1, 2).getString(), "2")
72 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 2, 2).getString(), "2")
73 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 2).getString(), "2")
74 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 2).getString(), "2")
75 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 2).getString(), "2")
76 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 1, 3).getString(), "3")
77 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 2, 3).getString(), "3")
78 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 3).getString(), "3")
79 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 3).getString(), "3")
80 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 3).getString(), "3")
81 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 1).getFormula(), "=D2")
82 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 1).getFormula(), "=D2")
83 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 2).getFormula(), "=E3")
84 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 5, 2).getFormula(), "=E3")
85 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 3, 3).getFormula(), "=F4")
86 self
.assertEqual(get_cell_by_position(calc_doc
, 0, 4, 3).getFormula(), "=F4")
88 # vim: set shiftwidth=4 softtabstop=4 expandtab: