2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 from org
.libreoffice
.unotest
import UnoInProcess
12 from com
.sun
.star
.lang
import IllegalArgumentException
13 from com
.sun
.star
.beans
import PropertyValue
16 class TestXModel(unittest
.TestCase
):
20 cls
._uno
= UnoInProcess()
24 def tearDownClass(cls
):
27 def test_setArgs_valid(self
):
28 xDoc
= self
._uno
.openEmptyWriterDoc()
29 self
.assertIsNotNone(xDoc
)
31 p1
= PropertyValue(Name
="SuggestedSaveAsName", Value
="prettyFileName")
32 p2
= PropertyValue(Name
="SuggestedSaveAsDir", Value
="/my/dir")
33 p3
= PropertyValue(Name
="LockContentExtraction", Value
=True)
34 p4
= PropertyValue(Name
="LockExport", Value
=True)
35 p5
= PropertyValue(Name
="LockPrint", Value
=True)
36 p6
= PropertyValue(Name
="LockSave", Value
=True)
37 p7
= PropertyValue(Name
="LockEditDoc", Value
=True)
38 p8
= PropertyValue(Name
="Replaceable", Value
=True)
39 xDoc
.setArgs([p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
])
41 # Make sure that all properties are returned with getArgs()
43 self
.assertTrue(p1
in args
)
44 self
.assertTrue(p2
in args
)
45 self
.assertTrue(p3
in args
)
46 self
.assertTrue(p4
in args
)
47 self
.assertTrue(p5
in args
)
48 self
.assertTrue(p6
in args
)
49 self
.assertTrue(p7
in args
)
50 self
.assertTrue(p8
in args
)
54 def test_setArgs_invalid(self
):
55 xDoc
= self
._uno
.openEmptyWriterDoc()
56 self
.assertIsNotNone(xDoc
)
58 # IllegalArgumentException should be thrown when setting a non-existing property
59 p1
= PropertyValue(Name
="PropertyNotExists", Value
="doesntmatter")
60 with self
.assertRaises(IllegalArgumentException
):
66 if __name__
== '__main__':
69 # vim: set shiftwidth=4 softtabstop=4 expandtab: