diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-04-12 18:04:41 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-05-09 10:31:33 +0000 |
commit | 89de72f370157aaf4e5c9f7a6fe24ecd83e9df09 (patch) | |
tree | 310c24bbe6bacacd0e59cc83cef6b9da0a9dea22 | |
parent | 9038ccbc6c45579536f006e82c500f527ed6a799 (diff) |
Rewrite tst_QQuickHeaderView::testOrientation
This test was behaving differently on different operating systems.
On desktop systems it was drawing all the QML elements only when
QTest::qWaitForWindowActive() was called, after setSyncDirection()
was already called for both header views with incorrect parameters.
During the drawing all the necessary checks were executed, so the
invalid sync directions were discarded and the test passed.
On Android, however, the drawing of all elements happend right after
the component.create() call, so there was nothing to redraw when the
test reached QTest::qWaitForWindowActive().
As a result, the test was failing.
The test was also missing calls to setSyncView(), so the headers
were not rebuilt once setSyncDirection() was called. The test used
a hack with explicitly calling flick(), but that didn't seem to
help.
This patch introduces a second dummy QQuickTableView, and uses it
as a sync view for the headers. Once that is done, each call to
setSyncDirection() will force a rebuild, which leads to validation
of the sync directions. As a result, the invalid parameters are
discarded. So we do not need to call flick() or use any other hacks
to force HeaderView updates.
Fixes: QTBUG-100177
Change-Id: I06d1503eb55e59077293763ce3e659a40daca8a6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 71964c066a8845d90959471d0107c8d13754f127)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tests/auto/quickcontrols2/qquickheaderview/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp | 17 |
2 files changed, 13 insertions, 7 deletions
diff --git a/tests/auto/quickcontrols2/qquickheaderview/BLACKLIST b/tests/auto/quickcontrols2/qquickheaderview/BLACKLIST deleted file mode 100644 index 313c412deb..0000000000 --- a/tests/auto/quickcontrols2/qquickheaderview/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -# QTBUG-100177 -[testOrientation] -android diff --git a/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp index 5f8ad65248..62593f60cc 100644 --- a/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp +++ b/tests/auto/quickcontrols2/qquickheaderview/tst_qquickheaderview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -28,6 +28,7 @@ #include <QtTest/qsignalspy.h> #include <QtTest/qtest.h> +#include <QtQuickTest/quicktest.h> #include <QAbstractItemModelTester> #include <QtQml/QQmlEngine> @@ -301,6 +302,13 @@ void tst_QQuickHeaderView::testOrientation() QScopedPointer<QObject> root(component.create()); QVERIFY2(root, qPrintable(component.errorString())); + // Make sure that the window is shown at this point, so that the test + // behaves similarly on all platforms + QVERIFY(QTest::qWaitForWindowActive(qobject_cast<QWindow *>(root.data()))); + + // If we want to make use of syncDirection, we need to set syncView as well. + // For that we need to create a second dummy table view. + QQuickTableView otherView; auto hhv = root->findChild<QQuickHorizontalHeaderView *>("horizontalHeader"); QVERIFY(hhv); @@ -309,13 +317,14 @@ void tst_QQuickHeaderView::testOrientation() auto vhv = root->findChild<QQuickVerticalHeaderView *>("verticalHeader"); QVERIFY(vhv); + hhv->setSyncView(&otherView); hhv->setSyncDirection(Qt::Vertical); - hhv->flick(10, 20); + QVERIFY(QQuickTest::qWaitForItemPolished(hhv)); + vhv->setSyncView(&otherView); vhv->setSyncDirection(Qt::Horizontal); - vhv->flick(20, 10); + QVERIFY(QQuickTest::qWaitForItemPolished(vhv)); - QVERIFY(QTest::qWaitForWindowActive(qobject_cast<QWindow *>(root.data()))); // Explicitly setting a different synDirection is ignored QCOMPARE(hhv->syncDirection(), Qt::Horizontal); QCOMPARE(hhv->flickableDirection(), QQuickFlickable::HorizontalFlick); |