diff options
Diffstat (limited to 'tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp')
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index b4be24f0e0..6c63d1ee90 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -55,6 +55,7 @@ #include <qmenu.h> #include <qstyle.h> +#include <QTimer> #include <qdebug.h> Q_DECLARE_METATYPE(Qt::Key); @@ -132,6 +133,7 @@ private: enum { num_builtins = 10 }; QAction *activated, *highlighted, *builtins[num_builtins]; QString statustip; + bool m_onStatusTipTimerExecuted; }; // Testing get/set functions @@ -158,6 +160,7 @@ void tst_QMenu::getSetCheck() } tst_QMenu::tst_QMenu() + : m_onStatusTipTimerExecuted(false) { QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); } @@ -193,6 +196,7 @@ void tst_QMenu::init() { activated = highlighted = 0; lastMenu = 0; + m_onStatusTipTimerExecuted = false; } void tst_QMenu::createActions() @@ -492,8 +496,13 @@ void tst_QMenu::statusTip() //because showMenu calls QMenu::exec, we need to use a singleshot //to continue the test - QTimer::singleShot(200,this, SLOT(onStatusTipTimer())); + QTimer timer; + timer.setSingleShot(true); + connect(&timer, &QTimer::timeout, this, &tst_QMenu::onStatusTipTimer); + timer.setInterval(200); + timer.start(); btn->showMenu(); + QVERIFY(m_onStatusTipTimerExecuted); QVERIFY(statustip.isEmpty()); } @@ -513,6 +522,7 @@ void tst_QMenu::onStatusTipTimer() QCOMPARE(st, QString("sub action")); QVERIFY(menu->isVisible() == false); + m_onStatusTipTimerExecuted = true; } void tst_QMenu::widgetActionFocus() @@ -1037,6 +1047,14 @@ void tst_QMenu::QTBUG_37933_ampersands_data() QTest::newRow("simple") << QString("Test") << QString("Test"); QTest::newRow("ampersand") << QString("&Test") << QString("Test"); QTest::newRow("double_ampersand") << QString("&Test && more") << QString("Test & more"); + QTest::newRow("ampersand_in_parentheses") << QString("Test(&T) (&&) more") << QString("Test (&) more"); + QTest::newRow("ampersand_in_parentheses_after_space") << QString("Test (&T)") << QString("Test"); + QTest::newRow("ampersand_in_parentheses_after_spaces") << QString("Test (&T)") << QString("Test"); + QTest::newRow("ampersand_in_parentheses_before_space") << QString("Test(&T) ") << QString("Test "); + QTest::newRow("only_ampersand_in_parentheses") << QString("(&T)") << QString(""); + QTest::newRow("only_ampersand_in_parentheses_after_space") << QString(" (&T)") << QString(""); + QTest::newRow("parentheses_after_space") << QString(" (Dummy)") << QString(" (Dummy)"); + QTest::newRow("ampersand_after_space") << QString("About &Qt Project") << QString("About Qt Project"); } void tst_qmenu_QTBUG_37933_ampersands(); |