diff options
Diffstat (limited to 'sw/qa/uitest/ui')
-rw-r--r-- | sw/qa/uitest/ui/fmtui/fmtui.py | 33 | ||||
-rw-r--r-- | sw/qa/uitest/ui/frmdlg/frmdlg.py | 153 | ||||
-rw-r--r-- | sw/qa/uitest/ui/index/index.py | 53 | ||||
-rw-r--r-- | sw/qa/uitest/ui/misc/misc.py | 74 |
4 files changed, 313 insertions, 0 deletions
diff --git a/sw/qa/uitest/ui/fmtui/fmtui.py b/sw/qa/uitest/ui/fmtui/fmtui.py new file mode 100644 index 0000000000..87f3250837 --- /dev/null +++ b/sw/qa/uitest/ui/fmtui/fmtui.py @@ -0,0 +1,33 @@ +# -*- 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/. +# + +"""Covers sw/source/ui/fmtui/ fixes.""" + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class TestTmpdlg(UITestCase): + + def test_para_style_semi_transparent_text(self): + + with self.ui_test.create_doc_in_start_center("writer"): + with self.ui_test.execute_dialog_through_command(".uno:EditStyle", close_button="cancel") as xDialog: + + xTabs = xDialog.getChild("tabcontrol") + # Select RID_SVXPAGE_CHAR_EFFECTS. + select_pos(xTabs, "1") + xFontTransparency = xDialog.getChild("fonttransparencymtr") + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 'false' != 'true' + # i.e. the control was hidden in the paragraph style dialog. + self.assertEqual(get_state_as_dict(xFontTransparency)["Visible"], "true") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py new file mode 100644 index 0000000000..36de1876bd --- /dev/null +++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py @@ -0,0 +1,153 @@ +# -*- 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/. +# + +"""Covers sw/source/ui/frmdlg/ fixes.""" + +import time +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import get_url_for_data_file + + +class Test(UITestCase): + def test_uno_frame_dialog(self): + with self.ui_test.create_doc_in_start_center("writer") as xComponent: + # Given a document with a floating table: + args = { + "Columns": 1, + "Rows": 1, + } + self.xUITest.executeCommandWithParameters(".uno:InsertTable", mkPropertyValues(args)) + self.xUITest.executeCommand(".uno:SelectAll") + args = { + "AnchorType": 0, + } + self.xUITest.executeCommandWithParameters(".uno:InsertFrame", mkPropertyValues(args)) + # Wait until SwTextShell is replaced with SwDrawShell after 120 ms, as set in the SwView + # ctor. + time.sleep(0.2) + self.assertEqual(xComponent.TextFrames.Frame1.IsSplitAllowed, False) + + # When allowing it to split on the UI: + with self.ui_test.execute_dialog_through_command(".uno:FrameDialog") as xDialog: + xFlysplit = xDialog.getChild("flysplit") + self.assertEqual(get_state_as_dict(xFlysplit)['Visible'], "true") + self.assertEqual(get_state_as_dict(xFlysplit)['Selected'], "false") + xFlysplit.executeAction("CLICK", tuple()) + + # Then make sure the doc model is updated correctly: + self.assertEqual(xComponent.TextFrames.Frame1.IsSplitAllowed, True) + + def test_chained_fly_split(self): + # Given a document with 2 chained fly frames: + with self.ui_test.load_file(get_url_for_data_file("chained-frames.odt")): + # When selecting the first and opening the fly frame properties dialog: + self.xUITest.executeCommand(".uno:JumpToNextFrame") + # Wait until SwTextShell is replaced with SwDrawShell after 120 ms, as set in the SwView + # ctor. + time.sleep(0.2) + with self.ui_test.execute_dialog_through_command(".uno:FrameDialog") as xDialog: + # Then make sure that the 'split' checkbox is hidden: + xFlysplit = xDialog.getChild("flysplit") + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 'true' != 'false' + # i.e. the UI didn't hide this option, leading to some weird mix of chained shapes + # and floating tables. + self.assertEqual(get_state_as_dict(xFlysplit)['Visible'], "false") + + def test_insert_frame_dialog(self): + # Change from inch to cm to hit the rounding error. 2 means Centimeter, see + # officecfg/registry/schema/org/openoffice/Office/Writer.xcs. + with self.ui_test.set_config('/org.openoffice.Office.Writer/Layout/Other/MeasureUnit', 2): + # Given a Writer document: + with self.ui_test.create_doc_in_start_center("writer") as xComponent: + # When inserting a new frame with the default width: + with self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog: + xWidth = xDialog.getChild("width") + frame_width = float(get_state_as_dict(xWidth)["Value"]) + # Then make sure the width is not zero: + # cm -> mm100 + expected_mm100 = frame_width * 1000 + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 0 != 2000.0 + # i.e. the width was empty instead of the size from the UI. + self.assertEqual(xComponent.TextFrames.Frame1.Size.Width, expected_mm100) + + def test_insert_floating_table(self): + with self.ui_test.create_doc_in_start_center("writer") as xComponent: + # Given a Writer document with a selected (inline) table: + args = { + "Columns": 1, + "Rows": 1, + } + self.xUITest.executeCommandWithParameters(".uno:InsertTable", mkPropertyValues(args)) + self.xUITest.executeCommand(".uno:SelectAll") + # When converting it to a split fly: + with self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog: + xFlySplit = xDialog.getChild("flysplit") + fly_split_visible = get_state_as_dict(xFlySplit)["Visible"] == "true" + # Then make sure the inserted fly can be marked as "split allowed": + # Without the accompanying fix in place, this test would have failed, the fly had to be + # inserted first, only then it could be marked as "split allowed". + self.assertEqual(fly_split_visible, True) + + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 2 != 0 + # i.e. the frame had a border by default when the table already had its own border. + self.assertEqual(xComponent.TextFrames.Frame1.LeftBorder.LineWidth, 0) + + def test_insert_simple_frame(self): + # Given a Writer document: + with self.ui_test.create_doc_in_start_center("writer") as xComponent: + # When inserting a simple text frame (not a floating table): + with self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialog: + to_char = xDialog.getChild("tochar") + to_char_enabled = get_state_as_dict(to_char)["Checked"] == "true" + # Then make sure the anchor type is to-char, matching the default anchor for images: + # This failed, text frames defaulted to to-para, images defaulted to to-char, which was + # inconsistent. + self.assertTrue(to_char_enabled) + + def test_floattable_in_shape_text(self): + with self.ui_test.load_file(get_url_for_data_file("floattable-in-shape-text.docx")) as xComponent: + # Given a table in a frame, anchored in shape text (TextBox case): + self.xUITest.executeCommand(".uno:SelectAll") + # Insert frame around the selected table: + args = { + "AnchorType": 0, + } + self.xUITest.executeCommandWithParameters(".uno:InsertFrame", mkPropertyValues(args)) + # Cut it from the body text: + self.xUITest.executeCommand(".uno:Cut") + # Select the shape: + xComponent.CurrentController.select(xComponent.DrawPage.getByIndex(0)) + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + # Begin text edit on the shape: + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"})) + # Paste it into the shape text: + self.xUITest.executeCommand(".uno:Paste") + + # When editing that frame: + visible = "true" + with self.ui_test.execute_dialog_through_command(".uno:FrameDialog") as xDialog: + xFlysplit = xDialog.getChild("flysplit") + visible = get_state_as_dict(xFlysplit)['Visible'] + + # Then make sure that the option allow split is hidden: + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 'true' != 'false' + # - true + # + false + # i.e. the UI allowed creating split floating tables in shape text, which is unnecessary + # complexity. + self.assertEqual(visible, "false") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/ui/index/index.py b/sw/qa/uitest/ui/index/index.py new file mode 100644 index 0000000000..64c936c6c7 --- /dev/null +++ b/sw/qa/uitest/ui/index/index.py @@ -0,0 +1,53 @@ +# -*- 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/. +# + +"""Covers sw/source/ui/index/ fixes.""" + +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import type_text + + +class TestSwuiidxmrk(UITestCase): + + def test_bibliography_local_page_number_insert(self): + + # Given an empty Writer document: + with self.ui_test.create_doc_in_start_center("writer") as component: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:InsertAuthoritiesEntry", close_button="close") as insert_entry: + from_document = insert_entry.getChild("fromdocument") + from_document.executeAction("CLICK", tuple()) + new = insert_entry.getChild("new") + + # When inserting a biblio entry field with a page number: + with self.ui_test.execute_blocking_action(new.executeAction, args=('CLICK', ())) as define_entry: + entry = define_entry.getChild("entry") + type_text(entry, "aaa") + listbox = define_entry.getChild("listbox") + select_pos(listbox, "16") # WWW document, just select a valid position + pagecb = define_entry.getChild("pagecb-local-visible") + pagecb.executeAction("CLICK", tuple()) + + insert = insert_entry.getChild("insert") + insert.executeAction("CLICK", tuple()) + + # Then make sure the local URL contains that page number: + paragraphs = component.Text.createEnumeration() + paragraph = paragraphs.nextElement() + portions = paragraph.createEnumeration() + portion = portions.nextElement() + for field in portion.TextField.Fields: + if field.Name != "LocalURL": + continue + # Without the accompanying fix in place, this test would have failed with: + # Could not find child with id: pagecb-local-visible + self.assertEqual(field.Value, "#page=1") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/ui/misc/misc.py b/sw/qa/uitest/ui/misc/misc.py new file mode 100644 index 0000000000..8af00054a5 --- /dev/null +++ b/sw/qa/uitest/ui/misc/misc.py @@ -0,0 +1,74 @@ +# -*- 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/. +# + +"""Covers sw/source/ui/misc/ fixes.""" + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import type_text + + +class TestTmpdlg(UITestCase): + def test_content_control_dialog(self): + with self.ui_test.create_doc_in_start_center("writer") as xComponent: + # Insert a dropdown content control, verify that a placeholder item is provided. + self.xUITest.executeCommand(".uno:InsertDropdownContentControl") + paragraphs = xComponent.Text.createEnumeration() + paragraph = paragraphs.nextElement() + portions = paragraph.createEnumeration() + portion = portions.nextElement() + contentControl = portion.ContentControl + contentControl.Alias = "my alias" + contentControl.Tag = "my tag" + contentControl.TabIndex = "1" + listItems = contentControl.ListItems + self.assertEqual(len(listItems), 1) + self.assertEqual(listItems[0][0].Name, "DisplayText") + self.assertEqual(listItems[0][0].Value, "") + self.assertEqual(listItems[0][1].Name, "Value") + self.assertEqual(listItems[0][1].Value, "Choose an item") + + # Append a new list item. + with self.ui_test.execute_dialog_through_command(".uno:ContentControlProperties") as xDialog: + xAlias = xDialog.getChild("aliasentry") + self.assertEqual(get_state_as_dict(xAlias)['Text'], "my alias") + type_text(xAlias, "new alias ") + xTag = xDialog.getChild("tagentry") + self.assertEqual(get_state_as_dict(xTag)['Text'], "my tag") + type_text(xTag, "new tag ") + xAdd = xDialog.getChild("add") + + xId = xDialog.getChild("idspinbutton") + self.assertEqual(get_state_as_dict(xId)['Text'], "0") + type_text(xId, "429496729") # added in front, making it 4294967290 + + xTabIndex = xDialog.getChild("tabindexspinbutton") + self.assertEqual(get_state_as_dict(xTabIndex)['Text'], "1") + type_text(xTabIndex, "-") # add a minus in front, making it -1 + + with self.ui_test.execute_blocking_action(xAdd.executeAction, args=('CLICK', ())) as xSubDialog: + xDisplayName = xSubDialog.getChild("displayname") + type_text(xDisplayName, "Foo Bar") + xValue = xSubDialog.getChild("value") + type_text(xValue, "foo-bar") + + # Verify that the UI appended the list item. + listItems = contentControl.ListItems + self.assertEqual(len(listItems), 2) + self.assertEqual(listItems[1][0].Name, "DisplayText") + self.assertEqual(listItems[1][0].Value, "Foo Bar") + self.assertEqual(listItems[1][1].Name, "Value") + self.assertEqual(listItems[1][1].Value, "foo-bar") + self.assertEqual(contentControl.Alias, "new alias my alias") + self.assertEqual(contentControl.Tag, "new tag my tag") + self.assertEqual(contentControl.Id, -6) # stored as signed, displays as unsigned + self.assertEqual(contentControl.TabIndex, 4294967295) # stored as unsigned, displays as signed + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |