diff options
Diffstat (limited to 'tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp | 111 |
1 files changed, 43 insertions, 68 deletions
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 107c91507b..67fef3cf44 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -1,33 +1,8 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + + +#include <QTest> #include <qkeysequence.h> #include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme_p.h> @@ -171,19 +146,19 @@ tst_QKeySequence::~tst_QKeySequence() void tst_QKeySequence::initTestCase() { ourTranslator = new QTranslator(this); - ourTranslator->load(":/keys_de"); + (void)ourTranslator->load(":/keys_de"); qtTranslator = new QTranslator(this); - qtTranslator->load(":/qt_de"); + (void)qtTranslator->load(":/qt_de"); } void tst_QKeySequence::swap() { - QKeySequence ks1(Qt::CTRL+Qt::Key_O); - QKeySequence ks2(Qt::CTRL+Qt::Key_L); + QKeySequence ks1(Qt::CTRL | Qt::Key_O); + QKeySequence ks2(Qt::CTRL | Qt::Key_L); ks1.swap(ks2); - QCOMPARE(ks1[0], Qt::CTRL+Qt::Key_L); - QCOMPARE(ks2[0], Qt::CTRL+Qt::Key_O); + QCOMPARE(ks1[0], Qt::CTRL | Qt::Key_L); + QCOMPARE(ks2[0], Qt::CTRL | Qt::Key_O); } void tst_QKeySequence::operatorQString_data() @@ -498,11 +473,15 @@ void tst_QKeySequence::toStringFromKeycode_data() QTest::newRow("A") << QKeySequence(Qt::Key_A) << "A"; QTest::newRow("-1") << QKeySequence(-1) << ""; QTest::newRow("Unknown") << QKeySequence(Qt::Key_unknown) << ""; + QTest::newRow("Ctrl+Unknown") << QKeySequence(Qt::ControlModifier | Qt::Key_unknown) << ""; QTest::newRow("Ctrl+Num+Ins") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Insert) << "Ctrl+Num+Ins"; QTest::newRow("Ctrl+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Num+Del"; QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del"; QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins"; - QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins"; + QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control"; + QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt"; + QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift"; + QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta"; } void tst_QKeySequence::toStringFromKeycode() @@ -549,11 +528,11 @@ void tst_QKeySequence::parseString_data() // Valid QTest::newRow("A") << "A" << QKeySequence(Qt::Key_A); QTest::newRow("a") << "a" << QKeySequence(Qt::Key_A); - QTest::newRow("Ctrl+Left") << "Ctrl+Left" << QKeySequence(Qt::CTRL + Qt::Key_Left); - QTest::newRow("CTRL+LEFT") << "CTRL+LEFT" << QKeySequence(Qt::CTRL + Qt::Key_Left); - QTest::newRow("Meta+A") << "Meta+a" << QKeySequence(Qt::META + Qt::Key_A); - QTest::newRow("mEtA+A") << "mEtA+a" << QKeySequence(Qt::META + Qt::Key_A); - QTest::newRow("Ctrl++") << "Ctrl++" << QKeySequence(Qt::CTRL + Qt::Key_Plus); + QTest::newRow("Ctrl+Left") << "Ctrl+Left" << QKeySequence(Qt::CTRL | Qt::Key_Left); + QTest::newRow("CTRL+LEFT") << "CTRL+LEFT" << QKeySequence(Qt::CTRL | Qt::Key_Left); + QTest::newRow("Meta+A") << "Meta+a" << QKeySequence(Qt::META | Qt::Key_A); + QTest::newRow("mEtA+A") << "mEtA+a" << QKeySequence(Qt::META | Qt::Key_A); + QTest::newRow("Ctrl++") << "Ctrl++" << QKeySequence(Qt::CTRL | Qt::Key_Plus); // Invalid modifiers QTest::newRow("Win+A") << "Win+a" << QKeySequence(Qt::Key_unknown); @@ -580,10 +559,6 @@ void tst_QKeySequence::parseString_data() //QTest::newRow("Ctrl") << "Ctrl" << QKeySequence(Qt::CTRL); //QTest::newRow("Shift") << "Shift" << QKeySequence(Qt::SHIFT); - // Only Keys - QTest::newRow("a") << "a" << QKeySequence(Qt::Key_A); - QTest::newRow("A") << "A" << QKeySequence(Qt::Key_A); - // Incomplete QTest::newRow("Meta+Shift+") << "Meta+Shift+" << QKeySequence(Qt::Key_unknown); } @@ -630,34 +605,34 @@ void tst_QKeySequence::listToString_data() QList<QKeySequence> sequences; - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) - << QKeySequence(Qt::META + Qt::Key_A); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+Left; Meta+A") << "Ctrl+Left; Meta+A" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Semicolon) - << QKeySequence(Qt::META + Qt::Key_A); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Semicolon) + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+;; Meta+A") << "Ctrl+;; Meta+A" << sequences; sequences.clear(); sequences << QKeySequence(Qt::Key_Semicolon) - << QKeySequence(Qt::META + Qt::Key_A); + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow(";; Meta+A") << ";; Meta+A" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) - << QKeySequence(Qt::META + Qt::Key_Semicolon); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) + << QKeySequence(Qt::META | Qt::Key_Semicolon); QTest::newRow("Ctrl+Left; Meta+;") << "Ctrl+Left; Meta+;" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) << QKeySequence(); QTest::newRow("Ctrl+Left; ") << "Ctrl+Left; " << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) << QKeySequence() - << QKeySequence(Qt::META + Qt::Key_A); + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+Left; ; Meta+A") << "Ctrl+Left; ; Meta+A" << sequences; } @@ -676,40 +651,40 @@ void tst_QKeySequence::listFromString_data() QList<QKeySequence> sequences; - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) - << QKeySequence(Qt::META + Qt::Key_A); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+Left; Meta+A") << "Ctrl+Left; Meta+A" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Semicolon) - << QKeySequence(Qt::META + Qt::Key_A); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Semicolon) + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+;; Meta+A") << "Ctrl+;; Meta+A" << sequences; sequences.clear(); sequences << QKeySequence(Qt::Key_Semicolon) - << QKeySequence(Qt::META + Qt::Key_A); + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow(";; Meta+A") << ";; Meta+A" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) - << QKeySequence(Qt::META + Qt::Key_Semicolon); + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) + << QKeySequence(Qt::META | Qt::Key_Semicolon); QTest::newRow("Ctrl+Left; Meta+;") << "Ctrl+Left; Meta+;" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) << QKeySequence(); QTest::newRow("Ctrl+Left; ") << "Ctrl+Left; " << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) << QKeySequence() - << QKeySequence(Qt::META + Qt::Key_A); + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+Left; ; Meta+A") << "Ctrl+Left; ; Meta+A" << sequences; sequences.clear(); - sequences << QKeySequence(Qt::CTRL + Qt::Key_Left) + sequences << QKeySequence(Qt::CTRL | Qt::Key_Left) << QKeySequence(Qt::Key_unknown) - << QKeySequence(Qt::META + Qt::Key_A); + << QKeySequence(Qt::META | Qt::Key_A); QTest::newRow("Ctrl+Left; 4+3=2; Meta+A") << "Ctrl+Left; 4+3=2; Meta+A" << sequences; } |