1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.common
import get_state_as_dict
11 from uitest
.uihelper
.common
import select_pos
12 from uitest
.uihelper
.calc
import enter_text_to_cell
13 from libreoffice
.calc
.document
import get_cell_by_position
14 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
16 class tdf100517(UITestCase
):
18 def execute_sort_dialog(self
, gridwin
, bIncludeNotes
):
19 gridwin
.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B3"}))
21 with self
.ui_test
.execute_dialog_through_command(".uno:DataSort") as xDialog
:
22 xTabs
= xDialog
.getChild("tabcontrol")
23 select_pos(xTabs
, "1")
25 xIncludeNotes
= xDialog
.getChild("includenotes")
27 if (get_state_as_dict(xIncludeNotes
)["Selected"]) != bIncludeNotes
:
28 xIncludeNotes
.executeAction("CLICK", tuple())
31 def test_tdf100517(self
):
32 with self
.ui_test
.create_doc_in_start_center("calc") as document
:
33 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
34 gridwin
= xCalcDoc
.getChild("grid_window")
36 enter_text_to_cell(gridwin
, "A1", "Text 2")
37 enter_text_to_cell(gridwin
, "A2", "Text 3")
38 enter_text_to_cell(gridwin
, "A3", "Text 1")
40 for i
in ['B1', 'B2', 'B3']:
41 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": i
}))
42 xArgs
= mkPropertyValues({"Text": i
})
44 self
.xUITest
.executeCommandWithParameters(".uno:InsertAnnotation", xArgs
)
46 self
.execute_sort_dialog(gridwin
, "true")
48 self
.assertEqual("Text 1", get_cell_by_position(document
, 0, 0, 0).getString())
49 self
.assertEqual("Text 2", get_cell_by_position(document
, 0, 0, 1).getString())
50 self
.assertEqual("Text 3", get_cell_by_position(document
, 0, 0, 2).getString())
52 self
.assertEqual("B3", get_cell_by_position(document
, 0, 1, 0).Annotation
.String
)
53 self
.assertEqual("B1", get_cell_by_position(document
, 0, 1, 1).Annotation
.String
)
54 self
.assertEqual("B2", get_cell_by_position(document
, 0, 1, 2).Annotation
.String
)
56 self
.xUITest
.executeCommand(".uno:Undo")
58 self
.assertEqual("Text 2", get_cell_by_position(document
, 0, 0, 0).getString())
59 self
.assertEqual("Text 3", get_cell_by_position(document
, 0, 0, 1).getString())
60 self
.assertEqual("Text 1", get_cell_by_position(document
, 0, 0, 2).getString())
62 self
.assertEqual("B1", get_cell_by_position(document
, 0, 1, 0).Annotation
.String
)
63 self
.assertEqual("B2", get_cell_by_position(document
, 0, 1, 1).Annotation
.String
)
64 self
.assertEqual("B3", get_cell_by_position(document
, 0, 1, 2).Annotation
.String
)
66 self
.execute_sort_dialog(gridwin
, "false")
68 self
.assertEqual("Text 1", get_cell_by_position(document
, 0, 0, 0).getString())
69 self
.assertEqual("Text 2", get_cell_by_position(document
, 0, 0, 1).getString())
70 self
.assertEqual("Text 3", get_cell_by_position(document
, 0, 0, 2).getString())
72 self
.assertEqual("B1", get_cell_by_position(document
, 0, 1, 0).Annotation
.String
)
73 self
.assertEqual("B2", get_cell_by_position(document
, 0, 1, 1).Annotation
.String
)
74 self
.assertEqual("B3", get_cell_by_position(document
, 0, 1, 2).Annotation
.String
)
77 # vim: set shiftwidth=4 softtabstop=4 expandtab: