aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-09-13 14:29:37 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-13 14:53:08 +0000
commit4a434666c374d44cea44f1c1eb50b64c363419ef (patch)
tree93db0940accdf2ccff084d7de0bc1d333048d90a
parent3571770380257c50471ce03b9448804622871375 (diff)
Fix flaky ToolTip::test_activateShortcutWhileToolTipVisible test
Ensure that the window has focus, otherwise QQuickShortcutContext::matcher will return false. The patch also adds a logging category to allow debugging similar issues in the future without modifying Qt sources (which consumes an ungodly amount of time to do in a CI VM), and fixes a typo. Fixes: QTBUG-106465 Change-Id: I11f78479a7ed2e43ad25e8fccd7fd2af7338c6ea Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 8c6ff5a68d2da9b1520db69a56708f7e88b4e58f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quicktemplates2/qquickshortcutcontext.cpp5
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_tooltip.qml8
2 files changed, 12 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickshortcutcontext.cpp b/src/quicktemplates2/qquickshortcutcontext.cpp
index 70dc912fa8..3fdbea2865 100644
--- a/src/quicktemplates2/qquickshortcutcontext.cpp
+++ b/src/quicktemplates2/qquickshortcutcontext.cpp
@@ -44,11 +44,14 @@
#include "qquickmenu_p_p.h"
#include "qquickpopup_p.h"
+#include <QtCore/qloggingcategory.h>
#include <QtGui/qguiapplication.h>
#include <QtQuick/qquickrendercontrol.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcContextMatcher, "qt.quick.controls.shortcutcontext.matcher")
+
static bool isBlockedByPopup(QQuickItem *item)
{
if (!item || !item->window())
@@ -100,6 +103,8 @@ bool QQuickShortcutContext::matcher(QObject *obj, Qt::ShortcutContext context)
}
if (QWindow *renderWindow = QQuickRenderControl::renderWindowFor(qobject_cast<QQuickWindow *>(obj)))
obj = renderWindow;
+ qCDebug(lcContextMatcher) << "obj" << obj << "focusWindow" << QGuiApplication::focusWindow()
+ << "!isBlockedByPopup(item)" << !isBlockedByPopup(item);
return obj && obj == QGuiApplication::focusWindow() && !isBlockedByPopup(item);
default:
return false;
diff --git a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
index 3b3e0b43c1..89e179575f 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_tooltip.qml
@@ -296,7 +296,13 @@ TestCase {
function test_activateShortcutWhileToolTipVisible() {
if ((Qt.platform.pluginName === "offscreen")
|| (Qt.platform.pluginName === "minimal"))
- skip("Mouse hoovering not functional on offscreen/minimal platforms")
+ skip("Mouse hovering not functional on offscreen/minimal platforms")
+
+ // Window shortcuts (the default context for Shortcut) require the window to have focus.
+ var window = testCase.Window.window
+ verify(window)
+ window.requestActivate()
+ tryCompare(window, "active", true)
var root = createTemporaryObject(buttonAndShortcutComponent, testCase)
verify(root)