tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / qa / uitest / calc_tests4 / saveToCSV.py
blob09949b7d71e87f5bfed37e8a475cbc4703b5750f
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 import os.path
11 from tempfile import TemporaryDirectory
13 from uitest.framework import UITestCase
14 from uitest.uihelper.calc import enter_text_to_cell
15 from uitest.uihelper.common import get_state_as_dict
16 from uitest.uihelper.common import select_by_text
17 from libreoffice.uno.propertyvalue import mkPropertyValues
20 class saveToCSV(UITestCase):
22 def test_saveToCSVDialog(self):
24 with TemporaryDirectory() as tempdir:
25 xFilePath = os.path.join(tempdir, 'exportToCSV-tmp.csv')
27 with self.ui_test.create_doc_in_start_center("calc"):
29 calcDoc = self.xUITest.getTopFocusWindow()
30 gridwin = calcDoc.getChild("grid_window")
32 enter_text_to_cell(gridwin, "A1", "1")
33 enter_text_to_cell(gridwin, "A2", "2")
34 enter_text_to_cell(gridwin, "A3", "3")
35 enter_text_to_cell(gridwin, "A4", "=SUM(A1:A3)")
37 # Save the document
38 with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog:
39 xFileName = xSaveDialog.getChild("file_name")
40 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
41 xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
42 xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath}))
43 xFileTypeCombo = xSaveDialog.getChild("file_type")
44 select_by_text(xFileTypeCombo, "Text CSV (.csv)")
45 xOpen = xSaveDialog.getChild("open")
47 with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog:
48 # CSV confirmation dialog is displayed
49 xSave = xWarnDialog.getChild("save")
51 with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog:
52 xFormulas = xCsvDialog.getChild("formulas")
53 xAsShown = xCsvDialog.getChild("asshown")
54 xFixedWidth = xCsvDialog.getChild("fixedwidth")
55 xQuoteAll = xCsvDialog.getChild("quoteall")
56 self.assertEqual("false", get_state_as_dict(xFormulas)['Selected'])
57 self.assertEqual("false", get_state_as_dict(xQuoteAll)['Selected'])
58 self.assertEqual("false", get_state_as_dict(xFixedWidth)['Selected'])
59 self.assertEqual("true", get_state_as_dict(xAsShown)['Selected'])
61 xFormulas.executeAction("CLICK", tuple())
63 with open(xFilePath, "r") as f:
64 lines = f.readlines()
65 self.assertEqual("1", lines[0].strip())
66 self.assertEqual("2", lines[1].strip())
67 self.assertEqual("3", lines[2].strip())
68 self.assertEqual("=SUM(A1:A3)", lines[3].strip())
70 # vim: set shiftwidth=4 softtabstop=4 expandtab: