Commit 13468fc1 authored by Christian Stenger's avatar Christian Stenger

Squish: Add workaround for tst_QMLS04

Additionally added user-defined exception to JIRA class for
usage inside workaround functions.

Change-Id: I1f6c6c269dd93e00f69741af36c4de3324693da9
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
parent a9b53d50
...@@ -64,6 +64,13 @@ JIRA_URL='https://bugreports.qt-project.org/browse' ...@@ -64,6 +64,13 @@ JIRA_URL='https://bugreports.qt-project.org/browse'
class JIRA: class JIRA:
__instance__ = None __instance__ = None
# internal exception to be used inside workaround functions (lack of having return values)
class JiraException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
# Helper class # Helper class
class Bug: class Bug:
CREATOR = 'QTCREATORBUG' CREATOR = 'QTCREATORBUG'
...@@ -117,7 +124,15 @@ class JIRA: ...@@ -117,7 +124,15 @@ class JIRA:
functionToCall = JIRA.getInstance().__bugs__.get("%s-%d" % (bugType, number), None) functionToCall = JIRA.getInstance().__bugs__.get("%s-%d" % (bugType, number), None)
if functionToCall: if functionToCall:
test.warning("Using workaround for %s-%d" % (bugType, number)) test.warning("Using workaround for %s-%d" % (bugType, number))
functionToCall(*args) try:
functionToCall(*args)
except:
t, v = sys.exc_info()[0:2]
if t == JIRA.JiraException:
raise JIRA.JiraException(v)
else:
test.warning("Exception caught while executing workaround function.",
"%s (%s)" % (str(t), str(v)))
return True return True
else: else:
JIRA.getInstance()._exitFatal_(bugType, number) JIRA.getInstance()._exitFatal_(bugType, number)
...@@ -245,6 +260,7 @@ class JIRA: ...@@ -245,6 +260,7 @@ class JIRA:
def __initBugDict__(self): def __initBugDict__(self):
self.__bugs__= { self.__bugs__= {
'QTCREATORBUG-6853':self._workaroundCreator6853_, 'QTCREATORBUG-6853':self._workaroundCreator6853_,
'QTCREATORBUG-11548':self._workaroundCreator11548_
} }
# helper function - will be called if no workaround for the requested bug is deposited # helper function - will be called if no workaround for the requested bug is deposited
def _exitFatal_(self, bugType, number): def _exitFatal_(self, bugType, number):
...@@ -255,3 +271,38 @@ class JIRA: ...@@ -255,3 +271,38 @@ class JIRA:
def _workaroundCreator6853_(self, *args): def _workaroundCreator6853_(self, *args):
if "Release" in args[0] and platform.system() == "Linux": if "Release" in args[0] and platform.system() == "Linux":
snooze(2) snooze(2)
def _workaroundCreator11548_(self, *args):
if len(args) != 3:
test.fatal("Need 3 arguments (project directory, project name, path to the file to "
"be added to the qrc file) to perform workaround.")
raise JIRA.JiraException("Wrong invocation of _workaroundCreator11548_().")
(pDir, pName, fPath) = args
try:
selectFromCombo(":Qt Creator_Core::Internal::NavComboBox", "Projects")
navigator = waitForObject(":Qt Creator_Utils::NavigationTreeView")
try:
openItemContextMenu(navigator, "%s.Resources.qml\.qrc" % pName, 5, 5, 0)
except:
treeElement = addBranchWildcardToRoot("%s.Resources.qml\.qrc" % pName)
openItemContextMenu(navigator, treeElement, 5, 5, 0)
if platform.system() == 'Darwin':
waitFor("macHackActivateContextMenuItem('Add Existing Files...')", 6000)
else:
activateItem(waitForObjectItem(":Qt Creator.Project.Menu.Folder_QMenu",
"Add Existing Files..."))
selectFromFileDialog(fPath)
# handle version control if necessary
try:
dlg = ("{name='Core__Internal__AddToVcsDialog' type='Core::Internal::AddToVcsDialog' "
"visible='1' windowTitle='Add to Version Control'}")
waitForObject(dlg, 3000)
clickButton(waitForObject("{text='No' type='QPushButton' unnamed='1' "
"visible='1' window=%s}" % dlg))
except:
pass
# known issue with running inside Squish
setWindowState(waitForObject(":Qt Creator_Core::Internal::MainWindow"), WindowState.Normal)
except:
test.fatal("Failed to perform workaround for QTCREATORBUG-11548")
raise JIRA.JiraException("Failed to perform workaround for QTCREATORBUG-11548")
...@@ -56,8 +56,8 @@ def main(): ...@@ -56,8 +56,8 @@ def main():
test.passes("Refactoring was properly applied in source file") test.passes("Refactoring was properly applied in source file")
else: else:
test.fail("Refactoring of Text to MyComponent failed in source file. Content of editor:\n%s" % codeText) test.fail("Refactoring of Text to MyComponent failed in source file. Content of editor:\n%s" % codeText)
myCompTE = "SampleApp.QML.qml.MyComponent\\.qml" myCompTE = "SampleApp.Resources.qml\\.qrc./.qml/MyComponent\\.qml"
appeared = False filePath = os.path.join(projectDir, "SampleApp", "qml", "MyComponent.qml")
# there should be new QML file generated with name "MyComponent.qml" # there should be new QML file generated with name "MyComponent.qml"
try: try:
waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", myCompTE, 3000) waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", myCompTE, 3000)
...@@ -65,10 +65,15 @@ def main(): ...@@ -65,10 +65,15 @@ def main():
try: try:
waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", addBranchWildcardToRoot(myCompTE), 1000) waitForObjectItem(":Qt Creator_Utils::NavigationTreeView", addBranchWildcardToRoot(myCompTE), 1000)
except: except:
test.fail("Refactoring failed - file MyComponent.qml was not generated properly in project explorer") test.xverify(False, "Refactoring failed - file MyComponent.qml was not generated "
#save and exit "properly in project explorer (QTCREATORBUG-11548")
invokeMenuItem("File", "Save All") try:
invokeMenuItem("File", "Exit") JIRA.performWorkaroundForBug(11548, JIRA.Bug.CREATOR, projectDir, "SampleApp", filePath)
except JIRA.JiraException:
#save and exit
invokeMenuItem("File", "Save All")
invokeMenuItem("File", "Exit")
return
test.passes("Refactoring - file MyComponent.qml was generated properly in project explorer") test.passes("Refactoring - file MyComponent.qml was generated properly in project explorer")
# open MyComponent.qml file for verification # open MyComponent.qml file for verification
if not openDocument(myCompTE): if not openDocument(myCompTE):
...@@ -86,7 +91,6 @@ def main(): ...@@ -86,7 +91,6 @@ def main():
#save and exit #save and exit
invokeMenuItem("File", "Save All") invokeMenuItem("File", "Save All")
# check if new file was created in file system # check if new file was created in file system
test.verify(os.path.exists(projectDir + "/SampleApp/qml/MyComponent.qml"), test.verify(os.path.exists(filePath),
"Verifying if MyComponent.qml exists in file system after save") "Verifying if MyComponent.qml exists in file system after save")
invokeMenuItem("File", "Exit") invokeMenuItem("File", "Exit")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment