| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
from uitest.framework import UITestCase |
| 10 |
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file |
| 11 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 12 |
from libreoffice.linguistic.linguservice import get_lingu_service_manager |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
class tdf160170(UITestCase): |
| 17 |
def is_supported_locale(self, language, country): |
| 18 |
xLinguServiceManager = get_lingu_service_manager(self.ui_test._xContext) |
| 19 |
xHyphenator = xLinguServiceManager.getHyphenator() |
| 20 |
locales = xHyphenator.getLocales() |
| 21 |
for locale in locales: |
| 22 |
if language is not None: |
| 23 |
if locale.Language != language: |
| 24 |
continue |
| 25 |
|
| 26 |
if country is not None: |
| 27 |
if locale.Country != country: |
| 28 |
continue |
| 29 |
|
| 30 |
|
| 31 |
return True |
| 32 |
|
| 33 |
def set_custom_hyphenation(self): |
| 34 |
with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: |
| 35 |
|
| 36 |
xPages = xDialog.getChild("pages") |
| 37 |
xLanguageEntry = xPages.getChild('2') |
| 38 |
xLanguageEntry.executeAction("EXPAND", tuple()) |
| 39 |
xxLanguageEntryWritingAidsEntry = xLanguageEntry.getChild('1') |
| 40 |
xxLanguageEntryWritingAidsEntry.executeAction("SELECT", tuple()) |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
dictionaries = xDialog.getChild("lingudicts") |
| 47 |
hasEditableDictionary = False |
| 48 |
for i in dictionaries.getChildren(): |
| 49 |
entry = dictionaries.getChild(i) |
| 50 |
entry_label = get_state_as_dict(entry)["Text"] |
| 51 |
if entry_label == "List of Ignored Words [All]": |
| 52 |
hasEditableDictionary = True |
| 53 |
entry.executeAction("SELECT", tuple()) |
| 54 |
break |
| 55 |
|
| 56 |
self.assertEqual(True, hasEditableDictionary) |
| 57 |
|
| 58 |
|
| 59 |
edit = xDialog.getChild("lingudictsedit") |
| 60 |
with self.ui_test.execute_blocking_action(edit.executeAction, args=('CLICK', ()), close_button="close") as xEdit: |
| 61 |
|
| 62 |
inputbox = xEdit.getChild("word") |
| 63 |
inputbox.executeAction("TYPE", mkPropertyValues({"TEXT": "phare=tra"})) |
| 64 |
add = xEdit.getChild("newreplace") |
| 65 |
add.executeAction("CLICK", tuple()) |
| 66 |
|
| 67 |
def test_tdf160170(self): |
| 68 |
supported_locale = self.is_supported_locale("en", "US") |
| 69 |
if not supported_locale: |
| 70 |
self.skipTest("no hyphenation patterns for en_US available") |
| 71 |
|
| 72 |
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') |
| 73 |
with self.ui_test.load_file(get_url_for_data_file("tdf160170.fodt")) as writer_doc: |
| 74 |
|
| 75 |
|
| 76 |
self.set_custom_hyphenation() |
| 77 |
xToolkit.processEventsToIdle() |
| 78 |
|
| 79 |
self.xUITest.executeCommand(".uno:GoToEndOfLine") |
| 80 |
self.xUITest.executeCommand('.uno:StartOfDocumentSel') |
| 81 |
self.xUITest.executeCommand('.uno:Delete') |
| 82 |
paragraphs = writer_doc.Text.createEnumeration() |
| 83 |
para1 = paragraphs.nextElement() |
| 84 |
|
| 85 |
self.assertEqual("tra. Fusce pellentesque est orci.", para1.String) |