aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-07-13 15:53:04 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-08 06:04:03 +0200
commit92562eacbc3c614a83a734f1108ed7df02415eae (patch)
tree05fc063849e032cb03e4f919811d8ea4da147773 /tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml
parentb2120f68683b7948891d72fe077f44ab7e6baf18 (diff)
Allow signal parameters which are custom QML object-types
This commit allows lazy resolution of signal parameter types, which allows QML object types to be used as signal parameters. If a signal is emitted with an incorrect parameter type, it will be passed through as a null parameter. Task-number: QTBUG-14550 Change-Id: I7e899ad57452826cc405bed10c541f8d35789d04 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml')
-rw-r--r--tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml b/tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml
new file mode 100644
index 0000000000..e3d4008962
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml
@@ -0,0 +1,44 @@
+import QtQml 2.0
+
+QtObject {
+ id: root
+
+ property bool success: false
+ property bool gotInvalid: false
+ property bool expectNull: false
+ property SignalEmitter e: SignalEmitter { testObject: root; handleSignal: true }
+
+ function determineSuccess(param) {
+ if (root.expectNull == true) {
+ if (param != null) {
+ // the parameter shouldn't have been passed through, but was.
+ root.success = false;
+ root.gotInvalid = true;
+ } else {
+ root.success = true;
+ root.gotInvalid = false;
+ }
+ return;
+ } else if (param == null) {
+ // the parameter should have been passed through, but wasn't.
+ root.success = false;
+ return;
+ }
+
+ if (param.testProperty == 42) {
+ // got the expected value. if we didn't previously
+ // get an unexpected value, set success to true.
+ root.success = (!root.gotInvalid);
+ } else {
+ // the value passed through was not what we expected.
+ root.gotInvalid = true;
+ root.success = false;
+ }
+ }
+
+ Component.onCompleted: {
+ success = false;
+ e.emitTestSignal();
+ // the handler in the SignalEmitter should call determineSuccess.
+ }
+}