aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/selftests/tst_tryVerify.qml
blob: 653afeac75c9e147ae97de62b0ea2cd956e1019c (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtQuick 2.8
import QtTest 1.1

TestCase {
    name: "tst_tryVerify"

    Item {
        id: item
    }

    QtObject {
        id: itemContainer
        property Item i
    }

    Timer {
        id: timer
        interval: 100
        onTriggered: itemContainer.i = item
    }

    function resetTimer() {
        itemContainer.i = null;
        timer.restart();
    }

    function test_tryVerify() {
        timer.start();
        tryVerify(function(){ return itemContainer.i; }, 200, "string");
        compare(itemContainer.i, item);

        resetTimer();
        tryVerify(function(){ return itemContainer.i; }, 200);
        compare(itemContainer.i, item);

        resetTimer();
        tryVerify(function(){ return itemContainer.i; });
        compare(itemContainer.i, item);

        resetTimer();
        tryVerify(function(){ return !itemContainer.i; }, 0, "string");
        verify(!itemContainer.i);
    }
}