diff options
Diffstat (limited to 'tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp index a08e51cafd..fc836dec4a 100644 --- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp +++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> @@ -115,11 +90,11 @@ void tst_QScrollBar::task_209492() QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int))); QCOMPARE(scrollArea.scrollCount, 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Simulate a mouse click on the "scroll down button". const QPoint pressPoint(verticalScrollBar->width() / 2, verticalScrollBar->height() - 10); - const QPoint globalPressPoint = verticalScrollBar->mapToGlobal(globalPressPoint); + const QPoint globalPressPoint = verticalScrollBar->mapToGlobal(pressPoint); QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, {}); QApplication::sendEvent(verticalScrollBar, &mousePressEvent); @@ -134,7 +109,7 @@ void tst_QScrollBar::task_209492() QSKIP("The result depends on system setting and is not relevant on Mac"); #endif QCOMPARE(scrollArea.scrollCount, 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } #if QT_CONFIG(wheelevent) @@ -184,7 +159,7 @@ void tst_QScrollBar::QTBUG_42871() QSignalSpy spy(&scrollBarWidget, SIGNAL(actionTriggered(int))); QVERIFY(spy.isValid()); QCOMPARE(myHandler.updatesCount, 0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); // Simulate a mouse click on the "scroll down button". const QPoint pressPoint(scrollBarWidget.width() / 2, scrollBarWidget.height() - 10); @@ -192,13 +167,20 @@ void tst_QScrollBar::QTBUG_42871() QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, {}); QApplication::sendEvent(&scrollBarWidget, &mousePressEvent); + QElapsedTimer timer; + timer.start(); QTest::qWait(1); QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint, Qt::LeftButton, Qt::LeftButton, {}); QApplication::sendEvent(&scrollBarWidget, &mouseReleaseEvent); + if (timer.elapsed() > 40) { + // took too long, we need to tolerate auto-repeat + if (myHandler.updatesCount > 1) + QEXPECT_FAIL("", "Took too long to process events, repeat timer fired", Continue); + } // Check that the action was triggered once. QCOMPARE(myHandler.updatesCount, 1); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), myHandler.updatesCount); } QTEST_MAIN(tst_QScrollBar) |