summaryrefslogtreecommitdiff
path: root/sw/qa/uitest/table
diff options
context:
space:
mode:
authorChenxiong Qi <qcxhome@gmail.com>2023-12-20 20:54:05 +0800
committerHossein <hossein@libreoffice.org>2024-01-23 14:00:46 +0100
commit74de0ebb810f3e13c45f01c63067cb8de794ce3c (patch)
treeb5f069ad74d12b5ce095b4ad9159861fd1445614 /sw/qa/uitest/table
parent3a20c691ab1d6a16ad0fc144926b22c098552be4 (diff)
tdf#97361 Make unittests more pythonic: XIndexAccess
Change-Id: I05ef274dd0ad5dc35b5455cfc01feabc6c0820a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161276 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest/table')
-rw-r--r--sw/qa/uitest/table/sheetToTable.py10
-rw-r--r--sw/qa/uitest/table/splitTable.py12
-rw-r--r--sw/qa/uitest/table/tableToText.py16
-rw-r--r--sw/qa/uitest/table/tdf51352.py8
-rw-r--r--sw/qa/uitest/table/tdf53460.py2
-rw-r--r--sw/qa/uitest/table/textToTable.py8
6 files changed, 28 insertions, 28 deletions
diff --git a/sw/qa/uitest/table/sheetToTable.py b/sw/qa/uitest/table/sheetToTable.py
index 4a40b6966935..372ea46884ac 100644
--- a/sw/qa/uitest/table/sheetToTable.py
+++ b/sw/qa/uitest/table/sheetToTable.py
@@ -22,7 +22,7 @@ class sheetToTable(UITestCase):
with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc:
self.xUITest.executeCommand(".uno:Paste")
#verify (don't copy hidden cells)
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
table = writer_doc.getTextTables()[0]
# This was 3 (copied hidden row)
self.assertEqual(len(table.getRows()), 2)
@@ -48,7 +48,7 @@ class sheetToTable(UITestCase):
self.xUITest.executeCommand(".uno:Paste")
#verify also tdf#124646 (don't copy hidden cells)
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
table = writer_doc.getTextTables()[0]
# This was 3 (copied hidden row)
self.assertEqual(len(table.getRows()), 2)
@@ -78,7 +78,7 @@ class sheetToTable(UITestCase):
self.xUITest.executeCommand(".uno:Paste")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
table = writer_doc.getTextTables()[0]
self.assertEqual(len(table.getRows()), 4)
self.assertEqual(table.getCellByName("A1").getString(), "Test 1")
@@ -106,7 +106,7 @@ class sheetToTable(UITestCase):
# Without the fix in place, this test would have failed with
# AssertionError: 0 != 1
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
table = writer_doc.getTextTables()[0]
self.assertEqual(len(table.getRows()), 4)
self.assertEqual(table.getCellByName("A1").getString(), "Test 1")
@@ -140,7 +140,7 @@ class sheetToTable(UITestCase):
# This was freezing
self.xUITest.executeCommand(".uno:Paste")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
table = writer_doc.getTextTables()[0]
self.assertEqual(len(table.getRows()), 4)
self.assertEqual(table.getCellByName("A1").getString(), "Test 1")
diff --git a/sw/qa/uitest/table/splitTable.py b/sw/qa/uitest/table/splitTable.py
index 06af8ee6c89d..b5b3c8cf4bf0 100644
--- a/sw/qa/uitest/table/splitTable.py
+++ b/sw/qa/uitest/table/splitTable.py
@@ -22,13 +22,13 @@ class splitTable(UITestCase):
copyheading = xDialog.getChild("copyheading")
copyheading.executeAction("CLICK", tuple())
- self.assertEqual(writer_doc.TextTables.getCount(), 2)
+ self.assertEqual(len(writer_doc.TextTables), 2)
tables = writer_doc.getTextTables()
self.assertEqual(len(tables[0].getRows()), 2)
self.assertEqual(len(tables[1].getRows()), 5)
#undo -> verify 1 tables
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
#dialog Split table, check Custom heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows
with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc:
@@ -39,13 +39,13 @@ class splitTable(UITestCase):
customheading = xDialog.getChild("customheading")
customheading.executeAction("CLICK", tuple())
- self.assertEqual(writer_doc.TextTables.getCount(), 2)
+ self.assertEqual(len(writer_doc.TextTables), 2)
tables = writer_doc.getTextTables()
self.assertEqual(len(tables[0].getRows()), 2)
self.assertEqual(len(tables[1].getRows()), 4)
#undo -> verify 1 tables
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
#dialog Split table, check No heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows
with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc:
@@ -56,13 +56,13 @@ class splitTable(UITestCase):
noheading = xDialog.getChild("noheading")
noheading.executeAction("CLICK", tuple())
- self.assertEqual(writer_doc.TextTables.getCount(), 2)
+ self.assertEqual(len(writer_doc.TextTables), 2)
tables = writer_doc.getTextTables()
self.assertEqual(len(tables[0].getRows()), 2)
self.assertEqual(len(tables[1].getRows()), 4)
#undo -> verify 1 tables
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
def test_tdf115572_remember_split_table_option(self):
with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")):
diff --git a/sw/qa/uitest/table/tableToText.py b/sw/qa/uitest/table/tableToText.py
index 0816cda7e607..2735285fc2c5 100644
--- a/sw/qa/uitest/table/tableToText.py
+++ b/sw/qa/uitest/table/tableToText.py
@@ -21,10 +21,10 @@ class tableToText(UITestCase):
tabs.executeAction("CLICK", tuple())
#verify
self.assertEqual(writer_doc.Text.String[0:3], "a\ta")
- self.assertEqual(writer_doc.TextTables.getCount(), 0)
+ self.assertEqual(len(writer_doc.TextTables), 0)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
#dialog Table to text - Paragraph; verify
with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog:
@@ -32,10 +32,10 @@ class tableToText(UITestCase):
paragraph.executeAction("CLICK", tuple())
#verify
self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:4], "a\na\n")
- self.assertEqual(writer_doc.TextTables.getCount(), 0)
+ self.assertEqual(len(writer_doc.TextTables), 0)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
#dialog Table to text - Semicolons; verify
with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog:
@@ -43,10 +43,10 @@ class tableToText(UITestCase):
semicolons.executeAction("CLICK", tuple())
#verify
self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:6], "a;a\n;\n")
- self.assertEqual(writer_doc.TextTables.getCount(), 0)
+ self.assertEqual(len(writer_doc.TextTables), 0)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
#dialog Table to text - other; verify
with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog:
@@ -58,9 +58,9 @@ class tableToText(UITestCase):
othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"}))
#verify
self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:6], "a:a\n:\n")
- self.assertEqual(writer_doc.TextTables.getCount(), 0)
+ self.assertEqual(len(writer_doc.TextTables), 0)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/table/tdf51352.py b/sw/qa/uitest/table/tdf51352.py
index 4a2fa79d5578..f8e741c19b25 100644
--- a/sw/qa/uitest/table/tdf51352.py
+++ b/sw/qa/uitest/table/tdf51352.py
@@ -32,15 +32,15 @@ class tdf51352(UITestCase):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
- self.assertEqual(document.TextTables.getCount(), 2)
+ self.assertEqual(len(document.TextTables), 2)
#4. From menu "Table->Convert->Table to Text
with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText"):
pass
- self.assertEqual(document.TextTables.getCount(), 0)
+ self.assertEqual(len(document.TextTables), 0)
#5. Undo/Redo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(document.TextTables.getCount(), 2)
+ self.assertEqual(len(document.TextTables), 2)
self.xUITest.executeCommand(".uno:Redo")
- self.assertEqual(document.TextTables.getCount(), 0)
+ self.assertEqual(len(document.TextTables), 0)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/table/tdf53460.py b/sw/qa/uitest/table/tdf53460.py
index b0e8fcabaaf1..866dcaaddfbc 100644
--- a/sw/qa/uitest/table/tdf53460.py
+++ b/sw/qa/uitest/table/tdf53460.py
@@ -70,5 +70,5 @@ class tdf53460(UITestCase):
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
- self.assertEqual(document.TextTables.getCount(), 2)
+ self.assertEqual(len(document.TextTables), 2)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/table/textToTable.py b/sw/qa/uitest/table/textToTable.py
index 5b70b89cc978..bde7433b4315 100644
--- a/sw/qa/uitest/table/textToTable.py
+++ b/sw/qa/uitest/table/textToTable.py
@@ -24,13 +24,13 @@ class textToTable(UITestCase):
semicolons = xDialog.getChild("semicolons")
semicolons.executeAction("CLICK", tuple())
#verify
- self.assertEqual(document.TextTables.getCount(), 1)
+ self.assertEqual(len(document.TextTables), 1)
tables = document.getTextTables()
self.assertEqual(len(tables[0].getRows()), 1)
self.assertEqual(len(tables[0].getColumns()), 3)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(document.TextTables.getCount(), 0)
+ self.assertEqual(len(document.TextTables), 0)
self.assertEqual(document.Text.String[0:5], "A;B;C")
@@ -48,13 +48,13 @@ class textToTable(UITestCase):
headingcb = xDialog.getChild("headingcb")
headingcb.executeAction("CLICK", tuple())
#verify
- self.assertEqual(writer_doc.TextTables.getCount(), 1)
+ self.assertEqual(len(writer_doc.TextTables), 1)
tables = writer_doc.getTextTables()
self.assertEqual(len(tables[0].getRows()), 4)
self.assertEqual(len(tables[0].getColumns()), 3)
#undo
self.xUITest.executeCommand(".uno:Undo")
- self.assertEqual(writer_doc.TextTables.getCount(), 0)
+ self.assertEqual(len(writer_doc.TextTables), 0)
self.assertEqual(writer_doc.Text.String[0:5], "A:B:C")
# vim: set shiftwidth=4 softtabstop=4 expandtab: