merge duplicate part of branches
[LibreOffice.git] / sw / qa / uitest / writer_tests5 / tdf145326.py
blob6a4d9e361495bec062026b86974f2ceff1163f5f
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/.
10 from uitest.framework import UITestCase
11 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from org.libreoffice.unotest import systemPathToFileUrl
14 from tempfile import TemporaryDirectory
15 import os.path
17 class Tdf145326(UITestCase):
19 def test_tdf145326(self):
21 with TemporaryDirectory() as tempdir:
22 xFilePath = os.path.join(tempdir, "tdf145326-temp.odt")
24 with self.ui_test.execute_dialog_through_command(".uno:Open", close_button="") as xOpenDialog:
26 xFileName = xOpenDialog.getChild("file_name")
27 xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf145326.odt")}))
29 xOpenBtn = xOpenDialog.getChild("open")
30 # Update all links dialog
31 with self.ui_test.wait_until_component_loaded():
32 with self.ui_test.execute_blocking_action(xOpenBtn.executeAction, args=('CLICK', ()), close_button="yes"):
33 pass
35 with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog:
37 sLinks = "TB_LINKS"
38 xLinks = xDialog.getChild(sLinks)
39 self.assertEqual(1, len(xLinks.getChildren()))
41 sFileName = "FULL_FILE_NAME"
42 xFileName = xDialog.getChild(sFileName)
43 self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("SAmple odp.ods"))
45 sBreakLink = "BREAK_LINK"
46 xBreakLink = xDialog.getChild(sBreakLink)
48 with self.ui_test.execute_blocking_action(xBreakLink.executeAction,
49 args=("CLICK", tuple()), close_button="yes"):
50 pass
52 # Save Copy as
53 with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="open") as xDialog:
54 xFileName = xDialog.getChild('file_name')
55 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
56 xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
57 xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath}))
59 self.ui_test.close_doc()
61 with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as doc2:
63 self.xUITest.executeCommand(".uno:LinkDialog")
65 # Since the image is no longer linked, the link dialog is not open.
66 # Without the fix in place, this dialog would have been opened
67 xMainWin = self.xUITest.getTopFocusWindow()
68 self.assertTrue(sLinks not in xMainWin.getChildren())
69 self.assertTrue(sFileName not in xMainWin.getChildren())
70 self.assertTrue(sBreakLink not in xMainWin.getChildren())
71 self.assertTrue("writer_edit" in xMainWin.getChildren())
73 self.assertEqual(len(doc2.TextTables), 1)
74 table = doc2.getTextTables()[0]
76 self.assertEqual(len(table.getRows()), 7)
77 self.assertEqual("10,000", table.getCellByName("D2").getString())
78 self.assertEqual("20,000", table.getCellByName("D3").getString())
79 self.assertEqual("5,000", table.getCellByName("D4").getString())
80 self.assertEqual("7,000", table.getCellByName("D5").getString())
81 self.assertEqual("5,000", table.getCellByName("D6").getString())
82 self.assertEqual("7,000", table.getCellByName("D7").getString())
84 # vim: set shiftwidth=4 softtabstop=4 expandtab: