aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@digia.com>2012-10-24 16:09:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 13:07:16 +0200
commit107444f7c479ed6a1a3d2c42b026ebc9c1fe4b29 (patch)
tree1b2d5de24ac315fc1e57beeb38d0fed141fafab6 /tests
parent3b0a9b27fec09cdab4cde7bfc41578c8c17a8832 (diff)
QmlProfiler: Pixmap Cache
Change-Id: Ibc237bb162c24030438b89d54fa8802ee66b080a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.pngbin0 -> 158 bytes
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml13
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro3
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp68
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp8
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h3
6 files changed, 95 insertions, 0 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png b/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png
new file mode 100644
index 0000000000..30228cbbdc
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/TestImage_2x2.png
Binary files differ
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml
new file mode 100644
index 0000000000..d56786bfae
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/pixmapCacheTest.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Rectangle {
+ Image {
+ source: "TestImage_2x2.png"
+ onStatusChanged: switch (status) {
+ case 0: console.log("no image"); break;
+ case 1: console.log("image loaded"); break;
+ case 2: console.log("image loading"); break;
+ case 3: console.log("image error"); break;
+ }
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
index 5bff33dd25..b2b325dc72 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -12,3 +12,6 @@ TESTDATA = data/*
QT += core qml testlib gui-private
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+
+OTHER_FILES += \
+ data/pixmapCacheTest.qml
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 9982e5d629..8ad4f52b91 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -77,6 +77,7 @@ public:
RangeLocation,
RangeEnd,
Complete, // end of transmission
+ PixmapCacheEvent,
MaximumMessage
};
@@ -102,6 +103,17 @@ public:
MaximumRangeType
};
+ enum PixmapEventType {
+ PixmapSizeKnown,
+ PixmapReferenceCountChanged,
+ PixmapCacheCountChanged,
+ PixmapLoadingStarted,
+ PixmapLoadingFinished,
+ PixmapLoadingError,
+
+ MaximumPixmapEventType
+ };
+
QQmlProfilerClient(QQmlDebugConnection *connection)
: QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection)
{
@@ -148,6 +160,7 @@ private slots:
void blockingConnectWithTraceEnabled();
void blockingConnectWithTraceDisabled();
void nonBlockingConnect();
+ void pixmapCacheData();
void profileOnExit();
};
@@ -219,6 +232,16 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message)
QVERIFY(data.line >= -2);
break;
}
+ case QQmlProfilerClient::PixmapCacheEvent: {
+ stream >> data.detailType >> data.detailData;
+ if (data.detailType == QQmlProfilerClient::PixmapSizeKnown)
+ stream >> data.line >> data.column;
+ if (data.detailType == QQmlProfilerClient::PixmapReferenceCountChanged)
+ stream >> data.animationcount;
+ if (data.detailType == QQmlProfilerClient::PixmapCacheCountChanged)
+ stream >> data.animationcount;
+ break;
+ }
default:
QString failMsg = QString("Unknown message type:") + data.messageType;
QFAIL(qPrintable(failMsg));
@@ -320,6 +343,51 @@ void tst_QQmlProfilerService::nonBlockingConnect()
QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
+void tst_QQmlProfilerService::pixmapCacheData()
+{
+ connect(true, "pixmapCacheTest.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput())));
+
+ QVERIFY(m_process->output().indexOf(QLatin1String("image loaded")) != -1 ||
+ m_process->output().indexOf(QLatin1String("image error")) != -1 );
+
+
+ m_client->setTraceState(false);
+
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time.");
+ QVERIFY(m_client->traceMessages.count());
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
+
+ // image starting to load
+ QCOMPARE(m_client->traceMessages[8].messageType, (int)QQmlProfilerClient::PixmapCacheEvent);
+ QCOMPARE(m_client->traceMessages[8].detailType, (int)QQmlProfilerClient::PixmapLoadingStarted);
+
+ // image loaded
+ QCOMPARE(m_client->traceMessages[9].messageType, (int)QQmlProfilerClient::PixmapCacheEvent);
+ QCOMPARE(m_client->traceMessages[9].detailType, (int)QQmlProfilerClient::PixmapLoadingFinished);
+
+ // image size
+ QCOMPARE(m_client->traceMessages[10].messageType, (int)QQmlProfilerClient::PixmapCacheEvent);
+ QCOMPARE(m_client->traceMessages[10].detailType, (int)QQmlProfilerClient::PixmapSizeKnown);
+ QCOMPARE(m_client->traceMessages[10].line, 2); // width
+ QCOMPARE(m_client->traceMessages[10].column, 2); // height
+
+ // cache size
+ QCOMPARE(m_client->traceMessages[11].messageType, (int)QQmlProfilerClient::PixmapCacheEvent);
+ QCOMPARE(m_client->traceMessages[11].detailType, (int)QQmlProfilerClient::PixmapCacheCountChanged);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
+
+}
+
void tst_QQmlProfilerService::profileOnExit()
{
connect(true, "exit.qml");
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index 6585f7eca2..ff3140f520 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -182,6 +182,8 @@ void QQmlDebugProcess::processAppOutput()
{
m_mutex.lock();
+ bool outputFromAppItself = false;
+
QString newOutput = m_process.readAll();
m_output.append(newOutput);
m_outputBuffer.append(newOutput);
@@ -208,7 +210,13 @@ void QQmlDebugProcess::processAppOutput()
m_eventLoop.quit();
continue;
}
+ } else {
+ // set to true if there is output not coming from the debugger
+ outputFromAppItself = true;
}
}
m_mutex.unlock();
+
+ if (outputFromAppItself)
+ emit readyReadStandardOutput();
}
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index 363aabbf39..11b16a1fb8 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -98,6 +98,9 @@ public:
QString output() const;
void stop();
+signals:
+ void readyReadStandardOutput();
+
private slots:
void timeout();
void processAppOutput();