| 1 |
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 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/. |
| 8 |
# |
| 9 |
|
| 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 |
| 16 |
import os |
| 17 |
|
| 18 |
|
| 19 |
class exportToPDF(UITestCase): |
| 20 |
|
| 21 |
def test_checkDefaultValues(self): |
| 22 |
|
| 23 |
# test does not work with --disable-pdfimport config option |
| 24 |
if os.getenv('ENABLE_PDFIMPORT') != 'TRUE': |
| 25 |
return |
| 26 |
|
| 27 |
with TemporaryDirectory() as tempdir: |
| 28 |
xFilePath = os.path.join(tempdir, 'exportToPDFFromImpress-tmp' + str(os.getpid()) + '.pdf') |
| 29 |
|
| 30 |
with self.ui_test.create_doc_in_start_center("impress"): |
| 31 |
|
| 32 |
xTemplateDlg = self.xUITest.getTopFocusWindow() |
| 33 |
xCancelBtn = xTemplateDlg.getChild("close") |
| 34 |
self.ui_test.close_dialog_through_button(xCancelBtn) |
| 35 |
|
| 36 |
xDoc = self.xUITest.getTopFocusWindow() |
| 37 |
xEdit = xDoc.getChild("impress_win") |
| 38 |
|
| 39 |
xEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"Hello World"})) |
| 40 |
|
| 41 |
# Export as PDF |
| 42 |
with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="") as xDialog: |
| 43 |
|
| 44 |
selectedChildren = ['bookmarks', 'display', 'effects', 'enablea11y', |
| 45 |
'enablecopy', 'exporturl', 'changeresolution', 'tagged'] |
| 46 |
|
| 47 |
for child in selectedChildren: |
| 48 |
self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Selected']) |
| 49 |
|
| 50 |
nonSelectedChildren = ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders', |
| 51 |
'firstonleft', 'forms', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfua', 'resize', 'singlepagesheets', |
| 52 |
'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window'] |
| 53 |
|
| 54 |
for child in nonSelectedChildren: |
| 55 |
self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Selected']) |
| 56 |
|
| 57 |
checkedChildren = ['all', 'allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'outline', 'printhigh'] |
| 58 |
|
| 59 |
for child in checkedChildren: |
| 60 |
self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) |
| 61 |
|
| 62 |
nonCheckedChildren = ['changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', |
| 63 |
'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange', |
| 64 |
'selection', 'singlelayout', 'thumbs', 'visiblebookmark'] |
| 65 |
|
| 66 |
for child in nonCheckedChildren: |
| 67 |
self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Checked']) |
| 68 |
|
| 69 |
self.assertEqual("300 DPI", get_state_as_dict(xDialog.getChild("resolution"))['Text']) |
| 70 |
self.assertEqual("90", get_state_as_dict(xDialog.getChild("quality"))['Value']) |
| 71 |
self.assertEqual("FDF", get_state_as_dict(xDialog.getChild("format"))['DisplayText']) |
| 72 |
|
| 73 |
xOk = xDialog.getChild("ok") |
| 74 |
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="open") as xSaveDialog: |
| 75 |
xFileName = xSaveDialog.getChild('file_name') |
| 76 |
xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'})) |
| 77 |
xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'})) |
| 78 |
xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath})) |
| 79 |
|
| 80 |
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: |
| 81 |
|
| 82 |
self.assertEqual("", document.DrawPages[0][0].String) |
| 83 |
self.assertEqual(" ", document.DrawPages[0][1].String) |
| 84 |
self.assertEqual(" ", document.DrawPages[0][2].String) |
| 85 |
self.assertEqual("Hello World", document.DrawPages[0][3].String) |
| 86 |
|
| 87 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |