summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_inputMethod.qml
blob: cf79e8a4d8926b55398eb67e3be6677a8388ed51 (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
53
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtQuick
import QtTest
import QtWebEngine
import Test.util
import "../../qmltests/data"

TestWebEngineView {
    id: webEngineView
    width: 200
    height: 400

    TestInputContext { id: testInputContext }

    TestCase {
        id: testCase
        name: "WebEngineViewInputMethod"
        when: windowShown

        function init() {
            testInputContext.create();
        }

        function cleanup() {
            testInputContext.release();
        }

        function test_softwareInputPanel() {
            verify(!Qt.inputMethod.visible);
            webEngineView.loadHtml(
                        "<html><body>" +
                        "   <form><input id='textInput' type='text' /></form>" +
                        "</body></html");
            verify(webEngineView.waitForLoadSucceeded());

            verify(!getActiveElementId());
            verify(!Qt.inputMethod.visible);

            // Show input panel
            webEngineView.runJavaScript("document.getElementById('textInput').focus()");
            webEngineView.verifyElementHasFocus("textInput");
            tryVerify(function() { return Qt.inputMethod.visible; });

            // Hide input panel
            webEngineView.runJavaScript("document.getElementById('textInput').blur()");
            verify(!getActiveElementId());
            tryVerify(function() { return !Qt.inputMethod.visible; });
        }
    }
}