Commit 86ba284d authored by Christian Stenger's avatar Christian Stenger
Browse files

Squish: Improved and refactored hook into



Change-Id: I05f17bbe49db7064cd6bf5131363ca0708aad087
Reviewed-by: default avatarBill King <bill.king@nokia.com>
Reviewed-by: default avatarRobert Löhning <robert.loehning@nokia.com>
parent 37bcdcf4
......@@ -15,6 +15,8 @@
:New.templatesView_QListView {name='templatesView' type='QListView' visible='1' window=':New_Core::Internal::NewDialog'}
:New_Core::Internal::NewDialog {name='Core__Internal__NewDialog' type='Core::Internal::NewDialog' visible='1' windowTitle='New'}
:Next_QPushButton {text~='(Next.*|Continue)' type='QPushButton' visible='1'}
:Options.qt_tabwidget_tabbar_QTabBar {name='qt_tabwidget_tabbar' type='QTabBar' visible='1' window=':Options_Core::Internal::SettingsDialog'}
:Options_Core::Internal::SettingsDialog {type='Core::Internal::SettingsDialog' unnamed='1' visible='1' windowTitle~='(Options|Preference)'}
:Project Setup.scrollArea_QScrollArea {name='scrollArea' type='QScrollArea' visible='1' window=':Project Setup_Qt4ProjectManager::Internal::ProjectLoadWizard'}
:Project Setup_Qt4ProjectManager::Internal::ProjectLoadWizard {type='Qt4ProjectManager::Internal::ProjectLoadWizard' unnamed='1' visible='1' windowTitle='Project Setup'}
:Qt Creator.QtCreator.MenuBar_QMenuBar {name='QtCreator.MenuBar' type='QMenuBar' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
......@@ -24,6 +26,7 @@
:Qt Creator_Core::Internal::MainWindow {type='Core::Internal::MainWindow' visible='1' windowTitle?='*Qt Creator'}
:Qt Creator_Core::Internal::OutputPaneToggleButton {occurrence='3' type='Core::Internal::OutputPaneToggleButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_CppEditor::Internal::CPPEditorWidget {type='CppEditor::Internal::CPPEditorWidget' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_QTableView {type='QTableView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::IconButton {occurrence='2' type='Utils::IconButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Creator_Utils::NavigationTreeView {type='Utils::NavigationTreeView' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
:Qt Gui Application.Form file:_QLabel {name='formLabel' text='Form file:' type='QLabel' visible='1' window=':Qt Gui Application_Qt4ProjectManager::Internal::GuiAppWizardDialog'}
......
# for easier re-usage (because Python hasn't an enum type)
class QtQuickConstants:
class Components:
BUILTIN = 1
SYMBIAN = 2
MEEGO_HARMATTAN = 4
EXISTING_QML = 8
class Targets:
DESKTOP = 1
SIMULATOR = 2
SYMBIAN = 4
MAEMO5 = 8
HARMATTAN = 16
@staticmethod
def getStringForComponents(components):
if components==QtQuickConstants.Components.BUILTIN:
return "Built-in elements only (for all platforms)"
elif components==QtQuickConstants.Components.SYMBIAN:
return "Qt Quick Components for Symbian"
elif components==QtQuickConstants.Components.MEEGO_HARMATTAN:
return "Qt Quick Components for Meego/Harmattan"
elif components==QtQuickConstants.Components.EXISTING_QML:
return "Use an existing .qml file"
else:
return None
@staticmethod
def getStringForTarget(target):
if target==QtQuickConstants.Targets.DESKTOP:
return "Desktop"
elif target==QtQuickConstants.Targets.SYMBIAN:
return "Symbian Device"
elif target==QtQuickConstants.Targets.MAEMO5:
return "Maemo5"
elif target==QtQuickConstants.Targets.SIMULATOR:
return "Qt Simulator"
elif target==QtQuickConstants.Targets.HARMATTAN:
return "Harmattan"
else:
return None
# this class holds some constants for easier usage inside the Projects view
class ProjectSettings:
BUILD = 1
RUN = 2
# this class defines some constants for the views of the creator's MainWindow
class ViewConstants:
WELCOME = 0
EDIT = 1
DESIGN = 2
DEBUG = 3
PROJECTS = 4
ANALYZE = 5
HELP = 6
# always adjust the following to the highest value of the available ViewConstants when adding new
LAST_AVAILABLE = HELP
# this function returns a regex of the tooltip of the FancyTabBar elements
# this is needed because the keyboard shortcut is OS specific
# if the provided argument does not match any of the ViewConstants it returns None
@staticmethod
def getToolTipForViewTab(viewTab):
if viewTab == ViewConstants.WELCOME:
return ur'Switch to <b>Welcome</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)1</span>'
elif viewTab == ViewConstants.EDIT:
return ur'Switch to <b>Edit</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)2</span>'
elif viewTab == ViewConstants.DESIGN:
return ur'Switch to <b>Design</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)3</span>'
elif viewTab == ViewConstants.DEBUG:
return ur'Switch to <b>Debug</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)4</span>'
elif viewTab == ViewConstants.PROJECTS:
return ur'Switch to <b>Projects</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)5</span>'
elif viewTab == ViewConstants.ANALYZE:
return ur'Switch to <b>Analyze</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)6</span>'
elif viewTab == ViewConstants.HELP:
return ur'Switch to <b>Help</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)7</span>'
else:
return None
class SubprocessType:
QT_WIDGET=0
QT_QUICK_APPLICATION=1
QT_QUICK_UI=2
USER_DEFINED=3
@staticmethod
def getWindowType(subprocessType):
if subprocessType == SubprocessType.QT_WIDGET:
return "QMainWindow"
if subprocessType == SubprocessType.QT_QUICK_APPLICATION:
return "QmlApplicationViewer"
if subprocessType == SubprocessType.QT_QUICK_UI:
return "QDeclarativeViewer"
if subprocessType == SubprocessType.USER_DEFINED:
return "user-defined"
test.fatal("Could not determine the WindowType for SubprocessType %s" % subprocessType)
return None
......@@ -29,12 +29,12 @@ def modifyRunSettingsForHookInto(projectName, port):
varName = str(model.data(index).toString())
# if its a special SQUISH var simply unset it
if varName == "PATH":
currentItem = __doubleClickQTableView__(row, 1)
currentItem = __doubleClickQTableView__(":scrollArea_QTableView", row, 1)
test.log("replacing PATH with '%s'" % qmakeBinPath)
replaceEditorContent(currentItem, qmakeBinPath)
elif varName.find("SQUISH") == 0:
if varName == "SQUISH_LIBQTDIR":
currentItem = __doubleClickQTableView__(row, 1)
currentItem = __doubleClickQTableView__(":scrollArea_QTableView", row, 1)
if platform.system() in ('Microsoft', 'Windows'):
replacement = qmakeBinPath
else:
......@@ -50,11 +50,142 @@ def modifyRunSettingsForHookInto(projectName, port):
switchViewTo(ViewConstants.EDIT)
return result
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 = getOutputFromCmdline("%s -query QMAKE_MKSPECS" % qmake).strip()
mkspec = mkspec + os.sep + "default" + os.sep + "qmake.conf"
mkspec = __getMkspecFromQMakeConf__(mkspec)
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='Executable:' "
"type='QLabel'} 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 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
else:
result = None
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'}"))
varNameLineEd = waitForObject("{type='QExpandingLineEdit' visible='1' unnamed='1'}")
replaceEditorContent(varNameLineEd, name)
valueLineEd = __doubleClickQTableView__(":Qt Creator_QTableView", row, 1)
replaceEditorContent(valueLineEd, value)
def __getMkspecFromQMakeConf__(qmakeConf):
if qmakeConf==None or not os.path.exists(qmakeConf):
test.warning("Missing qmake.conf file - got '%s'" % qmakeConf)
return None
if not platform.system() in ('Microsoft', 'Windows'):
return os.path.basename(os.path.realpath(os.path.dirname(qmakeConf)))
mkspec = None
file = codecs.open(qmakeConf, "r", "utf-8")
for line in file:
if "QMAKESPEC_ORIGINAL" in line:
mkspec = line.split("=")[1]
break
file.close()
if mkspec == None:
test.warning("Could not determine mkspec from '%s'" % qmakeConf)
return None
return os.path.basename(mkspec)
def getQMakeFromQtVersion(qtVersion):
invokeMenuItem("Tools", "Options...")
buildAndRun = waitForObject("{type='QModelIndex' text='Build & Run' "
"container={type='QListView' unnamed='1' visible='1' "
"window=':Options_Core::Internal::SettingsDialog'}}")
mouseClick(buildAndRun, 5, 5, 0, Qt.LeftButton)
qtVersionTab = waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' text='Qt Versions' type='TabItem'}")
mouseClick(qtVersionTab, 5, 5, 0, Qt.LeftButton)
qtVersionsTree = waitForObject("{name='qtdirList' type='QTreeWidget' visible='1'}")
rootIndex = qtVersionsTree.invisibleRootItem()
rows = rootIndex.childCount()
for currentRow in range(rows):
current = rootIndex.child(currentRow)
child = getTreeWidgetChildByText(current, qtVersion)
if child != None:
break
if child != None:
qmake = "%s" % child.text(1)
if not os.path.exists(qmake):
test.warning("Qt version ('%s') found inside SettingsDialog does not exist." % qtVersion)
qmake = None
else:
test.warning("Could not find the Qt version ('%s') inside SettingsDialog." % qtVersion)
qmake = None
clickButton(waitForObject("{text='Cancel' type='QPushButton' unnamed='1' visible='1' "
"window=':Options_Core::Internal::SettingsDialog'}"))
return qmake
def getTreeWidgetChildByText(parent, text, column=0):
childCount = parent.childCount()
for row in range(childCount):
child = parent.child(row)
if child.text(column)==text:
return child
return None
# helper that double clicks the table view at specified row and column
# returns the QExpandingLineEdit (the editable table cell)
def __doubleClickQTableView__(row, column):
doubleClick(waitForObject("{container=':scrollArea_QTableView' "
"type='QModelIndex' row='%d' column='%d'}" % (row, column)), 5, 5, 0, Qt.LeftButton)
def __doubleClickQTableView__(qtableView, row, column):
doubleClick(waitForObject("{container='%s' "
"type='QModelIndex' row='%d' column='%d'}" % (qtableView, row, column)), 5, 5, 0, Qt.LeftButton)
return waitForObject("{type='QExpandingLineEdit' visible='1' unnamed='1'}")
# this function configures the custom executable onto the run settings page (using startaut from Squish)
......@@ -177,7 +308,7 @@ def allowAppThroughWinFW(workingDir, projectName, isReleaseBuild=True):
if not __isWinFirewallRunning__():
return
# WinFirewall seems to run - hopefully no other
result = __configureFW__(projectName, isReleaseBuild)
result = __configureFW__(workingDir, projectName, isReleaseBuild)
if result == 0:
test.log("Added %s to firewall" % projectName)
else:
......@@ -191,7 +322,7 @@ def deleteAppFromWinFW(workingDir, projectName, isReleaseBuild=True):
if not __isWinFirewallRunning__():
return
# WinFirewall seems to run - hopefully no other
result = __configureFW__(projectName, isReleaseBuild, False)
result = __configureFW__(workingDir, projectName, isReleaseBuild, False)
if result == 0:
test.log("Deleted %s from firewall" % projectName)
else:
......@@ -199,8 +330,12 @@ def deleteAppFromWinFW(workingDir, projectName, isReleaseBuild=True):
# helper that can modify the win firewall to allow a program to communicate through it or delete it
# param addToFW defines whether to add (True) or delete (False) this programm to/from the firewall
def __configureFW__(projectName, isReleaseBuild, addToFW=True):
if isReleaseBuild:
def __configureFW__(workingDir, projectName, isReleaseBuild, addToFW=True):
if isReleaseBuild == None:
if projectName[-4:] == ".exe":
projectName = projectName[:-4]
path = "%s%s%s" % (workingDir, os.sep, projectName)
elif isReleaseBuild:
path = "%s%s%s%srelease%s%s" % (workingDir, os.sep, projectName, os.sep, os.sep, projectName)
else:
path = "%s%s%s%sdebug%s%s" % (workingDir, os.sep, projectName, os.sep, os.sep, projectName)
......
processStarted = False
processExited = False
def __handleProcessStarted__(object):
global processStarted
processStarted = True
def __handleProcessExited__(object, exitCode):
global processExited
processExited = True
def openQmakeProject(projectPath):
invokeMenuItem("File", "Open File or Project...")
if platform.system()=="Darwin":
......@@ -162,8 +173,9 @@ def createNewQtQuickUI(workingDir):
__createProjectSelectType__("Qt Quick Project", "Qt Quick UI")
if workingDir == None:
workingDir = tempDir()
__createProjectSetNameAndPath__(workingDir)
projectName = __createProjectSetNameAndPath__(workingDir)
__createProjectHandleLastPage__()
return projectName
def createNewQmlExtension(workingDir):
__createProjectSelectType__("Qt Quick Project", "Custom QML Extension Plugin")
......@@ -181,3 +193,150 @@ def createNewQmlExtension(workingDir):
replaceEditorContent(uriLineEd, "com.nokia.test.qmlcomponents")
clickButton(nextButton)
__createProjectHandleLastPage__()
# parameter components can only be one of the Constants defined in QtQuickConstants.Components
def __chooseComponents__(components=QtQuickConstants.Components.BUILTIN):
rbComponentToChoose = waitForObject("{type='QRadioButton' text='%s' visible='1'}"
% QtQuickConstants.getStringForComponents(components), 20000)
if rbComponentToChoose.checked:
test.passes("Selected QRadioButton is '%s'" % QtQuickConstants.getStringForComponents(components))
else:
clickButton(rbComponentToChoose)
test.verify(rbComponentToChoose.checked, "Selected QRadioButton is '%s'"
% QtQuickConstants.getStringForComponents(components))
# parameter target can be an OR'd value of QtQuickConstants.Targets
def __chooseTargets__(targets=QtQuickConstants.Targets.DESKTOP):
# DESKTOP should be always accessible
ensureChecked("{type='QCheckBox' text='%s' visible='1'}"
% QtQuickConstants.getStringForTarget(QtQuickConstants.Targets.DESKTOP),
targets & QtQuickConstants.Targets.DESKTOP)
# following targets depend on the build environment - added for further/later tests
available = [QtQuickConstants.Targets.MAEMO5,
QtQuickConstants.Targets.SIMULATOR, QtQuickConstants.Targets.HARMATTAN]
if platform.system() in ('Windows', 'Microsoft'):
available += [QtQuickConstants.Targets.SYMBIAN]
for current in available:
mustCheck = targets & current == current
try:
ensureChecked("{type='QCheckBox' text='%s' visible='1'}" % QtQuickConstants.getStringForTarget(current),
mustCheck)
except LookupError:
if mustCheck:
test.fail("Failed to check target '%s'" % QtQuickConstants.getStringForTarget(current))
# run and close an application
# withHookInto - if set to True the function tries to attach to the sub-process instead of simply pressing Stop inside Creator
# executable - must be defined when using hook-into
# port - must be defined when using hook-into
# function - can be a string holding a function name or a reference to the function itself - this function will be called on
# the sub-process when hooking-into has been successful - if its missing simply closing the Qt Quick app will be done
# sType the SubprocessType - is nearly mandatory - except when using the function parameter
# userDefinedType - if you set sType to SubprocessType.USER_DEFINED you must(!) specify the WindowType for hooking into
# by yourself (or use the function parameter)
# ATTENTION! Make sure this function won't fail and the sub-process will end when the function returns
def runAndCloseApp(withHookInto=False, executable=None, port=None, function=None, sType=None, userDefinedType=None):
global processStarted, processExited
processStarted = processExited = False
installLazySignalHandler("{type='ProjectExplorer::ApplicationLaucher'}", "processStarted()", "__handleProcessStarted__")
installLazySignalHandler("{type='ProjectExplorer::ApplicationLaucher'}", "processExited(int)", "__handleProcessExited__")
runButton = waitForObject("{type='Core::Internal::FancyToolButton' text='Run' visible='1'}", 20000)
clickButton(runButton)
if sType != SubprocessType.QT_QUICK_UI:
waitForSignal("{type='ProjectExplorer::BuildManager' unnamed='1'}", "buildQueueFinished(bool)", 300000)
buildSucceeded = checkLastBuild()
if not buildSucceeded:
test.fatal("Build inside run wasn't successful - leaving test")
invokeMenuItem("File", "Exit")
return False
waitFor("processStarted==True", 10000)
if not processStarted:
test.fatal("Couldn't start application - leaving test")
invokeMenuItem("File", "Exit")
return False
if withHookInto and not validType(sType, userDefinedType):
if function != None:
test.warning("You did not provide a valid value for the SubprocessType value - sType, but you have "
"provided a function to execute on the subprocess. Please ensure that your function "
"closes the subprocess before exiting, or this test will not complete.")
else:
test.warning("You did not provide a valid value for the SubprocessType value - sType, nor a "
"function to execute on the subprocess. Falling back to pushing the STOP button "
"inside creator to terminate execution of the subprocess.")
withHookInto = False
if withHookInto and not executable in ("", None):
__closeSubprocessByHookingInto__(executable, port, function, sType, userDefinedType)
else:
__closeSubprocessByPushingStop__(sType)
return True
def validType(sType, userDef):
if sType == None:
return False
ty = SubprocessType.getWindowType(sType)
return ty != None and not (ty == "user-defined" and (userDef == None or userDef.strip() == ""))
def __closeSubprocessByPushingStop__(sType):
ensureChecked(":Qt Creator_Core::Internal::OutputPaneToggleButton")
playButton = verifyEnabled(":Qt Creator.ReRun_QToolButton", False)
stopButton = verifyEnabled(":Qt Creator.Stop_QToolButton")
if stopButton.enabled:
clickButton(stopButton)
test.verify(playButton.enabled)
test.compare(stopButton.enabled, False)
if sType == SubprocessType.QT_QUICK_UI and platform.system() == "Darwin":
waitFor("stop.enabled==False")
snooze(2)
nativeType("<Escape>")
else:
test.fatal("Subprocess does not seem to have been started.")
def __closeSubprocessByHookingInto__(executable, port, function, sType, userDefType):
global processExited
ensureChecked(":Qt Creator_Core::Internal::OutputPaneToggleButton")
output = waitForObject("{type='Core::OutputWindow' visible='1' windowTitle='Application Output Window'}", 20000)
if port == None:
test.warning("I need a port number or attaching might fail.")
else:
waitFor("'Listening on port %d for incoming connectionsdone' in str(output.plainText)" % port, 5000)
try:
attachToApplication(executable)
except:
test.fatal("Could not attach to '%s' - using fallback of pushing STOP inside Creator." % executable)
resetApplicationContextToCreator()
__closeSubprocessByPushingStop__(sType)
return False
if function == None:
if sType==SubprocessType.USER_DEFINED:
sendEvent("QCloseEvent", "{type='%s' unnamed='1' visible='1'}" % userDefType)
else:
sendEvent("QCloseEvent", "{type='%s' unnamed='1' visible='1'}" % SubprocessType.getWindowType(sType))
resetApplicationContextToCreator()
else:
try:
if isinstance(function, (str, unicode)):
globals()[function]()
else:
function()
except:
test.fatal("Function to execute on sub-process could not be found.",
"Using fallback of pushing STOP inside Creator.")
resetApplicationContextToCreator()
__closeSubprocessByPushingStop__(sType)
waitFor("processExited==True", 10000)
if not processExited:
test.warning("Sub-process seems not to have closed properly.")
try:
resetApplicationContextToCreator()
__closeSubprocessByPushingStop__(sType)
except:
pass
return True
# this helper tries to reset the current application context back
# to creator - this strange work-around is needed _sometimes_ on MacOS
def resetApplicationContextToCreator():
appCtxt = applicationContext("qtcreator")
if appCtxt.name == "":
appCtxt = applicationContext("Qt Creator")
setApplicationContext(appCtxt)
import re;
# this class holds some constants for easier usage inside the Projects view
class ProjectSettings:
BUILD = 1
RUN = 2
# this class defines some constants for the views of the creator's MainWindow
class ViewConstants:
WELCOME = 0
EDIT = 1
DESIGN = 2
DEBUG = 3
PROJECTS = 4
ANALYZE = 5
HELP = 6
# always adjust the following to the highest value of the available ViewConstants when adding new
LAST_AVAILABLE = HELP
# this function returns a regex of the tooltip of the FancyTabBar elements
# this is needed because the keyboard shortcut is OS specific
# if the provided argument does not match any of the ViewConstants it returns None
@staticmethod
def getToolTipForViewTab(viewTab):
if viewTab == ViewConstants.WELCOME:
return ur'Switch to <b>Welcome</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)1</span>'
elif viewTab == ViewConstants.EDIT:
return ur'Switch to <b>Edit</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)2</span>'
elif viewTab == ViewConstants.DESIGN:
return ur'Switch to <b>Design</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)3</span>'
elif viewTab == ViewConstants.DEBUG:
return ur'Switch to <b>Debug</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)4</span>'
elif viewTab == ViewConstants.PROJECTS:
return ur'Switch to <b>Projects</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)5</span>'
elif viewTab == ViewConstants.ANALYZE:
return ur'Switch to <b>Analyze</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)6</span>'
elif viewTab == ViewConstants.HELP:
return ur'Switch to <b>Help</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)7</span>'
else:
return None
# this function switches the MainWindow of creator to the specified view
def switchViewTo(view):
if view < ViewConstants.WELCOME or view > ViewConstants.LAST_AVAILABLE:
......@@ -106,11 +67,14 @@ def prepareBuildSettings(targetCount, currentTarget, setReleaseBuild=True, disab
# param currentTarget specifies the target for which to switch into the specified settings (zero based index)
# param targetCount specifies the number of targets currently defined (must be correct!)
# param projectSettings specifies where to switch to (must be one of ProjectSettings.BUILD or ProjectSettings.RUN)
def switchToBuildOrRunSettingsFor(targetCount, currentTarget, projectSettings):
def switchToBuildOrRunSettingsFor(targetCount, currentTarget, projectSettings, isQtQuickUI=False):
try:
targetSel = waitForObject("{type='ProjectExplorer::Internal::TargetSelector' unnamed='1' "
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}")
except LookupError:
# if it's a QtQuick UI - this depends on the creator version - so better not fatal
if isQtQuickUI:
return True
test.fatal("Wrong (time of) call - must be already at Projects view")
return False
ADD_BUTTON_WIDTH = 27 # bad... (taken from source)
......
......@@ -13,9 +13,9 @@ SettingsPath = ''
tmpSettingsDir = ''
testSettings.logScreenshotOnFail = True
source("../../shared/classes.py")
source("../../shared/utils.py")
source("../../shared/build_utils.py")
source("../../shared/qtquick.py")
source("../../shared/project.py")
source("../../shared/editor_utils.py")
source("../../shared/project_explorer.py")
......
processStarted = False
processExited = False
# for easier re-usage (because Python hasn't an enum type)
class QtQuickConstants:
class Components:
BUILTIN = 1
SYMBIAN = 2
MEEGO_HARMATTAN = 4
EXISTING_QML = 8
class Targets:
DESKTOP = 1
SIMULATOR = 2
SYMBIAN = 4
MAEMO5 = 8
HARMATTAN = 16
@staticmethod
def getStringForComponents(components):
if components==QtQuickConstants.Components.BUILTIN:
return "Built-in elements only (for all platforms)"
elif components==QtQuickConstants.Components.SYMBIAN:
return "Qt Quick Components for Symbian"
elif components==QtQuickConstants.Components.MEEGO_HARMATTAN:
return "Qt Quick Components for Meego/Harmattan"
elif components==QtQuickConstants.Components.EXISTING_QML:
return "Use an existing .qml file"
else:
return None
@staticmethod
def getStringForTarget(target):
if target==QtQuickConstants.Targets.DESKTOP: