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/.
10 from uitest
.framework
import UITestCase
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import select_by_text
13 from uitest
.uihelper
.common
import type_text
15 class WriterSort(UITestCase
):
18 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
19 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
20 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
22 type_text(xWriterEdit
, "a")
23 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
24 type_text(xWriterEdit
, "c")
25 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
26 type_text(xWriterEdit
, "v")
28 self
.xUITest
.executeCommand(".uno:SelectAll") #select whole text
30 with self
.ui_test
.execute_dialog_through_command(".uno:SortDialog") as xDialog
:
31 xDown
= xDialog
.getChild("down1")
32 xDown
.executeAction("CLICK", tuple())
34 self
.assertEqual(document
.Text
.String
[0:1], "v")
37 def test_sort_numerical(self
):
38 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
39 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
40 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
42 type_text(xWriterEdit
, "1;2;3")
43 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
44 type_text(xWriterEdit
, "2;8;3")
46 self
.xUITest
.executeCommand(".uno:SelectAll") #select whole text
48 with self
.ui_test
.execute_dialog_through_command(".uno:SortDialog") as xDialog
:
49 xDown
= xDialog
.getChild("down1")
50 xtypelb1
= xDialog
.getChild("typelb1")
51 xcharacter
= xDialog
.getChild("character")
52 xseparator
= xDialog
.getChild("separator")
53 xDown
.executeAction("CLICK", tuple())
54 select_by_text(xtypelb1
, "Numerical")
55 xcharacter
.executeAction("CLICK", tuple())
56 xseparator
.executeAction("TYPE", mkPropertyValues({"TEXT":";"}))
58 self
.assertEqual(document
.Text
.String
[0:5], "2;8;3")
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: