From 8e93988cce4af9f1dab452152a0995f400f2d7d9 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Tue, 6 Mar 2018 15:04:37 +0200 Subject: Blacklist tst_QProcess::softExitInSlots on Windows Task-number: QTBUG-66903 Task-number: QTBUG-66216 Change-Id: I4a36d6f4b980f016e11fd7a8840dbc60a2964e83 Reviewed-by: Sami Nurmenniemi Reviewed-by: Ville Voutilainen --- tests/auto/corelib/io/qprocess/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST index a278af12d3..b355bb0f75 100644 --- a/tests/auto/corelib/io/qprocess/BLACKLIST +++ b/tests/auto/corelib/io/qprocess/BLACKLIST @@ -4,3 +4,6 @@ redhatenterpriselinuxworkstation-6.6 [fileWriterProcess] msvc-2015 ci msvc-2017 ci +[softExitInSlots] +# QTBUG-66903 +windows -- cgit v1.2.3 From 927db42882569a23a004722598ff02f57391c361 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 21 Mar 2018 19:29:39 +0200 Subject: tst_QWinEventNotifier: fix flakiness disableNotifiersInActivatedSlot(disable_signaled2) fails, if a signaled state of the event #2 is detected prior to the event #1. In this case, we get a timeout on waiting for event #1 which was disabled by the first notification. So, accept a disabled state of the notifier in condition for successful exit from the loop. Change-Id: I8a2fe76f8ec9362556d1ca1fe0be39a93ed58977 Reviewed-by: Joerg Bornemann --- .../corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 76efa008f7..e2a0c2dad3 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -125,6 +125,7 @@ public: HANDLE eventHandle() const { return notifier.handle(); } int numberOfTimesActivated() const { return activatedCount; } void setEnabled(bool b) { notifier.setEnabled(b); } + bool isEnabled() const { return notifier.isEnabled(); } signals: void activated(); @@ -218,8 +219,9 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot() for (int i = 0; i < count; ++i) events[i].reset(new EventWithNotifier); - auto isActivatedOrNull = [&events](int i) { - return !events.at(i) || events.at(i)->numberOfTimesActivated() > 0; + auto isActivatedOrDisabled = [&events](int i) { + return !events.at(i) || !events.at(i)->isEnabled() + || events.at(i)->numberOfTimesActivated() > 0; }; for (auto &e : events) { @@ -230,8 +232,10 @@ void tst_QWinEventNotifier::disableNotifiersInActivatedSlot() else events.at(i)->setEnabled(false); } - if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), isActivatedOrNull)) + if (std::all_of(notifiersToSignal.begin(), notifiersToSignal.end(), + isActivatedOrDisabled)) { QTimer::singleShot(0, &QTestEventLoop::instance(), SLOT(exitLoop())); + } }); } for (int i : notifiersToSignal) -- cgit v1.2.3 From edf96b984d406cb7c00eb83f1b7e8588ac663c1f Mon Sep 17 00:00:00 2001 From: Eric Lemanissier Date: Fri, 9 Mar 2018 10:18:02 +0100 Subject: fixup oversight in rvalue overloads of operator+=() and operator<<() ammends 4dee5446bee9c7417bf6f5dc44294a0b7238a9ba Change-Id: Ia0ca27644eb71815a93d6e76681b8a9e61a4e7ab Reviewed-by: Allan Sandfeld Jensen --- .../tools/qvarlengtharray/tst_qvarlengtharray.cpp | 59 +++++++++++++++++++--- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 23 ++++++++- 2 files changed, 73 insertions(+), 9 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index ac4c8c8d4e..5737db760c 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -957,19 +957,21 @@ void tst_QVarLengthArray::insertMove() QCOMPARE(MyBase::copyCount, 0); { - QVarLengthArray vec; + QVarLengthArray vec; MyMovable m1; MyMovable m2; MyMovable m3; MyMovable m4; + MyMovable m5; + MyMovable m6; QCOMPARE(MyBase::copyCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); vec.append(std::move(m3)); QVERIFY(m3.wasConstructedAt(nullptr)); QVERIFY(vec.at(0).wasConstructedAt(&m3)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 1); vec.push_back(std::move(m4)); @@ -977,7 +979,7 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(0).wasConstructedAt(&m3)); QVERIFY(vec.at(1).wasConstructedAt(&m4)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 2); vec.prepend(std::move(m1)); @@ -986,7 +988,7 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(1).wasConstructedAt(&m3)); QVERIFY(vec.at(2).wasConstructedAt(&m4)); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::movedCount, 3); vec.insert(1, std::move(m2)); @@ -995,11 +997,34 @@ void tst_QVarLengthArray::insertMove() QVERIFY(vec.at(1).wasConstructedAt(&m2)); QVERIFY(vec.at(2).wasConstructedAt(&m3)); QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QCOMPARE(MyBase::errorCount, 0); + QCOMPARE(MyBase::liveCount, 6); + QCOMPARE(MyBase::movedCount, 4); + + vec += std::move(m5); + QVERIFY(m5.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QCOMPARE(MyBase::errorCount, 0); + QCOMPARE(MyBase::liveCount, 6); + QCOMPARE(MyBase::movedCount, 5); + + vec << std::move(m6); + QVERIFY(m6.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QVERIFY(vec.at(5).wasConstructedAt(&m6)); QCOMPARE(MyBase::copyCount, 0); - QCOMPARE(MyBase::liveCount, 4); + QCOMPARE(MyBase::liveCount, 6); QCOMPARE(MyBase::errorCount, 0); - QCOMPARE(MyBase::movedCount, 4); + QCOMPARE(MyBase::movedCount, 6); } QCOMPARE(MyBase::liveCount, 0); QCOMPARE(MyBase::errorCount, 0); @@ -1013,10 +1038,14 @@ void tst_QVarLengthArray::nonCopyable() std::unique_ptr val2(new int(2)); std::unique_ptr val3(new int(3)); std::unique_ptr val4(new int(4)); + std::unique_ptr val5(new int(5)); + std::unique_ptr val6(new int(6)); int *const ptr1 = val1.get(); int *const ptr2 = val2.get(); int *const ptr3 = val3.get(); int *const ptr4 = val4.get(); + int *const ptr5 = val5.get(); + int *const ptr6 = val6.get(); vec.append(std::move(val3)); QVERIFY(!val3); @@ -1035,6 +1064,22 @@ void tst_QVarLengthArray::nonCopyable() QVERIFY(ptr1 == vec.at(0).get()); QVERIFY(ptr2 == vec.at(1).get()); QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + vec += std::move(val5); + QVERIFY(!val5); + QVERIFY(ptr1 == vec.at(0).get()); + QVERIFY(ptr2 == vec.at(1).get()); + QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + QVERIFY(ptr5 == vec.at(4).get()); + vec << std::move(val6); + QVERIFY(!val6); + QVERIFY(ptr1 == vec.at(0).get()); + QVERIFY(ptr2 == vec.at(1).get()); + QVERIFY(ptr3 == vec.at(2).get()); + QVERIFY(ptr4 == vec.at(3).get()); + QVERIFY(ptr5 == vec.at(4).get()); + QVERIFY(ptr6 == vec.at(5).get()); } QTEST_APPLESS_MAIN(tst_QVarLengthArray) diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 600291715a..a7faeb5ca5 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -2895,12 +2895,14 @@ void tst_QVector::insertMove() const const int instancesCount = Movable::counter.loadAcquire(); { QVector vec; - vec.reserve(5); + vec.reserve(7); Movable m0; Movable m1; Movable m2; Movable m3; Movable m4; + Movable m5; + Movable m6; vec.append(std::move(m3)); QVERIFY(m3.wasConstructedAt(nullptr)); @@ -2920,6 +2922,21 @@ void tst_QVector::insertMove() const QVERIFY(vec.at(1).wasConstructedAt(&m2)); QVERIFY(vec.at(2).wasConstructedAt(&m3)); QVERIFY(vec.at(3).wasConstructedAt(&m4)); + vec += std::move(m5); + QVERIFY(m5.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + vec << std::move(m6); + QVERIFY(m6.wasConstructedAt(nullptr)); + QVERIFY(vec.at(0).wasConstructedAt(&m1)); + QVERIFY(vec.at(1).wasConstructedAt(&m2)); + QVERIFY(vec.at(2).wasConstructedAt(&m3)); + QVERIFY(vec.at(3).wasConstructedAt(&m4)); + QVERIFY(vec.at(4).wasConstructedAt(&m5)); + QVERIFY(vec.at(5).wasConstructedAt(&m6)); vec.push_front(std::move(m0)); QVERIFY(m0.wasConstructedAt(nullptr)); QVERIFY(vec.at(0).wasConstructedAt(&m0)); @@ -2927,8 +2944,10 @@ void tst_QVector::insertMove() const QVERIFY(vec.at(2).wasConstructedAt(&m2)); QVERIFY(vec.at(3).wasConstructedAt(&m3)); QVERIFY(vec.at(4).wasConstructedAt(&m4)); + QVERIFY(vec.at(5).wasConstructedAt(&m5)); + QVERIFY(vec.at(6).wasConstructedAt(&m6)); - QCOMPARE(Movable::counter.loadAcquire(), instancesCount + 10); + QCOMPARE(Movable::counter.loadAcquire(), instancesCount + 14); } QCOMPARE(Movable::counter.loadAcquire(), instancesCount); } -- cgit v1.2.3 From 50cfbd6112a2682228cdf34cd72b5abae967cdb2 Mon Sep 17 00:00:00 2001 From: Svenn-Arne Dragly Date: Wed, 14 Mar 2018 16:36:09 +0100 Subject: Animation: Fix case where QEasingCurve::valueForProgress returns nan Previously, we would divide by zero in BezierEase::findTForX if factorT3 was zero when solving the cubic equation. This change fixes the problem by adding solutions for the special cases where the cubic equation can be reduced to a quadratic or linear equation. This change also adds tests that cover cases where the equation becomes quadratic, linear or invalid. Task-number: QTBUG-67061 Change-Id: I2b59f7e0392eb807663c3c8927509fd8b226ebc7 Reviewed-by: Christian Stromme --- .../tools/qeasingcurve/tst_qeasingcurve.cpp | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 0714883855..79309f960d 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -54,6 +54,7 @@ private slots: void testCbrtDouble(); void testCbrtFloat(); void cpp11(); + void quadraticEquation(); }; void tst_QEasingCurve::type() @@ -804,5 +805,74 @@ void tst_QEasingCurve::cpp11() #endif } +void tst_QEasingCurve::quadraticEquation() { + // We find the value for a given time by solving a cubic equation. + // ax^3 + bx^2 + cx + d = 0 + // However, the solver also needs to take care of cases where a = 0, + // b = 0 or c = 0, and the equation becomes quadratic, linear or invalid. + // A naive cubic solver might divide by zero and return nan, even + // when the solution is a real number. + // This test should triggers those cases. + + { + // If the control points are spaced 1/3 apart of the distance of the + // start- and endpoint, the equation becomes linear. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 1.0 / 3.0; + const qreal p2 = 1.0 - 1.0 / 3.0; + const qreal p3 = 1.0; + + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.15625) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.5) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.84375) < 1e-6); + } + + { + // If both the start point and the first control point + // are placed a 0.0, and the second control point is + // placed at 1/3, we get a case where a = 0 and b != 0 + // i.e. a quadratic equation. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 0.0; + const qreal p2 = 1.0 / 3.0; + const qreal p3 = 1.0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.5) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.792893) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.950962) < 1e-6); + } + + { + // If both the start point and the first control point + // are placed a 0.0, and the second control point is + // placed close to 1/3, we get a case where a = ~0 and b != 0. + // It's not truly a quadratic equation, but should be treated + // as one, because it causes some cubic solvers to fail. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p1 = 0.0; + const qreal p2 = 1.0 / 3.0 + 1e-6; + const qreal p3 = 1.0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + QVERIFY(qAbs(test.valueForProgress(0.25) - 0.499999) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.5) - 0.792892) < 1e-6); + QVERIFY(qAbs(test.valueForProgress(0.75) - 0.950961) < 1e-6); + } + + { + // A bad case, where the segment is of zero length. + // However, it might still happen in user code, + // and we should return a sensible answer. + QEasingCurve test(QEasingCurve::BezierSpline); + const qreal p0 = 0.0; + const qreal p1 = p0; + const qreal p2 = p0; + const qreal p3 = p0; + test.addCubicBezierSegment(QPointF(p1, 0.0), QPointF(p2, 1.0), QPointF(p3, 1.0)); + test.addCubicBezierSegment(QPointF(p3, 1.0), QPointF(1.0, 1.0), QPointF(1.0, 1.0)); + QCOMPARE(test.valueForProgress(0.0), 0.0); + } +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" -- cgit v1.2.3