From 8c0042da40c13c1ad5cf768e2e019f6d2a3f06e8 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 27 Jul 2018 15:43:55 +0200 Subject: [PATCH] Squish: Use sections for services in tst_codepasting Change-Id: If97331e3a18f44ca82ad81c7609dc3162caf5254 Reviewed-by: Christian Stenger --- .../suite_tools/tst_codepasting/test.py | 73 ++++++++++--------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index 160353b2c5d..b2df4f9943a 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -177,44 +177,45 @@ def main(): openGeneralMessages() clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) for protocol in protocolsToTest: - skippedPasting = True - description = "Paste from 2017-05-11" - if protocol == NAME_KDE: - pasteId = "pysjk6n2i" - pastedText = readFile(os.path.join(os.getcwd(), "testdata", "main-prepasted.cpp")) - elif skipPastingToPastebinCom and protocol == NAME_PBCOM: - pasteId = "8XHP0ZgH" - pastedText = readFile(os.path.join(os.getcwd(), "testdata", "main-prepasted.cpp")) - else: - skippedPasting = False - try: - pasteId, description, pastedText = pasteFile(sourceFile, protocol) - except Exception as e: - if e.message == serverProblems: - test.warning("Ignoring server side issues") + with TestSection(protocol): + skippedPasting = True + description = "Paste from 2017-05-11" + if protocol == NAME_KDE: + pasteId = "pysjk6n2i" + pastedText = readFile(os.path.join(os.getcwd(), "testdata", "main-prepasted.cpp")) + elif skipPastingToPastebinCom and protocol == NAME_PBCOM: + pasteId = "8XHP0ZgH" + pastedText = readFile(os.path.join(os.getcwd(), "testdata", "main-prepasted.cpp")) + else: + skippedPasting = False + try: + pasteId, description, pastedText = pasteFile(sourceFile, protocol) + except Exception as e: + if e.message == serverProblems: + test.warning("Ignoring server side issues") + continue + else: # if it was not our own exception re-raise + raise e + if not pasteId: + test.fatal("Could not get id of paste to %s" % protocol) continue - else: # if it was not our own exception re-raise - raise e - if not pasteId: - test.fatal("Could not get id of paste to %s" % protocol) + pasteId = fetchSnippet(protocol, description, pasteId, skippedPasting) + if pasteId == -1: continue - pasteId = fetchSnippet(protocol, description, pasteId, skippedPasting) - if pasteId == -1: - continue - filenameCombo = waitForObject(":Qt Creator_FilenameQComboBox") - waitFor("not filenameCombo.currentText.isEmpty()", 20000) - try: - editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") - except: - outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") - test.fail("Could not find editor with snippet", str(outputWindow.plainText)) - clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) - continue - test.compare(filenameCombo.currentText, "%s: %s" % (protocol, pasteId), "Verify title of editor") - if protocol in (NAME_KDE, NAME_PBCOM) and pastedText.endswith("\n"): - pastedText = pastedText[:-1] - test.compare(editor.plainText, pastedText, "Verify that pasted and fetched texts are the same") - invokeMenuItem("File", "Close All") + filenameCombo = waitForObject(":Qt Creator_FilenameQComboBox") + waitFor("not filenameCombo.currentText.isEmpty()", 20000) + try: + editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + except: + outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") + test.fail("Could not find editor with snippet", str(outputWindow.plainText)) + clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) + continue + test.compare(filenameCombo.currentText, "%s: %s" % (protocol, pasteId), "Verify title of editor") + if protocol in (NAME_KDE, NAME_PBCOM) and pastedText.endswith("\n"): + pastedText = pastedText[:-1] + test.compare(editor.plainText, pastedText, "Verify that pasted and fetched texts are the same") + invokeMenuItem("File", "Close All") invokeMenuItem("File", "Open File or Project...") selectFromFileDialog(sourceFile) editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")