tdf#164393 Change themes UI as per UX feedback
[LibreOffice.git] / sw / qa / python / check_xmodifiable2.py
blobb860e1f31d0fc92b1cb63ee8a80bf641120d259d
1 #! /usr/bin/env python
2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import unittest
11 from org.libreoffice.unotest import UnoInProcess
14 class XModifiable2(unittest.TestCase):
16 @classmethod
17 def setUpClass(cls):
18 cls._uno = UnoInProcess()
19 cls._uno.setUp()
21 @classmethod
22 def tearDownClass(cls):
23 cls._uno.tearDown()
25 def test_XModifiable2(self):
26 # initialization
27 xDoc = self._uno.openEmptyWriterDoc()
29 # perform unit test
30 self.assertTrue(xDoc.isSetModifiedEnabled())
32 self.assertTrue(xDoc.disableSetModified())
33 self.assertFalse(xDoc.isSetModifiedEnabled())
35 self.assertFalse(xDoc.enableSetModified())
36 self.assertTrue(xDoc.isSetModifiedEnabled())
38 # clean up
39 xDoc.close(True)
41 def test_XModifiable2_Double(self):
42 # initialization
43 xDoc = self._uno.openEmptyWriterDoc()
45 # perform unit test
46 self.assertTrue(xDoc.isSetModifiedEnabled())
48 # try to disable
49 # Expected return value:
50 # `TRUE` the changing of the modified state was disabled
51 self.assertTrue(xDoc.disableSetModified())
52 self.assertFalse(xDoc.isSetModifiedEnabled())
54 # try to disable twice
55 # Expected return value:
56 # `FALSE` the changing of the modified state was already disabled
57 self.assertFalse(xDoc.disableSetModified())
58 self.assertFalse(xDoc.isSetModifiedEnabled())
60 # try to disable third time
61 # Expected return value:
62 # `FALSE` the changing of the modified state was already disabled
63 # i.e. the same as in previous call
64 self.assertFalse(xDoc.disableSetModified())
65 self.assertFalse(xDoc.isSetModifiedEnabled())
67 # try to enable
68 # Expected return value:
69 # `FALSE` the changing of the modified state was enabled
70 self.assertFalse(xDoc.enableSetModified())
71 self.assertTrue(xDoc.isSetModifiedEnabled())
73 # try to enable twice
74 # Expected return value:
75 # `TRUE` the changing of the modified state was already enabled
76 self.assertTrue(xDoc.enableSetModified())
77 self.assertTrue(xDoc.isSetModifiedEnabled())
79 # try to enable third time
80 # Expected return value:
81 # `TRUE` the changing of the modified state was already enabled
82 # i.e. the same as in previous call
83 self.assertTrue(xDoc.enableSetModified())
84 self.assertTrue(xDoc.isSetModifiedEnabled())
86 # clean up
87 xDoc.close(True)
89 def test_XModifiable2_setModified(self):
90 # initialization
91 xDoc = self._uno.openEmptyWriterDoc()
93 # perform unit test
94 # try to set modified flag when modification enabled
95 self.assertTrue(xDoc.isSetModifiedEnabled())
97 self.assertFalse(xDoc.isModified())
98 xDoc.setModified(True)
99 self.assertTrue(xDoc.isModified())
101 xDoc.setModified(False)
102 self.assertFalse(xDoc.isModified())
104 # try to set modified flag when modification disabled
105 self.assertTrue(xDoc.disableSetModified())
106 self.assertFalse(xDoc.isSetModifiedEnabled())
108 self.assertFalse(xDoc.isModified())
109 xDoc.setModified(True)
110 self.assertFalse(xDoc.isModified())
112 self.assertFalse(xDoc.enableSetModified())
113 self.assertTrue(xDoc.isSetModifiedEnabled())
115 # document is still not modified
116 self.assertFalse(xDoc.isModified())
118 # try to set modified flag when modification enabled
119 # and when we have changed the modification possibility
120 self.assertTrue(xDoc.isSetModifiedEnabled())
122 self.assertFalse(xDoc.isModified())
123 xDoc.setModified(True)
124 self.assertTrue(xDoc.isModified())
126 xDoc.setModified(False)
127 self.assertFalse(xDoc.isModified())
129 # clean up
130 xDoc.close(True)
132 def test_setModified_ByContent(self):
133 # initialization
134 xDoc = self._uno.openEmptyWriterDoc()
136 # perform unit test:
137 # set modified flag using text editing
138 # when modification of the flag is enabled
139 self.assertTrue(xDoc.isSetModifiedEnabled())
140 self.assertFalse(xDoc.isModified())
142 cursor = xDoc.Text.createTextCursor()
143 xDoc.Text.insertString(cursor, "The first paragraph", 0)
145 self.assertTrue(xDoc.isSetModifiedEnabled())
146 self.assertTrue(xDoc.isModified())
148 # clean up
149 xDoc.close(True)
151 def test_setModified_ByContent_Blocked(self):
152 # initialization
153 xDoc = self._uno.openEmptyWriterDoc()
155 # perform unit test:
156 # it is unable to set modified flag using text editing
157 # when modification of the flag was disabled
158 self.assertTrue(xDoc.disableSetModified())
159 self.assertFalse(xDoc.isSetModifiedEnabled())
160 self.assertFalse(xDoc.isModified())
162 cursor = xDoc.Text.createTextCursor()
163 xDoc.Text.insertString(cursor, "The first paragraph", 0)
165 self.assertFalse(xDoc.isSetModifiedEnabled())
166 self.assertFalse(xDoc.isModified())
168 # clean up
169 xDoc.close(True)
171 def test_WriteProtectedDocument(self):
172 # initialization
173 xDoc = self._uno.openTemplateFromTDOC('WriteProtected.odt')
175 # perform unit test:
176 # it is able to set modified flag using text editing despite
177 # ODT file was marked to be opened as read-only
178 self.assertTrue(xDoc.isSetModifiedEnabled())
179 self.assertFalse(xDoc.isModified())
181 cursor = xDoc.Text.createTextCursor()
182 xDoc.Text.insertString(cursor, "The first paragraph", 0)
184 self.assertTrue(xDoc.isSetModifiedEnabled())
185 self.assertTrue(xDoc.isModified())
187 # clean up
188 xDoc.close(True)
191 if __name__ == '__main__':
192 unittest.main()
194 # vim: set shiftwidth=4 softtabstop=4 expandtab: