From 003821f93620b199aea0f8e8befdb6fdc32fc10a Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 28 Mar 2013 16:58:25 +0100 Subject: [PATCH] Squish: Prepare tst_CCOM01 for Qt5 Change-Id: Ic2806673cb65018000bcbe6ae66dad1b2f555e39 Reviewed-by: Christian Stenger --- tests/system/shared/editor_utils.py | 28 +++++++++++++++++++ tests/system/suite_CCOM/tst_CCOM01/test.py | 5 ++++ .../suite_editors/tst_rename_macros/test.py | 15 ---------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index ff4c8e284fc..8188af8da9e 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -311,3 +311,31 @@ def openDocument(treeElement): return True except: return False + +def earlyExit(details="No additional information"): + test.fail("Something went wrong running this test", details) + invokeMenuItem("File", "Save All") + invokeMenuItem("File", "Exit") + +def openDocumentPlaceCursor(doc, line, additionalFunction=None): + cppEditorStr = ":Qt Creator_CppEditor::Internal::CPPEditorWidget" + if openDocument(doc) and placeCursorToLine(cppEditorStr, line): + if additionalFunction: + additionalFunction() + return str(waitForObject(cppEditorStr).plainText) + else: + earlyExit("Open %s or placing cursor to line (%s) failed." % (doc, line)) + return None + +# Replaces a line in the editor with another +# param fileSpec a string specifying a file in Projects view +# param oldLine a string holding the line to be replaced +# param newLine a string holding the line to be inserted +def replaceLine(fileSpec, oldLine, newLine): + if openDocumentPlaceCursor(fileSpec, oldLine) == None: + return False + editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget") + for i in range(len(oldLine)): + type(editor, "") + type(editor, newLine) + return True diff --git a/tests/system/suite_CCOM/tst_CCOM01/test.py b/tests/system/suite_CCOM/tst_CCOM01/test.py index e8e4f7428d3..28290d7ea77 100755 --- a/tests/system/suite_CCOM/tst_CCOM01/test.py +++ b/tests/system/suite_CCOM/tst_CCOM01/test.py @@ -16,6 +16,11 @@ def main(): return # open example project checkedTargets = openQmakeProject(examplePath) + if not replaceLine("propertyanimation.Sources.main\\.cpp", + "#include ", + "#include "): + return + invokeMenuItem("File", "Save All") # build and wait until finished - on all build configurations availableConfigs = iterateBuildConfigs(len(checkedTargets)) if not availableConfigs: diff --git a/tests/system/suite_editors/tst_rename_macros/test.py b/tests/system/suite_editors/tst_rename_macros/test.py index f739b99aa8d..332189e6ce2 100644 --- a/tests/system/suite_editors/tst_rename_macros/test.py +++ b/tests/system/suite_editors/tst_rename_macros/test.py @@ -90,16 +90,6 @@ def testRenameMacroAfterSourceMoving(): revertChanges(formerTexts) return True -def openDocumentPlaceCursor(doc, line, additionalFunction=None): - global cppEditorStr - if openDocument(doc) and placeCursorToLine(cppEditorStr, line): - if additionalFunction: - additionalFunction() - return str(waitForObject(cppEditorStr).plainText) - else: - earlyExit("Open %s or placing cursor to line (%s) failed." % (simpleFileName(doc), line)) - return None - def performMacroRenaming(newMacroName): for i in range(10): type(cppEditorStr, "") @@ -150,8 +140,3 @@ def revertChanges(files): def simpleFileName(navigatorFileName): return ".".join(navigatorFileName.split(".")[-2:]).replace("\\","") - -def earlyExit(details="No additional information"): - test.fail("Something went wrong running this test", details) - invokeMenuItem("File", "Save All") - invokeMenuItem("File", "Exit")