1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
10 from uitest
.framework
import UITestCase
14 class CalcChartUIDemo(UITestCase
):
16 def add_content_to_cell(self
, gridwin
, cell
, content
):
17 selectProps
= mkPropertyValues({"CELL": cell
})
18 gridwin
.executeAction("SELECT", selectProps
)
20 contentProps
= mkPropertyValues({"TEXT": content
})
21 gridwin
.executeAction("TYPE", contentProps
)
23 def fill_spreadsheet(self
):
24 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
25 xGridWindow
= xCalcDoc
.getChild("grid_window")
27 self
.add_content_to_cell(xGridWindow
, "A1", "col1")
28 self
.add_content_to_cell(xGridWindow
, "B1", "col2")
29 self
.add_content_to_cell(xGridWindow
, "C1", "col3")
30 self
.add_content_to_cell(xGridWindow
, "A2", "1")
31 self
.add_content_to_cell(xGridWindow
, "B2", "3")
32 self
.add_content_to_cell(xGridWindow
, "C2", "5")
34 xGridWindow
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
36 def test_cancel_immediately(self
):
38 self
.ui_test
.create_doc_in_start_center("calc")
40 self
.fill_spreadsheet()
42 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
44 xChartDlg
= self
.xUITest
.getTopFocusWindow()
46 xCancelBtn
= xChartDlg
.getChild("cancel")
47 xCancelBtn
.executeAction("CLICK", tuple())
49 self
.ui_test
.close_doc()
51 def test_create_from_first_page(self
):
53 self
.ui_test
.create_doc_in_start_center("calc")
55 self
.fill_spreadsheet()
57 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
59 xChartDlg
= self
.xUITest
.getTopFocusWindow()
61 xOkBtn
= xChartDlg
.getChild("finish")
62 xOkBtn
.executeAction("CLICK", tuple())
64 self
.ui_test
.close_doc()
66 def test_create_from_second_page(self
):
68 self
.ui_test
.create_doc_in_start_center("calc")
70 self
.fill_spreadsheet()
72 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
74 xChartDlg
= self
.xUITest
.getTopFocusWindow()
76 xNextBtn
= xChartDlg
.getChild("next")
77 xNextBtn
.executeAction("CLICK", tuple())
79 xDataInRows
= xChartDlg
.getChild("RB_DATAROWS")
80 xDataInRows
.executeAction("CLICK", tuple())
82 xDataInCols
= xChartDlg
.getChild("RB_DATACOLS")
83 xDataInCols
.executeAction("CLICK", tuple())
85 xCancelBtn
= xChartDlg
.getChild("finish")
86 xCancelBtn
.executeAction("CLICK", tuple())
88 self
.ui_test
.close_doc()
90 def test_deselect_chart(self
):
91 self
.ui_test
.create_doc_in_start_center("calc")
93 self
.fill_spreadsheet()
95 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
96 xGridWindow
= xCalcDoc
.getChild("grid_window")
98 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
100 xChartDlg
= self
.xUITest
.getTopFocusWindow()
102 xNextBtn
= xChartDlg
.getChild("finish")
103 xNextBtn
.executeAction("CLICK", tuple())
105 xGridWindow
.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
109 self
.ui_test
.close_doc()
111 def test_activate_chart(self
):
113 self
.ui_test
.create_doc_in_start_center("calc")
115 self
.fill_spreadsheet()
117 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
118 xGridWindow
= xCalcDoc
.getChild("grid_window")
120 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
122 xChartDlg
= self
.xUITest
.getTopFocusWindow()
124 xNextBtn
= xChartDlg
.getChild("finish")
125 xNextBtn
.executeAction("CLICK", tuple())
127 xGridWindow
.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
129 xGridWindow
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
130 xGridWindow
.executeAction("ACTIVATE", tuple())
132 xGridWindow
.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
134 self
.ui_test
.close_doc()
136 def select_chart_element(self
):
138 self
.ui_test
.create_doc_in_start_center("calc")
140 self
.fill_spreadsheet()
142 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
143 xGridWindow
= xCalcDoc
.getChild("grid_window")
145 self
.ui_test
.execute_dialog_through_command(".uno:InsertObjectChart")
147 xChartDlg
= self
.xUITest
.getTopFocusWindow()
149 xNextBtn
= xChartDlg
.getChild("finish")
150 xNextBtn
.executeAction("CLICK", tuple())
152 xGridWindow
.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
154 xGridWindow
.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
155 xGridWindow
.executeAction("ACTIVATE", tuple())
157 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
158 self
.ui_test
.close_doc()
160 # vim: set shiftwidth=4 softtabstop=4 expandtab: