summaryrefslogtreecommitdiff
path: root/sc/qa/uitest/calc_tests/trackedChanges.py
blob: f846159d14c70d6a06de240c7559e661ea919957 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# -*- 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/.
# tests for tracked changes ; tdf912270

from uitest.framework import UITestCase
from uitest.debug import sleep
from libreoffice.calc.document import get_cell_by_position
import time
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.calc import enter_text_to_cell

class CalcTrackedChanges(UITestCase):

    def test_tdf66263_Protect_Records(self):
        calc_doc = self.ui_test.create_doc_in_start_center("calc")
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")
        document = self.ui_test.get_component()
        self.xUITest.executeCommand(".uno:TraceChangeMode")
        #protect dialog
        self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode")
        xDialog = self.xUITest.getTopFocusWindow()
        xpass = xDialog.getChild("pass1ed")
        xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
        xconfirm = xDialog.getChild("confirm1ed")
        xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
        xOkBtn = xDialog.getChild("ok")
        xOkBtn.executeAction("CLICK", tuple())
        #verify password
        self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode")
        xDialog = self.xUITest.getTopFocusWindow()
        xpass = xDialog.getChild("pass1ed")
        xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"}))
        xOkBtn = xDialog.getChild("ok")
        xOkBtn.executeAction("CLICK", tuple())

        self.ui_test.close_doc()

    def test_tracked_changes_accept(self):

        calc_doc = self.ui_test.create_doc_in_start_center("calc")
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")
        document = self.ui_test.get_component()
        #track changes;  enter text to cell
        self.xUITest.executeCommand(".uno:TraceChangeMode")
        enter_text_to_cell(gridwin, "A1", "Test LibreOffice")
        #accept tracked changes
        self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges")
        xTrackDlg = self.xUITest.getTopFocusWindow()
        xAccBtn = xTrackDlg.getChild("accept")
        xAccBtn.executeAction("CLICK", tuple())
        xCancBtn = xTrackDlg.getChild("close")
        xCancBtn.executeAction("CLICK", tuple())

        self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice")
        self.ui_test.close_doc()

    def test_tracked_changes_acceptall(self):

        calc_doc = self.ui_test.create_doc_in_start_center("calc")
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")
        document = self.ui_test.get_component()
        #track changes;  enter text to cell
        self.xUITest.executeCommand(".uno:TraceChangeMode")
        enter_text_to_cell(gridwin, "A1", "Test LibreOffice")
        #accept All tracked changes
        self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges")
        xTrackDlg = self.xUITest.getTopFocusWindow()

        xAccBtn = xTrackDlg.getChild("acceptall")
        xAccBtn.executeAction("CLICK", tuple())
        xCancBtn = xTrackDlg.getChild("close")
        xCancBtn.executeAction("CLICK", tuple())

        self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice")
        self.ui_test.close_doc()

    def test_tracked_changes_reject(self):

        calc_doc = self.ui_test.create_doc_in_start_center("calc")
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")
        document = self.ui_test.get_component()
        #track changes;  enter text to cell
        self.xUITest.executeCommand(".uno:TraceChangeMode")
        enter_text_to_cell(gridwin, "A1", "Test LibreOffice")
        #accept tracked changes
        self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges")
        xTrackDlg = self.xUITest.getTopFocusWindow()

        xRejBtn = xTrackDlg.getChild("reject")
        xRejBtn.executeAction("CLICK", tuple())
        xCancBtn = xTrackDlg.getChild("close")
        xCancBtn.executeAction("CLICK", tuple())

        self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "")
        self.ui_test.close_doc()

    def test_tracked_changes_rejectall(self):

        calc_doc = self.ui_test.create_doc_in_start_center("calc")
        xCalcDoc = self.xUITest.getTopFocusWindow()
        gridwin = xCalcDoc.getChild("grid_window")
        document = self.ui_test.get_component()
        #track changes;  enter text to cell
        self.xUITest.executeCommand(".uno:TraceChangeMode")
        enter_text_to_cell(gridwin, "A1", "Test LibreOffice")
        #accept tracked changes
        self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges")
        xTrackDlg = self.xUITest.getTopFocusWindow()

        xAccBtn = xTrackDlg.getChild("rejectall")
        xAccBtn.executeAction("CLICK", tuple())
        xCancBtn = xTrackDlg.getChild("close")
        xCancBtn.executeAction("CLICK", tuple())

        self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "")
        self.ui_test.close_doc()

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