summaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/statemachine/tst_nestedinitialstates.qml
blob: a37e1e76f98e4a380cf233b3a894a9b77eb12088 (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
// Copyright (C) 2016 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtTest
import QtQml.StateMachine

TestCase {
    StateMachine {
        id: myStateMachine
        initialState: parentState
        State {
            id: parentState
            initialState: childState1
            State {
                id: childState1
            }
            State {
                id: childState2
            }
        }
    }
    name: "nestedInitalStates"

    function test_nestedInitalStates() {
        compare(myStateMachine.running, false);
        compare(parentState.active, false);
        compare(childState1.active, false);
        compare(childState2.active, false);
        myStateMachine.start();
        tryCompare(myStateMachine, "running", true);
        tryCompare(parentState, "active", true);
        tryCompare(childState1, "active", true);
        compare(childState2.active, false);
    }
}