Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / table / textToTable.py
blob5b70b89cc9780de6e73c3f05f7b103694fe4a2d0
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 libreoffice.uno.propertyvalue import mkPropertyValues
11 from uitest.uihelper.common import get_url_for_data_file, type_text
13 #Writer Text to table
15 class textToTable(UITestCase):
16 def test_text_to_table(self):
17 with self.ui_test.create_doc_in_start_center("writer") as document:
18 xWriterDoc = self.xUITest.getTopFocusWindow()
19 xWriterEdit = xWriterDoc.getChild("writer_edit")
20 #Enter A;B ; select the text ; dialog Text to table - Semicolon; verify
21 type_text(xWriterEdit, "A;B;C")
22 xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "5"}))
23 with self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") as xDialog:
24 semicolons = xDialog.getChild("semicolons")
25 semicolons.executeAction("CLICK", tuple())
26 #verify
27 self.assertEqual(document.TextTables.getCount(), 1)
28 tables = document.getTextTables()
29 self.assertEqual(len(tables[0].getRows()), 1)
30 self.assertEqual(len(tables[0].getColumns()), 3)
31 #undo
32 self.xUITest.executeCommand(".uno:Undo")
33 self.assertEqual(document.TextTables.getCount(), 0)
34 self.assertEqual(document.Text.String[0:5], "A;B;C")
37 def test_text_to_table_header(self):
38 with self.ui_test.load_file(get_url_for_data_file("textToTable.odt")) as writer_doc:
39 #open file; select all text ; dialog Text to table - other ":"; verify
40 self.xUITest.executeCommand(".uno:SelectAll")
41 with self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") as xDialog:
42 other = xDialog.getChild("other")
43 other.executeAction("CLICK", tuple())
44 othered = xDialog.getChild("othered")
45 othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
46 othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
47 othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"}))
48 headingcb = xDialog.getChild("headingcb")
49 headingcb.executeAction("CLICK", tuple())
50 #verify
51 self.assertEqual(writer_doc.TextTables.getCount(), 1)
52 tables = writer_doc.getTextTables()
53 self.assertEqual(len(tables[0].getRows()), 4)
54 self.assertEqual(len(tables[0].getColumns()), 3)
55 #undo
56 self.xUITest.executeCommand(".uno:Undo")
57 self.assertEqual(writer_doc.TextTables.getCount(), 0)
58 self.assertEqual(writer_doc.Text.String[0:5], "A:B:C")
60 # vim: set shiftwidth=4 softtabstop=4 expandtab: