blob: d6c37bee1d74aa58ddb7f9b706ca69d3f5f44ffa (
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
50
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.4
QtObject {
property int resolveValue: 5
property var resultValue: [resolveValue, resolveValue, resolveValue]
property bool wasTestSuccessful: false
property var delayedEvent: Timer {
interval: 0
property var handler: null
onTriggered: {
if (handler) {
handler();
}
}
}
function postEvent(event, value) {
delayedEvent.handler = function() { event(value) }
delayedEvent.restart();
}
property var promise1: Promise.resolve(resolveValue);
property int promise2: resolveValue
property var promise3: new Promise(function (resolve, reject) {
postEvent(resolve, resolveValue)
})
Component.onCompleted: {
Promise.all([promise1, promise2, promise3]).then(function(value) {
if (value.length !== resultValue.length) {
return;
}
for (var i in value) {
if (value[i] !== resultValue[i]) {
return;
}
}
wasTestSuccessful = true
}, function() {
throw new Error("Should never be called")
})
}
}
|