summaryrefslogtreecommitdiff
path: root/sw/qa/uitest
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-12-26 10:52:08 +0300
committerJustin Luth <justin_luth@sil.org>2020-12-29 16:39:18 +0100
commitccfd8e9d09f9ac0a0ea92d0f378391006faaf934 (patch)
tree57867fcc0b60aece4194014bf2046a5a72e8be07 /sw/qa/uitest
parent764c2a9c2bfe4e2ab17a3bd21d65762a2bcfd351 (diff)
tdf#138907 sw TitlePageDlg: fix round-tripping
This Format -> Title Pages dialog is completely broken, so I threw in lots of FIXME notes. At least for the case of just using the existing pages and setting them up as title/follow page, fix: 1.) the ability to round-trip page number restart if a numbering restart without a page style already existed. (Yes, this likely is an odd case of someone messing around. In any case, a page number restart REQUIRES a page style) make UITest_writer_tests5 UITEST_TEST_NAME=\ titlePageWizard.tdf138907.test_tdf138907 Change-Id: I544145e9f749f471b54fa6686242e93bc98f50be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108322 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/qa/uitest')
-rw-r--r--sw/qa/uitest/data/tdf138907_titlePageDialog.odtbin0 -> 11320 bytes
-rw-r--r--sw/qa/uitest/writer_tests5/titlePageWizard.py73
2 files changed, 73 insertions, 0 deletions
diff --git a/sw/qa/uitest/data/tdf138907_titlePageDialog.odt b/sw/qa/uitest/data/tdf138907_titlePageDialog.odt
new file mode 100644
index 000000000000..837e0d0132cb
--- /dev/null
+++ b/sw/qa/uitest/data/tdf138907_titlePageDialog.odt
Binary files differ
diff --git a/sw/qa/uitest/writer_tests5/titlePageWizard.py b/sw/qa/uitest/writer_tests5/titlePageWizard.py
new file mode 100644
index 000000000000..f23c79c68768
--- /dev/null
+++ b/sw/qa/uitest/writer_tests5/titlePageWizard.py
@@ -0,0 +1,73 @@
+# -*- 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 get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+ return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+# This tests the Format->Title Page wizard, specifically the reset page number portion.
+class tdf138907(UITestCase):
+ def test_tdf138907(self):
+ self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt"))
+ document = self.ui_test.get_component()
+
+ # Confirm the starting state. Just a page break, without a valid restart page number on page 2
+ self.assertEqual(document.CurrentController.PageCount, 5)
+ Paragraphs = document.Text.createEnumeration()
+ Para1 = Paragraphs.nextElement()
+ self.assertEqual(Para1.String, "6")
+ self.assertEqual(Para1.PageDescName, "First Page")
+ Para2 = Paragraphs.nextElement()
+ self.assertEqual(Para2.String, "7")
+ self.assertEqual(Para2.PageDescName, None)
+
+ #dialog Title Page
+ self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ #set restart page number to 2. With this doc, it defaults to resetting to 1.
+ xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING")
+ xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ # This correctly reset the starting page number for page 2 as "1".
+ # It wasn't persistent across round-trips though
+ Paragraphs = document.Text.createEnumeration()
+ Para1 = Paragraphs.nextElement()
+ self.assertEqual(Para1.String, "6")
+ self.assertEqual(Para1.PageDescName, "First Page")
+ self.assertEqual(Para2.String, "2")
+ Para2 = Paragraphs.nextElement()
+ # Without this fix, there was no PageDescName specified, just Landscape as default.
+ self.assertEqual(Para2.PageDescName, "Landscape")
+
+ #re-run dialog Title Page
+ self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ #accept defaults and OK without making any changes.
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+ # Without this fix, re-running the wizard was failing with the title page restarting at page 2.
+ Paragraphs = document.Text.createEnumeration()
+ Para1 = Paragraphs.nextElement()
+ #self.assertEqual(Para1.String, "6")
+ self.assertEqual(Para1.PageDescName, "First Page")
+ Para2 = Paragraphs.nextElement()
+ self.assertEqual(Para2.String, "2")
+ self.assertEqual(Para2.PageDescName, "Landscape")
+
+ #Note: 6 virtual pages, including blank, even page seen in book view
+ self.assertEqual(document.CurrentController.PageCount, 6)
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: