summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@theqtcompany.com>2016-06-14 16:15:47 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2016-06-24 09:40:33 +0000
commitcc8fc6ca09e86a0433d69aaa8c4512da27790049 (patch)
treec50f65a0adb8c79cd3cbbd372969b6932e92afb6 /tests
parent964963f76acbcc6df8f021b5b36dbc5e726027b6 (diff)
Fix inputEventForwardingDisabledWhenActiveFocusOnPressDisabled test.
Test was flaky due to a couple of reasons, mainly: 1) Size of event recording widget did not match web view size, which led to some events not being caught. 2) There were some bogus QHoverEvents being sent by QQuickWindow whenever a QQuickItem is repositioned (can happen when using a tiling window manager on a Linux machine). 3) Usual timing issues. Change-Id: Idd9d4fa6bd65095f98125196025e0ad560025348 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 7e684a35a..8ea644c32 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -514,9 +514,10 @@ void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled_data()
}
class MouseTouchEventRecordingItem : public QQuickItem {
+ Q_OBJECT
public:
- explicit MouseTouchEventRecordingItem(QQuickItem *parent = 0) :
- QQuickItem(parent), m_eventCounter(0) {
+ explicit MouseTouchEventRecordingItem(QQuickItem* child, QQuickItem *parent = 0) :
+ QQuickItem(parent), m_eventCounter(0), m_child(child) {
setFlag(ItemHasContents);
setAcceptedMouseButtons(Qt::AllButtons);
setAcceptHoverEvents(true);
@@ -536,9 +537,6 @@ public:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
case QEvent::TouchCancel:
- case QEvent::HoverEnter:
- case QEvent::HoverMove:
- case QEvent::HoverLeave:
++m_eventCounter;
event->accept();
return true;
@@ -558,16 +556,34 @@ public:
return m_eventCounter;
}
+public Q_SLOTS:
+ void changeWidth() {
+ if (m_child)
+ setWidth(m_child->width());
+ }
+
+ void changeHeight() {
+ if (m_child)
+ setHeight(m_child->height());
+ }
+
private:
int m_eventCounter;
+ QQuickItem *m_child;
};
void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPressDisabled()
{
QQuickWebEngineView *view = webEngineView();
- MouseTouchEventRecordingItem item;
+ MouseTouchEventRecordingItem item(view);
item.setParentItem(m_window->contentItem());
- item.setSize(QSizeF(640, 480));
+
+ // Resize the event recorder whenever the view is resized, so that all event positions
+ // are contained in both of the item regions.
+ QObject::connect(view, &QQuickItem::widthChanged, &item,
+ &MouseTouchEventRecordingItem::changeWidth);
+ QObject::connect(view, &QQuickItem::heightChanged, &item,
+ &MouseTouchEventRecordingItem::changeHeight);
view->setParentItem(&item);
view->setSize(QSizeF(640, 480));
m_window->show();
@@ -575,6 +591,7 @@ void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPress
// Simulate click and move of mouse, so that last known position in the application
// is updated, thus a mouse move event is not generated when we don't expect it.
QTest::mouseClick(view->window(), Qt::LeftButton);
+ QTRY_COMPARE(item.eventCount(), 2);
item.clearEventCount();
// First disable view, so it does not receive focus on page load.