| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 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 |
| 16 |
|
| 17 |
class Tdf145326(UITestCase): |
| 18 |
|
| 19 |
def test_tdf145326(self): |
| 20 |
|
| 21 |
with TemporaryDirectory() as tempdir: |
| 22 |
xFilePath = os.path.join(tempdir, "tdf145326-temp.odt") |
| 23 |
|
| 24 |
with self.ui_test.execute_dialog_through_command(".uno:Open", close_button="") as xOpenDialog: |
| 25 |
|
| 26 |
xFileName = xOpenDialog.getChild("file_name") |
| 27 |
xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf145326.odt")})) |
| 28 |
|
| 29 |
xOpenBtn = xOpenDialog.getChild("open") |
| 30 |
|
| 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 |
| 34 |
|
| 35 |
with self.ui_test.execute_dialog_through_command(".uno:LinkDialog", close_button="close") as xDialog: |
| 36 |
|
| 37 |
sLinks = "TB_LINKS" |
| 38 |
xLinks = xDialog.getChild(sLinks) |
| 39 |
self.assertEqual(1, len(xLinks.getChildren())) |
| 40 |
|
| 41 |
sFileName = "FULL_FILE_NAME" |
| 42 |
xFileName = xDialog.getChild(sFileName) |
| 43 |
self.assertTrue(get_state_as_dict(xFileName)["Text"].endswith("SAmple odp.ods")) |
| 44 |
|
| 45 |
sBreakLink = "BREAK_LINK" |
| 46 |
xBreakLink = xDialog.getChild(sBreakLink) |
| 47 |
|
| 48 |
with self.ui_test.execute_blocking_action(xBreakLink.executeAction, |
| 49 |
args=("CLICK", tuple()), close_button="yes"): |
| 50 |
pass |
| 51 |
|
| 52 |
|
| 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})) |
| 58 |
|
| 59 |
self.ui_test.close_doc() |
| 60 |
|
| 61 |
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as doc2: |
| 62 |
|
| 63 |
self.xUITest.executeCommand(".uno:LinkDialog") |
| 64 |
|
| 65 |
|
| 66 |
|
| 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()) |
| 72 |
|
| 73 |
self.assertEqual(len(doc2.TextTables), 1) |
| 74 |
table = doc2.getTextTables()[0] |
| 75 |
|
| 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()) |
| 83 |
|
| 84 |
|