diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-26 15:29:47 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-17 10:54:19 (GMT) |
commit | 047090b2b7af7e5a3b88615dafed9d4d957fbe6e (patch) | |
tree | a229dc8559a91adced173c9005c38e3821440ae0 /tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp | |
parent | bc88d38905a80b2a025acf5b52858264c0ef0d39 (diff) | |
download | Qt-047090b2b7af7e5a3b88615dafed9d4d957fbe6e.zip Qt-047090b2b7af7e5a3b88615dafed9d4d957fbe6e.tar.gz Qt-047090b2b7af7e5a3b88615dafed9d4d957fbe6e.tar.bz2 |
Add a couple of extra functions to QElapsedTimer
Diffstat (limited to 'tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp')
-rw-r--r-- | tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp index d671d1b..5f797a3 100644 --- a/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp +++ b/tests/auto/qelapsedtimer/tst_qelapsedtimer.cpp @@ -10,11 +10,19 @@ class tst_QElapsedTimer : public QObject Q_OBJECT private Q_SLOTS: + void statics(); void validity(); void basics(); void elapsed(); }; +void tst_QElapsedTimer::statics() +{ + qDebug() << "Clock type is" << QElapsedTimer::clockType(); + qDebug() << "Said clock is" << (QElapsedTimer::isMonotonic() ? "monotonic" : "not monotonic"); + qDebug() << "Current time is" << QElapsedTimer::started().msecsSinceReference(); +} + void tst_QElapsedTimer::validity() { QElapsedTimer t; @@ -27,6 +35,12 @@ void tst_QElapsedTimer::validity() t.invalidate(); QVERIFY(!t.isValid()); + + t = QElapsedTimer::started(); + QVERIFY(t.isValid()); + + t = QElapsedTimer::invalid(); + QVERIFY(!t.isValid()); } void tst_QElapsedTimer::basics() @@ -34,14 +48,17 @@ void tst_QElapsedTimer::basics() QElapsedTimer t1; t1.start(); + QVERIFY(t1.msecsSinceReference() != 0); + QCOMPARE(t1, t1); QVERIFY(!(t1 != t1)); QVERIFY(!(t1 < t1)); QCOMPARE(t1.msecsTo(t1), qint64(0)); QCOMPARE(t1.secsTo(t1), qint64(0)); - QCOMPARE(t1 + 0, t1); - QCOMPARE(t1 - 0, t1); +// QCOMPARE(t1 + 0, t1); +// QCOMPARE(t1 - 0, t1); +#if 0 QElapsedTimer t2 = t1; t2 += 1000; // so we can use secsTo @@ -51,10 +68,14 @@ void tst_QElapsedTimer::basics() QVERIFY(!(t2 < t1)); QCOMPARE(t1.msecsTo(t2), qint64(1000)); QCOMPARE(t1.secsTo(t2), qint64(1)); - QCOMPARE(t2 - t1, qint64(1000)); - QCOMPARE(t1 - t2, qint64(-1000)); +// QCOMPARE(t2 - t1, qint64(1000)); +// QCOMPARE(t1 - t2, qint64(-1000)); +#endif + quint64 value1 = t1.msecsSinceReference(); qint64 elapsed = t1.restart(); + quint64 value2 = t1.msecsSinceReference(); + QCOMPARE(elapsed, qint64(value2 - value1)); QVERIFY(elapsed < minResolution); } @@ -72,7 +93,7 @@ void tst_QElapsedTimer::elapsed() QVERIFY(t1 < t2); QVERIFY(t1.msecsTo(t2) > 0); // don't check: t1.secsTo(t2) - QVERIFY(t1 - t2 < 0); +// QVERIFY(t1 - t2 < 0); QVERIFY(t1.elapsed() > 0); QVERIFY(t1.hasExpired(minResolution)); @@ -85,7 +106,7 @@ void tst_QElapsedTimer::elapsed() qint64 elapsed = t1.restart(); QVERIFY(elapsed > 3*minResolution); QVERIFY(elapsed < 5*minResolution); - qint64 diff = t1 - t2; + qint64 diff = t2.msecsTo(t1); QVERIFY(diff < minResolution); } |