Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / qa / uitest / impress_tests / exportToPDF.py
blob429e28df4f0dd2876e9de71ee1813146fa0a02af
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 uitest.uihelper.common import get_state_as_dict
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from org.libreoffice.unotest import systemPathToFileUrl
14 from tempfile import TemporaryDirectory
15 import os.path
18 class exportToPDF(UITestCase):
20 def test_checkDefaultValues(self):
22 with TemporaryDirectory() as tempdir:
23 xFilePath = os.path.join(tempdir, 'exportToPDFFromImpress-tmp.pdf')
25 with self.ui_test.create_doc_in_start_center("impress"):
27 xTemplateDlg = self.xUITest.getTopFocusWindow()
28 xCancelBtn = xTemplateDlg.getChild("close")
29 self.ui_test.close_dialog_through_button(xCancelBtn)
31 xDoc = self.xUITest.getTopFocusWindow()
32 xEdit = xDoc.getChild("impress_win")
34 xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"Hello World"}))
36 # Export as PDF
37 with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="") as xDialog:
39 selectedChildren = ['bookmarks', 'display', 'effects', 'enablea11y',
40 'enablecopy', 'exporturl', 'forms', 'reduceresolution', 'tagged']
42 for child in selectedChildren:
43 self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Selected'])
45 nonSelectedChildren = ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders',
46 'firstonleft', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfa', 'pdfua', 'resize', 'singlepagesheets',
47 'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window']
49 for child in nonSelectedChildren:
50 self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Selected'])
52 checkedChildren = ['all', 'allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'outline', 'printhigh']
54 for child in checkedChildren:
55 self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked'])
57 nonCheckedChildren = ['changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis',
58 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'range',
59 'selection', 'singlelayout', 'thumbs', 'visiblebookmark']
61 for child in nonCheckedChildren:
62 self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Checked'])
64 self.assertEqual("300 DPI", get_state_as_dict(xDialog.getChild("resolution"))['Text'])
65 self.assertEqual("90", get_state_as_dict(xDialog.getChild("quality"))['Value'])
66 self.assertEqual("FDF", get_state_as_dict(xDialog.getChild("format"))['DisplayText'])
68 xOk = xDialog.getChild("ok")
69 with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="open") as xSaveDialog:
70 xFileName = xSaveDialog.getChild('file_name')
71 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
72 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
73 xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath}))
75 with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
77 self.assertEqual("", document.DrawPages[0].getByIndex(0).String)
78 self.assertEqual(" ", document.DrawPages[0].getByIndex(1).String)
79 self.assertEqual(" ", document.DrawPages[0].getByIndex(2).String)
80 self.assertEqual("Hello World", document.DrawPages[0].getByIndex(3).String)
82 # vim: set shiftwidth=4 softtabstop=4 expandtab: