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
14 from uitest
.debug
import sleep
15 from uitest
.uihelper
.common
import select_pos
18 class documentProperties(UITestCase
):
20 def test_open_documentProperties_writer(self
):
21 self
.ui_test
.create_doc_in_start_center("writer")
22 self
.ui_test
.execute_dialog_through_command(".uno:SetDocumentProperties")
23 xDialog
= self
.xUITest
.getTopFocusWindow()
24 xResetBtn
= xDialog
.getChild("reset")
25 xResetBtn
.executeAction("CLICK", tuple())
27 xUserDataCheckbox
= xDialog
.getChild("userdatacb") # apply user data
28 xUserDataCheckbox
.executeAction("CLICK", tuple())
29 xThumbSaveCheckbox
= xDialog
.getChild("thumbnailsavecb") # save preview image with document
30 xThumbSaveCheckbox
.executeAction("CLICK", tuple())
33 xDigSignBtn
= xDialog
.getChild("signature")
35 def handle_sign_dlg(dialog
):
36 xNoBtn
= dialog
.getChild("no")
37 self
.ui_test
.close_dialog_through_button(xNoBtn
)
39 self
.ui_test
.execute_blocking_action(xDigSignBtn
.executeAction
, args
=('CLICK', ()),
40 dialog_handler
=handle_sign_dlg
)
42 xTabs
= xDialog
.getChild("tabcontrol")
43 select_pos(xTabs
, "1") #tab Description
45 xTitleText
= xDialog
.getChild("title")
46 xTitleText
.executeAction("TYPE", mkPropertyValues({"TEXT":"Title text"}))
47 xSubjectText
= xDialog
.getChild("subject")
48 xSubjectText
.executeAction("TYPE", mkPropertyValues({"TEXT":"Subject text"}))
49 xKeywordsText
= xDialog
.getChild("keywords")
50 xKeywordsText
.executeAction("TYPE", mkPropertyValues({"TEXT":"Keywords text"}))
51 xCommentsText
= xDialog
.getChild("comments")
52 xCommentsText
.executeAction("TYPE", mkPropertyValues({"TEXT":"Comments text"}))
56 select_pos(xTabs
, "5") #tab Fonts
57 xFontEmbedCheckbox
= xDialog
.getChild("embedFonts")
58 xFontEmbedCheckbox
.executeAction("CLICK", tuple())
61 select_pos(xTabs
, "4") #tab Security
62 xReadOnlyCheckbox
= xDialog
.getChild("readonly")
63 xReadOnlyCheckbox
.executeAction("CLICK", tuple())
64 xRecordChangesCheckbox
= xDialog
.getChild("recordchanges")
65 xRecordChangesCheckbox
.executeAction("CLICK", tuple())
66 xProtectBtn
= xDialog
.getChild("protect")
67 def handle_protect_dlg(dialog
):
68 xOkBtn
= dialog
.getChild("ok")
69 xPasswordText
= dialog
.getChild("pass1ed")
70 xPasswordText
.executeAction("TYPE", mkPropertyValues({"TEXT":"password"}))
71 xConfirmText
= dialog
.getChild("confirm1ed")
72 xConfirmText
.executeAction("TYPE", mkPropertyValues({"TEXT":"password"}))
73 self
.ui_test
.close_dialog_through_button(xOkBtn
)
75 self
.ui_test
.execute_blocking_action(xProtectBtn
.executeAction
, args
=('CLICK', ()),
76 dialog_handler
=handle_protect_dlg
)
78 select_pos(xTabs
, "2") #tab Custom properties
79 #add custom properties ------>>>>>>>>>>> not supported
80 xAddBtn
= xDialog
.getChild("add")
81 xAddBtn
.executeAction("CLICK", tuple())
83 select_pos(xTabs
, "6") #tab Statistics
84 xUpdateBtn
= xDialog
.getChild("update")
85 xUpdateBtn
.executeAction("CLICK", tuple())
87 xOkBtn
= xDialog
.getChild("ok")
88 xOkBtn
.executeAction("CLICK", tuple())
89 #now open the dialog again and read the properties
90 self
.ui_test
.execute_dialog_through_command(".uno:SetDocumentProperties")
91 xDialog
= self
.xUITest
.getTopFocusWindow()
92 xTitleText
= xDialog
.getChild("title")
93 xSubjectText
= xDialog
.getChild("subject")
94 xKeywordsText
= xDialog
.getChild("keywords")
95 xCommentsText
= xDialog
.getChild("comments")
96 xReadOnlyCheckbox
= xDialog
.getChild("readonly")
97 xRecordChangesCheckbox
= xDialog
.getChild("recordchanges")
98 xFontEmbedCheckbox
= xDialog
.getChild("embedFonts")
99 xUserDataCheckbox
= xDialog
.getChild("userdatacb")
100 xThumbSaveCheckbox
= xDialog
.getChild("thumbnailsavecb")
101 self
.assertEqual(get_state_as_dict(xTitleText
)["Text"], "Title text")
102 self
.assertEqual(get_state_as_dict(xSubjectText
)["Text"], "Subject text")
103 self
.assertEqual(get_state_as_dict(xKeywordsText
)["Text"], "Keywords text")
104 self
.assertEqual(get_state_as_dict(xReadOnlyCheckbox
)["Selected"], "true")
105 self
.assertEqual(get_state_as_dict(xRecordChangesCheckbox
)["Selected"], "true")
106 self
.assertEqual(get_state_as_dict(xReadOnlyCheckbox
)["Selected"], "true")
107 self
.assertEqual(get_state_as_dict(xFontEmbedCheckbox
)["Selected"], "true")
108 self
.assertEqual(get_state_as_dict(xUserDataCheckbox
)["Selected"], "false")
109 self
.assertEqual(get_state_as_dict(xThumbSaveCheckbox
)["Selected"], "false")
110 self
.assertEqual(get_state_as_dict(xCommentsText
)["Text"], "Comments text")
111 xResetBtn
= xDialog
.getChild("reset")
112 xResetBtn
.executeAction("CLICK", tuple())
113 xCancBtn
= xDialog
.getChild("cancel")
114 xCancBtn
.executeAction("CLICK", tuple())
116 self
.ui_test
.close_doc()
118 # vim: set shiftwidth=4 softtabstop=4 expandtab: