test.py 2.76 KB
Newer Older
1
2
3
4
5
6
source("../../shared/qtcreator.py")

workingDir = None
templateDir = None

def main():
7
    global workingDir,templateDir
8
9
10
    sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
    if not neededFilePresent(sourceExample):
        return
11
12
13
    startApplication("qtcreator" + SettingsPath)
    # using a temporary directory won't mess up an eventually exisiting
    workingDir = tempDir()
14
    prepareTemplate(sourceExample)
15
    projectName = createNewQtQuickApplication(workingDir, None, templateDir + "/qml/textselection.qml")
16
    # wait for parsing to complete
Robert Loehning's avatar
Robert Loehning committed
17
    waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)")
18
    test.log("Building project")
19
    result = modifyRunSettingsForHookInto(projectName, 11223)
20
    invokeMenuItem("Build","Build All")
Robert Loehning's avatar
Robert Loehning committed
21
    waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)")
22
23
24
25
26
    if not checkCompile():
        test.fatal("Compile failed")
    else:
        checkLastBuild()
        test.log("Running project (includes build)")
27
28
29
30
        if result:
            result = addExecutableAsAttachableAUT(projectName, 11223)
            allowAppThroughWinFW(workingDir, projectName)
            if result:
31
                result = runAndCloseApp(True, projectName, 11223, subprocessFunction, SubprocessType.QT_QUICK_APPLICATION)
32
            else:
33
                result = runAndCloseApp(sType=SubprocessType.QT_QUICK_APPLICATION)
34
35
36
37
38
            removeExecutableAsAttachableAUT(projectName, 11223)
            deleteAppFromWinFW(workingDir, projectName)
        else:
            result = runAndCloseApp()
        if result:
39
            logApplicationOutput()
40
41
    invokeMenuItem("File", "Exit")

42
43
44
45
46
47
48
49
50
51
52
53
def subprocessFunction():
    textEdit = waitForObject("{container={type='QmlApplicationViewer' unnamed='1' visible='1'} "
                             "enabled='true' type='TextEdit' unnamed='1' visible='true'}")
    test.log("Test dragging")
    dragItemBy(textEdit, 30, 30, 50, 50, 0, Qt.LeftButton)
    test.log("Test editing")
    textEdit.cursorPosition = 0
    type(textEdit, "This text is entered by Squish...")
    type(textEdit, "<Return>")
    test.log("Closing QmlApplicationViewer")
    sendEvent("QCloseEvent", "{type='QmlApplicationViewer' unnamed='1' visible='1'}")

54
def prepareTemplate(sourceExample):
55
56
57
58
59
60
61
62
    global templateDir
    templateDir = tempDir()
    templateDir = os.path.abspath(templateDir + "/template")
    shutil.copytree(sourceExample, templateDir)

def cleanup():
    global workingDir,templateDir
    # waiting for a clean exit - for a full-remove of the temp directory
63
    waitForCleanShutdown()
64
65
66
67
    if workingDir!=None:
        deleteDirIfExists(workingDir)
    if templateDir!=None:
        deleteDirIfExists(os.path.dirname(templateDir))