forked from qt-creator/qt-creator
Squish: Added alternative color values to tst_qml_editor
Change-Id: I00b7df0c33fc6553fe3dc3364c6bc4dc448d72a7 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -156,7 +156,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e
|
|||||||
test.warning("Could not get %s for line containing pattern '%s'" % (expectedType,line))
|
test.warning("Could not get %s for line containing pattern '%s'" % (expectedType,line))
|
||||||
else:
|
else:
|
||||||
if expectedType == "ColorTip":
|
if expectedType == "ColorTip":
|
||||||
__handleColorTips__(tip, expectedVals)
|
__handleColorTips__(tip, expectedVals, altVal)
|
||||||
elif expectedType == "TextTip":
|
elif expectedType == "TextTip":
|
||||||
__handleTextTips__(tip, expectedVals, altVal)
|
__handleTextTips__(tip, expectedVals, altVal)
|
||||||
elif expectedType == "WidgetTip":
|
elif expectedType == "WidgetTip":
|
||||||
@@ -203,20 +203,32 @@ def __handleTextTips__(textTip, expectedVals, alternativeVals):
|
|||||||
# param expectedColor a single string holding the color the ColorTip should have
|
# param expectedColor a single string holding the color the ColorTip should have
|
||||||
# Attention: because of being a non-standard Qt object it's not possible to
|
# Attention: because of being a non-standard Qt object it's not possible to
|
||||||
# verify colors which are (semi-)transparent!
|
# verify colors which are (semi-)transparent!
|
||||||
def __handleColorTips__(colTip, expectedColor):
|
def __handleColorTips__(colTip, expectedColor, alternativeColor):
|
||||||
|
def uint(value):
|
||||||
|
if value < 0:
|
||||||
|
return 0xffffffff + value + 1
|
||||||
|
return value
|
||||||
|
|
||||||
cmp = QColor()
|
cmp = QColor()
|
||||||
cmp.setNamedColor(expectedColor)
|
cmp.setNamedColor(expectedColor)
|
||||||
if cmp.alpha() != 255:
|
if alternativeColor:
|
||||||
|
alt = QColor()
|
||||||
|
alt.setNamedColor(alternativeColor)
|
||||||
|
if cmp.alpha() != 255 or alternativeColor and alt.alpha() != 255:
|
||||||
test.warning("Cannot handle transparent colors - cancelling this verification")
|
test.warning("Cannot handle transparent colors - cancelling this verification")
|
||||||
return
|
return
|
||||||
dPM = QPixmap.grabWidget(colTip, 1, 1, colTip.width-2, colTip.height-2)
|
dPM = QPixmap.grabWidget(colTip, 1, 1, colTip.width-2, colTip.height-2)
|
||||||
img = dPM.toImage()
|
img = dPM.toImage()
|
||||||
rgb = img.pixel(1, 1)
|
rgb = img.pixel(1, 1)
|
||||||
rgb = QColor(rgb)
|
rgb = QColor(rgb)
|
||||||
if rgb.rgba() == cmp.rgba():
|
if rgb.rgba() == cmp.rgba() or alternativeColor and rgb.rgba() == alt.rgba():
|
||||||
test.passes("ColorTip verified")
|
test.passes("ColorTip verified")
|
||||||
else:
|
else:
|
||||||
test.fail("ColorTip does not match - expected color '%s' got '%s'" % (cmp.rgb(), rgb.rgb()))
|
altColorText = ""
|
||||||
|
if alternativeColor:
|
||||||
|
altColorText = " or '%X'" % uint(alt.rgb())
|
||||||
|
test.fail("ColorTip does not match - expected color '%X'%s got '%X'"
|
||||||
|
% (uint(cmp.rgb()), altColorText, uint(rgb.rgb())))
|
||||||
|
|
||||||
# function that checks whether all expected properties (including their values)
|
# function that checks whether all expected properties (including their values)
|
||||||
# match the given properties
|
# match the given properties
|
||||||
|
@@ -176,15 +176,17 @@ def testHovering():
|
|||||||
lines=['color:\s*"black"', 'color:\s*"#3E606F"']
|
lines=['color:\s*"black"', 'color:\s*"#3E606F"']
|
||||||
additionalKeyPresses = ["<Left>"]
|
additionalKeyPresses = ["<Left>"]
|
||||||
expectedValues = ["black", "#3E606F"]
|
expectedValues = ["black", "#3E606F"]
|
||||||
|
alternativeValues = [None, "#39616B"]
|
||||||
expectedTypes = ["ColorTip", "ColorTip"]
|
expectedTypes = ["ColorTip", "ColorTip"]
|
||||||
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
|
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
|
||||||
doubleClickFile(navTree, "Core.ListMenu\\.qml")
|
doubleClickFile(navTree, "Core.ListMenu\\.qml")
|
||||||
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
|
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
|
||||||
lines=['Rectangle\s*\{.*color:\s*"#D1DBBD"', 'NumberAnimation\s*\{\s*.*Easing.OutQuint\s*\}']
|
lines=['Rectangle\s*\{.*color:\s*"#D1DBBD"', 'NumberAnimation\s*\{\s*.*Easing.OutQuint\s*\}']
|
||||||
additionalKeyPresses = ["<Left>", "<Left>", "<Left>", "<Left>"]
|
additionalKeyPresses = ["<Left>", "<Left>", "<Left>", "<Left>"]
|
||||||
expectedTypes = ["ColorTip", "TextTip"]
|
expectedTypes = ["ColorTip", "TextTip"]
|
||||||
expectedValues = ["#D1DBBD", {"text":"number"}]
|
expectedValues = ["#D1DBBD", {"text":"number"}]
|
||||||
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
|
alternativeValues = ["#D6DBBD", None]
|
||||||
|
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
|
||||||
|
|
||||||
def doubleClickFile(navTree, file):
|
def doubleClickFile(navTree, file):
|
||||||
global templateDir
|
global templateDir
|
||||||
|
Reference in New Issue
Block a user