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/.
9 from uitest
.framework
import UITestCase
10 from uitest
.uihelper
.common
import get_state_as_dict
11 from uitest
.uihelper
.common
import select_by_text
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 #TSCP: add advanced classification dialog https://cgit.freedesktop.org/libreoffice/core/commit/?id=71ee09947d5a71105d64fd225bb3672dfa7ce834
15 # This adds an advanced classification dialog, which enables the user
16 # to manually construct a header/footer message from classification
17 # properties in cases where the user needs more control. All the
18 # text is inserted as fields into the end document and can be changed
19 # by changing the document properties. The simple classification
20 # still functions as it did before, which is what most users will
21 # want to use in this case.
23 #[Bug 122491] Classification: dialog (Paragraph) Classification doesn't show previously chosen classification
24 #https://wiki.documentfoundation.org/TSCP-classification
26 #new file; open Doc classification dialog
27 #add classification Confidential, save
29 #verify watermark Bug 122586 - Classification: by using the dialog, Watermark text from policy is not placed in the document
30 #open dialog and add intellectualProperty text, save
31 #verify in doc properties text of IP (in API, cannot verify in UI)
32 #reopen and verify classification and Content
33 #do the same for Paragraph classification
34 # verify the text on characters 0-6 : "(Conf)"
35 #+ new file and do it only for Paragraph classification (no watermark!)
36 #+ bug with bold text Bug 122565 - Classification dialog - Button "bold" works only in dialog
38 #variants of content written manually, IP strings, classification (Conf, NB, GB, IO)
39 #[Bug 122491] with testdoc
41 class classification(UITestCase
):
42 def test_document_classification_dialog(self
):
43 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
44 with self
.ui_test
.execute_dialog_through_command(".uno:ClassificationDialog") as xDialog
:
45 classificationCB
= xDialog
.getChild("classificationCB")
46 internationalClassificationCB
= xDialog
.getChild("internationalClassificationCB")
48 select_by_text(classificationCB
, "Confidential")
49 #verify International is set too
50 self
.assertEqual(get_state_as_dict(internationalClassificationCB
)["SelectEntryText"], "Confidential")
51 #verify textBox Content
52 # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
54 header
= document
.StyleFamilies
.PageStyles
.Standard
.HeaderText
.createEnumeration().nextElement()
55 self
.assertEqual(header
.String
, "Confidential")
57 controller
= document
.getCurrentController()
58 self
.assertTrue(controller
.hasInfobar("classification"))
61 #Bug 122586 - Classification: by using the dialog, Watermark text from policy is not placed in the document
62 with self
.ui_test
.execute_dialog_through_command(".uno:Watermark", close_button
="cancel") as xDialog
:
63 xTextInput
= xDialog
.getChild("TextInput")
64 xAngle
= xDialog
.getChild("Angle")
65 xTransparency
= xDialog
.getChild("Transparency")
66 self
.assertEqual(get_state_as_dict(xTextInput
)["Text"], "Confidential")
67 self
.assertEqual(get_state_as_dict(xAngle
)["Text"], "45°")
68 self
.assertEqual((get_state_as_dict(xTransparency
)["Text"])[0:2], "50")
71 #open dialog and add intellectualProperty text, save
73 #reopen and verify classification and Content
75 #do the same for Paragraph classification
76 with self
.ui_test
.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog
:
77 classificationCB
= xDialog
.getChild("classificationCB")
78 internationalClassificationCB
= xDialog
.getChild("internationalClassificationCB")
80 select_by_text(classificationCB
, "Confidential")
81 #verify International is set too
82 self
.assertEqual(get_state_as_dict(internationalClassificationCB
)["SelectEntryText"], "Confidential")
83 #verify textBox Content TODO textbox not supported
84 #self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
86 self
.assertEqual(document
.Text
.String
[0:6], "(Conf)")
87 self
.assertEqual(header
.String
, "Confidential")
88 self
.assertTrue(controller
.hasInfobar("classification"))
91 def test_paragraph_classification_dialog(self
):
92 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
93 #+ new file and do it only for Paragraph classification (no watermark!)
94 with self
.ui_test
.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog
:
95 classificationCB
= xDialog
.getChild("classificationCB")
96 internationalClassificationCB
= xDialog
.getChild("internationalClassificationCB")
98 select_by_text(classificationCB
, "Confidential")
99 #verify International is set too
100 self
.assertEqual(get_state_as_dict(internationalClassificationCB
)["SelectEntryText"], "Confidential")
101 #verify textBox Content TODO - texbox not supported yet
102 # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
104 controller
= document
.getCurrentController()
105 self
.assertEqual(document
.Text
.String
[0:6], "(Conf)")
106 self
.assertFalse(controller
.hasInfobar("classification"))
107 self
.assertFalse(document
.StyleFamilies
.PageStyles
.Standard
.HeaderIsOn
)
110 def test_paragraph_classification_dialog_text(self
):
111 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
112 #+ new file and do it only for Paragraph classification (no watermark!)
113 with self
.ui_test
.execute_dialog_through_command(".uno:ParagraphClassificationDialog") as xDialog
:
114 classificationCB
= xDialog
.getChild("classificationCB")
115 internationalClassificationCB
= xDialog
.getChild("internationalClassificationCB")
116 intellectualPropertyPartEntry
= xDialog
.getChild("intellectualPropertyPartEntry")
117 intellectualPropertyPartAddButton
= xDialog
.getChild("intellectualPropertyPartAddButton")
119 intellectualPropertyPartEntry
.executeAction("TYPE", mkPropertyValues({"TEXT":"AA"}))
120 intellectualPropertyPartAddButton
.executeAction("CLICK", tuple())
121 select_by_text(classificationCB
, "Internal Only")
122 #verify International is set too
123 self
.assertEqual(get_state_as_dict(internationalClassificationCB
)["SelectEntryText"], "Internal Only")
124 #verify textBox Content TODO - texbox not supported yet
125 # self.assertEqual(get_state_as_dict(classificationEditWindow)["Text"], "Conf")
128 controller
= document
.getCurrentController()
129 self
.assertEqual(document
.Text
.String
[0:6], "(AAIO)")
130 self
.assertFalse(controller
.hasInfobar("classification"))
131 self
.assertFalse(document
.StyleFamilies
.PageStyles
.Standard
.HeaderIsOn
)
133 # vim: set shiftwidth=4 softtabstop=4 expandtab: