Commit b0f18491 authored by Robert Loehning's avatar Robert Loehning
Browse files

Squish: Added alternative color values to tst_qml_editor



Change-Id: I00b7df0c33fc6553fe3dc3364c6bc4dc448d72a7
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent a1fbcf7d
......@@ -156,7 +156,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e
test.warning("Could not get %s for line containing pattern '%s'" % (expectedType,line))
else:
if expectedType == "ColorTip":
__handleColorTips__(tip, expectedVals)
__handleColorTips__(tip, expectedVals, altVal)
elif expectedType == "TextTip":
__handleTextTips__(tip, expectedVals, altVal)
elif expectedType == "WidgetTip":
......@@ -203,20 +203,32 @@ def __handleTextTips__(textTip, expectedVals, alternativeVals):
# 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
# 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.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")
return
dPM = QPixmap.grabWidget(colTip, 1, 1, colTip.width-2, colTip.height-2)
img = dPM.toImage()
rgb = img.pixel(1, 1)
rgb = QColor(rgb)
if rgb.rgba() == cmp.rgba():
if rgb.rgba() == cmp.rgba() or alternativeColor and rgb.rgba() == alt.rgba():
test.passes("ColorTip verified")
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)
# match the given properties
......
......@@ -176,15 +176,17 @@ def testHovering():
lines=['color:\s*"black"', 'color:\s*"#3E606F"']
additionalKeyPresses = ["<Left>"]
expectedValues = ["black", "#3E606F"]
alternativeValues = [None, "#39616B"]
expectedTypes = ["ColorTip", "ColorTip"]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
doubleClickFile(navTree, "Core.ListMenu\\.qml")
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
lines=['Rectangle\s*\{.*color:\s*"#D1DBBD"', 'NumberAnimation\s*\{\s*.*Easing.OutQuint\s*\}']
additionalKeyPresses = ["<Left>", "<Left>", "<Left>", "<Left>"]
expectedTypes = ["ColorTip", "TextTip"]
expectedValues = ["#D1DBBD", {"text":"number"}]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
alternativeValues = ["#D6DBBD", None]
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
def doubleClickFile(navTree, file):
global templateDir
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment