From 8ec8439755e33aee40db14f8a2b5073e420294e7 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 5 Jun 2012 14:24:18 +1000 Subject: tst_qtoolbutton: stabilize and improve failure message Allow for a little more leeway in timers. Task-number: QTBUG-26004 Change-Id: I59936d0f675b7f734e04b3f5e63631c74ca4f163 Reviewed-by: Toby Tomkins Reviewed-by: Kalle Lehtonen (cherry picked from commit 4eecbf3b842afcfb91d78552ce19d2c0b8f8c53a) Reviewed-by: Sergio Ahumada --- tests/auto/qtoolbutton/tst_qtoolbutton.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp index 98a673e..1a9e7cb 100644 --- a/tests/auto/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/qtoolbutton/tst_qtoolbutton.cpp @@ -224,8 +224,13 @@ void tst_QToolButton::task176137_autoRepeatOfAction() QTest::mousePress ( &tb, Qt::LeftButton); QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 3000); qreal expected = (3000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1; - //we check that the difference is less than 10% (on some systems timers are not super accurate) - QVERIFY ( qAbs( (expected - repeatSpy.count()) / expected) < 0.1); + //we check that the difference is small (on some systems timers are not super accurate) + qreal diff = (expected - repeatSpy.count()) / expected; + QVERIFY2(qAbs(diff) < 0.2, qPrintable( + QString("expected: %1, actual: %2, diff (fraction): %3") + .arg(expected) + .arg(repeatSpy.count()) + .arg(diff))); } -- cgit v0.12