test.py 3.21 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
16
    createNewQtQuickApplication()
    # wait for parsing to complete
17
    waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000)
18
19
    test.log("Building project")
    invokeMenuItem("Build","Build All")
20
21
22
    waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
    checkCompile()
    checkLastBuild()
23
24
25
26
27
    test.log("Running project (includes build)")
    if runAndCloseApp():
        logApplicationOutput()
    invokeMenuItem("File", "Exit")

28
def prepareTemplate(sourceExample):
29
30
31
32
33
34
35
36
37
38
39
40
    global templateDir
    templateDir = tempDir()
    templateDir = os.path.abspath(templateDir + "/template")
    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)
41
    replaceEditorContent(baseLineEd, workingDir)
42
43
44
45
46
47
48
49
    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...!
50
    nextButton = waitForObject("{text~='(Next.*|Continue)' type='QPushButton' visible='1'}", 20000)
51
52
53
54
55
56
57
58
59
    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)
60
    clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
61
62
63
64

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