| 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 |
from uitest.framework import UITestCase |
| 10 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 11 |
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file |
| 12 |
from org.libreoffice.unotest import systemPathToFileUrl |
| 13 |
from tempfile import TemporaryDirectory |
| 14 |
import os.path |
| 15 |
|
| 16 |
class tdf141297(UITestCase): |
| 17 |
|
| 18 |
def test_tdf141297(self): |
| 19 |
with TemporaryDirectory() as tempdir: |
| 20 |
xFilePath = os.path.join(tempdir, "tdf141297-tmp.odp") |
| 21 |
|
| 22 |
with self.ui_test.create_doc_in_start_center("impress"): |
| 23 |
|
| 24 |
xTemplateDlg = self.xUITest.getTopFocusWindow() |
| 25 |
xCancelBtn = xTemplateDlg.getChild("close") |
| 26 |
self.ui_test.close_dialog_through_button(xCancelBtn) |
| 27 |
|
| 28 |
with self.ui_test.execute_dialog_through_command(".uno:InsertGraphic", close_button="") as xOpenDialog: |
| 29 |
|
| 30 |
xFileName = xOpenDialog.getChild("file_name") |
| 31 |
xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")})) |
| 32 |
|
| 33 |
xLink = xOpenDialog.getChild("link") |
| 34 |
self.assertEqual("false", get_state_as_dict(xLink)['Selected']) |
| 35 |
|
| 36 |
xLink.executeAction("CLICK", tuple()) |
| 37 |
|
| 38 |
xOpen = xOpenDialog.getChild("open") |
| 39 |
#Confirmation dialog is displayed |
| 40 |
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK"): |
| 41 |
pass |
| 42 |
|
| 43 |
with self.ui_test.execute_dialog_through_command(".uno:ManageLinks", close_button="close") as xDialog: |
| 44 |
|
| 45 |
sLinks = "TB_LINKS" |
| 46 |
xLinks = xDialog.getChild(sLinks) |
| 47 |
self.assertEqual(1, len(xLinks.getChildren())) |
| 48 |
|
| 49 |
sFileName = "FULL_FILE_NAME" |
| 50 |
xFileName = xDialog.getChild(sFileName) |
| 51 |
self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg")) |
| 52 |
|
| 53 |
sBreakLink = "BREAK_LINK" |
| 54 |
xBreakLink = xDialog.getChild(sBreakLink) |
| 55 |
|
| 56 |
with self.ui_test.execute_blocking_action(xBreakLink.executeAction, |
| 57 |
args=("CLICK", tuple()), close_button="yes"): |
| 58 |
pass |
| 59 |
|
| 60 |
# Save Copy as |
| 61 |
with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog: |
| 62 |
|
| 63 |
xFileName = xDialog.getChild("file_name") |
| 64 |
xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) |
| 65 |
xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) |
| 66 |
xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) |
| 67 |
|
| 68 |
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)): |
| 69 |
|
| 70 |
self.xUITest.executeCommand(".uno:ManageLinks") |
| 71 |
|
| 72 |
# Since the image is no longer linked, the link dialog is not open. |
| 73 |
# Without the fix in place, this dialog would have been opened |
| 74 |
xMainWin = self.xUITest.getTopFocusWindow() |
| 75 |
self.assertTrue(sLinks not in xMainWin.getChildren()) |
| 76 |
self.assertTrue(sFileName not in xMainWin.getChildren()) |
| 77 |
self.assertTrue(sBreakLink not in xMainWin.getChildren()) |
| 78 |
self.assertTrue("impress_win" in xMainWin.getChildren()) |
| 79 |
|
| 80 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |