aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/data/signalParameterTypes.1.qml
blob: e3d4008962c1246d7d08e24ed51c46d94123d06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.
    }
}