forked from qt-creator/qt-creator
Squish: Provide test for QmlJSConsole
Change-Id: Ib7cbf312b611176dbb762958bca687e043372a27 Reviewed-by: Robert Loehning <robert.loehning@digia.com>
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
:DebugModeWidget.Locals and Expressions_QDockWidget {container=':Qt Creator.DebugModeWidget_QSplitter' name='Debugger.Docks.LocalsAndWatchers' type='QDockWidget' visible='1' windowTitle='Locals and Expressions'}
|
||||
:DebugModeWidget.OK_QPushButton {container=':Qt Creator.DebugModeWidget_QSplitter' text='OK' type='QPushButton' unnamed='1' visible='1'}
|
||||
:DebugModeWidget_QComboBox {container=':Qt Creator.DebugModeWidget_QSplitter' occurrence='2' type='QComboBox' unnamed='1' visible='1'}
|
||||
:DebugModeWidget_QmlJSTools::Internal::QmlConsoleView {container=':Qt Creator.DebugModeWidget_QSplitter' type='QmlJSTools::Internal::QmlConsoleView' unnamed='1' visible='1'}
|
||||
:Debugger Toolbar.Continue_QToolButton {container=':DebugModeWidget.Debugger Toolbar_QDockWidget' text='Continue' type='QToolButton' unnamed='1' visible='1'}
|
||||
:Debugger Toolbar.Exit Debugger_QToolButton {container=':DebugModeWidget.Debugger Toolbar_QDockWidget' text='Stop Debugger' type='QToolButton' unnamed='1' visible='1'}
|
||||
:Debugger Toolbar.StatusText_Utils::StatusLabel {container=':DebugModeWidget.Debugger Toolbar_QDockWidget' type='Utils::StatusLabel' unnamed='1'}
|
||||
@@ -125,6 +126,7 @@
|
||||
:QML Debugging.No_QPushButton {text='No' type='QPushButton' unnamed='1' visible='1' window=':QML Debugging_QMessageBox'}
|
||||
:QML Debugging_QMessageBox {text='The option will only take effect if the project is recompiled. Do you want to recompile now?' type='QMessageBox' unnamed='1' visible='1'}
|
||||
:QWebPage {type='QWebPage' unnamed='1'}
|
||||
:QmlJSTools::Internal::QmlConsoleEdit {columnIndex='0' container=':DebugModeWidget_QmlJSTools::Internal::QmlConsoleView' rowIndex='0' type='QmlJSTools::Internal::QmlConsoleEdit' unnamed='1' visible='1'}
|
||||
:Qt Creator.Add Bookmark_QToolButton {text='Add Bookmark' type='QToolButton' unnamed='1' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
||||
:Qt Creator.Analyzer Toolbar_QDockWidget {name='Analyzer Toolbar' type='QDockWidget' visible='1' window=':Qt Creator_Core::Internal::MainWindow' windowTitle='Analyzer Toolbar'}
|
||||
:Qt Creator.CloseFind_QToolButton {name='close' type='QToolButton' visible='1' window=':Qt Creator_Core::Internal::MainWindow'}
|
||||
|
@@ -7,6 +7,6 @@ HOOK_SUB_PROCESSES=false
|
||||
IMPLICITAUTSTART=0
|
||||
LANGUAGE=Python
|
||||
OBJECTMAP=../objects.map
|
||||
TEST_CASES=tst_build_new_project tst_cli_output_console tst_debug_empty_main tst_qml_locals tst_simple_analyze tst_simple_debug
|
||||
TEST_CASES=tst_build_new_project tst_cli_output_console tst_debug_empty_main tst_qml_js_console tst_qml_locals tst_simple_analyze tst_simple_debug
|
||||
VERSION=2
|
||||
WRAPPERS=Qt
|
||||
|
184
tests/system/suite_debugger/tst_qml_js_console/test.py
Normal file
184
tests/system/suite_debugger/tst_qml_js_console/test.py
Normal file
@@ -0,0 +1,184 @@
|
||||
#############################################################################
|
||||
##
|
||||
## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
## Contact: http://www.qt-project.org/legal
|
||||
##
|
||||
## This file is part of Qt Creator.
|
||||
##
|
||||
## Commercial License Usage
|
||||
## Licensees holding valid commercial Qt licenses may use this file in
|
||||
## accordance with the commercial license agreement provided with the
|
||||
## Software or, alternatively, in accordance with the terms contained in
|
||||
## a written agreement between you and Digia. For licensing terms and
|
||||
## conditions see http://qt.digia.com/licensing. For further information
|
||||
## use the contact form at http://qt.digia.com/contact-us.
|
||||
##
|
||||
## GNU Lesser General Public License Usage
|
||||
## Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
## General Public License version 2.1 as published by the Free Software
|
||||
## Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
## packaging of this file. Please review the following information to
|
||||
## ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
##
|
||||
## In addition, as a special exception, Digia gives you certain additional
|
||||
## rights. These rights are described in the Digia Qt LGPL Exception
|
||||
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
##
|
||||
#############################################################################
|
||||
|
||||
source("../../shared/qtcreator.py")
|
||||
|
||||
def typeToQmlConsole(expression):
|
||||
editableIndex = getQModelIndexStr("text=''",
|
||||
":DebugModeWidget_QmlJSTools::Internal::QmlConsoleView")
|
||||
mouseClick(editableIndex, 5, 5, 0, Qt.LeftButton)
|
||||
type(waitForObject(":QmlJSTools::Internal::QmlConsoleEdit"), expression)
|
||||
type(waitForObject(":QmlJSTools::Internal::QmlConsoleEdit"), "<Return>")
|
||||
|
||||
def useQmlJSConsole(expression, expectedOutput, check=None, checkOutp=None):
|
||||
typeToQmlConsole(expression)
|
||||
|
||||
if expectedOutput == None:
|
||||
result = getQmlJSConsoleOutput()[-1]
|
||||
clickButton(":*Qt Creator.Clear_QToolButton")
|
||||
return result
|
||||
|
||||
expected = getQModelIndexStr("text='%s'" % expectedOutput,
|
||||
":DebugModeWidget_QmlJSTools::Internal::QmlConsoleView")
|
||||
try:
|
||||
obj = waitForObject(expected, 3000)
|
||||
test.compare(obj.text, expectedOutput, "Verifying whether expected output appeared.")
|
||||
except:
|
||||
test.fail("Expected output (%s) missing - got '%s'."
|
||||
% (expectedOutput, getQmlJSConsoleOutput()[-1]))
|
||||
clickButton(":*Qt Creator.Clear_QToolButton")
|
||||
if check:
|
||||
if checkOutp == None:
|
||||
checkOutp = expectedOutput
|
||||
useQmlJSConsole(check, checkOutp)
|
||||
|
||||
def debuggerHasStopped():
|
||||
stopDebugger = findObject(":Debugger Toolbar.Exit Debugger_QToolButton")
|
||||
fancyDebugButton = findObject(":*Qt Creator.Start Debugging_Core::Internal::FancyToolButton")
|
||||
result = test.verify(not stopDebugger.enabled and fancyDebugButton.enabled,
|
||||
"Verifying whether debugger buttons are in correct state.")
|
||||
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
|
||||
output = waitForObject("{type='Core::OutputWindow' visible='1' "
|
||||
"windowTitle='Application Output Window'}")
|
||||
result &= test.verify(waitFor("'Debugging has finished' in str(output.plainText)", 2000),
|
||||
"Verifying whether Application output contains 'Debugging has finished'.")
|
||||
return result
|
||||
|
||||
def getQmlJSConsoleOutput():
|
||||
try:
|
||||
result = []
|
||||
consoleView = waitForObject(":DebugModeWidget_QmlJSTools::Internal::QmlConsoleView")
|
||||
model = consoleView.model()
|
||||
return dumpItems(model)[:-1]
|
||||
except:
|
||||
return [""]
|
||||
|
||||
def runChecks(elementProps, parent, checks):
|
||||
mouseClick(getQModelIndexStr(elementProps, parent), 5, 5, 0, Qt.LeftButton)
|
||||
for check in checks:
|
||||
useQmlJSConsole(*check)
|
||||
|
||||
def testLoggingFeatures():
|
||||
expressions = ("console.log('info message'); console.info('info message2'); console.debug()",
|
||||
'console.warn("warning message")',
|
||||
"console.error('error message')")
|
||||
expected = (["info message", "info message2", "", "<undefined>"],
|
||||
["warning message", "<undefined>"],
|
||||
["error message", "<undefined>"])
|
||||
filterToolTips = ("Show debug, log, and info messages.",
|
||||
"Show debug, log, and info messages.' occurrence='2", #"Show warning messages.",
|
||||
"Show debug, log, and info messages.' occurrence='3", #"Show error messages."
|
||||
)
|
||||
|
||||
for expression, expect, tooltip in zip(expressions, expected, filterToolTips):
|
||||
typeToQmlConsole(expression)
|
||||
output = getQmlJSConsoleOutput()[1:]
|
||||
test.compare(output, expect, "Verifying expected output.")
|
||||
filterButton = waitForObject("{container=':Qt Creator.DebugModeWidget_QSplitter' "
|
||||
"toolTip='%s' type='QToolButton' unnamed='1' visible='1'}"
|
||||
% tooltip)
|
||||
ensureChecked(filterButton, False)
|
||||
output = getQmlJSConsoleOutput()[1:]
|
||||
test.compare(output, ["<undefined>"], "Verifying expected filtered output.")
|
||||
ensureChecked(filterButton, True)
|
||||
output = getQmlJSConsoleOutput()[1:]
|
||||
test.compare(output, expect, "Verifying unfiltered output is displayed again.")
|
||||
clickButton(":*Qt Creator.Clear_QToolButton")
|
||||
|
||||
def main():
|
||||
projName = "simpleQuickUI2.qmlproject"
|
||||
projFolder = os.path.dirname(findFile("testdata", "simpleQuickUI2/%s" % projName))
|
||||
if not neededFilePresent(os.path.join(projFolder, projName)):
|
||||
return
|
||||
qmlProjDir = prepareTemplate(projFolder)
|
||||
if qmlProjDir == None:
|
||||
test.fatal("Could not prepare test files - leaving test")
|
||||
return
|
||||
qmlProjFile = os.path.join(qmlProjDir, projName)
|
||||
# start Creator by passing a .qmlproject file
|
||||
startApplication('qtcreator' + SettingsPath + ' "%s"' % qmlProjFile)
|
||||
if not startedWithoutPluginError():
|
||||
return
|
||||
|
||||
# if Debug is enabled - 1 valid kit is assigned - real check for this is done in tst_qml_locals
|
||||
fancyDebugButton = findObject(":*Qt Creator.Start Debugging_Core::Internal::FancyToolButton")
|
||||
if test.verify(waitFor('fancyDebugButton.enabled', 5000), "Start Debugging is enabled."):
|
||||
# make sure QML Debugging is enabled
|
||||
switchViewTo(ViewConstants.PROJECTS)
|
||||
switchToBuildOrRunSettingsFor(1, 0, ProjectSettings.RUN, True)
|
||||
ensureChecked("{container=':Qt Creator.scrollArea_QScrollArea' text='Enable QML' "
|
||||
"type='QCheckBox' unnamed='1' visible='1'}")
|
||||
switchViewTo(ViewConstants.EDIT)
|
||||
# start debugging
|
||||
clickButton(fancyDebugButton)
|
||||
locAndExprTV = waitForObject(":Locals and Expressions_Debugger::Internal::WatchTreeView")
|
||||
rootIndex = getQModelIndexStr("text='Rectangle'",
|
||||
":Locals and Expressions_Debugger::Internal::WatchTreeView")
|
||||
# make sure the items inside the root item are visible
|
||||
doubleClick(waitForObject(rootIndex))
|
||||
if not object.exists(":DebugModeWidget_QmlJSTools::Internal::QmlConsoleView"):
|
||||
invokeMenuItem("Window", "Output Panes", "QML/JS Console")
|
||||
progressBarWait()
|
||||
# color and float values have additional ZERO WIDTH SPACE (\u200b), different usage of
|
||||
# whitespaces inside expressions is part of the test
|
||||
checks = [("color", u"#\u200b008000"), ("width", "50"),
|
||||
("color ='silver'", "silver", "color", u"#\u200bc0c0c0"),
|
||||
("width=66", "66", "width"), ("anchors.centerIn", "<unnamed object>"),
|
||||
("opacity", "1"), ("opacity = .2", u"0.\u200b2", "opacity")]
|
||||
# check green inner Rectangle
|
||||
runChecks("text='Rectangle'", rootIndex, checks)
|
||||
|
||||
checks = [("color", u"#\u200bff0000"), ("width", "100"), ("height", "100"),
|
||||
("radius = Math.min(width, height) / 2", "50", "radius"),
|
||||
("parent.objectName= 'mainRect'", "mainRect")]
|
||||
# check red inner Rectangle
|
||||
runChecks("text='Rectangle' occurrence='2'", rootIndex, checks)
|
||||
|
||||
checks = [("color", u"#\u200b000000"), ("font.pointSize=14", "14", "font.pointSize"),
|
||||
("font.bold", "false"), ("font.weight=Font.Bold", "75", "font.bold", "true"),
|
||||
("rotation", "0"), ("rotation = 180", "180", "rotation")]
|
||||
# check Text element
|
||||
runChecks("text='Text'", rootIndex, checks)
|
||||
# extended check must be done separately
|
||||
originalVal = useQmlJSConsole("x", None)
|
||||
if originalVal:
|
||||
# Text element uses anchors.centerIn, so modification of x should not do anything
|
||||
useQmlJSConsole("x=0", "0", "x", originalVal)
|
||||
useQmlJSConsole("anchors.centerIn", "mainRect")
|
||||
# ignore output as it has none
|
||||
useQmlJSConsole("anchors.centerIn = null", None)
|
||||
useQmlJSConsole("x = 0", "0", "x")
|
||||
|
||||
testLoggingFeatures()
|
||||
|
||||
test.log("Calling Qt.quit() from inside Qml/JS Console - inferior should quit.")
|
||||
useQmlJSConsole("Qt.quit()", "<undefined>")
|
||||
if not debuggerHasStopped():
|
||||
__stopDebugger__()
|
||||
invokeMenuItem("File", "Exit")
|
Reference in New Issue
Block a user