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 tdf119661(UITestCase
):
18 def test_tdf119661(self
):
19 with
TemporaryDirectory() as tempdir
:
20 xFilePath
= os
.path
.join(tempdir
, "tdf119661-tmp.odt")
22 with self
.ui_test
.create_doc_in_start_center("writer"):
24 with self
.ui_test
.execute_dialog_through_command(".uno:InsertGraphic", close_button
="") as xOpenDialog
:
25 xFileName
= xOpenDialog
.getChild("file_name")
26 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("LibreOffice.jpg")}))
28 xLink
= xOpenDialog
.getChild("link")
29 self
.assertEqual("false", get_state_as_dict(xLink
)['Selected'])
31 xLink
.executeAction("CLICK", tuple())
33 xOpenBtn
= xOpenDialog
.getChild("open")
35 #Confirmation dialog is displayed
36 with self
.ui_test
.execute_dialog_through_action(xOpenBtn
, 'CLICK'):
39 with self
.ui_test
.execute_dialog_through_command(".uno:LinkDialog", close_button
="close") as xDialog
:
43 xLinks
= xDialog
.getChild(sLinks
)
44 self
.assertEqual(1, len(xLinks
.getChildren()))
46 sFileName
= "FULL_FILE_NAME"
47 xFileName
= xDialog
.getChild(sFileName
)
48 self
.assertTrue(get_state_as_dict(xFileName
)["Text"].endswith("/LibreOffice.jpg"))
50 sBreakLink
= "BREAK_LINK"
51 xBreakLink
= xDialog
.getChild(sBreakLink
)
53 with self
.ui_test
.execute_blocking_action(xBreakLink
.executeAction
,
54 args
=("CLICK", tuple()), close_button
="yes"):
58 with self
.ui_test
.execute_dialog_through_command(".uno:SaveAs", close_button
="open") as xDialog
:
60 xFileName
= xDialog
.getChild("file_name")
61 xFileName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
62 xFileName
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
63 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath
}))
65 with self
.ui_test
.load_file(systemPathToFileUrl(xFilePath
)):
67 self
.xUITest
.executeCommand(".uno:LinkDialog")
69 # Since the image is no longer linked, the link dialog is not open.
70 # Without the fix in place, this dialog would have been opened
71 xMainWin
= self
.xUITest
.getTopFocusWindow()
72 self
.assertTrue(sLinks
not in xMainWin
.getChildren())
73 self
.assertTrue(sFileName
not in xMainWin
.getChildren())
74 self
.assertTrue(sBreakLink
not in xMainWin
.getChildren())
75 self
.assertTrue("writer_edit" in xMainWin
.getChildren())
77 # vim: set shiftwidth=4 softtabstop=4 expandtab: