aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/testlib/SignalSpy.qml24
-rw-r--r--src/imports/testlib/signalspy.qdoc22
2 files changed, 38 insertions, 8 deletions
diff --git a/src/imports/testlib/SignalSpy.qml b/src/imports/testlib/SignalSpy.qml
index 539cb178f5..a3c5111c53 100644
--- a/src/imports/testlib/SignalSpy.qml
+++ b/src/imports/testlib/SignalSpy.qml
@@ -49,16 +49,17 @@ Item {
TestUtil {
id: util
}
-
// Public API.
-
property var target: null
property string signalName: ""
- property int count: 0
+ readonly property alias count: spy.qtest_count
+ readonly property alias valid:spy.qtest_valid
+ readonly property alias signalArguments:spy.qtest_signalArguments
function clear() {
- count = 0
+ qtest_count = 0
qtest_expectedCount = 0
+ qtest_signalArguments = []
}
function wait(timeout) {
@@ -66,11 +67,11 @@ Item {
timeout = 5000
var expected = ++qtest_expectedCount
var i = 0
- while (i < timeout && count < expected) {
+ while (i < timeout && qtest_count < expected) {
qtest_results.wait(50)
i += 50
}
- var success = (count >= expected)
+ var success = (qtest_count >= expected)
if (!qtest_results.verify(success, "wait for signal " + signalName, util.callerFile(), util.callerLine()))
throw new Error("QtQuickTest::fail")
}
@@ -89,6 +90,9 @@ Item {
property var qtest_prevTarget: null
property string qtest_prevSignalName: ""
property int qtest_expectedCount: 0
+ property var qtest_signalArguments:[]
+ property int qtest_count: 0
+ property bool qtest_valid:false
function qtest_update() {
if (qtest_prevTarget != null) {
@@ -101,16 +105,22 @@ Item {
if (target != null && signalName != "") {
var func = target[signalName]
if (func === undefined) {
+ spy.qtest_valid = false
console.log("Signal '" + signalName + "' not found")
} else {
qtest_prevTarget = target
qtest_prevSignalName = signalName
func.connect(spy.qtest_activated)
+ spy.qtest_valid = true
+ spy.qtest_signalArguments = []
}
+ } else {
+ spy.qtest_valid = false
}
}
function qtest_activated() {
- ++count
+ ++qtest_count
+ spy.qtest_signalArguments[spy.qtest_signalArguments.length] = arguments
}
}
diff --git a/src/imports/testlib/signalspy.qdoc b/src/imports/testlib/signalspy.qdoc
index cdf6637918..504ab8de5e 100644
--- a/src/imports/testlib/signalspy.qdoc
+++ b/src/imports/testlib/signalspy.qdoc
@@ -94,18 +94,38 @@
*/
/*!
+ \qmlproperty list SignalSpy::signalArguments
+
+ This property holds a list of emitted signal arguments. Each emission of the signal will append one item to the list, containing the arguments of the signal.
+ When connecting to a new \l target or new \l signalName or calling the \l clear() method, the \l signalArguments will be reset to empty.
+
+ \sa signalName, clear()
+ \readonly
+*/
+
+/*!
+ \qmlproperty bool SignalSpy::valid
+
+ This property defines the current signal connection status. It will be true when the \l signalName of the \l target is connected successfully, otherwise it will be false.
+
+ \sa count, target, signalName, clear()
+ \readonly
+*/
+
+/*!
\qmlproperty int SignalSpy::count
This property defines the number of times that \l signalName has
been emitted from \l target since the last call to clear().
\sa target, signalName, clear()
+ \readonly
*/
/*!
\qmlmethod SignalSpy::clear()
- Clears \l count to 0.
+ Clears \l count to 0, resets \l valid to false and clears the \l signalArguments to empty.
\sa count, wait()
*/