summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml
blob: 440bd613aab299838f246529bb8a83230f50ea65 (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
45
46
47
48
49
// Copyright (C) 2017 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtTest
import QtQml.StateMachine

TestCase {
    id: testCase

    property string mystr
    property bool mybool
    property int myint

    StateMachine {
        id: machine
        initialState: startState
        running: true
        State {
            id: startState
            SignalTransition {
                id: signalTrans
                signal: testCase.mysignal
                onTriggered: function(strarg, boolarg, intarg) {
                    testCase.mystr = strarg
                    testCase.mybool = boolarg
                    testCase.myint = intarg
                }
                targetState: finalState
            }
        }
        FinalState {
            id: finalState
        }
    }

    signal mysignal(string mystr, bool mybool, int myint)

    name: "testTriggeredArguments2"
    function test_triggeredArguments()
    {
        tryCompare(startState, "active", true)

        // Emit the signalTrans.signal
        testCase.mysignal("test1", true, 2)
        compare(testCase.mystr, "test1")
        compare(testCase.mybool, true)
        compare(testCase.myint, 2)
    }
}