summaryrefslogtreecommitdiffstats
path: root/cui/qa/uitest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /cui/qa/uitest
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cui/qa/uitest/dialogs/chardlg.py167
-rw-r--r--cui/qa/uitest/dialogs/pastedlg.py43
-rw-r--r--cui/qa/uitest/dialogs/shortcuts.py39
-rw-r--r--cui/qa/uitest/tabpages/themepage.py87
-rw-r--r--cui/qa/uitest/tabpages/tpcolor.py69
5 files changed, 405 insertions, 0 deletions
diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py
new file mode 100644
index 000000000..c52664f36
--- /dev/null
+++ b/cui/qa/uitest/dialogs/chardlg.py
@@ -0,0 +1,167 @@
+#
+# 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_by_text
+
+# Test for cui/source/tabpages/chardlg.cxx.
+class Test(UITestCase):
+
+ def testSvxCharEffectsPage(self):
+ # Start Impress.
+ with self.ui_test.create_doc_in_start_center("impress") as component:
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+
+ # Now use Format -> Character.
+ with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontTransparency = xDialog.getChild("fonttransparencymtr")
+ for _ in range(5):
+ xFontTransparency.executeAction("UP", tuple())
+
+ # Verify the result.
+ drawPage = component.getDrawPages()[0]
+ shape = drawPage[0]
+
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 100 != 5
+ # i.e. the dialog did not set transparency to 5%, instead it left the character color at
+ # COL_AUTO.
+ self.assertEqual(shape.CharTransparence, 5)
+
+ def testSvxCharEffectsPageTheme(self):
+ # Given a document with a document theme:
+ # Start Impress.
+ with self.ui_test.create_doc_in_start_center("impress") as component:
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+
+ # Set theme colors.
+ drawPage = component.getDrawPages().getByIndex(0)
+ master = drawPage.MasterPage
+ theme = mkPropertyValues({
+ "Name": "nameA",
+ "ColorSchemeName": "colorSetA",
+ "ColorScheme": tuple([
+ 0x000000, # dk1
+ 0x000000, # lt1
+ 0x000000, # dk2
+ 0x000000, # lt2
+ 0x000000, # accent1
+ 0x000000, # accent2
+ 0x000000, # accent3
+ 0x000000, # accent4
+ 0x000000, # accent5
+ 0x000000, # accent6
+ 0x000000, # hlink
+ 0x000000, # folHlink
+ ])
+ })
+ master.Theme = theme
+
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+
+ # Now use Format -> Character.
+ with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+
+ # When setting the shape text color to accent 1:
+ accent1 = xDialog.getChild("fontcolorlb")
+ accent1.executeAction("OPENLIST", tuple())
+ floatWindow = self.xUITest.getFloatWindow()
+ paletteSelector = floatWindow.getChild("palette_listbox")
+ select_by_text(paletteSelector, "Theme colors")
+ colorSet = floatWindow.getChild("colorset")
+ # 4 would be accent1, +12 is the first from the effect variants.
+ colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": "16"}))
+
+ # Then make sure the doc model has the correct color theme index:
+ drawPage = component.getDrawPages().getByIndex(0)
+ shape = drawPage.getByIndex(0)
+ paragraphs = shape.createEnumeration()
+ paragraph = paragraphs.nextElement()
+ portions = paragraph.createEnumeration()
+ portion = portions.nextElement()
+
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: -1 != 4
+ # i.e. no theme index was set, instead of accent1 (index into the above color scheme).
+ self.assertEqual(portion.CharColorTheme, 4)
+
+ # Then make sure that '80% lighter' is lum-mod=2000 and lum-off=8000:
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 10000 != 2000
+ # i.e. the effects where not applied, luminance modulation was the default instead of a
+ # custom value.
+ self.assertEqual(portion.CharColorLumMod, 2000)
+ self.assertEqual(portion.CharColorLumOff, 8000)
+
+ def testSvxCharEffectsPageWriter(self):
+ # Start Writer.
+ with self.ui_test.create_doc_in_start_center("writer") as component:
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("writer_edit")
+ # Type a character and select it.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+
+ # Now use Format -> Character.
+ with self.ui_test.execute_dialog_through_command(".uno:FontDialog") 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 transparency widget was hidden.
+ self.assertEqual(get_state_as_dict(xFontTransparency)["Visible"], "true")
+ for _ in range(5):
+ xFontTransparency.executeAction("UP", tuple())
+
+ # Verify the result.
+ paragraph = component.Text.createEnumeration().nextElement()
+
+ self.assertEqual(paragraph.CharTransparence, 5)
+
+ def testSvxCharEffectsPageWriterAutomatic(self):
+ # Start Writer.
+ with self.ui_test.create_doc_in_start_center("writer"):
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("writer_edit")
+
+ # Use Format -> Character.
+ with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_CHAR_EFFECTS.
+ select_pos(xTabs, "1")
+ xFontColorLB = xDialog.getChild("fontcolorlb")
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'White' != 'Automatic'
+ # i.e. the auto color lost its alpha component and appeared as white.
+ self.assertEqual(get_state_as_dict(xFontColorLB)["Text"], "Automatic")
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/dialogs/pastedlg.py b/cui/qa/uitest/dialogs/pastedlg.py
new file mode 100644
index 000000000..50a39d232
--- /dev/null
+++ b/cui/qa/uitest/dialogs/pastedlg.py
@@ -0,0 +1,43 @@
+#
+# 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+
+
+# Test for SvPasteObjectDialog.
+class Test(UITestCase):
+
+ def testGetFormat(self):
+ # Copy a string in Impress.
+ with self.ui_test.create_doc_in_start_center("impress"):
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+ editWin.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
+ self.xUITest.executeCommand(".uno:SelectAll")
+ self.xUITest.executeCommand(".uno:Copy")
+
+ # Now use paste special to see what formats are offered.
+ with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial", close_button="cancel") as pasteSpecial:
+ formats = pasteSpecial.getChild("list")
+ entryCount = int(get_state_as_dict(formats)["Children"])
+ items = []
+ for index in range(entryCount):
+ entry = formats.getChild(str(index))
+ entry.executeAction("SELECT", tuple())
+ items.append(get_state_as_dict(formats)["SelectEntryText"])
+
+ # Make sure there is no RTF vs Richtext duplication.
+ self.assertTrue("Rich text formatting (RTF)" in items)
+ self.assertFalse("Rich text formatting (Richtext)" in items)
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/dialogs/shortcuts.py b/cui/qa/uitest/dialogs/shortcuts.py
new file mode 100644
index 000000000..99d2bd1cc
--- /dev/null
+++ b/cui/qa/uitest/dialogs/shortcuts.py
@@ -0,0 +1,39 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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 uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+
+class Test(UITestCase):
+
+ def test_tab_navigation(self):
+ with self.ui_test.create_doc_in_start_center("writer"):
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+ with self.ui_test.execute_dialog_through_command(".uno:EditStyle") as xDialog:
+
+ xTabs = xDialog.getChild("tabcontrol")
+ select_pos(xTabs, "0")
+
+ for i in range(16):
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
+
+ xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEDOWN"}))
+
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], "0")
+
+ for i in reversed(range(16)):
+ xTabs.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+PAGEUP"}))
+
+ self.assertEqual(get_state_as_dict(xTabs)["CurrPagePos"], str(i))
+
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/tabpages/themepage.py b/cui/qa/uitest/tabpages/themepage.py
new file mode 100644
index 000000000..f85af965f
--- /dev/null
+++ b/cui/qa/uitest/tabpages/themepage.py
@@ -0,0 +1,87 @@
+#
+# 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 libreoffice.uno.propertyvalue import convert_property_values_to_dict
+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 select_pos
+from uitest.uihelper.common import select_by_text
+
+# Test for cui/source/tabpages/themepage.cxx.
+class Test(UITestCase):
+
+ def testThemePage(self):
+ # Given an Impress document with a master page that has a theme:
+ with self.ui_test.create_doc_in_start_center("impress") as component:
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ drawPage = component.getDrawPages().getByIndex(0)
+ master = drawPage.MasterPage
+ theme = mkPropertyValues({
+ "Name": "nameA",
+ "ColorSchemeName": "colorSetA",
+ "ColorScheme": tuple([
+ 0x000000, # dk1
+ 0x000000, # lt1
+ 0x000000, # dk2
+ 0x000000, # lt2
+ 0x0000ff, # accent1
+ 0x000000, # accent2
+ 0x000000, # accent3
+ 0x000000, # accent4
+ 0x000000, # accent5
+ 0x000000, # accent6
+ 0x000000, # hlink
+ 0x000000, # folHlink
+ ])
+ })
+ master.Theme = theme
+
+ # When changing the name of the theme:
+ self.xUITest.executeCommand(".uno:SlideMasterPage")
+ with self.ui_test.execute_dialog_through_command(".uno:PageSetup") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ # Select RID_SVXPAGE_THEME.
+ select_pos(xTabs, "3")
+ themeName = xDialog.getChild("themeName")
+ themeName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ themeName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ themeName.executeAction("TYPE", mkPropertyValues({"TEXT": "nameB"}))
+ colorSetName = xDialog.getChild("colorSetName")
+ colorSetName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ colorSetName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ colorSetName.executeAction("TYPE", mkPropertyValues({"TEXT": "colorSetB"}))
+
+ # Select a custom accent1 color.
+ accent1 = xDialog.getChild("btnAccent1")
+ accent1.executeAction("OPENLIST", tuple())
+ floatWindow = self.xUITest.getFloatWindow()
+ paletteSelector = floatWindow.getChild("palette_listbox")
+ select_by_text(paletteSelector, "chart-palettes")
+ colorSet = floatWindow.getChild("colorset")
+ colorSet.executeAction("CHOOSE", mkPropertyValues({"POS": "2"}))
+
+ # Then make sure the doc model is updated accordingly:
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'nameA' != 'nameB'
+ # i.e. the UI didn't update the theme name.
+ theme = convert_property_values_to_dict(master.Theme)
+ self.assertEqual(theme["Name"], "nameB")
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 'colorSetA' != 'colorSetB'
+ # i.e. the UI didn't update the color scheme name.
+ self.assertEqual(theme["ColorSchemeName"], "colorSetB")
+ colorSet = theme["ColorScheme"]
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: 0 != 16728590 (#ff420e)
+ # i.e. the UI didn't update the accent1 color from black to a custom value.
+ self.assertEqual(colorSet[4], 0xff420e)
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/cui/qa/uitest/tabpages/tpcolor.py b/cui/qa/uitest/tabpages/tpcolor.py
new file mode 100644
index 000000000..e6ae91ada
--- /dev/null
+++ b/cui/qa/uitest/tabpages/tpcolor.py
@@ -0,0 +1,69 @@
+#
+# 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.framework import UITestCase
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.common import select_by_text
+
+
+# Test for cui/source/tabpages/tpcolor.cxx.
+class Test(UITestCase):
+
+ def testSvxColorTabPageTheme(self):
+ # Given an Impress document with a theme:
+ with self.ui_test.create_doc_in_start_center("impress") as component:
+ template = self.xUITest.getTopFocusWindow()
+ self.ui_test.close_dialog_through_button(template.getChild("close"))
+ doc = self.xUITest.getTopFocusWindow()
+ editWin = doc.getChild("impress_win")
+ # Set theme colors.
+ drawPage = component.getDrawPages().getByIndex(0)
+ master = drawPage.MasterPage
+ theme = mkPropertyValues({
+ "Name": "nameA",
+ "ColorSchemeName": "colorSetA",
+ "ColorScheme": tuple([
+ 0x000000, # dk1
+ 0x000000, # lt1
+ 0x000000, # dk2
+ 0x000000, # lt2
+ 0x0000ff, # accent1
+ 0x000000, # accent2
+ 0x000000, # accent3
+ 0x000000, # accent4
+ 0x000000, # accent5
+ 0x000000, # accent6
+ 0x000000, # hlink
+ 0x000000, # folHlink
+ ])
+ })
+ master.Theme = theme
+ # Select the title shape.
+ editWin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"}))
+
+ # When using right click -> Area to refer to a theme for shape fill:
+ with self.ui_test.execute_dialog_through_command(".uno:FormatArea") as xDialog:
+ tabControl = xDialog.getChild("tabcontrol")
+ # Area
+ select_pos(tabControl, "0")
+ # Color
+ btnColor = xDialog.getChild("btncolor")
+ btnColor.executeAction("CLICK", tuple())
+ paletteSelector = xDialog.getChild("paletteselector")
+ select_by_text(paletteSelector, "Theme colors")
+ colorSelector = xDialog.getChild("colorset")
+ colorSelector.executeAction("CHOOSE", mkPropertyValues({"POS": "4"}))
+
+ # Then make sure the doc model is updated accordingly:
+ shape = drawPage.getByIndex(0)
+ # Without the accompanying fix in place, this test would have failed with:
+ # AssertionError: -1 != 4
+ # i.e. the theme metadata of the selected fill color was lost.
+ self.assertEqual(shape.FillColorTheme, 4)
+
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: