diff options
Diffstat (limited to 'sw/qa/uitest/fieldDialog')
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf129796.py | 76 | ||||
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf135377.py | 46 | ||||
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf143483.py | 57 | ||||
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf145062.py | 63 | ||||
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf146462.py | 45 | ||||
-rw-r--r-- | sw/qa/uitest/fieldDialog/tdf148551.py | 44 |
6 files changed, 331 insertions, 0 deletions
diff --git a/sw/qa/uitest/fieldDialog/tdf129796.py b/sw/qa/uitest/fieldDialog/tdf129796.py new file mode 100644 index 000000000..fb764f7ae --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf129796.py @@ -0,0 +1,76 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class Tdf129796(UITestCase): + + def test_tdf129796(self): + + with self.ui_test.create_doc_in_start_center("writer") as writer_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "4") + + xType = xDialog.getChild("type-var") + xType.getChild('8').executeAction("SELECT", tuple()) + self.assertEqual("User Field", get_state_as_dict(xType)['SelectEntryText']) + + xNumFormat = xDialog.getChild("numformat-var") + xNumFormat.getChild('0').executeAction("SELECT", tuple()) + self.assertEqual("Text", get_state_as_dict(xNumFormat)['SelectEntryText']) + + xName = xDialog.getChild("name-var") + xName.executeAction("TYPE", mkPropertyValues({"TEXT": "MyField"})) + + xValue = xDialog.getChild("value-var") + xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "abc"})) + + xApplyBtn = xDialog.getChild("apply") + xApplyBtn.executeAction("CLICK", ()) + + xType.getChild('4').executeAction("SELECT", tuple()) + self.assertEqual("Input field", get_state_as_dict(xType)['SelectEntryText']) + + self.assertEqual("MyField", get_state_as_dict(xDialog.getChild("select-var"))["SelectEntryText"]) + + xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "ref"})) + + xOkBtn = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())) as xFieldDialog: + xName = xFieldDialog.getChild("name") + self.assertEqual("ref", get_state_as_dict(xName)['Text']) + xText = xFieldDialog.getChild("text") + self.assertEqual("abc", get_state_as_dict(xText)['Text']) + + textfields = writer_doc.getTextFields() + textfield = textfields.createEnumeration().nextElement() + self.assertEqual('MyField', textfield.Content) + self.assertTrue(textfield.supportsService("com.sun.star.text.TextField.InputUser")) + + # Move the cursor to the field + self.xUITest.executeCommand(".uno:GoLeft") + + with self.ui_test.execute_dialog_through_command(".uno:FieldDialog") as xDialog: + xType = xDialog.getChild("type-var") + xNumFormat = xDialog.getChild("numformat-var") + xValue = xDialog.getChild("value-var") + xName = xDialog.getChild("name-var") + + # Without the fix in place, this test would have crashed here + self.assertEqual("ref", get_state_as_dict(xValue)['Text']) + self.assertEqual("Input field", get_state_as_dict(xType)['SelectEntryText']) + self.assertEqual("General", get_state_as_dict(xNumFormat)['SelectEntryText']) + self.assertEqual("MyField", get_state_as_dict(xName)['Text']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/fieldDialog/tdf135377.py b/sw/qa/uitest/fieldDialog/tdf135377.py new file mode 100644 index 000000000..b5751bedf --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf135377.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class Tdf135377(UITestCase): + + def test_tdf135377(self): + + with self.ui_test.create_doc_in_start_center("writer") as writer_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "4") + + xType = xDialog.getChild("type-var") + xType.getChild('8').executeAction("SELECT", tuple()) + self.assertEqual("User Field", get_state_as_dict(xType)['SelectEntryText']) + + xName = xDialog.getChild("name-var") + xName.executeAction("TYPE", mkPropertyValues({"TEXT": "AA"})) + + xValue = xDialog.getChild("value-var") + xValue.executeAction("TYPE", mkPropertyValues({"TEXT": "BB"})) + + xNumFormat = xDialog.getChild("numformat-var") + + # Without the fix in place, this test would have failed with + # AssertionError: 'General' != '' + self.assertEqual("General", get_state_as_dict(xNumFormat)['SelectEntryText']) + + xApplyBtn = xDialog.getChild("apply") + xApplyBtn.executeAction("CLICK", ()) + + self.assertEqual("AA", get_state_as_dict(xDialog.getChild("select-var"))["SelectEntryText"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/fieldDialog/tdf143483.py b/sw/qa/uitest/fieldDialog/tdf143483.py new file mode 100644 index 000000000..346fe6074 --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf143483.py @@ -0,0 +1,57 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class Tdf143483(UITestCase): + + def test_tdf143483(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf143483.odt")) as document: + + self.xUITest.executeCommand(".uno:JumpToNextBookmark") + + with self.ui_test.execute_dialog_through_command(".uno:FieldDialog") as xDialog: + + xDoc = xDialog.getChild("type-doc") + self.assertEqual("Chapter", get_state_as_dict(xDoc)['SelectEntryText']) + + xFormat = xDialog.getChild("format-doc") + self.assertEqual("Chapter name", get_state_as_dict(xFormat)['SelectEntryText']) + + xNext = xDialog.getChild("next") + xNext.executeAction("CLICK", tuple()) + + self.assertEqual("Chapter", get_state_as_dict(xDoc)['SelectEntryText']) + self.assertEqual("Chapter number", get_state_as_dict(xFormat)['SelectEntryText']) + + xNext.executeAction("CLICK", tuple()) + + self.assertEqual("Chapter", get_state_as_dict(xDoc)['SelectEntryText']) + self.assertEqual("Chapter number and name", get_state_as_dict(xFormat)['SelectEntryText']) + + xNext.executeAction("CLICK", tuple()) + + self.assertEqual("Chapter", get_state_as_dict(xDoc)['SelectEntryText']) + self.assertEqual("Chapter number without separator", get_state_as_dict(xFormat)['SelectEntryText']) + + xEnumeration = document.Text.createEnumeration() + self.assertEqual("Another title", xEnumeration.nextElement().String) + self.assertEqual("", xEnumeration.nextElement().String) + self.assertEqual("1. Another title", xEnumeration.nextElement().String) + + # Without the fix in place, this test would have failed with + # AssertionError: '2. Chapter 1 -' != '2. Another title' + self.assertEqual("2. Chapter 1 -", xEnumeration.nextElement().String) + self.assertEqual("3. Chapter 1 - Another title", xEnumeration.nextElement().String) + self.assertEqual("4. 1", xEnumeration.nextElement().String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/fieldDialog/tdf145062.py b/sw/qa/uitest/fieldDialog/tdf145062.py new file mode 100644 index 000000000..09bcec80f --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf145062.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class Tdf145062(UITestCase): + + def test_tdf145062(self): + + with self.ui_test.create_doc_in_start_center("writer") as writer_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "2") + + xType = xDialog.getChild("type-func") + xType.getChild('2').executeAction("SELECT", tuple()) + self.assertEqual("Input field", get_state_as_dict(xType)['SelectEntryText']) + + xOkBtn = xDialog.getChild("ok") + with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())) as xFieldDialog: + xText = xFieldDialog.getChild("text") + xText.executeAction("TYPE", mkPropertyValues({"TEXT": "AAA"})) + + # move cursor to the middle of the field + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + + xType.getChild('6').executeAction("SELECT", tuple()) + self.assertEqual("Hidden text", get_state_as_dict(xType)['SelectEntryText']) + + # try to insert a hidden text a few times + # Without the fix in place, this test would have crashed here + for i in range(10): + xOkBtn.executeAction("CLICK", ()) + + # close_dialog_through_button should be used here but it hangs and + # the reason seems to be that interacting with the document while + # the dialog is open doesn't play well together in the uitests + # As a workaround, leave the dialog open, close the document, + # open a new one and then, close the dialog. + # If the dialog is not closed, it will be displayed in other tests + + textfields = writer_doc.getTextFields() + textfield = textfields.createEnumeration().nextElement() + self.assertTrue(textfield.supportsService("com.sun.star.text.TextField.Input")) + self.assertEqual('AAA', textfield.Content) + + with self.ui_test.load_empty_file("writer"): + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/fieldDialog/tdf146462.py b/sw/qa/uitest/fieldDialog/tdf146462.py new file mode 100644 index 000000000..95eae5ac0 --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf146462.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.uihelper.common import select_pos + +class Tdf146462(UITestCase): + + def test_tdf146462(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "Header") + + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%201&FamilyName:string=ParagraphStyles") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "1") + + xType = xDialog.getChild("type-ref") + xType.getChild('2').executeAction("SELECT", tuple()) + self.assertEqual("Headings", get_state_as_dict(xType)['SelectEntryText']) + + xFormat = xDialog.getChild("format-ref") + self.assertEqual("Page number (unstyled)", get_state_as_dict(xFormat)['SelectEntryText']) + + xSelect = xDialog.getChild("selecttip") + + # Without the fix in place, this test would have failed with + # AssertionError: 'Header' != '' + self.assertEqual("Header", get_state_as_dict(xSelect)['SelectEntryText']) + self.assertEqual("1", get_state_as_dict(xSelect)['Children']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/fieldDialog/tdf148551.py b/sw/qa/uitest/fieldDialog/tdf148551.py new file mode 100644 index 000000000..2d0de314b --- /dev/null +++ b/sw/qa/uitest/fieldDialog/tdf148551.py @@ -0,0 +1,44 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.uihelper.common import select_pos + +class Tdf148551(UITestCase): + + def test_tdf148551(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertField", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + xDoc = xDialog.getChild("type-doc") + xDoc.getChild('7').executeAction("SELECT", tuple()) + self.assertEqual("Statistics", get_state_as_dict(xDoc)['SelectEntryText']) + + xSelect = xDialog.getChild("select-doc") + self.assertEqual("Pages", get_state_as_dict(xSelect)['SelectEntryText']) + + xFormat = xDialog.getChild("format-doc") + self.assertEqual("As Page Style", get_state_as_dict(xFormat)['SelectEntryText']) + + xOk = xDialog.getChild("ok") + xOk.executeAction("CLICK", tuple()) + + # Without the fix in place, this test would have failed with + # AssertionError: '1' != 'A' + self.assertEqual("1", document.Text.createEnumeration().nextElement().String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |