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 libreoffice
.uno
.propertyvalue
import mkPropertyValues
11 from uitest
.uihelper
.common
import select_pos
12 from uitest
.uihelper
.common
import type_text
13 from uitest
.uihelper
.common
import get_url_for_data_file
15 class tdf46561(UITestCase
):
16 def check_header_texts(self
, master
="", first
="", left
="", right
=""):
17 # Get the current header style and its text contents
18 xPageStyle
= self
.document
.getStyleFamilies().getByIndex(2)
19 xHeaderText
= xPageStyle
.getByIndex(0).HeaderText
.String
20 xHeaderTextFirst
= xPageStyle
.getByIndex(0).HeaderTextFirst
.String
21 xHeaderTextLeft
= xPageStyle
.getByIndex(0).HeaderTextLeft
.String
22 xHeaderTextRight
= xPageStyle
.getByIndex(0).HeaderTextRight
.String
24 # Check the current values
25 self
.assertEqual(master
, xHeaderText
)
26 self
.assertEqual(first
, xHeaderTextFirst
)
27 self
.assertEqual(left
, xHeaderTextLeft
)
28 self
.assertEqual(right
, xHeaderTextRight
)
30 def test_tdf46561(self
):
31 with self
.ui_test
.load_file(get_url_for_data_file("tdf46561.odt")):
32 self
.document
= self
.ui_test
.get_component()
33 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
35 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
36 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
37 xWriterEdit
.executeAction("GOTO", mkPropertyValues({"PAGE": "2"}))
38 self
.xUITest
.executeCommand(".uno:JumpToHeader")
40 # Switch "same left and right page headers" on and off a few times
42 with self
.ui_test
.execute_dialog_through_command(".uno:PageDialog") as PageDialog
:
44 xTabs
= PageDialog
.getChild("tabcontrol")
45 select_pos(xTabs
, "4")
47 Button
= xTabs
.getChild('checkSameLR')
48 Button
.executeAction("CLICK",tuple())
50 # We should be back to the starting state after 2*k on/off changes
51 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
53 # Enter some additional text in the left page header
54 type_text(xWriterEdit
, "XXXX")
55 self
.check_header_texts(master
="right", first
="1st", left
="XXXXleft", right
="right")
57 # Now go back one change (before entering "XXXX")
58 self
.xUITest
.executeCommand(".uno:Undo")
59 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
61 # Undo the fourth change
62 self
.xUITest
.executeCommand(".uno:Undo")
63 self
.check_header_texts(master
="right", first
="1st", left
="right", right
="right")
65 # Undo the third change
66 self
.xUITest
.executeCommand(".uno:Undo")
67 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
69 # Undo the second change
70 self
.xUITest
.executeCommand(".uno:Undo")
71 self
.check_header_texts(master
="right", first
="1st", left
="right", right
="right")
73 # Undo the first change
74 self
.xUITest
.executeCommand(".uno:Undo")
75 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
77 # Redo the first change
78 self
.xUITest
.executeCommand(".uno:Redo")
79 self
.check_header_texts(master
="right", first
="1st", left
="right", right
="right")
81 # Redo the second change
82 self
.xUITest
.executeCommand(".uno:Redo")
83 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
85 # Redo the third change
86 self
.xUITest
.executeCommand(".uno:Redo")
87 self
.check_header_texts(master
="right", first
="1st", left
="right", right
="right")
89 # Redo the fourth change
90 self
.xUITest
.executeCommand(".uno:Redo")
91 self
.check_header_texts(master
="right", first
="1st", left
="left", right
="right")
93 # Redo the final change
94 self
.xUITest
.executeCommand(".uno:Redo")
95 self
.check_header_texts(master
="right", first
="1st", left
="XXXXleft", right
="right")
97 # vim: set shiftwidth=4 softtabstop=4 expandtab: