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/.
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
16 class tdf141297(UITestCase
):
18 def test_tdf141297(self
):
19 with
TemporaryDirectory() as tempdir
:
20 xFilePath
= os
.path
.join(tempdir
, "tdf141297-tmp.odp")
22 with self
.ui_test
.create_doc_in_start_center("impress"):
24 xTemplateDlg
= self
.xUITest
.getTopFocusWindow()
25 xCancelBtn
= xTemplateDlg
.getChild("close")
26 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
28 with self
.ui_test
.execute_dialog_through_command(".uno:InsertGraphic", close_button
="") as xOpenDialog
:
30 xFileName
= xOpenDialog
.getChild("file_name")
31 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")}))
33 xLink
= xOpenDialog
.getChild("link")
34 self
.assertEqual("false", get_state_as_dict(xLink
)['Selected'])
36 xLink
.executeAction("CLICK", tuple())
38 xOpen
= xOpenDialog
.getChild("open")
39 #Confirmation dialog is displayed
40 with self
.ui_test
.execute_dialog_through_action(xOpen
, "CLICK"):
43 with self
.ui_test
.execute_dialog_through_command(".uno:ManageLinks", close_button
="close") as xDialog
:
46 xLinks
= xDialog
.getChild(sLinks
)
47 self
.assertEqual(1, len(xLinks
.getChildren()))
49 sFileName
= "FULL_FILE_NAME"
50 xFileName
= xDialog
.getChild(sFileName
)
51 self
.assertTrue(get_state_as_dict(xFileName
)["Text"].endswith("/LibreOffice.jpg"))
53 sBreakLink
= "BREAK_LINK"
54 xBreakLink
= xDialog
.getChild(sBreakLink
)
56 with self
.ui_test
.execute_blocking_action(xBreakLink
.executeAction
,
57 args
=("CLICK", tuple()), close_button
="yes"):
61 with self
.ui_test
.execute_dialog_through_command(".uno:SaveAs", close_button
="open") as xDialog
:
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
}))
68 with self
.ui_test
.load_file(systemPathToFileUrl(xFilePath
)):
70 self
.xUITest
.executeCommand(".uno:ManageLinks")
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())
80 # vim: set shiftwidth=4 softtabstop=4 expandtab: