diff --git a/tests/benchmarks/gui/kernel/CMakeLists.txt b/tests/benchmarks/gui/kernel/CMakeLists.txt index 1f79c7d99bc..9d5e480faa9 100644 --- a/tests/benchmarks/gui/kernel/CMakeLists.txt +++ b/tests/benchmarks/gui/kernel/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory(qguimetatype) add_subdirectory(qguivariant) +add_subdirectory(qkeysequence) diff --git a/tests/benchmarks/gui/kernel/qkeysequence/CMakeLists.txt b/tests/benchmarks/gui/kernel/qkeysequence/CMakeLists.txt new file mode 100644 index 00000000000..44332343d2e --- /dev/null +++ b/tests/benchmarks/gui/kernel/qkeysequence/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (C) 2025 Vlad Zahorodnii +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_bench_qkeysequence Binary: +##################################################################### + +qt_internal_add_benchmark(tst_bench_qkeysequence + SOURCES + tst_qkeysequence.cpp + LIBRARIES + Qt::Gui + Qt::Test +) diff --git a/tests/benchmarks/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/benchmarks/gui/kernel/qkeysequence/tst_qkeysequence.cpp new file mode 100644 index 00000000000..2ab9120d94c --- /dev/null +++ b/tests/benchmarks/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2025 Vlad Zahorodnii +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include +#include + +class tst_QKeySequence : public QObject +{ + Q_OBJECT + +private slots: + void fromString_data(); + void fromString(); +}; + +void tst_QKeySequence::fromString_data() +{ + QTest::addColumn("text"); + QTest::addColumn("format"); + + QTest::newRow("empty (portable)") << QString() << QKeySequence::PortableText; + QTest::newRow("empty (native)") << QString() << QKeySequence::NativeText; + + QTest::newRow("invalid (portable)") << QStringLiteral("pizza") << QKeySequence::PortableText; + QTest::newRow("invalid (native)") << QStringLiteral("pizza") << QKeySequence::NativeText; + + QTest::newRow("F (portable)") << QStringLiteral("F") << QKeySequence::PortableText; + QTest::newRow("F (native)") << QStringLiteral("F") << QKeySequence::NativeText; + + QTest::newRow("Ctrl+F (portable)") << QStringLiteral("Ctrl+F") << QKeySequence::PortableText; + QTest::newRow("Ctrl+F (native)") << QStringLiteral("Ctrl+F") << QKeySequence::NativeText; + + QTest::newRow("Meta+Ctrl+Alt+Shift+F (portable)") << QStringLiteral("Meta+Ctrl+Alt+Shift+F") << QKeySequence::PortableText; + QTest::newRow("Meta+Ctrl+Alt+Shift+F (native)") << QStringLiteral("Meta+Ctrl+Alt+Shift+F") << QKeySequence::NativeText; +} + +void tst_QKeySequence::fromString() +{ + QFETCH(QString, text); + QFETCH(QKeySequence::SequenceFormat, format); + + QBENCHMARK { + auto sequence = QKeySequence::fromString(text, format); + Q_UNUSED(sequence) + } +} + +QTEST_MAIN(tst_QKeySequence) +#include "tst_qkeysequence.moc"