Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / qa / python / check_change_color.py
blobd8562bc77b52c33749d8d48ec5c8fb74d288b51e
1 '''
2 This file is part of the LibreOffice project.
4 This Source Code Form is subject to the terms of the Mozilla Public
5 License, v. 2.0. If a copy of the MPL was not distributed with this
6 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 This file incorporates work covered by the following license notice:
10 Licensed to the Apache Software Foundation (ASF) under one or more
11 contributor license agreements. See the NOTICE file distributed
12 with this work for additional information regarding copyright
13 ownership. The ASF licenses this file to you under the Apache
14 License, Version 2.0 (the "License"); you may not use this file
15 except in compliance with the License. You may obtain a copy of
16 the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 '''
19 import unittest
20 from org.libreoffice.unotest import UnoInProcess
21 from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
22 from com.sun.star.awt.FontUnderline import SINGLE
24 class CheckChangeColor(unittest.TestCase):
26 @classmethod
27 def setUpClass(cls):
28 cls._uno = UnoInProcess()
29 cls._uno.setUp()
30 cls._xEmptyDoc = cls._uno.openEmptyWriterDoc()
31 cls.RED = 0xFF0000
32 cls.BLUE = 0x0000FF
33 cls.GREEN = 0x008000
35 @classmethod
36 def tearDownClass(cls):
37 cls._uno.tearDown()
39 def test_change_color(self):
40 xDoc = CheckChangeColor._uno.openEmptyWriterDoc()
41 xPageStyles = xDoc.StyleFamilies["PageStyles"]
42 xPageStyle = xPageStyles["Standard"]
44 self.assertEqual(xPageStyle.BackColor, -1)
45 self.assertEqual(xPageStyle.IsLandscape, False)
47 xPageStyle.BackColor = self.RED
48 xPageStyle.IsLandscape = True
49 self.assertEqual(xPageStyle.BackColor, self.RED)
50 self.assertEqual(xPageStyle.IsLandscape, True)
52 xPageStyle.GridColor = self.GREEN
53 self.assertEqual(xPageStyle.GridColor, self.GREEN)
55 xPageStyle.FootnoteLineColor = self.BLUE
56 self.assertEqual(xPageStyle.FootnoteLineColor, self.BLUE)
58 xDoc.dispose()
60 def test_change_text_color(self):
61 xDoc = CheckChangeColor._uno.openEmptyWriterDoc()
62 cursor = xDoc.Text.createTextCursor()
64 cursor.CharColor = self.RED
65 self.assertEqual(cursor.CharColor, self.RED)
67 cursor.CharBackColor = self.BLUE
68 self.assertEqual(cursor.CharBackColor, self.BLUE)
70 self.assertEqual(cursor.CharUnderlineHasColor, False)
71 cursor.CharUnderlineHasColor = True
72 cursor.CharUnderline = SINGLE
73 cursor.CharUnderlineColor = self.GREEN
74 self.assertEqual(cursor.CharUnderlineColor, self.GREEN)
75 self.assertEqual(cursor.CharUnderline, SINGLE)
76 self.assertEqual(cursor.CharUnderlineHasColor, True)
78 xDoc.Text.insertString(cursor, "One foo to rule them all", 0)
80 self.assertEqual(xDoc.getText().createTextCursor().CharColor, self.RED)
81 self.assertEqual(xDoc.getText().createTextCursor().CharBackColor, self.BLUE)
82 self.assertEqual(xDoc.getText().createTextCursor().CharUnderlineColor, self.GREEN)
84 xDoc.dispose()
86 def test_change_paragraph_color(self):
87 xDoc = CheckChangeColor._uno.openEmptyWriterDoc()
88 cursor = xDoc.Text.createTextCursor()
90 cursor.ParaBackColor = self.RED
91 self.assertEqual(cursor.ParaBackColor, self.RED)
93 xDoc.Text.insertControlCharacter(cursor, PARAGRAPH_BREAK, False)
94 xDoc.Text.insertString(cursor, "One foo to find them all", 0)
96 self.assertEqual(xDoc.getText().createTextCursor().ParaBackColor, self.RED)
98 xDoc.dispose()
100 if __name__ == '__main__':
101 unittest.main()