Avoid potential negative array index access to cached text.
[LibreOffice.git] / sc / qa / uitest / calc_tests4 / exportToPDF.py
blob777d9899e4211d5c5243d26351e28b82ebf2e6da
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 libreoffice.uno.propertyvalue import mkPropertyValues
17 from org.libreoffice.unotest import systemPathToFileUrl
20 class exportToPDF(UITestCase):
22 def test_checkDefaultValues(self):
24 with TemporaryDirectory() as tempdir:
25 xFilePath = os.path.join(tempdir, 'exportToPDFFromCalc-tmp.pdf')
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", "Hello World")
34 # Export as PDF
35 with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="") as xDialog:
37 selectedChildren = ['bookmarks', 'display', 'effects', 'enablea11y',
38 'enablecopy', 'exporturl', 'forms', 'reduceresolution', 'tagged']
40 for child in selectedChildren:
41 self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Selected'])
43 nonSelectedChildren = ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders',
44 'firstonleft', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfa', 'pdfua', 'resize', 'singlepagesheets',
45 'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window']
47 for child in nonSelectedChildren:
48 self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Selected'])
50 checkedChildren = ['allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'outline', 'printhigh', 'selection']
52 for child in checkedChildren:
53 self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked'])
55 nonCheckedChildren = ['all', 'changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', 'fitwidth',
56 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange', 'sheetrange',
57 'singlelayout', 'thumbs', 'visiblebookmark']
59 for child in nonCheckedChildren:
60 self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Checked'])
62 self.assertEqual("300 DPI", get_state_as_dict(xDialog.getChild("resolution"))['Text'])
63 self.assertEqual("90", get_state_as_dict(xDialog.getChild("quality"))['Value'])
64 self.assertEqual("FDF", get_state_as_dict(xDialog.getChild("format"))['DisplayText'])
66 xOk = xDialog.getChild("ok")
67 with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="open") as xSaveDialog:
68 xFileName = xSaveDialog.getChild('file_name')
69 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
70 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
71 xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath}))
73 with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
75 self.assertEqual("Sheet1", document.DrawPages[0][0].String)
76 self.assertEqual("Page 1", document.DrawPages[0][1].String)
77 self.assertEqual("Hello World", document.DrawPages[0][2].String)
79 # vim: set shiftwidth=4 softtabstop=4 expandtab: