diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index 023d7853127..998b36bf84f 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -42,6 +42,19 @@ def invalidPasteId(protocol): else: return -1 +def closeHTTPStatusAndPasterDialog(protocol, pasterDialog): + mBoxStr = "{type='QMessageBox' unnamed='1' visible='1' windowTitle?='%s *'}" % protocol + mBox = waitForObject(mBoxStr, 1000) + text = str(mBox.text) + # close message box and paster window + clickButton("{type='QPushButton' text='Cancel' visible='1' window=%s}" % mBoxStr) + clickButton("{type='QPushButton' text='Cancel' visible='1' window='%s'}" % pasterDialog) + if 'Service Unavailable' in text: + test.warning(text) + return True + test.log("Closed dialog without expected error.", text) + return False + def pasteFile(sourceFile, protocol): def resetFiles(): clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) @@ -71,12 +84,17 @@ def pasteFile(sourceFile, protocol): # make sure to read all former errors (they won't get read twice) aut.readStderr() clickButton(waitForObject(":Send to Codepaster.Paste_QPushButton")) - outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") - waitFor("'https://' in str(outputWindow.plainText)", 20000) try: + outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") + waitFor("'https://' in str(outputWindow.plainText)", 20000) output = str(outputWindow.plainText).splitlines()[-1] except: output = "" + try: + if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'): + raise Exception(serverProblems) + except: + pass stdErrOut = aut.readStderr() match = re.search("^%s protocol error: (.*)$" % protocol, stdErrOut, re.MULTILINE) if match: @@ -102,7 +120,14 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting): foundSnippet = True invokeMenuItem("Tools", "Code Pasting", "Fetch Snippet...") selectFromCombo(":PasteSelectDialog.protocolBox_QComboBox", protocol) - pasteModel = waitForObject(":PasteSelectDialog.listWidget_QListWidget").model() + try: + pasteModel = waitForObject(":PasteSelectDialog.listWidget_QListWidget").model() + except: + try: + if closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog'): + return -1 + except: + pass waitFor("pasteModel.rowCount() > 1", 20000) if (not skippedPasting and not protocol == NAME_PBCA and not any(map(lambda str:pasteId in str, dumpItems(pasteModel)))):