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/.
7 from uitest
.framework
import UITestCase
8 from uitest
.uihelper
.common
import get_state_as_dict
9 from uitest
.uihelper
.common
import select_pos
10 from uitest
.uihelper
.calc
import enter_text_to_cell
11 from libreoffice
.calc
.document
import get_cell_by_position
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 #Bug 122977 - CRASH: "Tools"->"Options" "LibreOfficeDev"->"Charts"->"Default Colors"
16 class chartDefaultColors(UITestCase
):
17 def test_tdf122977_crash_chart_default_colors_options(self
):
18 calc_doc
= self
.ui_test
.create_doc_in_start_center("calc")
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 gridwin
= xCalcDoc
.getChild("grid_window")
21 document
= self
.ui_test
.get_component()
23 #Go to Tools -> Options -> Charts -> Default Colors
24 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
25 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
27 xPages
= xDialogOpt
.getChild("pages")
28 xChartEntry
= xPages
.getChild('5') # Charts
29 xChartEntry
.executeAction("EXPAND", tuple())
30 xChartGeneralEntry
= xChartEntry
.getChild('0')
31 xChartGeneralEntry
.executeAction("SELECT", tuple()) #Default Colors
32 xColors
= xDialogOpt
.getChild("colors")
33 xAdd
= xDialogOpt
.getChild("add")
34 xDelete
= xDialogOpt
.getChild("delete")
35 xDefault
= xDialogOpt
.getChild("default")
37 #click Default - reset
38 xDefault
.executeAction("CLICK", tuple())
39 nrDefaultColors
= get_state_as_dict(xColors
)["Children"]
40 nrDefaultColors1
= int(nrDefaultColors
) + 1
41 xAdd
.executeAction("CLICK", tuple()) #add new color
42 self
.assertEqual(get_state_as_dict(xColors
)["Children"], str(nrDefaultColors1
))
45 def handle_delete_dlg(dialog
):
46 xyesBtn
= dialog
.getChild("yes")
47 self
.ui_test
.close_dialog_through_button(xyesBtn
)
49 self
.ui_test
.execute_blocking_action(xDelete
.executeAction
, args
=('CLICK', ()),
50 dialog_handler
=handle_delete_dlg
)
51 self
.assertEqual(get_state_as_dict(xColors
)["Children"], nrDefaultColors
)
53 xAdd
.executeAction("CLICK", tuple()) #add new color
54 self
.assertEqual(get_state_as_dict(xColors
)["Children"], str(nrDefaultColors1
))
56 xDefault
.executeAction("CLICK", tuple())
57 self
.assertEqual(get_state_as_dict(xColors
)["Children"], nrDefaultColors
)
59 xCancelBtn
= xDialogOpt
.getChild("cancel")
60 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
62 self
.ui_test
.close_doc()
64 # vim: set shiftwidth=4 softtabstop=4 expandtab: