summaryrefslogtreecommitdiff
path: root/sw/qa/uitest/writer_tests7/tdf46561.py
blob: 1c34a89a71b4e0deb92f8c4faf8776d2e0421b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import select_pos
from uitest.uihelper.common import type_text
from uitest.uihelper.common import get_url_for_data_file

class tdf46561(UITestCase):
    def check_header_texts(self, master="", first="", left="", right=""):
        # Get the current header style and its text contents
        xPageStyle = self.document.getStyleFamilies().getByIndex(2)
        xHeaderText = xPageStyle.getByIndex(0).HeaderText.String
        xHeaderTextFirst = xPageStyle.getByIndex(0).HeaderTextFirst.String
        xHeaderTextLeft = xPageStyle.getByIndex(0).HeaderTextLeft.String
        xHeaderTextRight = xPageStyle.getByIndex(0).HeaderTextRight.String

        # Check the current values
        self.assertEqual(master, xHeaderText)
        self.assertEqual(first, xHeaderTextFirst)
        self.assertEqual(left, xHeaderTextLeft)
        self.assertEqual(right, xHeaderTextRight)

    def test_tdf46561(self):
        with self.ui_test.load_file(get_url_for_data_file("tdf46561.odt")):
            self.document = self.ui_test.get_component()
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            xWriterDoc = self.xUITest.getTopFocusWindow()
            xWriterEdit = xWriterDoc.getChild("writer_edit")
            xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"}))
            self.xUITest.executeCommand(".uno:JumpToHeader")

            # Switch "same left and right page headers" on and off a few times
            for _ in range(4):
                self.ui_test.execute_dialog_through_command(".uno:PageDialog")
                PageDialog = self.xUITest.getTopFocusWindow();

                xTabs = PageDialog.getChild("tabcontrol")
                select_pos(xTabs, "4")

                Button = xTabs.getChild('checkSameLR')
                Button.executeAction("CLICK",tuple())
                ok = PageDialog.getChild("ok")
                self.ui_test.close_dialog_through_button(ok)

            # We should be back to the starting state after 2*k on/off changes
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Enter some additional text in the left page header
            type_text(xWriterEdit, "XXXX")
            self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right")

            # Now go back one change (before entering "XXXX")
            self.xUITest.executeCommand(".uno:Undo")
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Undo the fourth change
            self.xUITest.executeCommand(".uno:Undo")
            self.check_header_texts(master="right", first="1st", left="right", right="right")

            # Undo the third change
            self.xUITest.executeCommand(".uno:Undo")
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Undo the second change
            self.xUITest.executeCommand(".uno:Undo")
            self.check_header_texts(master="right", first="1st", left="right", right="right")

            # Undo the first change
            self.xUITest.executeCommand(".uno:Undo")
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Redo the first change
            self.xUITest.executeCommand(".uno:Redo")
            self.check_header_texts(master="right", first="1st", left="right", right="right")

            # Redo the second change
            self.xUITest.executeCommand(".uno:Redo")
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Redo the third change
            self.xUITest.executeCommand(".uno:Redo")
            self.check_header_texts(master="right", first="1st", left="right", right="right")

            # Redo the fourth change
            self.xUITest.executeCommand(".uno:Redo")
            self.check_header_texts(master="right", first="1st", left="left", right="right")

            # Redo the final change
            self.xUITest.executeCommand(".uno:Redo")
            self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right")

# vim: set shiftwidth=4 softtabstop=4 expandtab: