OSDN Git Service

1e70ab4299adc7c37828248b90b7ccd506bee924
[qt-creator-jp/qt-creator-jp.git] / tests / system / suite_qtquick / tst_qtquick_creation2 / test.py
1 source("../../shared/qtcreator.py")
2
3 workingDir = None
4 templateDir = None
5
6 def main():
7     global workingDir,templateDir
8     sourceExample = os.path.abspath(sdkPath + "/Examples/4.7/declarative/text/textselection")
9     if not neededFilePresent(sourceExample):
10         return
11     startApplication("qtcreator" + SettingsPath)
12     # using a temporary directory won't mess up an eventually exisiting
13     workingDir = tempDir()
14     prepareTemplate(sourceExample)
15     createNewQtQuickApplication()
16     # wait for parsing to complete
17     waitForSignal("{type='CppTools::Internal::CppModelManager' unnamed='1'}", "sourceFilesRefreshed(QStringList)", 30000)
18     test.log("Building project")
19     invokeMenuItem("Build","Build All")
20     waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
21     if not checkCompile():
22         test.fatal("Compile failed")
23     else:
24         checkLastBuild()
25         test.log("Running project (includes build)")
26         if runAndCloseApp():
27             logApplicationOutput()
28     invokeMenuItem("File", "Exit")
29
30 def prepareTemplate(sourceExample):
31     global templateDir
32     templateDir = tempDir()
33     templateDir = os.path.abspath(templateDir + "/template")
34     shutil.copytree(sourceExample, templateDir)
35
36 def createNewQtQuickApplication():
37     global workingDir,templateDir
38     invokeMenuItem("File", "New File or Project...")
39     clickItem(waitForObject("{type='QTreeView' name='templateCategoryView'}", 20000), "Projects.Qt Quick Project", 5, 5, 0, Qt.LeftButton)
40     clickItem(waitForObject("{name='templatesView' type='QListView'}", 20000), "Qt Quick Application", 5, 5, 0, Qt.LeftButton)
41     clickButton(waitForObject("{text='Choose...' type='QPushButton' unnamed='1' visible='1'}", 20000))
42     baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
43     replaceEditorContent(baseLineEd, workingDir)
44     stateLabel = findObject("{type='QLabel' name='stateLabel'}")
45     labelCheck = stateLabel.text=="" and stateLabel.styleSheet == ""
46     test.verify(labelCheck, "Project name and base directory without warning or error")
47     # make sure this is not set as default location
48     cbDefaultLocation = waitForObject("{type='QCheckBox' name='projectsDirectoryCheckBox' visible='1'}", 20000)
49     if cbDefaultLocation.checked:
50         clickButton(cbDefaultLocation)
51     # now there's the 'untitled' project inside a temporary directory - step forward...!
52     nextButton = waitForObject("{text~='(Next.*|Continue)' type='QPushButton' visible='1'}", 20000)
53     clickButton(nextButton)
54     chooseComponents(QtQuickConstants.Components.EXISTING_QML)
55     # define the existing qml file to import
56     baseLineEd = waitForObject("{type='Utils::BaseValidatingLineEdit' unnamed='1' visible='1'}", 20000)
57     type(baseLineEd, templateDir+"/qml/textselection.qml")
58     clickButton(nextButton)
59     chooseDestination()
60     snooze(1)
61     clickButton(nextButton)
62     clickButton(waitForObject("{type='QPushButton' text~='(Finish|Done)' visible='1'}", 20000))
63
64 def cleanup():
65     global workingDir,templateDir
66     # waiting for a clean exit - for a full-remove of the temp directory
67     waitForCleanShutdown()
68     if workingDir!=None:
69         deleteDirIfExists(workingDir)
70     if templateDir!=None:
71         deleteDirIfExists(os.path.dirname(templateDir))