diff options
Diffstat (limited to 'tests/auto/corelib/global/qkeycombination')
-rw-r--r-- | tests/auto/corelib/global/qkeycombination/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp | 96 |
2 files changed, 39 insertions, 68 deletions
diff --git a/tests/auto/corelib/global/qkeycombination/CMakeLists.txt b/tests/auto/corelib/global/qkeycombination/CMakeLists.txt index 9553a35dea..911eef7289 100644 --- a/tests/auto/corelib/global/qkeycombination/CMakeLists.txt +++ b/tests/auto/corelib/global/qkeycombination/CMakeLists.txt @@ -1,10 +1,19 @@ -# Generated from qkeycombination.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qkeycombination Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qkeycombination LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qkeycombination SOURCES tst_qkeycombination.cpp + LIBRARIES + Qt::TestPrivate ) diff --git a/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp b/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp index 7e70cdb70f..9941f8e154 100644 --- a/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp +++ b/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp @@ -1,38 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** 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) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QObject> #include <QTest> +#include <QtTest/private/qcomparisontesthelper_p.h> class tst_QKeyCombination : public QObject { Q_OBJECT private slots: + void compareCompiles(); void construction(); void operator_eq(); void operator_or(); @@ -49,6 +26,11 @@ constexpr auto bitwiseOr(T ... args) return (... | ((int)args)); } +void tst_QKeyCombination::compareCompiles() +{ + QTestPrivate::testEqualityOperatorsCompile<QKeyCombination>(); +} + void tst_QKeyCombination::construction() { { @@ -156,145 +138,125 @@ void tst_QKeyCombination::operator_eq() // default { QKeyCombination a, b; - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } // key only { QKeyCombination a; QKeyCombination b(Qt::Key_X); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::Key_Y); QKeyCombination b; - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::Key_Y); QKeyCombination b(Qt::Key_X); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::Key_F1); QKeyCombination b(Qt::Key_F1); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } // modifier only { QKeyCombination a; QKeyCombination b(Qt::CTRL); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::CTRL); QKeyCombination b; - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::CTRL); QKeyCombination b(Qt::SHIFT); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::CTRL); QKeyCombination b(Qt::CTRL); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } { QKeyCombination a(Qt::CTRL); QKeyCombination b(Qt::ControlModifier); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } { QKeyCombination a(Qt::ControlModifier); QKeyCombination b(Qt::CTRL); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } { QKeyCombination a(Qt::ControlModifier); QKeyCombination b(Qt::ControlModifier); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } // key and modifier { QKeyCombination a(Qt::Key_A); QKeyCombination b(Qt::SHIFT, Qt::Key_A); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::CTRL, Qt::Key_A); QKeyCombination b(Qt::SHIFT, Qt::Key_A); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::SHIFT, Qt::Key_A); QKeyCombination b(Qt::SHIFT, Qt::Key_A); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } { QKeyCombination a(Qt::SHIFT, Qt::Key_A); QKeyCombination b(Qt::SHIFT, Qt::Key_Escape); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::SHIFT, Qt::Key_A); QKeyCombination b(Qt::ShiftModifier, Qt::Key_A); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } { QKeyCombination a(Qt::SHIFT | Qt::CTRL, Qt::Key_A); QKeyCombination b(Qt::ControlModifier | Qt::ShiftModifier, Qt::Key_A); - QVERIFY(a == b); - QVERIFY(!(a != b)); + QT_TEST_EQUALITY_OPS(a, b, true); } // corner cases { QKeyCombination a(Qt::CTRL); QKeyCombination b(Qt::Key_Control); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } { QKeyCombination a(Qt::ALT); QKeyCombination b(Qt::Key_Alt); - QVERIFY(a != b); - QVERIFY(!(a == b)); + QT_TEST_EQUALITY_OPS(a, b, false); } } |