forked from qt-creator/qt-creator
Make WidgetTips Squish-testable
Change-Id: I337fdca3541c5b2fb8f09ab2d7721b8950c0bea9 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -107,6 +107,7 @@ void ToolTip::show(const QPoint &pos,
|
|||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
tooltipWidget->setLayout(layout);
|
tooltipWidget->setLayout(layout);
|
||||||
auto label = new QLabel;
|
auto label = new QLabel;
|
||||||
|
label->setObjectName("qcWidgetTipTopLabel");
|
||||||
label->setTextFormat(format);
|
label->setTextFormat(format);
|
||||||
label->setText(content);
|
label->setText(content);
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
|
|||||||
@@ -163,10 +163,13 @@ void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoi
|
|||||||
auto layout = new QVBoxLayout;
|
auto layout = new QVBoxLayout;
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
auto label = new QLabel;
|
auto label = new QLabel;
|
||||||
|
label->setObjectName("qcWidgetTipTopLabel");
|
||||||
label->setTextFormat(m_textFormat);
|
label->setTextFormat(m_textFormat);
|
||||||
label->setText(m_toolTip);
|
label->setText(m_toolTip);
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
layout->addWidget(new QLabel("<hr/>" + helpContents));
|
auto helpContentLabel = new QLabel("<hr/>" + helpContents);
|
||||||
|
helpContentLabel->setObjectName("qcWidgetTipHelpLabel");
|
||||||
|
layout->addWidget(helpContentLabel);
|
||||||
Utils::ToolTip::show(point, layout, editorWidget, helpItem);
|
Utils::ToolTip::show(point, layout, editorWidget, helpItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e
|
|||||||
elif expectedType == "TextTip":
|
elif expectedType == "TextTip":
|
||||||
__handleTextTips__(tip, expectedVals, altVal)
|
__handleTextTips__(tip, expectedVals, altVal)
|
||||||
elif expectedType == "WidgetTip":
|
elif expectedType == "WidgetTip":
|
||||||
test.warning("Sorry - WidgetTip checks aren't implemented yet.")
|
__handleWidgetTips__(tip, expectedVals)
|
||||||
sendEvent("QMouseEvent", editor, QEvent.MouseMove, 0, -50, Qt.NoButton, 0)
|
sendEvent("QMouseEvent", editor, QEvent.MouseMove, 0, -50, Qt.NoButton, 0)
|
||||||
waitFor("isNull(tip)", 10000)
|
waitFor("isNull(tip)", 10000)
|
||||||
|
|
||||||
@@ -228,6 +228,19 @@ def __handleColorTips__(colTip, expectedColor, alternativeColor):
|
|||||||
test.fail("ColorTip does not match - expected color '%X'%s got '%X'"
|
test.fail("ColorTip does not match - expected color '%X'%s got '%X'"
|
||||||
% (uint(cmp.rgb()), altColorText, uint(rgb.rgb())))
|
% (uint(cmp.rgb()), altColorText, uint(rgb.rgb())))
|
||||||
|
|
||||||
|
# helper function that handles verification of WidgetTip hoverings
|
||||||
|
# param widgetTip the WidgetTip object
|
||||||
|
# param expectedVals a dict holding property value pairs that must match
|
||||||
|
def __handleWidgetTips__(widgetTip, expectedVals):
|
||||||
|
toplabel = waitForObject("{type='QLabel' objectName='qcWidgetTipTopLabel' visible='1'}")
|
||||||
|
foundText = str(toplabel.text)
|
||||||
|
try:
|
||||||
|
helplabel = waitForObject("{type='QLabel' objectName='qcWidgetTipHelpLabel' visible='1'}", 1000)
|
||||||
|
foundText += str(helplabel.text)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
test.compare(foundText, expectedVals["text"])
|
||||||
|
|
||||||
# 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
|
||||||
# param properties a dict holding the properties to check
|
# param properties a dict holding the properties to check
|
||||||
|
|||||||
@@ -122,35 +122,26 @@ def testHovering():
|
|||||||
else:
|
else:
|
||||||
home = "<Home>"
|
home = "<Home>"
|
||||||
additionalKeyPresses = [home, "<Right>"]
|
additionalKeyPresses = [home, "<Right>"]
|
||||||
expectedTypes = ["TextTip", "TextTip"]
|
expectedTypes = ["WidgetTip", "WidgetTip"]
|
||||||
expectedValues = [
|
expectedValues = [
|
||||||
{'text':'<table><tr><td valign=middle><p>FocusScope</p><hr/><p>\n<p>Explicitly '
|
{'text':'FocusScope<hr/>\n<p>Explicitly creates a focus scope.</p>'},
|
||||||
'creates a focus scope </p></p></td><td> <img src=":/utils/tooltip/images/f1.png"></td></tr></table>'},
|
{'text':'Rectangle<hr/>\n<p>Paints a filled rectangle with an optional border.</p>'}
|
||||||
{'text':'<table><tr><td valign=middle><p>Rectangle</p><hr/><p>\n<p>Paints a filled rectangle with an '
|
|
||||||
'optional border </p></p></td><td> <img src=":/utils/tooltip/images/f1.png"></td></tr></table>'}
|
|
||||||
]
|
]
|
||||||
alternativeValues = [{"text":"<p>FocusScope</p>"}, {"text":"<p>Rectangle</p>"}]
|
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues)
|
||||||
verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues)
|
|
||||||
test.log("Testing hovering properties")
|
test.log("Testing hovering properties")
|
||||||
openDocument(focusDocumentPath % "focus\\.qml")
|
openDocument(focusDocumentPath % "focus\\.qml")
|
||||||
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
|
editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget")
|
||||||
lines = ['focus:\s*true', 'color:\s*"black"', 'states:\s*State\s*\{', 'transitions:\s*Transition\s*\{']
|
lines = ['focus:\s*true', 'color:\s*"black"', 'states:\s*State\s*\{', 'transitions:\s*Transition\s*\{']
|
||||||
expectedTypes = ["TextTip", "TextTip", "TextTip", "TextTip"]
|
expectedTypes = ["TextTip", "WidgetTip", "WidgetTip", "WidgetTip"]
|
||||||
expectedValues = [
|
expectedValues = [
|
||||||
{'text':'<table><tr><td valign=middle><p>boolean</p><hr/><p><p>This property indicates whether the item has focus '
|
{'text':'<table><tr><td valign=middle><p>boolean</p><hr/><p><p>This property indicates whether the item has focus '
|
||||||
'within the enclosing focus scope. If true, this item will gain active focus when the enclosing '
|
'within the enclosing focus scope. If true, this item will gain active focus when the enclosing '
|
||||||
'focus scope gains active focus. In the following example, <tt>input</tt> will be given active focus '
|
'focus scope gains active focus. In the following example, <tt>input</tt> will be given active focus '
|
||||||
'when <tt>scope</tt> gains active focus.</p></p></td><td> <img src=":/utils/tooltip/images/f1.png"'
|
'when <tt>scope</tt> gains active focus.</p></p></td><td> <img src=":/utils/tooltip/images/f1.png"'
|
||||||
'></td></tr></table>'},
|
'></td></tr></table>'},
|
||||||
{'text':'<table><tr><td valign=middle><p>string</p><hr/><p><p>This property holds the color used to fill the rectangle.'
|
{'text':'string'},
|
||||||
'</p></p></td><td> <img src=":/utils/tooltip/images/f1.png"></td></tr></table>'},
|
{'text':'State'},
|
||||||
{'text':'<table><tr><td valign=middle><p>State</p><hr/><p><p>This property holds the list of possible states for this item. '
|
{'text':'Transition'}
|
||||||
'To change the state of this item, set the state property to one of these states, or set the state property '
|
|
||||||
'to an empty string to revert the item to its default state.'
|
|
||||||
'</p></p></td><td> <img src=":/utils/tooltip/images/f1.png"></td></tr></table>'},
|
|
||||||
{'text':'<table><tr><td valign=middle><p>Transition</p><hr/><p><p>This property holds the list of transitions for this item. '
|
|
||||||
'These define the transitions to be applied to the item whenever it changes its state.'
|
|
||||||
'</p></p></td><td> <img src=":/utils/tooltip/images/f1.png"></td></tr></table>'}
|
|
||||||
]
|
]
|
||||||
alternativeValues = [{"text":"<p>boolean</p>"}, {"text":"<p>string</p>"},
|
alternativeValues = [{"text":"<p>boolean</p>"}, {"text":"<p>string</p>"},
|
||||||
{"text":"<p>State</p>"}, {"text":"<p>Transition</p>"}]
|
{"text":"<p>State</p>"}, {"text":"<p>Transition</p>"}]
|
||||||
|
|||||||
Reference in New Issue
Block a user