summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@digia.com>2013-09-12 17:24:00 +0200
committerRobert Loehning <robert.loehning@digia.com>2013-09-18 11:56:22 +0200
commitb0f18491c947192da651965e346efce6dc0deb42 (patch)
treee8c3844712997c80ab5c2e775c3184ab6815b3fb
parenta1fbcf7d0872ad91b60f535a6ba5c91ee413a808 (diff)
downloadqt-creator-b0f18491c947192da651965e346efce6dc0deb42.tar.gz
Squish: Added alternative color values to tst_qml_editor
Change-Id: I00b7df0c33fc6553fe3dc3364c6bc4dc448d72a7 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r--tests/system/shared/editor_utils.py22
-rw-r--r--tests/system/suite_editors/tst_qml_editor/test.py6
2 files changed, 21 insertions, 7 deletions
diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py
index e7bd16cada..ae211bb992 100644
--- a/tests/system/shared/editor_utils.py
+++ b/tests/system/shared/editor_utils.py
@@ -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
diff --git a/tests/system/suite_editors/tst_qml_editor/test.py b/tests/system/suite_editors/tst_qml_editor/test.py
index 06a256a015..ae2a3f12b6 100644
--- a/tests/system/suite_editors/tst_qml_editor/test.py
+++ b/tests/system/suite_editors/tst_qml_editor/test.py
@@ -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