diff options
Diffstat (limited to 'tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp')
-rw-r--r-- | tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp index 173e137d17..678f4491c4 100644 --- a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp +++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp @@ -1,32 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#include <QtTest/QtTest> +#include <QTest> #include <private/qinputcontrol_p.h> #include <QtGui/QKeyEvent> @@ -58,6 +33,52 @@ void tst_QInputControl::isAcceptableInput_data() QTest::newRow("printable-latin-with-ctrl-shift") << QString(QLatin1Char('a')) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << false; QTest::newRow("printable-hebrew") << QString(QChar(0x2135)) << Qt::KeyboardModifiers() << true; QTest::newRow("private-use-area") << QString(QChar(0xE832)) << Qt::KeyboardModifiers() << true; + QTest::newRow("good-surrogate-0") << QString::fromUtf16(u"\U0001F44D") << Qt::KeyboardModifiers() << true; + { + const QChar data[] = { QChar(0xD800), QChar(0xDC00) }; + const QString str = QString(data, 2); + QTest::newRow("good-surrogate-1") << str << Qt::KeyboardModifiers() << true; + } + { + const QChar data[] = { QChar(0xD800), QChar(0xDFFF) }; + const QString str = QString(data, 2); + QTest::newRow("good-surrogate-2") << str << Qt::KeyboardModifiers() << true; + } + { + const QChar data[] = { QChar(0xDBFF), QChar(0xDC00) }; + const QString str = QString(data, 2); + QTest::newRow("good-surrogate-3") << str << Qt::KeyboardModifiers() << true; + } + { + const QChar data[] = { QChar(0xDBFF), QChar(0xDFFF) }; + const QString str = QString(data, 2); + QTest::newRow("good-surrogate-4") << str << Qt::KeyboardModifiers() << true; + } + { + const QChar data[] = { QChar(0xD7FF), QChar(0xDC00) }; + const QString str = QString(data, 2); + QTest::newRow("bad-surrogate-1") << str << Qt::KeyboardModifiers() << false; + } + { + const QChar data[] = { QChar(0xD7FF), QChar(0xDFFF) }; + const QString str = QString(data, 2); + QTest::newRow("bad-surrogate-2") << str << Qt::KeyboardModifiers() << false; + } + { + const QChar data[] = { QChar(0xDC00), QChar(0xDC00) }; + const QString str = QString(data, 2); + QTest::newRow("bad-surrogate-3") << str << Qt::KeyboardModifiers() << false; + } + { + const QChar data[] = { QChar(0xD800), QChar(0xE000) }; + const QString str = QString(data, 2); + QTest::newRow("bad-surrogate-4") << str << Qt::KeyboardModifiers() << false; + } + { + const QChar data[] = { QChar(0xD800) }; + const QString str = QString(data, 1); + QTest::newRow("bad-surrogate-5") << str << Qt::KeyboardModifiers() << false; + } QTest::newRow("multiple-printable") << QStringLiteral("foobar") << Qt::KeyboardModifiers() << true; QTest::newRow("rlm") << QString(QChar(0x200F)) << Qt::KeyboardModifiers() << true; QTest::newRow("rlm-with-ctrl") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true; |