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) :
{
}
void FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
int FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
{
// Notes only work with timeline models
QmlProfilerRangeModel *rangeModel = new QmlProfilerRangeModel(manager, Javascript, manager);
int rangeModelId = rangeModel->modelId();
manager->notesModel()->addTimelineModel(rangeModel);
manager->startAcquiring();
......@@ -87,13 +88,14 @@ void FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
manager->notesModel()->setNotes(QVector<QmlNote>({QmlNote(0, 2, 1, 20, "dings")}));
manager->notesModel()->loadData();
QCOMPARE(manager->state(), QmlProfilerModelManager::Done);
return rangeModelId;
}
void FlameGraphModelTest::initTestCase()
{
QCOMPARE(model.modelManager(), &manager);
generateData(&manager);
rangeModelId = generateData(&manager);
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
}
void FlameGraphModelTest::testIndex()
......@@ -203,7 +205,7 @@ void FlameGraphModelTest::testRoleNames()
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(),
QString("dings\nblubb"));
manager.notesModel()->remove(0);
......
......@@ -37,7 +37,7 @@ class FlameGraphModelTest : public QObject
Q_OBJECT
public:
FlameGraphModelTest(QObject *parent = nullptr);
static void generateData(QmlProfilerModelManager *manager);
static int generateData(QmlProfilerModelManager *manager);
private slots:
void initTestCase();
......@@ -52,6 +52,7 @@ private:
Utils::FileInProjectFinder finder;
QmlProfilerModelManager manager;
FlameGraphModel model;
int rangeModelId = -1;
};
} // namespace Internal
......
......@@ -42,6 +42,7 @@ FlameGraphViewTest::FlameGraphViewTest(QObject *parent) : QObject(parent), manag
void FlameGraphViewTest::initTestCase()
{
FlameGraphModelTest::generateData(&manager);
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
view.resize(500, 500);
view.show();
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