From 59c186de5f3cbf3f85cec0735fd05a9050aa617f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 21 Dec 2016 18:27:45 +0100 Subject: [PATCH] QmlProfiler: Resolve pixmap file name via pixmapcache model in test This tests that the file name is correctly stored in the model and it removes the detour via the model manager. Change-Id: Icc592b6383edcb18bfe31a81eb7ae0736a4f5508 Reviewed-by: Christian Kandeler --- src/plugins/qmlprofiler/pixmapcachemodel.cpp | 6 ++++++ src/plugins/qmlprofiler/pixmapcachemodel.h | 1 + src/plugins/qmlprofiler/tests/pixmapcachemodel_test.cpp | 3 +-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmlprofiler/pixmapcachemodel.cpp b/src/plugins/qmlprofiler/pixmapcachemodel.cpp index 22375bb8c64..6ea4d5db2b6 100644 --- a/src/plugins/qmlprofiler/pixmapcachemodel.cpp +++ b/src/plugins/qmlprofiler/pixmapcachemodel.cpp @@ -419,6 +419,12 @@ PixmapCacheModel::CacheState PixmapCacheModel::cacheState(int index) const return m_pixmaps[item.urlIndex].sizes[item.sizeIndex].cacheState; } + +QString PixmapCacheModel::fileName(int index) const +{ + const PixmapCacheItem &item = m_data[index]; + return (item.urlIndex == -1) ? QString() : m_pixmaps[item.urlIndex].url; +} #endif // WITH_TESTS void PixmapCacheModel::computeMaxCacheSize() diff --git a/src/plugins/qmlprofiler/pixmapcachemodel.h b/src/plugins/qmlprofiler/pixmapcachemodel.h index ccc7e703649..2427b6d3e97 100644 --- a/src/plugins/qmlprofiler/pixmapcachemodel.h +++ b/src/plugins/qmlprofiler/pixmapcachemodel.h @@ -116,6 +116,7 @@ public: #ifdef WITH_TESTS LoadState loadState(int index) const; CacheState cacheState(int index) const; + QString fileName(int index) const; #endif private: diff --git a/src/plugins/qmlprofiler/tests/pixmapcachemodel_test.cpp b/src/plugins/qmlprofiler/tests/pixmapcachemodel_test.cpp index cc7beb7ec66..adfd1682427 100644 --- a/src/plugins/qmlprofiler/tests/pixmapcachemodel_test.cpp +++ b/src/plugins/qmlprofiler/tests/pixmapcachemodel_test.cpp @@ -281,8 +281,7 @@ void PixmapCacheModelTest::testColor() else QCOMPARE(model.color(i), row1Color); } else { - const QmlEventType &type = manager.qmlModel()->eventTypes()[model.typeId(i)]; - QRgb &pixmapColor = (type.location().filename() == QString("blah.png")) ? + QRgb &pixmapColor = (model.fileName(i) == QString("blah.png")) ? blahColor : dingsColor; if (pixmapColor == 0) pixmapColor = model.color(i);