Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / writer_tests7 / tdf128744.py
blob5e38bc548a1cd37faeb4ce8c095673593909942a
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/.
10 from uitest.framework import UITestCase
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict
13 from uitest.uihelper.common import select_pos
14 from uitest.uihelper.common import get_url_for_data_file
16 class tdf128744(UITestCase):
18 def test_tdf128744(self):
19 # load the sample file
20 with self.ui_test.load_file(get_url_for_data_file("tdf128744.docx")):
22 # first try to unprotect Record Changes with an invalid password
24 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") as xDialog:
25 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
26 self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "true")
27 xTabs = xDialog.getChild("tabcontrol")
28 select_pos(xTabs, "3") #tab Security
29 xProtectBtn = xDialog.getChild("protect")
31 # No close_button: click on the "Ok" inside to check the "Invalid password" infobox
32 with self.ui_test.execute_blocking_action(xProtectBtn.executeAction, args=('CLICK', ()), close_button="") as xPasswordDialog:
33 self.assertEqual(get_state_as_dict(xPasswordDialog)["DisplayText"], "Enter Password")
34 xPassword = xPasswordDialog.getChild("pass1ed")
35 xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "bad password"}))
36 xOkBtn = xPasswordDialog.getChild("ok")
37 with self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ())) as xInfoBox:
38 # "Invalid password" infobox
39 self.assertEqual(get_state_as_dict(xInfoBox)["DisplayText"], 'Information')
41 # now open the dialog again and read the properties, Record Changes checkbox is still enabled
42 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties", close_button="cancel") as xDialog:
43 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
44 self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "true")
45 xResetBtn = xDialog.getChild("reset")
46 xResetBtn.executeAction("CLICK", tuple())
48 # unprotect Record Changes with the valid password "test"
50 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") as xDialog:
51 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
52 self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "true")
53 xTabs = xDialog.getChild("tabcontrol")
54 select_pos(xTabs, "3") #tab Security
55 xProtectBtn = xDialog.getChild("protect")
57 with self.ui_test.execute_blocking_action(xProtectBtn.executeAction, args=('CLICK', ())) as xPasswordDialog:
58 self.assertEqual(get_state_as_dict(xPasswordDialog)["DisplayText"], "Enter Password")
59 xPassword = xPasswordDialog.getChild("pass1ed")
60 # give the correct password
61 xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "test"}))
63 # now open the dialog again and read the properties, Record Changes checkbox is disabled now
64 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties", close_button="cancel") as xDialog:
65 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
66 self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "false")
67 xResetBtn = xDialog.getChild("reset")
68 xResetBtn.executeAction("CLICK", tuple())
70 # vim: set shiftwidth=4 softtabstop=4 expandtab: