From fdbad25c5d5a1792bec5ab72a573fc4ad60378fc Mon Sep 17 00:00:00 2001 From: Frantisek Vacek Date: Fri, 28 Sep 2012 11:27:49 +0200 Subject: QDeclarativeTrace patch for a custom trace instance Needed for the BB10 Cascades profiling. There are more reasons for introducing this patch: 1) Cascades do not use QtGui library for QML rendering. It has its own paint engine with client-server architecture. Profiler traces are sent asynchronously from non Qt renderer thread to the Qt client. The QPerformanceTimer has to be patched too, cause we need to know time difference between tracing zero time and some time in past, see: qint64 QPerformanceTimer::elapsed(qint64 to_monotonic_time_ns) const 2) Since we need more sophisticated trace engine in cascades, this patch allows explicitly assign custom class derived from QDeclaraqtiveDebugtrace to the trace framework. If no custom instance is assigned, the default QDeclarativeDebugTrace instance is created implicitly on first trace request. Using custom trace instance which is not part of Qt (it is part of libbbcascades) allows us to implement all Cascades trace special needs in libbbcascades and not to carry Qt with the platform specific code. 3) The NO_CUSTOM_DECLARATIVE_DEBUG_TRACE_INSTANCE macro is introduced to allow custom trace engine only on the bleckberry platform, see declarative.pro. If this macro is defined Qt compiles from its original code. 4) Possibility of custom QDeclaraqtiveDebugTrace instance might be usable for other projects which needs to extends somehow default Qt trace functionality. 5) Patch is not intended to be applied to Qt Quick 2, since declarative debugging infrastructure is changed there. Change-Id: I199211c1de66e930e252e8c033503d7f4940565f Reviewed-by: Kai Koehne Reviewed-by: Christiaan Janssen --- .../qperformancetimer/tst_qperformancetimer.cpp | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/declarative/qperformancetimer/tst_qperformancetimer.cpp b/tests/auto/declarative/qperformancetimer/tst_qperformancetimer.cpp index 28dd95ba..958fb1a2 100644 --- a/tests/auto/declarative/qperformancetimer/tst_qperformancetimer.cpp +++ b/tests/auto/declarative/qperformancetimer/tst_qperformancetimer.cpp @@ -58,9 +58,27 @@ void tst_qperformancetimer::units() { QPerformanceTimer timer; timer.start(); - QTest::qWait(300); - qint64 elapsed = timer.elapsed(); - QVERIFY(elapsed > 300000000 && elapsed < 310000000); + { + QTest::qWait(300); + qint64 elapsed = timer.elapsed(); + QVERIFY(elapsed > 300000000 && elapsed < 310000000); + } + { + qint64 monotonic_time_in_far_future = 1000000000 * 60 * 60 * 24 * 365 * 10; /// 10 years uptime + qint64 elapsed = timer.elapsedToAbsoluteTime(time_in_far_future); + elapsed = elapsed - timer.elapsedToAbsoluteTime(time_in_far_future - 2000000); + QVERIFY(elapsed == 2000000); + } + { + qint64 elapsed = timer.elapsed(); + qint64 elapsed2 = timer.elapsedToAbsoluteTime(elapsed); + qint64 monotonic_now = 2 * elapsed - elapsed2; + QTest::qWait(300); + elapsed = timer.elapsed(); + elapsed2 = timer.elapsedToAbsoluteTime(monotonic_now + 300 * 1000000); + qint64 diff = elapsed - elapsed2; + QVERIFY(diff > -10000000 && diff < 10000000); + } } QTEST_MAIN(tst_qperformancetimer) -- cgit v1.2.3