diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-09-16 15:14:37 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-09-27 08:30:47 +0000 |
commit | 2689383fd3e1026eeaf5fcddfad69e97c136cc7d (patch) | |
tree | e569a923a49fe66b91cc7b08a98a756ab3a2ef2b /src/plugins | |
parent | d1c8c5ded375bb5b75598e4dd8d399cfa695514b (diff) | |
download | qt-creator-2689383fd3e1026eeaf5fcddfad69e97c136cc7d.tar.gz |
QmlProfiler: Fix flame graph model test
The flame graph keeps separate "flames" for compile and other QML/JS
events now. The test has to be adapted to check for this.
Change-Id: Ifdbc3331240d30a3acbb9df62a6a44654466273e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmlprofiler/tests/flamegraphmodel_test.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/plugins/qmlprofiler/tests/flamegraphmodel_test.cpp b/src/plugins/qmlprofiler/tests/flamegraphmodel_test.cpp index c8a6beaeae..660bd3e4a8 100644 --- a/src/plugins/qmlprofiler/tests/flamegraphmodel_test.cpp +++ b/src/plugins/qmlprofiler/tests/flamegraphmodel_test.cpp @@ -111,8 +111,9 @@ void FlameGraphModelTest::testIndex() void FlameGraphModelTest::testCounts() { - QCOMPARE(model.rowCount(), 1); + QCOMPARE(model.rowCount(), 2); QCOMPARE(model.rowCount(model.index(0, 0)), 1); + QCOMPARE(model.rowCount(model.index(1, 0)), 1); QCOMPARE(model.columnCount(), 1); } @@ -122,40 +123,65 @@ void FlameGraphModelTest::testData() FlameGraphModel::tr("JavaScript"), FlameGraphModel::tr("Signal"), FlameGraphModel::tr("Binding"), - FlameGraphModel::tr("Create"), - FlameGraphModel::tr("Compile"), + FlameGraphModel::tr("Create") }); QModelIndex index = model.index(0, 0); + QModelIndex index2 = model.index(1, 0); QCOMPARE(model.data(index, FlameGraphModel::TypeIdRole).toInt(), 0); + QCOMPARE(model.data(index2, FlameGraphModel::TypeIdRole).toInt(), 4); QCOMPARE(model.data(index, FlameGraphModel::TypeRole).toString(), FlameGraphModel::tr("JavaScript")); + QCOMPARE(model.data(index2, FlameGraphModel::TypeRole).toString(), + FlameGraphModel::tr("Compile")); QCOMPARE(model.data(index, FlameGraphModel::DurationRole).toLongLong(), 20); + QCOMPARE(model.data(index2, FlameGraphModel::DurationRole).toLongLong(), 12); QCOMPARE(model.data(index, FlameGraphModel::CallCountRole).toInt(), 1); + QCOMPARE(model.data(index2, FlameGraphModel::CallCountRole).toInt(), 1); QCOMPARE(model.data(index, FlameGraphModel::DetailsRole).toString(), QLatin1String("funcfunc")); + QCOMPARE(model.data(index2, FlameGraphModel::DetailsRole).toString(), + QLatin1String("funcfunc")); QCOMPARE(model.data(index, FlameGraphModel::FilenameRole).toString(), QLatin1String("somefile.js")); + QCOMPARE(model.data(index2, FlameGraphModel::FilenameRole).toString(), + QLatin1String("somefile.js")); QCOMPARE(model.data(index, FlameGraphModel::LineRole).toInt(), 0); + QCOMPARE(model.data(index2, FlameGraphModel::LineRole).toInt(), 4); QCOMPARE(model.data(index, FlameGraphModel::ColumnRole).toInt(), 20); + QCOMPARE(model.data(index2, FlameGraphModel::ColumnRole).toInt(), 16); QCOMPARE(model.data(index, FlameGraphModel::NoteRole).toString(), QString("dings")); + QCOMPARE(model.data(index2, FlameGraphModel::NoteRole).toString(), QString()); QCOMPARE(model.data(index, FlameGraphModel::TimePerCallRole).toLongLong(), 20); - QCOMPARE(model.data(index, FlameGraphModel::TimeInPercentRole).toInt(), 100); + QCOMPARE(model.data(index2, FlameGraphModel::TimePerCallRole).toLongLong(), 12); + QCOMPARE(model.data(index, FlameGraphModel::TimeInPercentRole).toInt(), 62); + QCOMPARE(model.data(index2, FlameGraphModel::TimeInPercentRole).toInt(), 37); QCOMPARE(model.data(index, FlameGraphModel::RangeTypeRole).toInt(), static_cast<int>(Javascript)); + QCOMPARE(model.data(index2, FlameGraphModel::RangeTypeRole).toInt(), + static_cast<int>(Compiling)); QCOMPARE(model.data(index, FlameGraphModel::LocationRole).toString(), QLatin1String("somefile.js:0")); + QCOMPARE(model.data(index2, FlameGraphModel::LocationRole).toString(), + QLatin1String("somefile.js:4")); QVERIFY(!model.data(index, -10).isValid()); + QVERIFY(!model.data(index2, -10).isValid()); QVERIFY(!model.data(QModelIndex(), FlameGraphModel::LineRole).isValid()); - for (int i = 1; i < 10; ++i) { + for (int i = 1; i < 8; ++i) { index = model.index(0, 0, index); QCOMPARE(model.data(index, FlameGraphModel::TypeRole).toString(), typeRoles[i % typeRoles.length()]); QCOMPARE(model.data(index, FlameGraphModel::NoteRole).toString(), (i % typeRoles.length() == 0) ? QString("dings") : QString()); } - QCOMPARE(model.data(index, FlameGraphModel::CallCountRole).toInt(), 2); + QCOMPARE(model.data(index, FlameGraphModel::CallCountRole).toInt(), 1); + + index2 = model.index(0, 0, index2); + QCOMPARE(model.data(index2, FlameGraphModel::TypeRole).toString(), + FlameGraphModel::tr("Compile")); + QCOMPARE(model.data(index2, FlameGraphModel::NoteRole).toString(), QString()); + QCOMPARE(model.data(index2, FlameGraphModel::CallCountRole).toInt(), 2); } void FlameGraphModelTest::testRoleNames() |