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_sheet_from_doc
12 from libreoffice
.calc
.conditional_format
import get_conditional_format_from_sheet
13 from uitest
.debug
import sleep
14 from libreoffice
.calc
.document
import get_cell_by_position
15 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
16 #Bug 81696 - CRASH while sorting cells with conditional formatting
18 import org
.libreoffice
.unotest
21 def get_url_for_data_file(file_name
):
22 return pathlib
.Path(org
.libreoffice
.unotest
.makeCopyFromTDOC(file_name
)).as_uri()
24 class tdf81696(UITestCase
):
26 def test_tdf81696_sort_cell_conditional_formatting(self
):
27 calc_doc
= self
.ui_test
.load_file(get_url_for_data_file("tdf81696.ods"))
28 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
29 gridwin
= xCalcDoc
.getChild("grid_window")
30 document
= self
.ui_test
.get_component()
32 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"}))
33 #Open sort dialog by DATA - SORT,Just sort it by Column A, ascending. (it's default)
34 self
.ui_test
.execute_dialog_through_command(".uno:DataSort")
35 xDialog
= self
.xUITest
.getTopFocusWindow()
36 xTabs
= xDialog
.getChild("tabcontrol")
37 xleftright
= xDialog
.getChild("leftright")
38 select_pos(xTabs
, "0")
40 xOK
= xDialog
.getChild("ok")
41 self
.ui_test
.close_dialog_through_button(xOK
)
43 self
.assertEqual(get_cell_by_position(document
, 0, 0, 0).getString(), "A")
44 self
.assertEqual(get_cell_by_position(document
, 0, 1, 0).getString(), "B")
45 self
.assertEqual(get_cell_by_position(document
, 0, 0, 1).getValue(), 1)
46 self
.assertEqual(get_cell_by_position(document
, 0, 1, 1).getValue(), 2)
47 self
.assertEqual(get_cell_by_position(document
, 0, 0, 2).getValue(), 2)
48 self
.assertEqual(get_cell_by_position(document
, 0, 1, 2).getValue(), 1)
50 self
.ui_test
.close_doc()
51 # vim: set shiftwidth=4 softtabstop=4 expandtab: