From 89a6611e9e2470afd8e56271d2953a8466c9e625 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 9 Jan 2018 15:48:16 +0100 Subject: [PATCH] QmlProfiler: Test that server recording changes only clear events ... and not event types. Change-Id: Ic6c4ac3ef52bf07678d1ff0c0aaaf15242ea472e Reviewed-by: Christian Kandeler --- .../tests/qmlprofilertool_test.cpp | 31 ++++++++++++++++++- .../qmlprofiler/tests/qmlprofilertool_test.h | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp index d2680450667..e973e96780f 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp @@ -27,8 +27,10 @@ #include "fakedebugserver.h" #include -#include #include +#include +#include +#include #include #include @@ -75,5 +77,32 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() QTRY_VERIFY(runControl->isStopped()); } +void QmlProfilerToolTest::testClearEvents() +{ + QmlProfilerTool profilerTool(nullptr); + QmlProfilerModelManager *modelManager = profilerTool.modelManager(); + QVERIFY(modelManager); + QmlProfilerStateManager *stateManager = profilerTool.stateManager(); + QVERIFY(stateManager); + + stateManager->setCurrentState(QmlProfilerStateManager::AppRunning); + stateManager->setServerRecording(true); + QCOMPARE(modelManager->numLoadedEventTypes(), 0u); + QCOMPARE(modelManager->numLoadedEvents(), 0u); + modelManager->addEventType(QmlEventType()); + modelManager->addEvent(QmlEvent(0, 0, "")); + QCOMPARE(modelManager->numLoadedEventTypes(), 1u); + QCOMPARE(modelManager->numLoadedEvents(), 1u); + stateManager->setServerRecording(false); + QCOMPARE(modelManager->numLoadedEventTypes(), 1u); + QCOMPARE(modelManager->numLoadedEvents(), 1u); + stateManager->setServerRecording(true); // clears previous events, but not types + QCOMPARE(modelManager->numLoadedEventTypes(), 1u); + QCOMPARE(modelManager->numLoadedEvents(), 0u); + modelManager->addEvent(QmlEvent(0, 0, "")); + QCOMPARE(modelManager->numLoadedEventTypes(), 1u); + QCOMPARE(modelManager->numLoadedEvents(), 1u); +} + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.h b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.h index 24a143b46a7..afc176b3756 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.h +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.h @@ -34,6 +34,7 @@ class QmlProfilerToolTest : public QObject Q_OBJECT private slots: void testAttachToWaitingApplication(); + void testClearEvents(); }; } // namespace Internal