merge duplicate part of branches
[LibreOffice.git] / sw / qa / uitest / writer_tests5 / titlePageWizard2.py
blob4f34735306d037d30150ffefaefd37b89affbe99
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 from uitest.framework import UITestCase
10 from uitest.uihelper.common import get_url_for_data_file
12 # This tests both an edge cases, and some more realistic situations.
13 class tdf138907(UITestCase):
14 def test_tdf138907(self):
15 with self.ui_test.load_file(get_url_for_data_file("tdf138907_titlePageDialog.odt")) as document:
17 # Test an undefined situation - try to modify pages beyond the end of the document.
19 #dialog Title Page
20 with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog:
21 #set restart page number to 2. With this doc, it defaults to resetting to 1.
22 xRestartNumbering = xDialog.getChild("NF_RESTART_NUMBERING")
23 xRestartNumbering.executeAction("UP", tuple()) # restart numbering at 2
25 #Convert three pages to title/index pages starting at non-existing page twenty.
26 xPageCount = xDialog.getChild("NF_PAGE_COUNT")
27 for _ in range(0,2):
28 xPageCount.executeAction("UP", tuple())
29 xUseStartingPage = xDialog.getChild("RB_PAGE_START")
30 xUseStartingPage.executeAction("CLICK", tuple())
31 xStartingPage = xDialog.getChild("NF_PAGE_START")
32 for _ in range(0,19):
33 xStartingPage.executeAction("UP", tuple()) #Start at mythical page 20.
36 # Nothing should happen when modifying pages that don't exist.
37 # Just a page break, without a valid restart page number on page 2
38 self.assertEqual(document.CurrentController.PageCount, 5)
39 Paragraphs = document.Text.createEnumeration()
40 Para1 = Paragraphs.nextElement()
41 self.assertEqual(Para1.String, "6")
42 self.assertEqual(Para1.PageDescName, "First Page")
43 Para2 = Paragraphs.nextElement()
44 self.assertEqual(Para2.String, "7")
45 self.assertEqual(Para2.PageDescName, None)
46 Para3 = Paragraphs.nextElement()
47 self.assertEqual(Para3.String, "8")
48 self.assertEqual(Para3.PageDescName, None)
49 Para4 = Paragraphs.nextElement()
50 self.assertEqual(Para4.String, "9")
51 self.assertEqual(Para4.PageDescName, None)
52 Para5 = Paragraphs.nextElement()
53 self.assertEqual(Para5.String, "10")
54 self.assertEqual(Para5.PageDescName, None)
57 #dialog Title Page
58 with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog:
59 #set restart page number to 1 - which is the default.
60 #set restart title page to 1 - the current value for this document is 6.
61 xRestartNumbering = xDialog.getChild("NF_SET_PAGE_NUMBER")
62 for _ in range(0,5):
63 xRestartNumbering.executeAction("DOWN", tuple()) # restart title numbering at 1
64 #Insert two title/index pages at beginning of the document.
65 newPages = xDialog.getChild("RB_INSERT_NEW_PAGES")
66 newPages.executeAction("CLICK", tuple())
67 xPageCount = xDialog.getChild("NF_PAGE_COUNT")
68 for _ in range(0,1):
69 xPageCount.executeAction("UP", tuple())
72 Paragraphs = document.Text.createEnumeration()
73 Para1 = Paragraphs.nextElement()
74 self.assertEqual(Para1.String, "")
75 self.assertEqual(Para1.PageDescName, "First Page")
76 Para2 = Paragraphs.nextElement()
77 self.assertEqual(Para2.String, "")
78 self.assertEqual(Para2.PageDescName, "Index")
79 Para3 = Paragraphs.nextElement()
80 self.assertEqual(Para3.String, "1")
81 self.assertEqual(Para3.PageDescName, "Landscape")
82 Para4 = Paragraphs.nextElement()
83 self.assertEqual(Para4.String, "2")
84 Para5 = Paragraphs.nextElement()
85 self.assertEqual(Para5.String, "3")
86 Para6 = Paragraphs.nextElement()
87 self.assertEqual(Para6.String, "4")
88 Para7 = Paragraphs.nextElement()
89 self.assertEqual(Para7.String, "5")
91 #Now test replacing several pages with title and index styles
93 #dialog Title Page
94 with self.ui_test.execute_dialog_through_command(".uno:TitlePageDialog") as xDialog:
95 #Convert four pages to title/index pages starting at page one.
96 xPageCount = xDialog.getChild("NF_PAGE_COUNT")
97 for _ in range(0,3):
98 xPageCount.executeAction("DOWN", tuple()) #reset to 1 first
99 for _ in range(0,3):
100 xPageCount.executeAction("UP", tuple())
103 Paragraphs = document.Text.createEnumeration()
104 Para1 = Paragraphs.nextElement()
105 self.assertEqual(Para1.String, "")
106 self.assertEqual(Para1.PageDescName, "First Page")
107 Para2 = Paragraphs.nextElement()
108 self.assertEqual(Para2.String, "")
109 self.assertEqual(Para2.PageDescName, "Index")
110 Para3 = Paragraphs.nextElement()
111 self.assertEqual(Para3.String, "3")
112 self.assertEqual(Para3.PageDescName, "Index")
113 Para4 = Paragraphs.nextElement()
114 self.assertEqual(Para4.String, "4")
115 self.assertEqual(Para4.PageDescName, "Index")
116 Para5 = Paragraphs.nextElement()
117 self.assertEqual(Para5.String, "1")
118 self.assertEqual(Para5.PageDescName, "Landscape")
119 Para6 = Paragraphs.nextElement()
120 self.assertEqual(Para6.String, "2")
121 Para7 = Paragraphs.nextElement()
122 self.assertEqual(Para7.String, "3")
124 # vim: set shiftwidth=4 softtabstop=4 expandtab: