Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / writer_tests6 / infobar.py
blobcb525fc9bf803056e35b881aa66b3bd9fe977474
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
11 from com.sun.star.beans import StringPair
12 from com.sun.star.frame import InfobarType
13 from com.sun.star.lang import IllegalArgumentException
14 from com.sun.star.container import NoSuchElementException
17 # Test for Infobar API
19 class tdf97926(UITestCase):
20 def test_infobar_add(self):
21 with self.ui_test.create_doc_in_start_center("writer") as document:
22 controller = document.getCurrentController()
23 buttons = [StringPair("Close", ".uno:CloseDoc")]
24 controller.appendInfobar(
25 "my", "Hello world", "The quick, brown fox jumps over a lazy dog.", InfobarType.INFO, buttons, True)
27 # Adding another infobar with the same ID should throw an exception
28 with self.assertRaises(IllegalArgumentException):
29 controller.appendInfobar(
30 "my", "Hello world", "The quick, brown fox jumps over a lazy dog.", InfobarType.INFO, buttons, True)
32 def test_infobar_update(self):
33 with self.ui_test.create_doc_in_start_center("writer") as document:
34 controller = document.getCurrentController()
35 buttons = [StringPair("Close", ".uno:CloseDoc")]
36 controller.appendInfobar(
37 "my", "Hello world", "The quick, brown fox jumps over a lazy dog.", InfobarType.INFO, buttons, True)
38 controller.updateInfobar("my", "Hello universe", "", InfobarType.WARNING)
40 # Updating non-existing infobars should throw an exception
41 with self.assertRaises(NoSuchElementException):
42 controller.updateInfobar("notexisting", "", "", InfobarType.WARNING)
44 # Passing invalid values for InfobarType should throw an exception
45 with self.assertRaises(IllegalArgumentException):
46 controller.updateInfobar("my", "", "", 120)
48 def test_infobar_remove(self):
49 with self.ui_test.create_doc_in_start_center("writer") as document:
50 controller = document.getCurrentController()
51 buttons = [StringPair("Close", ".uno:CloseDoc")]
52 controller.appendInfobar(
53 "my", "Hello world", "The quick, brown fox jumps over a lazy dog.", InfobarType.INFO, buttons, True)
55 controller.removeInfobar("my")
57 # Removing an already removed infobar should throw an exception
58 with self.assertRaises(NoSuchElementException):
59 controller.removeInfobar("my")
61 # vim: set shiftwidth=4 softtabstop=4 expandtab: