Debian Codegraph @

sw/qa/uitest/writer_tests7/tdf119661.py

raw symbols SCIP
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 tdf119661(UITestCase):
17
18 def test_tdf119661(self):
19 with TemporaryDirectory() as tempdir:
20 xFilePath = os.path.join(tempdir, "tdf119661-tmp.odt")
21
22 with self.ui_test.create_doc_in_start_center("writer"):
23
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")}))
27
28 xLink = xOpenDialog.getChild("link")
29 self.assertEqual("false", get_state_as_dict(xLink)['Selected'])
30
31 xLink.executeAction("CLICK", tuple())
32
33 xOpenBtn = xOpenDialog.getChild("open")
34
35 #Confirmation dialog is displayed
36 with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK'):
37 pass
38
39 with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog:
40
41
42 sLinks = "TB_LINKS"
43 xLinks = xDialog.getChild(sLinks)
44 self.assertEqual(1, len(xLinks.getChildren()))
45
46 sFileName = "FULL_FILE_NAME"
47 xFileName = xDialog.getChild(sFileName)
48 self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("/LibreOffice.jpg"))
49
50 sBreakLink = "BREAK_LINK"
51 xBreakLink = xDialog.getChild(sBreakLink)
52
53 with self.ui_test.execute_blocking_action(xBreakLink.executeAction,
54 args=("CLICK", tuple()), close_button="yes"):
55 pass
56
57 # Save Copy as
58 with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="open") as xDialog:
59
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}))
64
65 with self.ui_test.load_file(systemPathToFileUrl(xFilePath)):
66
67 self.xUITest.executeCommand(".uno:LinkDialog")
68
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())
76
77 # vim: set shiftwidth=4 softtabstop=4 expandtab: