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 uitest
.uihelper
.common
import type_text
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 from org
.libreoffice
.unotest
import systemPathToFileUrl
15 from tempfile
import TemporaryDirectory
18 class exportToPDF(UITestCase
):
20 def test_checkDefaultValues(self
):
22 with
TemporaryDirectory() as tempdir
:
23 xFilePath
= os
.path
.join(tempdir
, 'exportToPDFFromWriter-tmp.pdf')
25 with self
.ui_test
.create_doc_in_start_center("writer"):
27 xMainWindow
= self
.xUITest
.getTopFocusWindow()
28 xEdit
= xMainWindow
.getChild("writer_edit")
30 type_text(xEdit
, "Hello World")
33 with self
.ui_test
.execute_dialog_through_command('.uno:ExportToPDF', close_button
="") as xDialog
:
35 selectedChildren
= ['bookmarks', 'display', 'effects', 'enablea11y',
36 'enablecopy', 'exporturl', 'changeresolution', 'tagged']
38 for child
in selectedChildren
:
39 self
.assertEqual("true", get_state_as_dict(xDialog
.getChild(child
))['Selected'])
41 nonSelectedChildren
= ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders',
42 'firstonleft', 'forms', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfa', 'pdfua', 'resize', 'singlepagesheets',
43 'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window']
45 for child
in nonSelectedChildren
:
46 self
.assertEqual("false", get_state_as_dict(xDialog
.getChild(child
))['Selected'])
48 checkedChildren
= ['all', 'allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'outline', 'printhigh']
50 for child
in checkedChildren
:
51 self
.assertEqual("true", get_state_as_dict(xDialog
.getChild(child
))['Checked'])
53 nonCheckedChildren
= ['changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis',
54 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange',
55 'selection', 'singlelayout', 'thumbs', 'visiblebookmark']
57 for child
in nonCheckedChildren
:
58 self
.assertEqual("false", get_state_as_dict(xDialog
.getChild(child
))['Checked'])
60 self
.assertEqual("300 DPI", get_state_as_dict(xDialog
.getChild("resolution"))['Text'])
61 self
.assertEqual("90", get_state_as_dict(xDialog
.getChild("quality"))['Value'])
62 self
.assertEqual("FDF", get_state_as_dict(xDialog
.getChild("format"))['DisplayText'])
64 xOk
= xDialog
.getChild("ok")
65 with self
.ui_test
.execute_dialog_through_action(xOk
, "CLICK", close_button
="open") as xSaveDialog
:
66 xFileName
= xSaveDialog
.getChild('file_name')
67 xFileName
.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
68 xFileName
.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
69 xFileName
.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath
}))
71 with self
.ui_test
.load_file(systemPathToFileUrl(xFilePath
)) as document
:
73 self
.assertEqual("Hello World", document
.DrawPages
[0][0].String
)
75 # vim: set shiftwidth=4 softtabstop=4 expandtab: