tdf#97361: Removed getByIndex in calc and writer

Change-Id: I477e1129d7b8deb91920b3ffd715bc217e606d20
Reviewed-on: https://gerrit.libreoffice.org/80140
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
This commit is contained in:
Mayank Suman 2019-10-03 19:37:36 +05:30 committed by Michael Stahl
parent c1f60d7d11
commit d5dc19402e
10 changed files with 31 additions and 31 deletions

View file

@ -70,7 +70,7 @@ class CalcRTL(unittest.TestCase):
return worked
def getSpreadsheet(self):
return self.xSheetDoc.getSheets().getByIndex(0)
return self.xSheetDoc.getSheets()[0]
if __name__ == '__main__':
unittest.main()

View file

@ -46,21 +46,21 @@ class moveCopySheet(UITestCase):
newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"}))
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName"
# Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName"
self.assertEqual(document.Sheets.getCount(), 2)
self.assertEqual(document.Sheets.getByIndex(0).Name, "Sheet1")
self.assertEqual(document.Sheets.getByIndex(1).Name, "moveName")
self.assertEqual(document.Sheets[0].Name, "Sheet1")
self.assertEqual(document.Sheets[1].Name, "moveName")
#verify that the cancel button does not do anything
# Verify that the cancel button does not do anything
self.ui_test.execute_dialog_through_command(".uno:Move")
xDialog = self.xUITest.getTopFocusWindow()
xCancelBtn = xDialog.getChild("cancel")
self.ui_test.close_dialog_through_button(xCancelBtn)
self.assertEqual(document.Sheets.getCount(), 2)
self.assertEqual(document.Sheets.getByIndex(0).Name, "Sheet1")
self.assertEqual(document.Sheets.getByIndex(1).Name, "moveName")
self.assertEqual(document.Sheets[0].Name, "Sheet1")
self.assertEqual(document.Sheets[1].Name, "moveName")
self.ui_test.close_doc()

View file

@ -77,10 +77,10 @@ class CheckStyle(unittest.TestCase):
self.assertListEqual(vNames, vExpectedNames)
def __test_StyleFamilyIndex(self, xFamily, vExpectedNames, sElementImplName):
self.assertEqual(xFamily.Count, len(vExpectedNames))
self.assertEqual(len(xFamily), len(vExpectedNames))
for nIndex in range(xFamily.Count):
xStyle = xFamily.getByIndex(nIndex)
for nIndex in range(len(xFamily)):
xStyle = xFamily[nIndex]
self.assertEqual(xStyle.ImplementationName, sElementImplName)
self.assertIn(xStyle.Name, vExpectedNames)
self.assertFalse(xStyle.isUserDefined())
@ -176,7 +176,7 @@ class CheckStyle(unittest.TestCase):
self.assertIsNotNone(xTableStyles.getByName(sStyleName))
#check SwXTextCellStyles
vCellStyles = ["first-row", "last-row", "first-column", "last-column", "body", "even-rows", "odd-rows", "even-columns", "odd-columns", "background"]
xDefaultTableStyle = xTableStyles.getByIndex(0)
xDefaultTableStyle = xTableStyles[0]
for sCellStyle in vCellStyles:
xCellStyle = xDefaultTableStyle.getByName(sCellStyle)
self.assertIsNotNone(xCellStyle.getPropertyValue("BackColor"))

View file

@ -126,7 +126,7 @@ class TestVarFields(unittest.TestCase):
xDoc.storeToURL(url, tuple(list(range(0))))
# 19. retrieve the section
xSection = xDoc.getTextSections().getByIndex(0)
xSection = xDoc.getTextSections()[0]
# 20. retrieve the condition property of that section
read_content = xSection.getPropertyValue("Condition")

View file

@ -41,9 +41,9 @@ class insertCaption(UITestCase):
xOkBtn=xDialogCaption.getChild("ok")
xOkBtn.executeAction("CLICK", tuple())
xFrame = document.TextFrames.getByIndex(0)
xFrame = document.TextFrames[0]
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nText 1: Caption")
self.assertEqual(document.TextFrames[0].Text.String, "\nText 1: Caption")
self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 2nd caption
xDialogCaption = self.xUITest.getTopFocusWindow()
@ -55,7 +55,7 @@ class insertCaption(UITestCase):
xOkBtn=xDialogCaption.getChild("ok")
xOkBtn.executeAction("CLICK", tuple())
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nText 1: Caption\nText 2-: Caption2")
self.assertEqual(document.TextFrames[0].Text.String, "\nText 1: Caption\nText 2-: Caption2")
self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 3. caption
xDialogCaption = self.xUITest.getTopFocusWindow()
@ -69,8 +69,8 @@ class insertCaption(UITestCase):
xOkBtn=xDialogCaption.getChild("ok")
xOkBtn.executeAction("CLICK", tuple())
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3")
self.assertEqual(document.TextFrames[0].Text.String, "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View file

@ -21,18 +21,18 @@ class insertFootnote(UITestCase):
self.xUITest.executeCommand(".uno:InsertFootnote")
type_text(xWriterEdit, "LibreOffice")
self.assertEqual(document.Footnotes.getByIndex(0).String, "LibreOffice")
self.assertEqual(document.Footnotes[0].String, "LibreOffice")
self.assertEqual(document.Footnotes.getCount(), 1)
self.xUITest.executeCommand(".uno:Undo")
self.assertEqual(document.Footnotes.getByIndex(0).String, "")
self.assertEqual(document.Footnotes[0].String, "")
self.xUITest.executeCommand(".uno:Undo")
self.assertEqual(document.Footnotes.getCount(), 0)
self.xUITest.executeCommand(".uno:Redo")
self.assertEqual(document.Footnotes.getByIndex(0).String, "")
self.assertEqual(document.Footnotes[0].String, "")
self.assertEqual(document.Footnotes.getCount(), 1)
self.xUITest.executeCommand(".uno:Redo")
self.assertEqual(document.Footnotes.getByIndex(0).String, "LibreOffice")
self.assertEqual(document.Footnotes[0].String, "LibreOffice")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View file

@ -29,7 +29,7 @@ class tdf116474(UITestCase):
textGraphic.Graphic = graphic
text.insertTextContent(cursor, textGraphic, False)
#select image
document.getCurrentController().select(document.getDrawPage().getByIndex(0))
document.getCurrentController().select(document.getDrawPage()[0])
self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # caption
xDialogCaption = self.xUITest.getTopFocusWindow()
@ -40,14 +40,14 @@ class tdf116474(UITestCase):
xOkBtn=xDialogCaption.getChild("ok")
xOkBtn.executeAction("CLICK", tuple())
xFrame = document.TextFrames.getByIndex(0)
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nFigure 1: Caption")
xFrame = document.TextFrames[0]
self.assertEqual(document.TextFrames[0].Text.String, "\nFigure 1: Caption")
self.assertEqual(document.GraphicObjects.getCount(), 1) #nr. of images
#Undo, redo
self.xUITest.executeCommand(".uno:Undo")
self.xUITest.executeCommand(".uno:Redo")
#Verify
self.assertEqual(document.TextFrames.getByIndex(0).Text.String, "\nFigure 1: Caption")
self.assertEqual(document.TextFrames[0].Text.String, "\nFigure 1: Caption")
self.assertEqual(document.GraphicObjects.getCount(), 1) #nr. of images
self.ui_test.close_doc()

View file

@ -22,17 +22,17 @@ class insertEndnote(UITestCase):
type_text(xWriterEdit, "LibreOffice")
self.assertEqual(document.Endnotes.getByIndex(0).String, "LibreOffice")
self.assertEqual(document.Endnotes[0].String, "LibreOffice")
self.assertEqual(document.Endnotes.getCount(), 1)
self.xUITest.executeCommand(".uno:Undo")
self.assertEqual(document.Endnotes.getByIndex(0).String, "")
self.assertEqual(document.Endnotes[0].String, "")
self.xUITest.executeCommand(".uno:Undo")
self.assertEqual(document.Endnotes.getCount(), 0)
self.xUITest.executeCommand(".uno:Redo")
self.assertEqual(document.Endnotes.getByIndex(0).String, "")
self.assertEqual(document.Endnotes[0].String, "")
self.assertEqual(document.Endnotes.getCount(), 1)
self.xUITest.executeCommand(".uno:Redo")
self.assertEqual(document.Endnotes.getByIndex(0).String, "LibreOffice")
self.assertEqual(document.Endnotes[0].String, "LibreOffice")
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:

View file

@ -51,7 +51,7 @@ class tdf107975(UITestCase):
self.assertEqual(writer_doc.getGraphicObjects().getCount(), 1)
# try again with anchor at start of doc which is another special case
xShape = writer_doc.getGraphicObjects().getByIndex(0)
xShape = writer_doc.getGraphicObjects()[0]
xStart = writer_doc.getText().getStart()
xShape.attach(xStart)

View file

@ -39,7 +39,7 @@ class tdf44837(UITestCase):
self.ui_test.close_dialog_through_button(xcloseBtn)
self.assertEqual(document.Text.String[0:8], "bsd bsd")
self.assertEqual(len(document.CurrentSelection.getByIndex(0).String) > 1, True)
self.assertEqual(len(document.CurrentSelection[0].String) > 1, True)
#follow-up bug 125663
self.ui_test.close_doc()