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