tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / sw / qa / uitest / writer_tests2 / documentProperties.py
blob5b1eeb583c8cc25490458699acd84438ade1108b
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
15 class documentProperties(UITestCase):
17 def assert_custom_properties(self, dialog, bIsFirstItemVisible):
18 for i in range(6):
19 aExpected = 'false'
20 if bIsFirstItemVisible and i == 0:
21 aExpected = 'true'
22 xNameBox = dialog.getChild("namebox" + str(i + 1))
23 xTypeBox = dialog.getChild("typebox" + str(i + 1))
24 xValueEdit = dialog.getChild("valueedit" + str(i + 1))
25 xRemoveBtn = dialog.getChild("remove" + str(i + 1))
26 self.assertEqual(aExpected, get_state_as_dict(xNameBox)['ReallyVisible'])
27 self.assertEqual(aExpected, get_state_as_dict(xTypeBox)['ReallyVisible'])
28 self.assertEqual(aExpected, get_state_as_dict(xValueEdit)['ReallyVisible'])
29 self.assertEqual(aExpected, get_state_as_dict(xRemoveBtn)['ReallyVisible'])
31 def test_open_documentProperties_writer(self):
32 with self.ui_test.create_doc_in_start_center("writer"):
33 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") as xDialog:
34 xResetBtn = xDialog.getChild("reset")
35 xResetBtn.executeAction("CLICK", tuple())
37 xUserDataCheckbox = xDialog.getChild("userdatacb") # apply user data
38 xUserDataCheckbox.executeAction("CLICK", tuple())
39 xThumbSaveCheckbox = xDialog.getChild("thumbnailsavecb") # save preview image with document
40 xThumbSaveCheckbox.executeAction("CLICK", tuple())
42 #digital signature
43 xDigSignBtn = xDialog.getChild("signature")
45 with self.ui_test.execute_blocking_action(xDigSignBtn.executeAction, args=('CLICK', ()), close_button="no"):
46 pass
48 xTabs = xDialog.getChild("tabcontrol")
49 select_pos(xTabs, "1") #tab Description
51 xTitleText = xDialog.getChild("title")
52 xTitleText.executeAction("TYPE", mkPropertyValues({"TEXT":"Title text"}))
53 xSubjectText = xDialog.getChild("subject")
54 xSubjectText.executeAction("TYPE", mkPropertyValues({"TEXT":"Subject text"}))
55 xKeywordsText = xDialog.getChild("keywords")
56 xKeywordsText.executeAction("TYPE", mkPropertyValues({"TEXT":"Keywords text"}))
57 xCommentsText = xDialog.getChild("comments")
58 xCommentsText.executeAction("TYPE", mkPropertyValues({"TEXT":"Comments text"}))
61 #Font tab
62 select_pos(xTabs, "4") #tab Fonts
63 xFontEmbedCheckbox = xDialog.getChild("embedFonts")
64 xFontEmbedCheckbox.executeAction("CLICK", tuple())
66 #Security tab
67 select_pos(xTabs, "3") #tab Security
68 xReadOnlyCheckbox = xDialog.getChild("readonly")
69 xReadOnlyCheckbox.executeAction("CLICK", tuple())
70 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
71 xRecordChangesCheckbox.executeAction("CLICK", tuple())
72 xProtectBtn = xDialog.getChild("protect")
74 with self.ui_test.execute_blocking_action(xProtectBtn.executeAction, args=('CLICK', ())) as dialog:
75 xPasswordText = dialog.getChild("pass1ed")
76 xPasswordText.executeAction("TYPE", mkPropertyValues({"TEXT":"password"}))
77 xConfirmText = dialog.getChild("confirm1ed")
78 xConfirmText.executeAction("TYPE", mkPropertyValues({"TEXT":"password"}))
80 select_pos(xTabs, "2") #tab Custom properties
82 self.assert_custom_properties(xDialog, False)
84 xAddBtn = xDialog.getChild("add")
85 xAddBtn.executeAction("CLICK", tuple())
87 self.assert_custom_properties(xDialog, True)
89 xRemoveBtn = xDialog.getChild("remove1")
90 xRemoveBtn.executeAction("CLICK", tuple())
92 self.assert_custom_properties(xDialog, False)
94 select_pos(xTabs, "5") #tab Statistics
95 xUpdateBtn = xDialog.getChild("update")
96 xUpdateBtn.executeAction("CLICK", tuple())
98 #now open the dialog again and read the properties
99 with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties", close_button="cancel") as xDialog:
100 xTitleText = xDialog.getChild("title")
101 xSubjectText = xDialog.getChild("subject")
102 xKeywordsText = xDialog.getChild("keywords")
103 xCommentsText = xDialog.getChild("comments")
104 xReadOnlyCheckbox = xDialog.getChild("readonly")
105 xRecordChangesCheckbox = xDialog.getChild("recordchanges")
106 xFontEmbedCheckbox = xDialog.getChild("embedFonts")
107 xUserDataCheckbox = xDialog.getChild("userdatacb")
108 xThumbSaveCheckbox = xDialog.getChild("thumbnailsavecb")
109 self.assertEqual(get_state_as_dict(xTitleText)["Text"], "Title text")
110 self.assertEqual(get_state_as_dict(xSubjectText)["Text"], "Subject text")
111 self.assertEqual(get_state_as_dict(xKeywordsText)["Text"], "Keywords text")
112 self.assertEqual(get_state_as_dict(xReadOnlyCheckbox)["Selected"], "true")
113 self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "true")
114 self.assertEqual(get_state_as_dict(xReadOnlyCheckbox)["Selected"], "true")
115 self.assertEqual(get_state_as_dict(xFontEmbedCheckbox)["Selected"], "true")
116 self.assertEqual(get_state_as_dict(xUserDataCheckbox)["Selected"], "false")
117 self.assertEqual(get_state_as_dict(xThumbSaveCheckbox)["Selected"], "false")
118 self.assertEqual(get_state_as_dict(xCommentsText)["Text"], "Comments text")
119 xResetBtn = xDialog.getChild("reset")
120 xResetBtn.executeAction("CLICK", tuple())
123 # vim: set shiftwidth=4 softtabstop=4 expandtab: