aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/textedit/tst_textedit_editingfinished.qml
blob: 1cc338fdea279f8691f1a00c93382aff106a183e (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
51
52
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick 2.6
import QtTest 1.1

Row {
    width: 100
    height: 50
    spacing: 10

    property alias control1: _control1
    property alias control2: _control2
    TextEdit {
        id: _control1
        text: 'A'
        property bool myeditingfinished: false
        onEditingFinished: myeditingfinished = true
        activeFocusOnTab: true
    }
    TextEdit {
        id: _control2
        text: 'B'
        property bool myeditingfinished: false
        onEditingFinished: myeditingfinished = true
        activeFocusOnTab: true
    }

    TestCase {
        name: "TextEdit_editingFinished"
        when: windowShown

        function test_editingFinished() {
            control1.forceActiveFocus()
            verify(control1.activeFocus)
            verify(!control2.activeFocus)

            verify(control1.myeditingfinished === false)
            verify(control2.myeditingfinished === false)

            keyClick(Qt.Key_Backtab)
            verify(!control1.activeFocus)
            verify(control2.activeFocus)
            verify(control1.myeditingfinished === true)

            keyClick(Qt.Key_Backtab)
            verify(control1.activeFocus)
            verify(!control2.activeFocus)
            verify(control2.myeditingfinished === true)
        }
    }
}