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()
22 #Go to Tools -> Options -> Charts -> Default Colors
23 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
24 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
26 xPages
= xDialogOpt
.getChild("pages")
27 xChartEntry
= xPages
.getChild('5') # Charts
28 xChartEntry
.executeAction("EXPAND", tuple())
29 xChartGeneralEntry
= xChartEntry
.getChild('0')
30 xChartGeneralEntry
.executeAction("SELECT", tuple()) #Default Colors
31 xColors
= xDialogOpt
.getChild("colors")
32 xAdd
= xDialogOpt
.getChild("add")
33 xDelete
= xDialogOpt
.getChild("delete")
34 xDefault
= xDialogOpt
.getChild("default")
35 #click Default - reset
36 xDefault
.executeAction("CLICK", tuple())
37 nrDefaultColors
= get_state_as_dict(xColors
)["EntryCount"]
38 nrDefaultColors1
= int(nrDefaultColors
) + 1
39 xAdd
.executeAction("CLICK", tuple()) #add new color
40 self
.assertEqual(get_state_as_dict(xColors
)["EntryCount"], str(nrDefaultColors1
))
42 def handle_delete_dlg(dialog
):
43 xyesBtn
= dialog
.getChild("yes")
44 self
.ui_test
.close_dialog_through_button(xyesBtn
)
46 self
.ui_test
.execute_blocking_action(xDelete
.executeAction
, args
=('CLICK', ()),
47 dialog_handler
=handle_delete_dlg
)
48 self
.assertEqual(get_state_as_dict(xColors
)["EntryCount"], nrDefaultColors
)
50 xAdd
.executeAction("CLICK", tuple()) #add new color
51 self
.assertEqual(get_state_as_dict(xColors
)["EntryCount"], str(nrDefaultColors1
))
53 xDefault
.executeAction("CLICK", tuple())
54 self
.assertEqual(get_state_as_dict(xColors
)["EntryCount"], nrDefaultColors
)
56 xCancelBtn
= xDialogOpt
.getChild("cancel")
57 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
59 self
.ui_test
.close_doc()
61 # vim: set shiftwidth=4 softtabstop=4 expandtab: