Commit 7477411d authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Calculate the model ID in the flame graph model test

... instead of guessing it. This is more robust.

Change-Id: I4855b78da23cb1caefa3a7a95bfa60c5733b32c5
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
parent 92db5afb
...@@ -37,10 +37,11 @@ FlameGraphModelTest::FlameGraphModelTest(QObject *parent) : ...@@ -37,10 +37,11 @@ FlameGraphModelTest::FlameGraphModelTest(QObject *parent) :
{ {
} }
void FlameGraphModelTest::generateData(QmlProfilerModelManager *manager) int FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
{ {
// Notes only work with timeline models // Notes only work with timeline models
QmlProfilerRangeModel *rangeModel = new QmlProfilerRangeModel(manager, Javascript, manager); QmlProfilerRangeModel *rangeModel = new QmlProfilerRangeModel(manager, Javascript, manager);
int rangeModelId = rangeModel->modelId();
manager->notesModel()->addTimelineModel(rangeModel); manager->notesModel()->addTimelineModel(rangeModel);
manager->startAcquiring(); manager->startAcquiring();
...@@ -87,13 +88,14 @@ void FlameGraphModelTest::generateData(QmlProfilerModelManager *manager) ...@@ -87,13 +88,14 @@ void FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
manager->notesModel()->setNotes(QVector<QmlNote>({QmlNote(0, 2, 1, 20, "dings")})); manager->notesModel()->setNotes(QVector<QmlNote>({QmlNote(0, 2, 1, 20, "dings")}));
manager->notesModel()->loadData(); manager->notesModel()->loadData();
QCOMPARE(manager->state(), QmlProfilerModelManager::Done); return rangeModelId;
} }
void FlameGraphModelTest::initTestCase() void FlameGraphModelTest::initTestCase()
{ {
QCOMPARE(model.modelManager(), &manager); QCOMPARE(model.modelManager(), &manager);
generateData(&manager); rangeModelId = generateData(&manager);
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
} }
void FlameGraphModelTest::testIndex() void FlameGraphModelTest::testIndex()
...@@ -203,7 +205,7 @@ void FlameGraphModelTest::testRoleNames() ...@@ -203,7 +205,7 @@ void FlameGraphModelTest::testRoleNames()
void FlameGraphModelTest::testNotes() void FlameGraphModelTest::testNotes()
{ {
manager.notesModel()->add(2, 1, QString("blubb")); manager.notesModel()->add(rangeModelId, 1, QString("blubb"));
QCOMPARE(model.data(model.index(0, 0), FlameGraphModel::NoteRole).toString(), QCOMPARE(model.data(model.index(0, 0), FlameGraphModel::NoteRole).toString(),
QString("dings\nblubb")); QString("dings\nblubb"));
manager.notesModel()->remove(0); manager.notesModel()->remove(0);
......
...@@ -37,7 +37,7 @@ class FlameGraphModelTest : public QObject ...@@ -37,7 +37,7 @@ class FlameGraphModelTest : public QObject
Q_OBJECT Q_OBJECT
public: public:
FlameGraphModelTest(QObject *parent = nullptr); FlameGraphModelTest(QObject *parent = nullptr);
static void generateData(QmlProfilerModelManager *manager); static int generateData(QmlProfilerModelManager *manager);
private slots: private slots:
void initTestCase(); void initTestCase();
...@@ -52,6 +52,7 @@ private: ...@@ -52,6 +52,7 @@ private:
Utils::FileInProjectFinder finder; Utils::FileInProjectFinder finder;
QmlProfilerModelManager manager; QmlProfilerModelManager manager;
FlameGraphModel model; FlameGraphModel model;
int rangeModelId = -1;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -42,6 +42,7 @@ FlameGraphViewTest::FlameGraphViewTest(QObject *parent) : QObject(parent), manag ...@@ -42,6 +42,7 @@ FlameGraphViewTest::FlameGraphViewTest(QObject *parent) : QObject(parent), manag
void FlameGraphViewTest::initTestCase() void FlameGraphViewTest::initTestCase()
{ {
FlameGraphModelTest::generateData(&manager); FlameGraphModelTest::generateData(&manager);
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
view.resize(500, 500); view.resize(500, 500);
view.show(); view.show();
QTest::qWaitForWindowExposed(&view); QTest::qWaitForWindowExposed(&view);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment