test.py 3.16 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
11
12
13
    startApplication("qtcreator" + SettingsPath)
    # using a temporary directory won't mess up an eventually exisiting
    workingDir = tempDir()
    prepareTemplate()
    createNewQtQuickApplication()
    # wait for parsing to complete
14
    waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000)
15
16
    test.log("Building project")
    invokeMenuItem("Build","Build All")
17
18
19
    waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
    checkCompile()
    checkLastBuild()
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    test.log("Running project (includes build)")
    if runAndCloseApp():
        logApplicationOutput()
    invokeMenuItem("File", "Exit")

def prepareTemplate():
    global templateDir
    templateDir = tempDir()
    templateDir = os.path.abspath(templateDir + "/template")
    sourceExample = os.path.abspath(SDKPath + "/../Examples/4.7/declarative/text/textselection")
    shutil.copytree(sourceExample, templateDir)

def createNewQtQuickApplication():
    global workingDir,templateDir
    invokeMenuItem("File", "New File or Project...")
    clickItem(waitForObject("{type='QTreeView' name='templateCategoryView'}", 20000), "Projects.Qt Quick Project", 5, 5, 0, Qt.LeftButton)
    clickItem(waitForObject("{name='templatesView' type='QListView'}", 20000), "Qt Quick Application", 5, 5, 0, Qt.LeftButton)
    clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}", 20000))
    baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
    replaceLineEditorContent(baseLineEd, workingDir)
    stateLabel = findObject("{type='QLabel' name='stateLabel'}")
    labelCheck = stateLabel.text=="" and stateLabel.styleSheet == ""
    test.verify(labelCheck, "Project name and base directory without warning or error")
    # make sure this is not set as default location
    cbDefaultLocation = waitForObject("{type='QCheckBox' name='projectsDirectoryCheckBox' visible='1'}", 20000)
    if cbDefaultLocation.checked:
        clickButton(cbDefaultLocation)
    # now there's the 'untitled' project inside a temporary directory - step forward...!
    nextButton = waitForObject("{text='Next' type='QPushButton' visible='1'}", 20000)
    clickButton(nextButton)
    chooseComponents(QtQuickConstants.Components.EXISTING_QML)
    # define the existing qml file to import
    baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
    type(baseLineEd, templateDir+"/qml/textselection.qml")
    clickButton(nextButton)
    chooseDestination()
    snooze(1)
    clickButton(nextButton)
    clickButton(waitForObject("{type='QPushButton' text='Finish' visible='1'}", 20000))

def cleanup():
    global workingDir,templateDir
    # waiting for a clean exit - for a full-remove of the temp directory
    appCtxt = currentApplicationContext()
    waitFor("appCtxt.isRunning==False")
    if workingDir!=None:
        deleteDirIfExists(workingDir)
    if templateDir!=None:
        deleteDirIfExists(os.path.dirname(templateDir))