Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / uitest / calc_tests / create_chart.py
blob5b97199bdf59670eab3200a71038c2c4ec2beacf
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
11 from uitest.uihelper.calc import enter_text_to_cell
13 import time
14 import unittest
16 class CalcChartUIDemo(UITestCase):
18 def fill_spreadsheet(self):
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 xGridWindow = xCalcDoc.getChild("grid_window")
22 enter_text_to_cell(xGridWindow, "A1", "col1")
23 enter_text_to_cell(xGridWindow, "B1", "col2")
24 enter_text_to_cell(xGridWindow, "C1", "col3")
25 enter_text_to_cell(xGridWindow, "A2", "1")
26 enter_text_to_cell(xGridWindow, "B2", "3")
27 enter_text_to_cell(xGridWindow, "C2", "5")
29 xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C2"}))
31 def test_cancel_immediately(self):
33 self.ui_test.create_doc_in_start_center("calc")
35 self.fill_spreadsheet()
37 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
39 xChartDlg = self.xUITest.getTopFocusWindow()
41 xCancelBtn = xChartDlg.getChild("cancel")
42 self.ui_test.close_dialog_through_button(xCancelBtn)
44 self.ui_test.close_doc()
46 def test_create_from_first_page(self):
48 self.ui_test.create_doc_in_start_center("calc")
50 self.fill_spreadsheet()
52 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
54 xChartDlg = self.xUITest.getTopFocusWindow()
56 xOkBtn = xChartDlg.getChild("finish")
57 self.ui_test.close_dialog_through_button(xOkBtn)
59 self.ui_test.close_doc()
61 def test_create_from_second_page(self):
63 self.ui_test.create_doc_in_start_center("calc")
65 self.fill_spreadsheet()
67 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
69 xChartDlg = self.xUITest.getTopFocusWindow()
71 xNextBtn = xChartDlg.getChild("next")
72 xNextBtn.executeAction("CLICK", tuple())
74 xDataInRows = xChartDlg.getChild("RB_DATAROWS")
75 xDataInRows.executeAction("CLICK", tuple())
77 xDataInCols = xChartDlg.getChild("RB_DATACOLS")
78 xDataInCols.executeAction("CLICK", tuple())
80 xCancelBtn = xChartDlg.getChild("finish")
81 self.ui_test.close_dialog_through_button(xCancelBtn)
83 self.ui_test.close_doc()
85 def test_deselect_chart(self):
86 self.ui_test.create_doc_in_start_center("calc")
88 self.fill_spreadsheet()
90 xCalcDoc = self.xUITest.getTopFocusWindow()
91 xGridWindow = xCalcDoc.getChild("grid_window")
93 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
95 xChartDlg = self.xUITest.getTopFocusWindow()
97 xNextBtn = xChartDlg.getChild("finish")
98 self.ui_test.close_dialog_through_button(xNextBtn)
100 xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
102 time.sleep(2)
104 self.ui_test.close_doc()
106 def test_activate_chart(self):
108 self.ui_test.create_doc_in_start_center("calc")
110 self.fill_spreadsheet()
112 xCalcDoc = self.xUITest.getTopFocusWindow()
113 xGridWindow = xCalcDoc.getChild("grid_window")
115 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
117 xChartDlg = self.xUITest.getTopFocusWindow()
119 xNextBtn = xChartDlg.getChild("finish")
120 self.ui_test.close_dialog_through_button(xNextBtn)
122 xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
124 xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
125 xGridWindow.executeAction("ACTIVATE", tuple())
127 xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
129 self.ui_test.close_doc()
131 def select_chart_element(self):
133 self.ui_test.create_doc_in_start_center("calc")
135 self.fill_spreadsheet()
137 xCalcDoc = self.xUITest.getTopFocusWindow()
138 xGridWindow = xCalcDoc.getChild("grid_window")
140 self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart")
142 xChartDlg = self.xUITest.getTopFocusWindow()
144 xNextBtn = xChartDlg.getChild("finish")
145 self.ui_test.close_dialog_through_button(xNextBtn)
147 xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""}))
149 xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"}))
150 xGridWindow.executeAction("ACTIVATE", tuple())
152 xCalcDoc = self.xUITest.getTopFocusWindow()
153 self.ui_test.close_doc()
155 # vim: set shiftwidth=4 softtabstop=4 expandtab: