Skip to content

Commit

Permalink
tst_QKeySequence: Test qt_set_sequence_auto_mnemonic()
Browse files Browse the repository at this point in the history
qt_set_sequence_auto_mnemonic() is documented in the public api but its
on/off effect is not covered by any test.

Change-Id: I682da014bcf04db3ef2508c09781ee32d297eb1f
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
zzag committed Jan 10, 2025
1 parent 5bab844 commit 25c2396
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ static QChar macSymbolForQtKey(int key)

#endif

QT_BEGIN_NAMESPACE
extern void qt_set_sequence_auto_mnemonic(bool);
QT_END_NAMESPACE

class tst_QKeySequence : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -367,9 +371,6 @@ void tst_QKeySequence::keyBindings()

void tst_QKeySequence::mnemonic_data()
{
#ifdef Q_OS_MAC
QSKIP("Test not applicable to OS X");
#endif
QTest::addColumn<QString>("string");
QTest::addColumn<QString>("key");
QTest::addColumn<bool>("warning");
Expand All @@ -389,11 +390,21 @@ void tst_QKeySequence::mnemonic_data()

void tst_QKeySequence::mnemonic()
{
const auto resetAutoMnemonic = qScopeGuard([] {
#ifndef Q_OS_MAC
qt_set_sequence_auto_mnemonic(true);
#else
qt_set_sequence_auto_mnemonic(false);
#endif
});

QFETCH(QString, string);
QFETCH(QString, key);
QFETCH(bool, warning);

qt_set_sequence_auto_mnemonic(false);
QCOMPARE(QKeySequence::mnemonic(string), QKeySequence());

#ifdef QT_NO_DEBUG
Q_UNUSED(warning);
#else
Expand All @@ -403,11 +414,9 @@ void tst_QKeySequence::mnemonic()
// qWarning(qPrintable(str));
}
#endif
QKeySequence seq = QKeySequence::mnemonic(string);
QKeySequence res = QKeySequence(key);

QCOMPARE(seq, res);
#endif
qt_set_sequence_auto_mnemonic(true);
QCOMPARE(QKeySequence::mnemonic(string), QKeySequence(key));
}

void tst_QKeySequence::toString_data()
Expand Down

0 comments on commit 25c2396

Please sign in to comment.