summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qmltests/data/tst_inputTextDirection.qml
blob: 2141db4c80ad1c42da3b034cc77b64a799e464a4 (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
// Copyright (C) 2023 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

TestWebEngineView {
    id: webEngineView
    width: 400
    height: 400

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

        function getInputTextDirection(element) {
            var dir;
            runJavaScript("document.getElementById('" + element + "').dir", function(result) {
                dir = result;
            });
            tryVerify(function() { return dir != undefined; });
            return dir;
        }

        function test_changeInputTextDirection() {
            webEngineView.loadHtml("<html><body><input type='text' id='textfield' value='some text'></body></html>");
            verify(webEngineView.waitForLoadSucceeded());
            setFocusToElement("textfield");

            var rtlAction = webEngineView.action(WebEngineView.ChangeTextDirectionRTL);
            verify(rtlAction);
            rtlAction.trigger();
            compare(getInputTextDirection("textfield"), "rtl");

            var ltrAction = webEngineView.action(WebEngineView.ChangeTextDirectionLTR);
            verify(ltrAction);
            ltrAction.trigger();
            compare(getInputTextDirection("textfield"), "ltr");
        }
    }
}