diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-11 09:12:00 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-18 07:45:24 +0000 |
commit | dde49f989e6f77a8db87d7fafc2d4ced34113135 (patch) | |
tree | 5684c1e0e166e5dd5d575697fde728f81f00c289 /tests/auto/qml/debugger | |
parent | 7bf74dbddb25d48e267788c02ee7d06288bfada9 (diff) |
QML Preview: Add a frames per second counter
It is instructive to the client to know how many frames per second the
current QML can achieve in the preview.
Change-Id: I8b73e2b5218410d903a07dfe27c038663c84fdee
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/debugger')
-rw-r--r-- | tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp index 152a4a7f9f..9477603654 100644 --- a/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp +++ b/tests/auto/qml/debugger/qqmlpreview/tst_qqmlpreview.cpp @@ -57,6 +57,7 @@ private: QStringList m_filesNotFound; QStringList m_directories; QStringList m_serviceErrors; + quint16 m_frames = 0; private slots: void cleanup() final; @@ -67,6 +68,7 @@ private slots: void blacklist(); void error(); void zoom(); + void fps(); }; QQmlDebugTest::ConnectResult tst_QQmlPreview::startQmlProcess(const QString &qmlFile) @@ -102,6 +104,9 @@ QList<QQmlDebugClient *> tst_QQmlPreview::createClients() QObject::connect(m_client, &QQmlPreviewClient::error, this, [this](const QString &error) { m_serviceErrors.append(error); }); + QObject::connect(m_client, &QQmlPreviewClient::fps, this, [this](quint16 frames) { + m_frames += frames; + }); return QList<QQmlDebugClient *>({m_client}); } @@ -135,6 +140,7 @@ void tst_QQmlPreview::cleanup() m_files.clear(); m_filesNotFound.clear(); m_serviceErrors.clear(); + m_frames = 0; } void tst_QQmlPreview::connect() @@ -323,6 +329,18 @@ void tst_QQmlPreview::zoom() QVERIFY(m_serviceErrors.isEmpty()); } +void tst_QQmlPreview::fps() +{ + const QString file("qtquick2.qml"); + QCOMPARE(startQmlProcess(file), ConnectSuccess); + QVERIFY(m_client); + m_client->triggerLoad(testFileUrl(file)); + if (QGuiApplication::platformName() != "offscreen") + QTRY_VERIFY(m_frames > 100); + else + QSKIP("offscreen rendering doesn't produce any frames"); +} + QTEST_MAIN(tst_QQmlPreview) #include "tst_qqmlpreview.moc" |