Kaydet (Commit) 615c2931 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

add set/getData tests

Change-Id: I846ac849461d986d331b0366c36af46558fe9a14
üst ea3661e6
...@@ -8,6 +8,14 @@ from com.sun.star.table.BorderLineStyle import (DOUBLE, SOLID, EMBOSSED,\ ...@@ -8,6 +8,14 @@ from com.sun.star.table.BorderLineStyle import (DOUBLE, SOLID, EMBOSSED,\
class CheckTable(unittest.TestCase): class CheckTable(unittest.TestCase):
_uno = None _uno = None
def _fill_table(self, xTable):
for x in range(3):
for y in range(3):
xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
def _check_table(self, xTable):
for x in range(3):
for y in range(3):
self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls._uno = UnoInProcess() cls._uno = UnoInProcess()
...@@ -248,14 +256,6 @@ class CheckTable(unittest.TestCase): ...@@ -248,14 +256,6 @@ class CheckTable(unittest.TestCase):
# close document # close document
xDoc.dispose() xDoc.dispose()
def _fill_table(self, xTable):
for x in range(3):
for y in range(3):
xTable.getCellByPosition(x, y).String = 'Cell %d %d' % (x, y)
def _check_table(self, xTable):
for x in range(3):
for y in range(3):
self.assertEqual('Cell %d %d' % (x, y), xTable.getCellByPosition(x, y).String)
def test_descriptions(self): def test_descriptions(self):
xDoc = CheckTable._uno.openEmptyWriterDoc() xDoc = CheckTable._uno.openEmptyWriterDoc()
# insert table # insert table
...@@ -310,6 +310,33 @@ class CheckTable(unittest.TestCase): ...@@ -310,6 +310,33 @@ class CheckTable(unittest.TestCase):
foo = xTable2.ColumnDescriptions foo = xTable2.ColumnDescriptions
xDoc.dispose() xDoc.dispose()
def test_getset_data(self):
xDoc = CheckTable._uno.openEmptyWriterDoc()
# insert table
xTable = xDoc.createInstance("com.sun.star.text.TextTable")
xTable.initialize(3, 3)
xCursor = xDoc.Text.createTextCursor()
xDoc.Text.insertTextContent(xCursor, xTable, False)
xTable.ChartColumnAsLabel = False
xTable.ChartRowAsLabel = False
# roundtrip
xTable.Data = ((1,2,3), (4,5,6), (7,8,9))
self.assertEqual( xTable.Data, ((1,2,3), (4,5,6), (7,8,9)))
# missing row
with self.assertRaises(Exception):
xTable.Data = ((1,2,3), (4,5,6))
# missing column
with self.assertRaises(Exception):
xTable.Data = ((1,2), (4,5), (7,8))
# with labels
xTable.ChartColumnAsLabel = True
xTable.ChartRowAsLabel = True
self.assertEqual( xTable.Data, ((5,6), (8,9)))
xTable.Data = ((55,66), (88,99))
xTable.ChartColumnAsLabel = False
xTable.ChartRowAsLabel = False
self.assertEqual( xTable.Data, ((1,2,3), (4,55,66), (7,88,99)))
xDoc.dispose()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment