aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/buttonclick/tst_buttonclick.qml
blob: ba1537cd7c9046f282d591fa054f713effd94881 (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
// 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.0
import QtTest 1.1

Button {
    id: button
    onClicked: text = "Clicked"

    SignalSpy {
        id: spy
        target: button
        signalName: "clicked"
    }

    TestCase {
        name: "ButtonClick"
        when: windowShown

        function test_click() {

            compare(spy.count, 0)
            button.clicked(1, 2);
            compare(button.text, "Clicked");

            compare(spy.count, 1)
            compare(spy.signalArguments.length, 1)
            compare(spy.signalArguments[0][0], 1)
            compare(spy.signalArguments[0][1], 2)
            verify(spy.valid)
            spy.clear()
            compare(spy.count, 0)
            verify(spy.valid)
            compare(spy.signalArguments.length, 0)
            spy.signalName = ""
            verify(!spy.valid)
        }
    }
}