diff --git a/tests/system/objects.map b/tests/system/objects.map index c8df65ecf5a1083aef7ba5eb16446a830a1b4963..028ceba9e144952662d8be6c0a5b77fb70bc5c11 100644 --- a/tests/system/objects.map +++ b/tests/system/objects.map @@ -54,13 +54,17 @@ :Qt Gui Application.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1'} :Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog {type='Qt4ProjectManager::Internal::GuiAppWizardDialog' unnamed='1' visible='1' windowTitle='Qt Gui Application'} :QtSupport__Internal__QtVersionManager.QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' type='QLabel' unnamed='1' visible='1'} +:QtSupport__Internal__QtVersionManager.qmake_QLabel {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qmakePath' type='QLabel' visible='1'} :QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget {container=':qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget' name='qtdirList' type='QTreeWidget' visible='1'} :Symbol Server_Utils::CheckableMessageBox {type='Utils::CheckableMessageBox' unnamed='1' visible='1' windowTitle='Symbol Server'} +:Targets_QTreeView {container=':qt_tabwidget_stackedwidget_QWidget' type='QTreeView' unnamed='1' visible='1'} +:Targets_QtVersion_QComboBox {container=':qt_tabwidget_stackedwidget_QWidget' occurrence='4' type='QComboBox' unnamed='1' visible='1'} :addToVersionControlComboBox_QComboBox {name='addToVersionControlComboBox' type='QComboBox' visible='1'} :formFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Form file:_QLabel' name='formFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'} :frame.templateDescription_QTextBrowser {container=':New.frame_QFrame' name='templateDescription' type='QTextBrowser' visible='1'} :headerFileLineEdit_Utils::FileNameValidatingLineEdit {buddy=':Qt Gui Application.Header file:_QLabel' name='headerFileLineEdit' type='Utils::FileNameValidatingLineEdit' visible='1'} :qt_tabwidget_stackedwidget.QtSupport__Internal__QtVersionManager_QtSupport::Internal::QtOptionsPageWidget {container=':Options.qt_tabwidget_stackedwidget_QStackedWidget' name='QtSupport__Internal__QtVersionManager' type='QtSupport::Internal::QtOptionsPageWidget' visible='1'} +:qt_tabwidget_stackedwidget_QWidget {container=':Options.qt_tabwidget_stackedwidget_QStackedWidget' type='QWidget' unnamed='1' visible='1'} :scrollArea.Create Build Configurations:_QComboBox_2 {container=':Qt Gui Application.scrollArea_QScrollArea' leftWidget=':scrollArea.Create Build Configurations:_QLabel_2' type='QComboBox' unnamed='1' visible='1'} :scrollArea.Create Build Configurations:_QLabel_2 {container=':Qt Gui Application.scrollArea_QScrollArea' text='Create build configurations:' type='QLabel' unnamed='1' visible='1'} :scrollArea.Details_Utils::DetailsButton {text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'} diff --git a/tests/system/shared/hook_utils.py b/tests/system/shared/hook_utils.py index 30a1a87a47fb6e8c78a25816f3d949d9707cd16b..ced6286c62ea15cb8e07e653843e3c295bfe4268 100644 --- a/tests/system/shared/hook_utils.py +++ b/tests/system/shared/hook_utils.py @@ -59,79 +59,80 @@ def modifyRunSettingsForHookIntoQtQuickUI(projectName, port): global workingDir switchViewTo(ViewConstants.PROJECTS) switchToBuildOrRunSettingsFor(1, 0, ProjectSettings.RUN, True) - qtVersionCombo = waitForObject("{leftWidget={type='QLabel' text='Qt version:' unnamed='1' visible='1'} " - "type='QComboBox' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}", 5000) - currentQtVersion = qtVersionCombo.currentText - qmake = getQMakeFromQtVersion(currentQtVersion) - if qmake != None: - mkspec = __getMkspecFromQmake__(qmake) - if mkspec != None: - qtVer = getOutputFromCmdline("%s -query QT_VERSION" % qmake).strip() - squishPath = getSquishPath(mkspec, qtVer) - if squishPath == None: - test.warning("Could not determine the Squish path for %s/%s" % (qtVer, mkspec), - "Using fallback of pushing STOP inside Creator.") - return None - test.log("Using (QtVersion/mkspec) %s/%s with SquishPath %s" % (qtVer, mkspec, squishPath)) - if platform.system() == "Darwin": - qmlViewer = os.path.abspath(os.path.dirname(qmake) + "/QMLViewer.app") - else: - qmlViewer = os.path.abspath(os.path.dirname(qmake) + "/qmlviewer") - if platform.system() in ('Microsoft', 'Windows'): - qmlViewer = qmlViewer + ".exe" - addRunConfig = waitForObject("{type='QPushButton' text='Add' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow' occurrence='2'}") - clickButton(addRunConfig) - activateItem(waitForObject("{type='QMenu' visible='1' unnamed='1'}"), "Custom Executable") - exePathChooser = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' text='Command:' " - "type='QLabel' unnamed='1' visible='1'} type='Utils::PathChooser' " - "unnamed='1' visible='1'}") - exeLineEd = getChildByClass(exePathChooser, "Utils::BaseValidatingLineEdit") - argLineEd = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' type='QLabel' " - "text='Arguments:' visible='1'} type='QLineEdit' unnamed='1' visible='1'}") - wdPathChooser = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' text='Working directory:' " - "type='QLabel'} type='Utils::PathChooser' unnamed='1' visible='1'}") - wdLineEd = getChildByClass(wdPathChooser, "Utils::BaseValidatingLineEdit") - startAUT = os.path.abspath(squishPath + "/bin/startaut") - if platform.system() in ('Microsoft', 'Windows'): - startAUT = startAUT + ".exe" - projectPath = os.path.abspath("%s/%s" % (workingDir, projectName)) - replaceEditorContent(exeLineEd, startAUT) - replaceEditorContent(argLineEd, "--verbose --port=%d %s %s.qml" % (port, qmlViewer, projectName)) - replaceEditorContent(wdLineEd, projectPath) - clickButton(waitForObject("{text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow' " - "leftWidget={type='QLabel' text~='Us(e|ing) <b>Build Environment</b>' unnamed='1' visible='1'}}")) - qtLibPath = os.path.abspath(os.path.dirname(qmake)) - if not platform.system() in ('Microsoft', 'Windows'): - qtLibPath = os.path.abspath(qtLibPath+"/../lib") - row = 0 - for varName in ("PATH", "SQUISH_LIBQTDIR"): - __addVariableToRunEnvironment__(varName, qtLibPath, row) - row = row + 1 - if not platform.system() in ('Microsoft', 'Windows', 'Darwin'): - __addVariableToRunEnvironment__("LD_LIBRARY_PATH", qtLibPath, 0) - if platform.system() == "Darwin": - __addVariableToRunEnvironment__("DYLD_FRAMEWORK_PATH", qtLibPath, 0) - if not platform.system() in ('Microsoft', 'Windows'): - __addVariableToRunEnvironment__("DISPLAY", ":0.0", 0) - result = qmlViewer - else: - result = None + + qtVersion, mkspec, qtLibPath, qmake = getQtInformationForQmlProject() + if None in (qtVersion, mkspec, qtLibPath, qmake): + test.fatal("At least one of the Qt information returned None - leaving...", + "Qt version: %s, mkspec: %s, Qt LibPath: %s, qmake: '%s'" + % (qtVersion, mkspec, qtLibPath, qmake)) + return None + + squishPath = getSquishPath(mkspec, qtVersion) + if squishPath == None: + test.warning("Could not determine the Squish path for %s/%s" % (qtVersion, mkspec), + "Using fallback of pushing STOP inside Creator.") + return None + test.log("Using (QtVersion/mkspec) %s/%s with SquishPath %s" % (qtVersion, mkspec, squishPath)) + if platform.system() == "Darwin": + qmlViewer = os.path.abspath(os.path.dirname(qmake) + "/QMLViewer.app") else: - result = None + qmlViewer = os.path.abspath(os.path.dirname(qmake) + "/qmlviewer") + if platform.system() in ('Microsoft', 'Windows'): + qmlViewer = qmlViewer + ".exe" + addRunConfig = waitForObject("{container={window=':Qt Creator_Core::Internal::MainWindow' " + "type='ProjectExplorer::Internal::RunSettingsWidget' unnamed='1' " + "visible='1'} occurrence='2' text='Add' type='QPushButton' " + "unnamed='1' visible='1'}") + clickButton(addRunConfig) + activateItem(waitForObject("{type='QMenu' visible='1' unnamed='1'}"), "Custom Executable") + exePathChooser = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' " + "text='Command:' type='QLabel' unnamed='1' visible='1'} " + "type='Utils::PathChooser' unnamed='1' visible='1'}") + exeLineEd = getChildByClass(exePathChooser, "Utils::BaseValidatingLineEdit") + argLineEd = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' " + "type='QLabel' text='Arguments:' visible='1'} type='QLineEdit' " + "unnamed='1' visible='1'}") + wdPathChooser = waitForObject("{buddy={window=':Qt Creator_Core::Internal::MainWindow' " + "text='Working directory:' type='QLabel'} " + "type='Utils::PathChooser' unnamed='1' visible='1'}") + wdLineEd = getChildByClass(wdPathChooser, "Utils::BaseValidatingLineEdit") + startAUT = os.path.abspath(squishPath + "/bin/startaut") + if platform.system() in ('Microsoft', 'Windows'): + startAUT = startAUT + ".exe" + projectPath = os.path.abspath("%s/%s" % (workingDir, projectName)) + replaceEditorContent(exeLineEd, startAUT) + replaceEditorContent(argLineEd, "--verbose --port=%d %s %s.qml" + % (port, qmlViewer, projectName)) + replaceEditorContent(wdLineEd, projectPath) + clickButton(waitForObject("{text='Details' type='Utils::DetailsButton' unnamed='1' visible='1' " + "window=':Qt Creator_Core::Internal::MainWindow' " + "leftWidget={type='QLabel' text~='Us(e|ing) <b>Build Environment</b>'" + " unnamed='1' visible='1'}}")) + row = 0 + for varName in ("PATH", "SQUISH_LIBQTDIR"): + __addVariableToRunEnvironment__(varName, qtLibPath, row) + row = row + 1 + if not platform.system() in ('Microsoft', 'Windows', 'Darwin'): + __addVariableToRunEnvironment__("LD_LIBRARY_PATH", qtLibPath, 0) + if platform.system() == "Darwin": + __addVariableToRunEnvironment__("DYLD_FRAMEWORK_PATH", qtLibPath, 0) + if not platform.system() in ('Microsoft', 'Windows'): + __addVariableToRunEnvironment__("DISPLAY", ":0.0", 0) + result = qmlViewer switchViewTo(ViewConstants.EDIT) return result # this helper method must be called on the run settings page of a Qt Quick UI with DetailsWidget # for the run settings already opened - it won't work on other views because of a different layout def __addVariableToRunEnvironment__(name, value, row): - clickButton(waitForObject("{occurrence='3' text='Add' type='QPushButton' unnamed='1' visible='1' " - "window=':Qt Creator_Core::Internal::MainWindow'}")) + clickButton(waitForObject("{text='Add' type='QPushButton' unnamed='1' visible='1' " + "container={window=':Qt Creator_Core::Internal::MainWindow' " + "type='Utils::DetailsWidget' unnamed='1' visible='1' occurrence='2'}}")) varNameLineEd = waitForObject("{type='QExpandingLineEdit' visible='1' unnamed='1'}") replaceEditorContent(varNameLineEd, name) valueLineEd = __doubleClickQTableView__(":Qt Creator_QTableView", row, 1) replaceEditorContent(valueLineEd, value) + type(valueLineEd, "<Return>") def __getMkspecFromQMakeConf__(qmakeConf): if qmakeConf==None or not os.path.exists(qmakeConf): diff --git a/tests/system/shared/project_explorer.py b/tests/system/shared/project_explorer.py index 43d5530c9daf6bb5686a949087dfd0517bca3c04..aa33d160d12067ccf2bc16ea6b85fff0b46d5377 100644 --- a/tests/system/shared/project_explorer.py +++ b/tests/system/shared/project_explorer.py @@ -144,6 +144,75 @@ def getQtInformationForBuildSettings(alreadyOnProjectsBuildSettings=False, after test.warning("Don't know where you trying to switch to (%s)" % afterSwitchTo) return qtVersion, mkspec, qtBinPath, qtLibPath +def getQtInformationForQmlProject(): + fancyToolButton = waitForObject(":*Qt Creator_Core::Internal::FancyToolButton") + target = __getTargetFromToolTip__(str(fancyToolButton.toolTip)) + if not target: + test.fatal("Could not figure out which target you're using...") + return None, None, None, None + test.log("Searching for Qt information for target '%s'" % target) + invokeMenuItem("Tools", "Options...") + waitForObjectItem(":Options_QListView", "Build & Run") + clickItem(":Options_QListView", "Build & Run", 14, 15, 0, Qt.LeftButton) + clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Targets") + targetsTreeView = waitForObject(":Targets_QTreeView") + if not __selectTreeItemOnBuildAndRun__(targetsTreeView, "%s(\s\(default\))?" % target, True): + test.fatal("Found no matching target - this shouldn't happen.") + clickButton(waitForObject(":Options.Cancel_QPushButton")) + return None, None, None, None + qtVersionStr = str(waitForObject(":Targets_QtVersion_QComboBox").currentText) + test.log("Target '%s' uses Qt Version '%s'" % (target, qtVersionStr)) + clickTab(waitForObject(":Options.qt_tabwidget_tabbar_QTabBar"), "Qt Versions") + treeWidget = waitForObject(":QtSupport__Internal__QtVersionManager.qtdirList_QTreeWidget") + if not __selectTreeItemOnBuildAndRun__(treeWidget, qtVersionStr): + test.fatal("Found no matching Qt Version for target - this shouldn't happen.") + clickButton(waitForObject(":Options.Cancel_QPushButton")) + return None, None, None, None + qmake = str(waitForObject(":QtSupport__Internal__QtVersionManager.qmake_QLabel").text) + test.log("Qt Version '%s' uses qmake at '%s'" % (qtVersionStr, qmake)) + qtDir = os.path.dirname(os.path.dirname(qmake)) + qtVersion = getQtInformationByQMakeCall(qtDir, QtInformation.QT_VERSION) + qtLibPath = getQtInformationByQMakeCall(qtDir, QtInformation.QT_LIBPATH) + mkspec = __getMkspecFromQmake__(qmake) + clickButton(waitForObject(":Options.Cancel_QPushButton")) + return qtVersion, mkspec, qtLibPath, qmake + +def __selectTreeItemOnBuildAndRun__(treeViewOrWidget, itemText, isRegex=False): + model = treeViewOrWidget.model() + test.compare(model.rowCount(), 2, "Verifying expected target section count") + autoDetected = model.index(0, 0) + test.compare(autoDetected.data().toString(), "Auto-detected", + "Verifying label for target section") + manual = model.index(1, 0) + test.compare(manual.data().toString(), "Manual", "Verifying label for target section") + if isRegex: + pattern = re.compile(itemText) + found = False + for section in [autoDetected, manual]: + for index in [section.child(i, 0) for i in range(model.rowCount(section))]: + if (isRegex and pattern.match(str(index.data().toString())) + or itemText == (str(index.data().toString()))): + found = True + item = ".".join([str(section.data().toString()), + str(index.data().toString()).replace(".", "\\.")]) + clickItem(treeViewOrWidget, item, 5, 5, 0, Qt.LeftButton) + break + if found: + break + return found + +def __getTargetFromToolTip__(toolTip): + if toolTip == None or not isinstance(toolTip, (str, unicode)): + test.warning("Parameter toolTip must be of type str or unicode and can't be None!") + return None + pattern = re.compile(".*<b>Target:</b>(.*)<b>Deploy.*") + target = pattern.match(toolTip) + if target == None: + test.fatal("UI seems to have changed - expected ToolTip does not match.", + "ToolTip: '%s'" % toolTip) + return None + return target.group(1).split("<br/>")[0].strip() + def __getMkspecFromQMakeCall__(qmakeCall): qCall = qmakeCall.split("</b>")[1].strip() tmp = qCall.split()