summaryrefslogtreecommitdiff
path: root/uitest/mass-testing/writer.py
blob: 83ead7844757cb73d0a2db1b677bf3852ac1ef5f (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
99
100
101
#
# 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 https://mozilla.org/MPL/2.0/.
#

import os
import signal
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from contextlib import contextmanager

class massTesting(UITestCase):

    @contextmanager
    def load_file(self):
        #TODO: Ignore password protected files

        fileName = os.environ["TESTFILENAME"]

        with self.ui_test.load_file(fileName) as document:
            # Ignore read-only files
            if not hasattr(document, 'isReadonly') or document.isReadonly():
                print("mass-uitesting:skipped", flush=True)
                raise

            try:
                xDoc = self.xUITest.getTopFocusWindow()
                xEdit = xDoc.getChild("writer_edit")
            except:
                #In case the mimetype is wrong and the file is open with another component
                print("mass-uitesting:skipped", flush=True)
                raise

            print("mass-uitesting:loaded", flush=True)

            yield xEdit

    def test_remove_all_and_undo(self):
        with self.load_file() as xEdit:
            self.xUITest.executeCommand(".uno:SelectAll")
            self.xUITest.executeCommand(".uno:SelectAll")
            self.xUITest.executeCommand(".uno:SelectAll")
            xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DELETE"}))

            self.xUITest.executeCommand(".uno:Undo")

    def test_insert_returns_and_undo(self):
        with self.load_file() as xEdit:
            for i in range(60):
                xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))

            for i in range(60):
                self.xUITest.executeCommand(".uno:Undo")

    def test_insert_pageBreaks_and_undo(self):
        with self.load_file() as xEdit:
            for i in range(5):
                self.xUITest.executeCommand(".uno:InsertPagebreak")

            for i in range(5):
                self.xUITest.executeCommand(".uno:Undo")

    def test_copy_all_paste_undo(self):
        with self.load_file() as xEdit:
            self.xUITest.executeCommand(".uno:SelectAll")
            self.xUITest.executeCommand(".uno:SelectAll")
            self.xUITest.executeCommand(".uno:SelectAll")

            self.xUITest.executeCommand(".uno:Copy")

            for i in range(5):
                self.xUITest.executeCommand(".uno:Paste")

            for i in range(5):
                self.xUITest.executeCommand(".uno:Undo")

    def test_traverse_all_pages(self):
        with self.load_file() as xEdit:
            document = self.ui_test.get_component()
            pageCount = document.CurrentController.PageCount

            for i in range(pageCount):
                xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"PAGEDOWN"}))

            for i in range(pageCount):
                xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"PAGEUP"}))

    def test_sidebar(self):
        with self.load_file() as xEdit:
            self.xUITest.executeCommand(".uno:Sidebar")

            panels = [ "TextPropertyPanel", "StyleListPanel", "GalleryPanel",
                    "SwNavigatorPanel", "PageFormatPanel", "InspectorTextPanel", "SwManageChangesPanel" ]

            for panel in panels:
                xEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": panel}))

            self.xUITest.executeCommand(".uno:Sidebar")

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