Replace calls to uno.invoke with direct method call when just for Any
Now that the restriction on passing on Any as an argument to a method has been lifted we can simplify some of the PythonTests that were calling uno.invoke in order to pass an Any and just call the method directly. Change-Id: I14af4e3f50236e46f6108f8fea0284f696b59e44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195464 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
This commit is contained in:
committed by
Stephan Bergmann
parent
507b6c2b90
commit
68f8ddc153
@@ -30,7 +30,7 @@ class TestXIndexContainer(CollectionsTestBase):
|
||||
values = sm.createInstanceWithContext("com.sun.star.document.IndexedPropertyValues", self.context)
|
||||
for i in range(count):
|
||||
properties = (PropertyValue(Name='n'+str(i), Value='v'+str(i)),)
|
||||
uno.invoke(values, "insertByIndex", (i, uno.Any("[]com.sun.star.beans.PropertyValue", properties)))
|
||||
values.insertByIndex(i, uno.Any("[]com.sun.star.beans.PropertyValue", properties))
|
||||
return values
|
||||
|
||||
def generateTestTuple(self, values):
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestXIndexReplace(CollectionsTestBase):
|
||||
index = getContentIndexInstance(doc)
|
||||
for i in range(10):
|
||||
styles = ('n'+str(i),)
|
||||
uno.invoke(index.LevelParagraphStyles, "replaceByIndex", (i, uno.Any("[]string", styles)))
|
||||
index.LevelParagraphStyles.replaceByIndex(i, uno.Any("[]string", styles))
|
||||
return index
|
||||
|
||||
def generateTestTuple(self, values):
|
||||
|
||||
@@ -51,34 +51,34 @@ class CheckIndexedPropertyValues(unittest.TestCase):
|
||||
prop3 = uno.Any("[]com.sun.star.beans.PropertyValue", (p3,))
|
||||
|
||||
self.assertEqual(0, len(xCont), "Initial container is not empty")
|
||||
uno.invoke(xCont, "insertByIndex", (0, prop1))
|
||||
xCont.insertByIndex(0, prop1)
|
||||
|
||||
ret = xCont[0]
|
||||
self.assertEqual(p1.Name, ret[0].Name)
|
||||
self.assertEqual(p1.Value, ret[0].Value)
|
||||
|
||||
uno.invoke(xCont, "replaceByIndex", (0, prop2))
|
||||
xCont.replaceByIndex(0, prop2)
|
||||
ret = xCont[0]
|
||||
self.assertEqual(p2.Name, ret[0].Name)
|
||||
self.assertEqual(p2.Value, ret[0].Value)
|
||||
|
||||
xCont.removeByIndex(0)
|
||||
self.assertTrue(not(xCont.hasElements()) and len(xCont) == 0, "Could not remove PropertyValue")
|
||||
uno.invoke(xCont, "insertByIndex", (0, prop1))
|
||||
uno.invoke(xCont, "insertByIndex", (1, prop2))
|
||||
xCont.insertByIndex(0, prop1)
|
||||
xCont.insertByIndex(1, prop2)
|
||||
self.assertTrue(xCont.hasElements() and len(xCont) == 2, "Did not insert PropertyValue")
|
||||
|
||||
uno.invoke(xCont, "insertByIndex", (1, prop2))
|
||||
uno.invoke(xCont, "insertByIndex", (1, prop3))
|
||||
xCont.insertByIndex(1, prop2)
|
||||
xCont.insertByIndex(1, prop3)
|
||||
ret = xCont[1]
|
||||
self.assertEqual(p3.Name, ret[0].Name)
|
||||
self.assertEqual(p3.Value, ret[0].Value)
|
||||
|
||||
with self.assertRaises(IndexOutOfBoundsException):
|
||||
uno.invoke(xCont, "insertByIndex", (25, prop2))
|
||||
xCont.insertByIndex(25, prop2)
|
||||
|
||||
with self.assertRaises(IndexOutOfBoundsException):
|
||||
xCont.removeByIndex(25)
|
||||
|
||||
with self.assertRaises(IllegalArgumentException):
|
||||
uno.invoke(xCont, "insertByIndex", (3, "Example String"))
|
||||
xCont.insertByIndex(3, "Example String")
|
||||
|
||||
@@ -51,20 +51,20 @@ class CheckNamedPropertyValues(unittest.TestCase):
|
||||
|
||||
self.assertFalse(xCont.hasElements(), "Initial container is not empty")
|
||||
|
||||
uno.invoke(xCont, "insertByName", ("prop1", prop1))
|
||||
xCont.insertByName("prop1", prop1)
|
||||
ret = xCont["prop1"]
|
||||
self.assertEqual(p1.Name, ret[0].Name)
|
||||
self.assertEqual(p1.Value, ret[0].Value)
|
||||
|
||||
uno.invoke(xCont, "replaceByName", ("prop1", prop2))
|
||||
xCont.replaceByName("prop1", prop2)
|
||||
ret = xCont["prop1"]
|
||||
self.assertEqual(p2.Name, ret[0].Name)
|
||||
self.assertEqual(p2.Value, ret[0].Value)
|
||||
|
||||
xCont.removeByName("prop1")
|
||||
self.assertFalse(xCont.hasElements(), "Could not remove PropertyValue.")
|
||||
uno.invoke(xCont, "insertByName", ("prop1", prop1))
|
||||
uno.invoke(xCont, "insertByName", ("prop2", prop2))
|
||||
xCont.insertByName("prop1", prop1)
|
||||
xCont.insertByName("prop2", prop2)
|
||||
self.assertTrue(xCont.hasElements(), "Did not insert PropertyValue")
|
||||
names = xCont.getElementNames()
|
||||
self.assertEqual(2, len(names), "Not all element names were returned")
|
||||
@@ -73,10 +73,10 @@ class CheckNamedPropertyValues(unittest.TestCase):
|
||||
self.assertIn(names[i], ["prop1", "prop2"], "Got a wrong element name")
|
||||
|
||||
with self.assertRaises(ElementExistException):
|
||||
uno.invoke(xCont, "insertByName", ("prop2", prop1))
|
||||
xCont.insertByName("prop2", prop1)
|
||||
|
||||
with self.assertRaises(IllegalArgumentException):
|
||||
uno.invoke(xCont, "insertByName", ("prop3", "Example String"))
|
||||
xCont.insertByName("prop3", "Example String")
|
||||
|
||||
with self.assertRaises(NoSuchElementException):
|
||||
xCont.removeByName("prop3")
|
||||
|
||||
Reference in New Issue
Block a user