2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# Copyright (C) 2022 The Qt Company Ltd.
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-19 15:59:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-15 13:17:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:39:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import tempfile
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:04:12 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def neededFilePresent(path):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    found = os.path.exists(path)
							 | 
						
					
						
							
								
									
										
										
										
											2012-02-07 14:25:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if os.getenv("SYSTEST_DEBUG") == "1":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        checkAccess(path)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    elif not found:
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:04:12 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.fatal("Missing file or directory: " + path)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return found
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def tempDir():
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-21 11:29:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    Result = os.path.abspath(os.getcwd()+"/../../testing")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not os.path.exists(Result):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        os.mkdir(Result)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return tempfile.mkdtemp(prefix="qtcreator_", dir=Result)
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def deleteDirIfExists(path):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    shutil.rmtree(path, True)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-19 10:28:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def verifyChecked(objectName, checked=True):
							 | 
						
					
						
							
								
									
										
										
										
											2012-11-02 19:34:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    object = waitForObject(objectName)
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-19 10:28:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    test.compare(object.checked, checked)
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-13 11:37:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def ensureChecked(objectName, shouldBeChecked = True, timeout=20000):
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-09 16:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if shouldBeChecked:
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        targetState = Qt.Checked
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-09 16:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        state = "checked"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        targetState = Qt.Unchecked
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-09 16:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        state = "unchecked"
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    widget = waitForObject(objectName, timeout)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # needed for transition Qt::PartiallyChecked -> Qt::Checked -> Qt::Unchecked
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        clicked = 0
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-24 12:49:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        while not waitFor('widget.checkState() == targetState', 1500) and clicked < 2:
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            clickButton(widget)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            clicked += 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.verify(waitFor("widget.checkState() == targetState", 1000))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # widgets not derived from QCheckbox don't have checkState()
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-24 12:49:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if not waitFor('widget.checked == shouldBeChecked', 1500):
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            mouseClick(widget)
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.verify(waitFor("widget.checked == shouldBeChecked", 1000))
							 | 
						
					
						
							
								
									
										
										
										
											2012-07-13 11:37:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    test.log("New state for QCheckBox: %s" % state,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             str(objectName))
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-12 14:42:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return widget
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-08 13:20:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-24 15:25:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# verify that an object is in an expected enable state. Returns the object.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param objectSpec  specifies the object to check. It can either be a string determining an object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#                   or the object itself. If it is an object, it must exist already.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param expectedState is the expected enable state of the object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def verifyEnabled(objectSpec, expectedState = True):
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-29 14:38:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if isString(objectSpec):
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-24 14:15:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        waitFor("object.exists('" + str(objectSpec).replace("'", "\\'") + "')", 20000)
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-24 15:25:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        foundObject = findObject(objectSpec)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        foundObject = objectSpec
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if objectSpec == None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.warning("No valid object in function verifyEnabled.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.compare(foundObject.enabled, expectedState)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return foundObject
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-24 15:25:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# select an item from a combo box
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param objectSpec  specifies the combo box. It can either be a string determining an object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#                   or the object itself. If it is an object, it must exist already.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param itemName is the item to be selected in the combo box
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-17 13:47:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# returns True if selection was changed or False if the wanted value was already selected
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-24 15:25:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def selectFromCombo(objectSpec, itemName):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    object = verifyEnabled(objectSpec)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-17 13:47:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if itemName == str(object.currentText):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return False
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        mouseClick(object)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-14 15:37:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-26 15:12:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # params required here
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mouseClick(waitForObjectItem(object, itemName.replace(".", "\\.")), 5, 5, 0, Qt.LeftButton)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-31 09:57:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.verify(waitFor("str(object.currentText)==itemName", 5000),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    "Switched combo item to '%s'" % itemName)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-17 13:47:47 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return True
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-01 13:47:26 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def selectFromLocator(filter, itemName = None):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if itemName == None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        itemName = filter
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-15 15:17:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    itemName = itemName.replace(".", "\\.").replace("_", "\\_")
							 | 
						
					
						
							
								
									
										
										
										
											2012-11-02 19:34:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    locator = waitForObject(":*Qt Creator_Utils::FilterLineEdit")
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-12 08:32:26 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(locator)
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-01 13:47:26 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    replaceEditorContent(locator, filter)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # clicking the wanted item
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # if you replace this by pressing ENTER, be sure that something is selected
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # otherwise you will run into unwanted behavior
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-09 08:02:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-01 13:47:26 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    wantedItem = waitForObjectItem("{type='QTreeView' unnamed='1' visible='1'}", itemName)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    doubleClick(wantedItem, 5, 5, 0, Qt.LeftButton)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def wordUnderCursor(window):
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 18:57:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return textUnderCursor(window, QTextCursor.StartOfWord, QTextCursor.EndOfWord)
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def lineUnderCursor(window):
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 18:57:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return textUnderCursor(window, QTextCursor.StartOfLine, QTextCursor.EndOfLine)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def textUnderCursor(window, fromPos, toPos):
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    cursor = window.textCursor()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    oldposition = cursor.position()
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 18:57:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    cursor.movePosition(fromPos)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    cursor.movePosition(toPos, QTextCursor.KeepAnchor)
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    returnValue = cursor.selectedText()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    cursor.setPosition(oldposition)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return returnValue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def which(program):
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-08 18:18:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Don't use spawn.find_executable because it can't find .bat or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # .cmd files and doesn't check whether a file is executable (!)
							 | 
						
					
						
							
								
									
										
										
										
											2012-03-05 17:16:36 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if platform.system() in ('Windows', 'Microsoft'):
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-08 18:18:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        command = "where"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        command = "which"
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:52:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    foundPath = getOutputFromCmdline([command, program], acceptedError=1)
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-08 18:18:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if foundPath:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return foundPath.splitlines()[0]
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-25 10:05:28 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							
								
									
										
										
										
											2012-03-05 17:16:36 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return None
							 | 
						
					
						
							
								
									
										
										
										
											2011-08-26 11:14:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:39:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# this function removes the user files of given pro file(s)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# can be called with a single string object or a list of strings holding path(s) to
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# the pro file(s) returns False if it could not remove all user files or has been
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# called with an unsupported object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def cleanUpUserFiles(pathsToProFiles=None):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if pathsToProFiles==None:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return False
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-29 14:38:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if isString(pathsToProFiles):
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:39:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        filelist = glob.glob(pathsToProFiles+".user*")
							 | 
						
					
						
							
								
									
										
										
										
											2011-10-17 19:09:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    elif isinstance(pathsToProFiles, (list, tuple)):
							 | 
						
					
						
							
								
									
										
										
										
											2011-09-27 11:39:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        filelist = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for p in pathsToProFiles:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            filelist.extend(glob.glob(p+".user*"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fatal("Got an unsupported object.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return False
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    doneWithoutErrors = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for file in filelist:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            file = os.path.abspath(file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            os.remove(file)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            doneWithoutErrors = False
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return doneWithoutErrors
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-21 21:51:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-30 09:32:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def invokeMenuItem(menu, item, *subItems):
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-27 12:58:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if platform.system() == "Darwin":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            waitForObject(":Qt Creator.QtCreator.MenuBar_QMenuBar", 2000)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            nativeMouseClick(waitForObject(":Qt Creator_Core::Internal::MainWindow", 1000), 20, 20, 0, Qt.LeftButton)
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 18:05:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # Use Locator for menu items which wouldn't work on macOS
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if menu == "Edit" and item == "Preferences..." or menu == "File" and item == "Exit":
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 18:05:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        selectFromLocator("t %s" % item, item)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							
								
									
										
										
										
											2012-02-24 15:21:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    menuObject = waitForObjectItem(":Qt Creator.QtCreator.MenuBar_QMenuBar", menu)
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-08 12:10:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 15:26:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    waitFor("menuObject.visible", 1000)
							 | 
						
					
						
							
								
									
										
										
										
											2011-10-06 20:16:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    activateItem(menuObject)
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-05 18:37:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    itemObject = waitForObjectItem(objectMap.realName(menuObject), item)
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 15:26:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    waitFor("itemObject.enabled", 2000)
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-05 18:37:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    activateItem(itemObject)
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-22 21:29:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    numberedPrefix = "%d | "
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-30 09:32:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for subItem in subItems:
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-16 09:30:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # we might have numbered sub items (e.g. "Recent Files") - these have this special prefix
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if subItem.startswith(numberedPrefix):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            triggered = False
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-22 21:29:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for i in range(1, 10):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    itemObject = waitForObjectItem(itemObject, subItem % i, 1000)
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-16 09:30:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    activateItem(itemObject)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    triggered = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    break
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-22 21:29:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    continue
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-16 09:30:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if not triggered:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                test.fail("Could not trigger '%s' - item missing or code wrong?" % subItem,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          "Function arguments: '%s', '%s', %s" % (menu, item, str(subItems)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                break # we failed to trigger - no need to process subItems further
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-21 21:51:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            itemObject = waitForObjectItem(itemObject, subItem)
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-16 09:30:26 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            activateItem(itemObject)
							 | 
						
					
						
							
								
									
										
										
										
											2011-10-06 20:16:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-21 21:51:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-10-06 20:16:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def logApplicationOutput():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # make sure application output is shown
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-05 16:49:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 15:26:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											2012-11-02 19:34:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        output = waitForObject("{type='Core::OutputWindow' visible='1' windowTitle='Application Output Window'}")
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 15:26:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.log("Application Output:\n%s" % output.plainText)
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-10 12:46:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return str(output.plainText)
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 15:26:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fail("Could not find any Application Output - did the project run?")
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-10 12:46:43 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return None
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-09 16:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# get the output from a given cmdline call
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:52:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def getOutputFromCmdline(cmdline, environment=None, acceptedError=0):
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-24 12:39:30 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 07:07:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return stringify(subprocess.check_output(cmdline, env=environment))
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-24 12:39:30 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except subprocess.CalledProcessError as e:
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-30 11:52:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if e.returncode != acceptedError:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.warning("Command '%s' returned %d" % (e.cmd, e.returncode))
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 07:07:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return stringify(e.output)
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-19 11:18:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-07 12:45:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def selectFromFileDialog(fileName, waitForFile=False, ignoreFinalSnooze=False):
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-09 11:14:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def __closePopupIfNecessary__():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if not isNull(QApplication.activePopupWidget()):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.log("Closing active popup widget")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            QApplication.activePopupWidget().close()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-07 10:41:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    fName = os.path.basename(os.path.abspath(fileName))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    pName = os.path.dirname(os.path.abspath(fileName)) + os.sep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        waitForObject("{name='QFileDialog' type='QFileDialog' visible='1'}", 5000)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        pathLine = waitForObject("{name='fileNameEdit' type='QLineEdit' visible='1'}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        replaceEditorContent(pathLine, pName)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-11 17:04:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-07 10:41:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject("{text='Open' type='QPushButton'}"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        waitFor("str(pathLine.text)==''")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        replaceEditorContent(pathLine, fName)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-11 17:04:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        snooze(1)
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-07 10:41:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        __closePopupIfNecessary__()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject("{text='Open' type='QPushButton'}"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        nativeType("<Ctrl+a>")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        nativeType("<Delete>")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        nativeType(pName + fName)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        seconds = len(pName + fName) / 20
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("Using snooze(%d) [problems with event processing of nativeType()]" % seconds)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        snooze(seconds)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-11 17:04:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        nativeType("<Return>")
							 | 
						
					
						
							
								
									
										
										
										
											2017-09-07 12:45:01 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if not ignoreFinalSnooze:
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-07 10:41:06 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            snooze(3)
							 | 
						
					
						
							
								
									
										
										
										
											2013-02-28 17:15:04 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if waitForFile:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fileCombo = waitForObject(":Qt Creator_FilenameQComboBox")
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-01 11:42:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if not waitFor("str(fileCombo.currentText) in fileName", 5000):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.fail("%s could not be opened in time." % fileName)
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-11 17:04:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-18 10:27:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# add Qt documentations from given paths
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param which a list/tuple of the paths to the qch files to be added
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def addHelpDocumentation(which):
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    invokeMenuItem("Edit", "Preferences...")
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(waitForObjectItem(":Options_QListView", "Help"))
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-19 11:18:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' type='TabItem' text='Documentation'}")
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:41:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Documentation")
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-19 11:18:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # get rid of all docs already registered
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-17 13:13:01 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    listWidget = waitForObject("{type='QListView' name='docsListView' visible='1'}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if listWidget.model().rowCount() > 0:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mouseClick(listWidget)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-18 14:37:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        type(listWidget, "<Ctrl+a>")
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-17 13:13:01 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject("{type='QPushButton' name='removeButton' visible='1'}"))
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-18 10:27:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for qch in which:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject("{type='QPushButton' name='addButton' visible='1' text='Add...'}"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        selectFromFileDialog(qch)
							 | 
						
					
						
							
								
									
										
										
										
											2011-12-19 11:18:24 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickButton(waitForObject(":Options.OK_QPushButton"))
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-31 15:49:59 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 17:04:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def addCurrentCreatorDocumentation():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    currentCreatorPath = currentApplicationContext().cwd
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if platform.system() == "Darwin":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        docPath = os.path.abspath(os.path.join(currentCreatorPath, "Qt Creator.app", "Contents",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                               "Resources", "doc", "qtcreator.qch"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        docPath = os.path.abspath(os.path.join(currentCreatorPath, "..", "share", "doc",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                               "qtcreator", "qtcreator.qch"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not os.path.exists(docPath):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fatal("Missing current Qt Creator documentation (expected in %s)" % docPath)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    invokeMenuItem("Edit", "Preferences...")
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(waitForObjectItem(":Options_QListView", "Help"))
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 17:04:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    waitForObject("{container=':Options.qt_tabwidget_tabbar_QTabBar' type='TabItem' text='Documentation'}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Documentation")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    clickButton(waitForObject("{type='QPushButton' name='addButton' visible='1' text='Add...'}"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    selectFromFileDialog(docPath)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-24 22:48:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        windowStr = ("{type='QMessageBox' unnamed='1' visible='1' "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      "text~='Unable to register documentation.*'}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        waitForObject(windowStr, 3000)
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 17:04:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        test.passes("Qt Creator's documentation found already registered.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject("{type='QPushButton' text='OK' unnamed='1' visible='1' "
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-24 22:48:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                  "window=%s}" % windowStr))
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 17:04:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fail("Added Qt Creator's documentation explicitly.")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    clickButton(waitForObject(":Options.OK_QPushButton"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-01-31 15:49:59 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def verifyOutput(string, substring, outputFrom, outputIn):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    index = string.find(substring)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (index == -1):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fail("Output from " + outputFrom + " could not be found in " + outputIn)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.passes("Output from " + outputFrom + " found at position " + str(index) + " of " + outputIn)
							 | 
						
					
						
							
								
									
										
										
										
											2012-02-07 14:25:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-04 00:12:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# function that verifies the existence and the read permissions
							 | 
						
					
						
							
								
									
										
										
										
											2012-02-07 14:25:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# of the given file path
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# if the executing user hasn't the read permission it checks
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# the parent folders for their execute permission
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def checkAccess(pathToFile):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if os.path.exists(pathToFile):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("Path '%s' exists" % pathToFile)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if os.access(pathToFile, os.R_OK):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.log("Got read access on '%s'" % pathToFile)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.fail("No read permission on '%s'" % pathToFile)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.fatal("Path '%s' does not exist or cannot be accessed" % pathToFile)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        __checkParentAccess__(pathToFile)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# helper function for checking the execute rights of all
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# parents of filePath
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def __checkParentAccess__(filePath):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for i in range(1, filePath.count(os.sep)):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        tmp = filePath.rsplit(os.sep, i)[0]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if os.access(tmp, os.X_OK):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.log("Got execute permission on '%s'" % tmp)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.fail("No execute permission on '%s'" % tmp)
							 | 
						
					
						
							
								
									
										
										
										
											2012-02-17 17:10:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# this function checks for all configured Qt versions inside
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-04 16:59:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# options dialog and returns a dict holding the kits as keys
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# and a list of information of its configured Qt
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-24 12:06:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def getConfiguredKits():
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def __setQtVersionForKit__(kit, kitName, kitsQtVersionName):
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        mouseClick(waitForObjectItem(":BuildAndRun_QTreeView", kit))
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-12 13:44:52 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        qtVersionStr = str(waitForObjectExists(":Kits_QtVersion_QComboBox").currentText)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-16 17:16:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        invalid = qtVersionStr.endswith(" (invalid)")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if invalid:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            qtVersionStr = qtVersionStr[:-10]
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        kitsQtVersionName[kitName] = qtVersionStr
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # end of internal function for iterate kits
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    kitsWithQtVersionName = {}
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    result = []
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # collect kits and their Qt versions
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    qtVersionNames = iterateQtVersions()
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # update collected Qt versions with their configured device and version
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    iterateKits(False, True, __setQtVersionForKit__, kitsWithQtVersionName)
							 | 
						
					
						
							
								
									
										
										
										
											2012-08-22 12:39:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # merge defined target names with their configured Qt versions and devices
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-15 12:59:44 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    for kit, qtVersion in kitsWithQtVersionName.iteritems():
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if qtVersion in qtVersionNames:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            result.append(kit)
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-07 15:59:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.fail("Qt version '%s' for kit '%s' can't be found in qtVersionNames."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      % (qtVersion, kit))
							 | 
						
					
						
							
								
									
										
										
										
											2012-08-22 12:39:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickButton(waitForObject(":Options.Cancel_QPushButton"))
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-04 16:59:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    test.log("Configured kits: %s" % str(result))
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return result
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-30 11:14:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def enabledCheckBoxExists(text):
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											2019-09-30 11:14:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        waitForObject("{type='QCheckBox' text='%s'}" % text, 100)
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return False
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# this function verifies if the text matches the given
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# regex inside expectedTexts
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-29 14:38:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# param text must be a single str
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param expectedTexts can be str/list/tuple
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def regexVerify(text, expectedTexts):
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-29 14:38:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if isString(expectedTexts):
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        expectedTexts = [expectedTexts]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for curr in expectedTexts:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        pattern = re.compile(curr)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if pattern.match(text):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return False
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-04-02 17:20:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# function that opens Options Dialog and parses the configured Qt versions
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# the function returns a list of the found Qt versions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def iterateQtVersions():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    qtVersionNames = []
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    invokeMenuItem("Edit", "Preferences...")
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(waitForObjectItem(":Options_QListView", "Kits"))
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:41:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Qt Versions")
							 | 
						
					
						
							
								
									
										
										
										
											2015-10-29 14:30:58 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    treeView = waitForObject(":qtdirList_QTreeView")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    model = treeView.model()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for rootIndex in dumpIndices(model):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        rootChildText = str(rootIndex.data()).replace(".", "\\.").replace("_", "\\_")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for subIndex in dumpIndices(model, rootIndex):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            subChildText = str(subIndex.data()).replace(".", "\\.").replace("_", "\\_")
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-31 08:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            treeView.scrollTo(subIndex)
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 22:41:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            mouseClick(waitForObjectItem(treeView, ".".join([rootChildText, subChildText])))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            qtVersionNames.append(str(treeView.currentIndex().data().toString()))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return qtVersionNames
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# function that opens Options Dialog (if necessary) and parses the configured Kits
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# param clickOkWhenDone set to True if the Options dialog should be closed by clicking the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#       "OK" button. If False, the dialog will stay open
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# param alreadyOnOptionsDialog set to True if you already have opened the Options Dialog
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#       (if False this function will open it via the MenuBar -> Edit -> Preferences...)
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# param additionalFunction pass a function or name of a defined function to execute
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#       for each configured item on the list of Kits
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#       this function must take at least 2 parameters - the first is the full string
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#       of the kit which can be used in waitForObjectItem(), the second the Kit name itself
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param argsForAdditionalFunc you can specify as many parameters as you want to pass
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#       to additionalFunction from the outside
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# this function will return a list of Kit names as well as the returned value(s) from
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# additionalFunction. You MUST call this function like
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# result, additionalResult = iterateKits(...)
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# where additionalResult is the result of all executions of additionalFunction which
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# means it is a list of results.
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def iterateKits(clickOkWhenDone, alreadyOnOptionsDialog,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                additionalFunction, *argsForAdditionalFunc):
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    result = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    additionalResult = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not alreadyOnOptionsDialog:
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        invokeMenuItem("Edit", "Preferences...")
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(waitForObjectItem(":Options_QListView", "Kits"))
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:41:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "Kits")
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-17 13:52:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    treeView = waitForObject(":BuildAndRun_QTreeView")
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    model = treeView.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")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for section in [autoDetected, manual]:
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-25 12:59:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for currentItem in dumpItems(model, section):
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            kitName = currentItem.rsplit(" (default)", 1)[0]
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-02 11:46:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            result.append(kitName)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-25 00:35:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            try:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                item = ".".join([str(section.data().toString()),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                 currentItem.replace(".", "\\.")])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                currResult = additionalFunction(item, kitName, *argsForAdditionalFunc)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            except:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                t, v, _ = sys.exc_info()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                currResult = None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                test.fatal("Function to additionally execute on Options Dialog could not be "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                           "found or an exception occurred while executing it.", "%s(%s)" %
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                           (str(t), str(v)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            additionalResult.append(currResult)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if clickOkWhenDone:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        clickButton(waitForObject(":Options.OK_QPushButton"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return result, additionalResult
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-18 12:48:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-28 15:29:37 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								# set a help viewer that will always be used, regardless of Creator's width
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class HelpViewer:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    HELPMODE, SIDEBYSIDE, EXTERNALWINDOW = range(3)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def setFixedHelpViewer(helpViewer):
							 | 
						
					
						
							
								
									
										
										
										
											2022-06-22 15:59:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    invokeMenuItem("Edit", "Preferences...")
							 | 
						
					
						
							
								
									
										
										
										
											2019-07-24 15:12:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mouseClick(waitForObjectItem(":Options_QListView", "Help"))
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:41:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickOnTab(":Options.qt_tabwidget_tabbar_QTabBar", "General")
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-28 15:29:37 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    mode = "Always Show "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if helpViewer == HelpViewer.HELPMODE:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mode += "in Help Mode"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    elif helpViewer == HelpViewer.SIDEBYSIDE:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mode += "Side-by-Side"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    elif helpViewer == HelpViewer.EXTERNALWINDOW:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        mode += "in External Window"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    selectFromCombo(":Startup.contextHelpComboBox_QComboBox", mode)
							 | 
						
					
						
							
								
									
										
										
										
											2012-09-18 12:48:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickButton(waitForObject(":Options.OK_QPushButton"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def removePackagingDirectory(projectPath):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    qtcPackaging = os.path.join(projectPath, "qtc_packaging")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if os.path.exists(qtcPackaging):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("Removing old packaging directory '%s'" % qtcPackaging)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        deleteDirIfExists(qtcPackaging)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("Couldn't remove packaging directory '%s' - did not exist." % qtcPackaging)
							 | 
						
					
						
							
								
									
										
										
										
											2012-10-25 12:59:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# returns the indices from a QAbstractItemModel
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def dumpIndices(model, parent=None, column=0):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if parent:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return [model.index(row, column, parent) for row in range(model.rowCount(parent))]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return [model.index(row, column) for row in range(model.rowCount())]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								DisplayRole = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# returns the data from a QAbstractItemModel as strings
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def dumpItems(model, parent=None, role=DisplayRole, column=0):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return [str(index.data(role)) for index in dumpIndices(model, parent, column)]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# returns the children of a QTreeWidgetItem
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def dumpChildren(item):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return [item.child(index) for index in range(item.childCount())]
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-04 11:02:55 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def writeTestResults(folder):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not os.path.exists(folder):
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-25 16:38:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        print("Skipping writing test results (folder '%s' does not exist)." % folder)
							 | 
						
					
						
							
								
									
										
										
										
											2013-03-04 11:02:55 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    resultFile = open("%s.srf" % os.path.join(folder, os.path.basename(squishinfo.testCase)), "w")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    resultFile.write("suite:%s\n" % os.path.basename(os.path.dirname(squishinfo.testCase)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    categories = ["passes", "fails", "fatals", "errors", "tests", "warnings", "xfails", "xpasses"]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for cat in categories:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        resultFile.write("%s:%d\n" % (cat, test.resultCount(cat)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    resultFile.close()
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-05 13:35:13 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# wait and verify if object exists/not exists
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def checkIfObjectExists(name, shouldExist = True, timeout = 3000, verboseOnFail = False):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    result = waitFor("object.exists(name) == shouldExist", timeout)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if verboseOnFail and not result:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("checkIfObjectExists() failed for '%s'" % name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return result
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# wait for progress bar(s) to appear and disappear
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-08 12:24:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def progressBarWait(timeout=60000, warn=True):
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-20 13:57:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if not checkIfObjectExists(":Qt Creator_Core::Internal::ProgressBar", True, 6000):
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-08 12:24:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if warn:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            test.warning("progressBarWait() timed out when waiting for ProgressBar.",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                         "This may lead to unforeseen behavior. Consider increasing the timeout.")
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-25 18:57:02 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    checkIfObjectExists(":Qt Creator_Core::Internal::ProgressBar", False, timeout)
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-25 16:04:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def readFile(filename):
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-31 08:21:18 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    with open(filename, "r") as f:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return f.read()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 17:19:25 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def simpleFileName(navigatorFileName):
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-04 09:44:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    # try to find the last part of the given name, assume it's inside a (folder) structure
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    search = re.search(".*[^\\\\]\.(.*)$", navigatorFileName)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if search:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return search.group(1).replace("\\", "")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    # it's just the filename
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return navigatorFileName.replace("\\", "")
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:41:37 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def clickOnTab(tabBarStr, tabText, timeout=5000):
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-20 11:09:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if not waitFor("object.exists(tabBarStr)", timeout):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        raise LookupError("Could not find QTabBar: %s" % objectMap.realName(tabBarStr))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    tabBar = findObject(tabBarStr)
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-19 15:20:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if not (platform.system() == 'Linux' or tabBar.visible):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.log("Using workaround for Mac and Windows.")
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-20 11:09:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        setWindowState(tabBar, WindowState.Normal)
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-24 13:45:55 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        tabBar = waitForObject(tabBarStr, 2000)
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-20 11:09:41 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    clickTab(tabBar, tabText)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    waitFor("str(tabBar.tabText(tabBar.currentIndex)) == '%s'" % tabText, timeout)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-02 15:21:05 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# constructs a string holding the properties for a QModelIndex
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param property a string holding additional properties including their values
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#       ATTENTION! use single quotes for values (e.g. "text='Text'", "text='Text' occurrence='2'")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# param container the container (str) to be used for this QModelIndex
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def getQModelIndexStr(property, container):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (container.startswith(":")):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        container = "'%s'" % container
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return ("{column='0' container=%s %s type='QModelIndex'}" % (container, property))
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-13 15:59:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def verifyItemOrder(items, text):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    text = str(text)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    lastIndex = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for item in items:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        index = text.find(item)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        test.verify(index > lastIndex, "'" + item + "' found at index " + str(index))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        lastIndex = index
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-13 15:05:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def openVcsLog():
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-17 13:26:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    try:
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-29 18:12:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        foundObj = waitForObject("{type='Core::OutputWindow' unnamed='1' visible='1' "
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-17 13:26:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                 "window=':Qt Creator_Core::Internal::MainWindow'}", 2000)
							 | 
						
					
						
							
								
									
										
										
										
											2016-02-29 18:12:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if className(foundObj) != 'Core::OutputWindow':
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-17 13:26:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            raise Exception("Found derived class, but not a pure QPlainTextEdit.")
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-12 12:50:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        waitForObject("{text='Version Control' type='QLabel' unnamed='1' visible='1' "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      "window=':Qt Creator_Core::Internal::MainWindow'}", 2000)
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-17 13:26:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    except:
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-18 10:08:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        invokeMenuItem("View", "Output", "Version Control")
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-17 13:26:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def openGeneralMessages():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if not object.exists(":Qt Creator_Core::OutputWindow"):
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-18 10:08:28 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        invokeMenuItem("View", "Output", "General Messages")
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-19 09:16:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# function that retrieves a specific child object by its class
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# this is sometimes the best way to avoid using waitForObject() on objects that
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# occur more than once - but could easily be found by using a compound object
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# (e.g. search for Utils::PathChooser instead of Utils::FancyLineEdit and get the child)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def getChildByClass(parent, classToSearchFor, occurrence=1):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    children = [child for child in object.children(parent) if className(child) == classToSearchFor]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if len(children) < occurrence:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return children[occurrence - 1]
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 15:56:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def getHelpViewer():
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-12 21:19:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return waitForObject("{type='QLiteHtmlWidget' unnamed='1' visible='1' "
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                         "window=':Qt Creator_Core::Internal::MainWindow'}",
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 19:09:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         1000)
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 15:56:27 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def getHelpTitle():
							 | 
						
					
						
							
								
									
										
										
										
											2020-10-12 21:19:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return str(getHelpViewer().title())
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-29 14:38:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def isString(sth):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if sys.version_info.major > 2:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return isinstance(sth, str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return isinstance(sth, (str, unicode))
							 | 
						
					
						
							
								
									
										
										
										
											2022-04-13 07:07:22 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# helper function to ensure we get str, converts bytes if necessary
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def stringify(obj):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    stringTypes = (str, unicode) if sys.version_info.major == 2 else (str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if isinstance(obj, stringTypes):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return obj
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if isinstance(obj, bytes):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        tmp = obj.decode('cp1252') if platform.system() in ('Microsoft','Windows') else obj.decode()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return tmp
							 |