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
, get_url_for_data_file
13 from libreoffice
.calc
.document
import get_cell_by_position
15 class xmlSource(UITestCase
):
17 def test_importXml(self
):
19 with self
.ui_test
.create_doc_in_start_center("calc") as calc_doc
:
22 with self
.ui_test
.execute_dialog_through_command(".uno:Insert") as xDialog
:
23 xAfter
= xDialog
.getChild('after')
24 xAfter
.executeAction("CLICK", tuple())
26 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ManageXMLSource") as xDialog
:
28 xSource
= xDialog
.getChild("selectsource")
30 with self
.ui_test
.execute_blocking_action(xSource
.executeAction
, args
=('CLICK', ()), close_button
="open") as xOpenDialog
:
31 xFileName
= xOpenDialog
.getChild("file_name")
32 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("xmlSource.xml")}))
34 xTree
= xDialog
.getChild("tree")
35 self
.assertEqual('13', get_state_as_dict(xTree
)["Children"])
37 xTree
.getChild('0').executeAction("SELECT", tuple())
38 xTree
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
39 xTree
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
41 self
.assertEqual("entry", get_state_as_dict(xTree
)["SelectEntryText"])
42 self
.assertEqual("11", get_state_as_dict(xTree
)["SelectionCount"])
44 xEdit
= xDialog
.getChild("edit")
45 xEdit
.executeAction("TYPE", mkPropertyValues({"TEXT": "$A$1"}))
47 # tdf#126565: Without the fix in place, this test would have failed with
48 # AssertionError: '' != 'name'
50 self
.assertEqual("", get_cell_by_position(calc_doc
, 0, i
, 0).getString())
53 self
.assertEqual("name", get_cell_by_position(calc_doc
, 1, 0, 0).getString())
54 self
.assertEqual("translated-address", get_cell_by_position(calc_doc
, 1, 1, 0).getString())
55 self
.assertEqual("to", get_cell_by_position(calc_doc
, 1, 2, 0).getString())
56 self
.assertEqual("from", get_cell_by_position(calc_doc
, 1, 3, 0).getString())
57 self
.assertEqual("source", get_cell_by_position(calc_doc
, 1, 4, 0).getString())
58 self
.assertEqual("destination", get_cell_by_position(calc_doc
, 1, 5, 0).getString())
59 self
.assertEqual("service", get_cell_by_position(calc_doc
, 1, 6, 0).getString())
60 self
.assertEqual("disabled", get_cell_by_position(calc_doc
, 1, 7, 0).getString())
62 def test_tdf153604(self
):
64 with self
.ui_test
.create_doc_in_start_center("calc") as calc_doc
:
66 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ManageXMLSource") as xDialog
:
68 xSource
= xDialog
.getChild("selectsource")
70 with self
.ui_test
.execute_blocking_action(xSource
.executeAction
, args
=('CLICK', ()), close_button
="open") as xOpenDialog
:
71 xFileName
= xOpenDialog
.getChild("file_name")
72 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf153604.xml")}))
74 xTree
= xDialog
.getChild("tree")
75 self
.assertEqual('2', get_state_as_dict(xTree
)["Children"])
77 xTree
.getChild('0').executeAction("SELECT", tuple())
78 xTree
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
80 self
.assertEqual("data", get_state_as_dict(xTree
)["SelectEntryText"])
82 xEdit
= xDialog
.getChild("edit")
83 xEdit
.executeAction("TYPE", mkPropertyValues({"TEXT": "$A$1"}))
85 # Without the fix in place, this test would have failed with
86 # AssertionError: 'data' != ''
87 self
.assertEqual("data", get_cell_by_position(calc_doc
, 0, 0, 0).getString())
88 self
.assertEqual("v1", get_cell_by_position(calc_doc
, 0, 0, 1).getString())
89 self
.assertEqual("v2", get_cell_by_position(calc_doc
, 0, 0, 2).getString())
90 self
.assertEqual("v3", get_cell_by_position(calc_doc
, 0, 0, 3).getString())
92 def test_tdf146260(self
):
94 with self
.ui_test
.create_doc_in_start_center("calc") as calc_doc
:
96 with self
.ui_test
.execute_modeless_dialog_through_command(".uno:ManageXMLSource") as xDialog
:
98 xSource
= xDialog
.getChild("selectsource")
100 with self
.ui_test
.execute_blocking_action(xSource
.executeAction
, args
=('CLICK', ()), close_button
="open") as xOpenDialog
:
101 xFileName
= xOpenDialog
.getChild("file_name")
102 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf146260.xml")}))
104 xTree
= xDialog
.getChild("tree")
105 self
.assertEqual('43', get_state_as_dict(xTree
)["Children"])
107 xTree
.getChild('0').executeAction("SELECT", tuple())
109 xTree
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
111 self
.assertEqual("Fp", get_state_as_dict(xTree
)["SelectEntryText"])
112 self
.assertEqual("38", get_state_as_dict(xTree
)["SelectionCount"])
114 xEdit
= xDialog
.getChild("edit")
115 xEdit
.executeAction("TYPE", mkPropertyValues({"TEXT": "$A$1"}))
117 # Without the fix in place, this test would have failed with
118 # AssertionError: 'data' != ''
119 self
.assertEqual("Djh", get_cell_by_position(calc_doc
, 0, 0, 0).getString())
120 self
.assertEqual("Fpzl", get_cell_by_position(calc_doc
, 0, 1, 0).getString())
122 for i
in range(1, 5):
123 # Without the fix in place, this test would have failed with
124 # AssertionError: '专用发票' != 'ר�÷�Ʊ'
125 self
.assertEqual("专用发票", get_cell_by_position(calc_doc
, 0, 1, i
).getString())
127 # vim: set shiftwidth=4 softtabstop=4 expandtab: