diff --git a/src/libs/utils/tooltip/tooltip.cpp b/src/libs/utils/tooltip/tooltip.cpp index 2546ae52177..2885f53ed7f 100644 --- a/src/libs/utils/tooltip/tooltip.cpp +++ b/src/libs/utils/tooltip/tooltip.cpp @@ -107,6 +107,7 @@ void ToolTip::show(const QPoint &pos, layout->setContentsMargins(0, 0, 0, 0); tooltipWidget->setLayout(layout); auto label = new QLabel; + label->setObjectName("qcWidgetTipTopLabel"); label->setTextFormat(format); label->setText(content); layout->addWidget(label); diff --git a/src/plugins/texteditor/basehoverhandler.cpp b/src/plugins/texteditor/basehoverhandler.cpp index 8d7fcad5173..34eb326b812 100644 --- a/src/plugins/texteditor/basehoverhandler.cpp +++ b/src/plugins/texteditor/basehoverhandler.cpp @@ -163,10 +163,13 @@ void BaseHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPoi auto layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); auto label = new QLabel; + label->setObjectName("qcWidgetTipTopLabel"); label->setTextFormat(m_textFormat); label->setText(m_toolTip); layout->addWidget(label); - layout->addWidget(new QLabel("
" + helpContents)); + auto helpContentLabel = new QLabel("
" + helpContents); + helpContentLabel->setObjectName("qcWidgetTipHelpLabel"); + layout->addWidget(helpContentLabel); Utils::ToolTip::show(point, layout, editorWidget, helpItem); } } diff --git a/tests/system/shared/editor_utils.py b/tests/system/shared/editor_utils.py index 8410e986ef9..34b1eca7c88 100644 --- a/tests/system/shared/editor_utils.py +++ b/tests/system/shared/editor_utils.py @@ -159,7 +159,7 @@ def verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, e elif expectedType == "TextTip": __handleTextTips__(tip, expectedVals, altVal) 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) 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'" % (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) # match the given properties # param properties a dict holding the properties to check diff --git a/tests/system/suite_editors/tst_qml_editor/test.py b/tests/system/suite_editors/tst_qml_editor/test.py index ecd9ab008e6..c26207ea6ec 100644 --- a/tests/system/suite_editors/tst_qml_editor/test.py +++ b/tests/system/suite_editors/tst_qml_editor/test.py @@ -122,35 +122,26 @@ def testHovering(): else: home = "" additionalKeyPresses = [home, ""] - expectedTypes = ["TextTip", "TextTip"] + expectedTypes = ["WidgetTip", "WidgetTip"] expectedValues = [ - {'text':'

FocusScope


\n

Explicitly ' - 'creates a focus scope

  
'}, - {'text':'

Rectangle


\n

Paints a filled rectangle with an ' - 'optional border

  
'} + {'text':'FocusScope
\n

Explicitly creates a focus scope.

'}, + {'text':'Rectangle
\n

Paints a filled rectangle with an optional border.

'} ] - alternativeValues = [{"text":"

FocusScope

"}, {"text":"

Rectangle

"}] - verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues, alternativeValues) + verifyHoveringOnEditor(editor, lines, additionalKeyPresses, expectedTypes, expectedValues) test.log("Testing hovering properties") openDocument(focusDocumentPath % "focus\\.qml") editor = waitForObject(":Qt Creator_QmlJSEditor::QmlJSTextEditorWidget") 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 = [ {'text':'

boolean


This property indicates whether the item has focus ' '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, input will be given active focus ' 'when scope gains active focus.

  
'}, - {'text':'

string


This property holds the color used to fill the rectangle.' - '

  
'}, - {'text':'

State


This property holds the list of possible states for this item. ' - '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.' - '

  
'}, - {'text':'

Transition


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.' - '

  
'} + {'text':'string'}, + {'text':'State'}, + {'text':'Transition'} ] alternativeValues = [{"text":"

boolean

"}, {"text":"

string

"}, {"text":"

State

"}, {"text":"

Transition

"}]