summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/BackendTestMultiplier.qml
blob: 8599937d63b92b4eeb22183d4493474e5f16c1b9 (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
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

import QtQuick
import QtOpcUa as QtOpcUa

Item {
    property int currentTest: 0
    property string testName

    QtOpcUa.Connection {
        id: connection
    }

    Component.onCompleted: {
        var component = Qt.createComponent(testName + ".qml")
        if (component.status != Component.Ready) {
            console.log("Failed to load component " + testName, component.errorString());
            return;
        }

        for (var backendIndex in connection.availableBackends) {
            var backend = connection.availableBackends[backendIndex];
            console.log("Setting up", testName, "for", backend);
            var child = component.createObject(this, { "backendName": backend });
            if (child == null) {
                console.log("Error creating object", testName);
                return;
            }
            child.completedChanged.connect(incrementTest);
            children.push(child);
        }
        children[currentTest].shouldRun = true;
    }

    function incrementTest() {
        currentTest += 1;
        if (currentTest < children.length)
            children[currentTest].shouldRun = true;
    }
}