summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-04 10:41:19 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-04 13:41:04 +0200
commitbc5f45052fd8f9a5481a37a6a4d55c7f6cbf037d (patch)
tree2c20e6c42ccd008e431a8d485450713883eacbb5 /tests
parentb8947e9194f0f88f464448ac51f6a05113d36a33 (diff)
parent3faf8f4d48abd982be8470786cc5f61372519722 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/corelib/global/qconfig-bootstrapped.h src/corelib/global/qglobal.h src/corelib/tools/qcryptographichash.cpp src/corelib/tools/qcryptographichash.h src/corelib/tools/qmessageauthenticationcode.cpp src/plugins/platforms/windows/qwindowswindow.h tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST Change-Id: Ib68112de985a3d714c2071f47c10e907e4f0229a
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST2
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp28
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp4
-rw-r--r--tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp64
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp106
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp26
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp105
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp48
-rw-r--r--tests/benchmarks/corelib/tools/qcryptographichash/main.cpp8
10 files changed, 371 insertions, 24 deletions
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index 9ffcf73d64..3e03d9e236 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -23,3 +23,5 @@ osx
osx-10.11 ci
osx-10.12 ci
+[testInputEvents]
+rhel-7.4
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index e995b69f60..542246ff2d 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -487,6 +487,7 @@ private Q_SLOTS:
void ioHttpRedirectPolicyErrors();
void ioHttpUserVerifiedRedirect_data();
void ioHttpUserVerifiedRedirect();
+ void ioHttpCookiesDuringRedirect();
#ifndef QT_NO_SSL
void putWithServerClosingConnectionImmediately();
#endif
@@ -8410,6 +8411,33 @@ void tst_QNetworkReply::ioHttpUserVerifiedRedirect()
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode);
}
+void tst_QNetworkReply::ioHttpCookiesDuringRedirect()
+{
+ MiniHttpServer target(httpEmpty200Response, false);
+
+ const QString cookieHeader = QStringLiteral("Set-Cookie: hello=world; Path=/;\r\n");
+ QString redirect = tempRedirectReplyStr();
+ // Insert 'cookieHeader' before the final \r\n
+ redirect.insert(redirect.length() - 2, cookieHeader);
+
+ QUrl url("http://localhost/");
+ url.setPort(target.serverPort());
+ redirect = redirect.arg(url.toString());
+ MiniHttpServer redirectServer(redirect.toLatin1(), false);
+
+ url = QUrl("http://localhost/");
+ url.setPort(redirectServer.serverPort());
+ QNetworkRequest request(url);
+ auto oldRedirectPolicy = manager.redirectPolicy();
+ manager.setRedirectPolicy(QNetworkRequest::RedirectPolicy::NoLessSafeRedirectPolicy);
+ QNetworkReplyPtr reply(manager.get(request));
+ // Set policy back to whatever it was
+ manager.setRedirectPolicy(oldRedirectPolicy);
+
+ QVERIFY(waitForFinish(reply) == Success);
+ QVERIFY(target.receivedData.contains("\r\nCookie: hello=world\r\n"));
+}
+
#ifndef QT_NO_SSL
class PutWithServerClosingConnectionImmediatelyHandler: public QObject
diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index f3a1ac84ff..90da0b64e2 100644
--- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -256,8 +256,8 @@ void tst_QNetworkProxyFactory::genericSystemProxy()
QFETCH(QString, hostName);
QFETCH(int, port);
-// The generic system proxy is only available on the following platforms
-#if (!defined Q_OS_WIN) && (!defined Q_OS_OSX) && !QT_CONFIG(libproxy)
+// We can only use the generic system proxy where available:
+#if !defined(Q_OS_WIN) && !defined(Q_OS_MACOS) && !QT_CONFIG(libproxy)
qputenv(envVar, url);
const QList<QNetworkProxy> systemProxy = QNetworkProxyFactory::systemProxyForQuery();
QCOMPARE(systemProxy.size(), 1);
diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
index b5bfde3cab..25c2701f69 100644
--- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
+++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/tst_qsslsocket_onDemandCertificates_member.cpp
@@ -168,29 +168,59 @@ void tst_QSslSocket_onDemandCertificates_member::proxyAuthenticationRequired(con
#ifndef QT_NO_OPENSSL
+static bool waitForEncrypted(QSslSocket *socket)
+{
+ Q_ASSERT(socket);
+
+ QEventLoop eventLoop;
+
+ QTimer connectionTimeoutWatcher;
+ connectionTimeoutWatcher.setSingleShot(true);
+ connectionTimeoutWatcher.connect(&connectionTimeoutWatcher, &QTimer::timeout,
+ [&eventLoop]() {
+ eventLoop.exit();
+ });
+
+ bool encrypted = false;
+ socket->connect(socket, &QSslSocket::encrypted, [&eventLoop, &encrypted](){
+ eventLoop.exit();
+ encrypted = true;
+ });
+
+ socket->connect(socket, QOverload<const QList<QSslError>&>::of(&QSslSocket::sslErrors),
+ [&eventLoop](){
+ eventLoop.exit();
+ });
+
+ // Wait for 30 s. maximum - the default timeout in our QSslSocket::waitForEncrypted ...
+ connectionTimeoutWatcher.start(30000);
+ eventLoop.exec();
+ return encrypted;
+}
+
void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMethods()
{
- QString host("www.qt.io");
+ const QString host("www.qt.io");
// not using any root certs -> should not work
QSslSocketPtr socket2 = newSocket();
this->socket = socket2.data();
socket2->setCaCertificates(QList<QSslCertificate>());
socket2->connectToHostEncrypted(host, 443);
- QVERIFY(!socket2->waitForEncrypted());
+ QVERIFY(!waitForEncrypted(socket2.data()));
// default: using on demand loading -> should work
QSslSocketPtr socket = newSocket();
this->socket = socket.data();
socket->connectToHostEncrypted(host, 443);
- QVERIFY2(socket->waitForEncrypted(), qPrintable(socket->errorString()));
+ QVERIFY2(waitForEncrypted(socket.data()), qPrintable(socket->errorString()));
// not using any root certs again -> should not work
QSslSocketPtr socket3 = newSocket();
this->socket = socket3.data();
socket3->setCaCertificates(QList<QSslCertificate>());
socket3->connectToHostEncrypted(host, 443);
- QVERIFY(!socket3->waitForEncrypted());
+ QVERIFY(!waitForEncrypted(socket3.data()));
// setting empty SSL configuration explicitly -> depends on on-demand loading
QSslSocketPtr socket4 = newSocket();
@@ -199,24 +229,16 @@ void tst_QSslSocket_onDemandCertificates_member::onDemandRootCertLoadingMemberMe
socket4->setSslConfiguration(conf);
socket4->connectToHostEncrypted(host, 443);
#ifdef QT_BUILD_INTERNAL
- bool rootCertLoadingAllowed = QSslSocketPrivate::rootCertOnDemandLoadingSupported();
-#if defined(Q_OS_LINUX)
- QCOMPARE(rootCertLoadingAllowed, true);
+ const bool works = QSslSocketPrivate::rootCertOnDemandLoadingSupported();
+#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
+ QCOMPARE(works, true);
#elif defined(Q_OS_MAC)
- QCOMPARE(rootCertLoadingAllowed, false);
-#endif // other platforms: undecided (Windows: depends on the version)
- // when we allow on demand loading, it is enabled by default,
- // so on Unix it will work without setting any certificates. Otherwise,
- // the configuration contains an empty set of certificates
- // and will fail.
- bool works;
-#if defined (Q_OS_WIN)
- works = false; // on Windows, this won't work even though we use on demand loading
- Q_UNUSED(rootCertLoadingAllowed)
-#else
- works = rootCertLoadingAllowed;
-#endif
- QCOMPARE(socket4->waitForEncrypted(), works);
+ QCOMPARE(works, false);
+#endif // other platforms: undecided.
+ // When we *allow* on-demand loading, we enable it by default; so, on Unix,
+ // it will work without setting any certificates. Otherwise, the configuration
+ // contains an empty set of certificates, so on-demand loading shall fail.
+ QCOMPARE(waitForEncrypted(socket4.data()), works);
#endif // QT_BUILD_INTERNAL
}
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index a63ca49cbb..7acdf98ec3 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -55,6 +55,8 @@
#include <qproxystyle.h>
#include <qdialog.h>
+Q_DECLARE_METATYPE(Qt::ItemFlags);
+
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
@@ -154,6 +156,8 @@ private slots:
void testDialogAsEditor();
void QTBUG46785_mouseout_hover_state();
void testClearModelInClickedSignal();
+ void inputMethodEnabled_data();
+ void inputMethodEnabled();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -2295,5 +2299,107 @@ void tst_QAbstractItemView::testClearModelInClickedSignal()
QCOMPARE(view.model(), nullptr);
}
+void tst_QAbstractItemView::inputMethodEnabled_data()
+{
+ QTest::addColumn<QByteArray>("viewType");
+ QTest::addColumn<Qt::ItemFlags>("itemFlags");
+ QTest::addColumn<bool>("result");
+
+ QList<QByteArray> widgets;
+ widgets << "QListView" << "QTreeView" << "QTableView";
+
+ for (const QByteArray &widget : qAsConst(widgets)) {
+ QTest::newRow(widget + ": no flags") << widget << Qt::ItemFlags(Qt::NoItemFlags) << false;
+ QTest::newRow(widget + ": checkable") << widget << Qt::ItemFlags(Qt::ItemIsUserCheckable) << false;
+ QTest::newRow(widget + ": selectable") << widget << Qt::ItemFlags(Qt::ItemIsSelectable) << false;
+ QTest::newRow(widget + ": enabled") << widget << Qt::ItemFlags(Qt::ItemIsEnabled) << false;
+ QTest::newRow(widget + ": selectable|enabled")
+ << widget << Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled) << false;
+ QTest::newRow(widget + ": editable|enabled")
+ << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled) << true;
+ QTest::newRow(widget + ": editable|enabled|selectable")
+ << widget << Qt::ItemFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable) << true;
+ }
+}
+
+void tst_QAbstractItemView::inputMethodEnabled()
+{
+ QFETCH(QByteArray, viewType);
+ QFETCH(Qt::ItemFlags, itemFlags);
+ QFETCH(bool, result);
+
+ QScopedPointer<QAbstractItemView> view;
+ if (viewType == "QListView")
+ view.reset(new QListView());
+ else if (viewType == "QTableView")
+ view.reset(new QTableView());
+ else if (viewType == "QTreeView")
+ view.reset(new QTreeView());
+ else
+ QVERIFY(0);
+
+ centerOnScreen(view.data());
+ view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
+
+ QStandardItemModel *model = new QStandardItemModel(view.data());
+ QStandardItem *item = new QStandardItem("first item");
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ model->appendRow(item);
+
+ QStandardItem *secondItem = new QStandardItem("test item");
+ secondItem->setFlags(Qt::ItemFlags(itemFlags));
+ model->appendRow(secondItem);
+
+ view->setModel(model);
+
+ // Check current changed
+ view->setCurrentIndex(model->index(0, 0));
+ QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled));
+ view->setCurrentIndex(model->index(1, 0));
+ QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result);
+ view->setCurrentIndex(model->index(0, 0));
+ QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled));
+
+ // Check focus by switching the activation of the window to force a focus in
+ view->setCurrentIndex(model->index(1, 0));
+ QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(view.data());
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
+ QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result);
+
+ view->setCurrentIndex(QModelIndex());
+ QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled));
+ QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(view.data());
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
+ QModelIndex index = model->index(1, 0);
+ QPoint p = view->visualRect(index).center();
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p);
+ if (itemFlags & Qt::ItemIsEnabled)
+ QCOMPARE(view->currentIndex(), index);
+ QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result);
+
+ index = model->index(0, 0);
+ QApplication::setActiveWindow(0);
+ QApplication::setActiveWindow(view.data());
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
+ p = view->visualRect(index).center();
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, Qt::NoModifier, p);
+ QCOMPARE(view->currentIndex(), index);
+ QVERIFY(!view->testAttribute(Qt::WA_InputMethodEnabled));
+
+ // There is a case when it goes to the first visible item so we
+ // make the flags of the first item match the ones we are testing
+ // to check the attribute correctly
+ QApplication::setActiveWindow(0);
+ view->setCurrentIndex(QModelIndex());
+ view->reset();
+ item->setFlags(Qt::ItemFlags(itemFlags));
+ QApplication::setActiveWindow(view.data());
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
+ QCOMPARE(view->testAttribute(Qt::WA_InputMethodEnabled), result);
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST
index a16fd19b99..fea108f3fd 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST
+++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST
@@ -1,2 +1,4 @@
[enterKey]
-opensuse-42.3
+opensuse-42.3 ci
+[testLineEditValidation]
+opensuse-42.3 ci
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 6ec1b754d0..a3e549aa50 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -74,6 +74,7 @@ private slots:
void testOwnership();
void testBehindTheScenesDeletion();
void testUnparenting();
+ void testUnparentReparent();
void testActivation();
void testAncestorChange();
void testDockWidget();
@@ -241,6 +242,31 @@ void tst_QWindowContainer::testUnparenting()
QVERIFY(!window->isVisible());
}
+void tst_QWindowContainer::testUnparentReparent()
+{
+ QWidget root;
+
+ QWindow *window = new QWindow();
+ QScopedPointer<QWidget> container(QWidget::createWindowContainer(window, &root));
+ container->setWindowTitle(QTest::currentTestFunction());
+ container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100);
+
+ root.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&root));
+
+ QTRY_VERIFY(window->isVisible());
+
+ container->setParent(nullptr);
+ QTRY_VERIFY(!window->isVisible());
+
+ container->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+ QTRY_VERIFY(window->isVisible());
+
+ container->setParent(&root); // This should not crash (QTBUG-63168)
+}
+
void tst_QWindowContainer::testAncestorChange()
{
QWidget root;
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index f8095badb8..3818b83584 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -143,6 +143,8 @@ private slots:
void task253125_lineEditCompletion();
void task247560_keyboardNavigation();
void QTBUG_14292_filesystem();
+ void QTBUG_52028_tabAutoCompletes();
+ void QTBUG_51889_activatedSentTwice();
private:
void filter(bool assync = false);
@@ -1742,5 +1744,108 @@ void tst_QCompleter::QTBUG_14292_filesystem()
QVERIFY(!comp.popup()->isVisible());
}
+void tst_QCompleter::QTBUG_52028_tabAutoCompletes()
+{
+ QStringList words;
+ words << "foobar1" << "foobar2" << "hux";
+
+ QWidget w;
+ w.setLayout(new QVBoxLayout);
+
+ QComboBox cbox;
+ cbox.setEditable(true);
+ cbox.setInsertPolicy(QComboBox::NoInsert);
+ cbox.addItems(words);
+
+ cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive);
+ cbox.completer()->setCompletionMode(QCompleter::PopupCompletion);
+
+ w.layout()->addWidget(&cbox);
+
+ // Adding a line edit is a good reason for tab to do something unrelated
+ QLineEdit le;
+ w.layout()->addWidget(&le);
+
+ const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
+ w.move(pos);
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated));
+
+ // Tab key will complete but not activate
+ cbox.lineEdit()->clear();
+ QTest::keyClick(&cbox, Qt::Key_H);
+ QVERIFY(cbox.completer()->popup());
+ QTRY_VERIFY(cbox.completer()->popup()->isVisible());
+ QTest::keyClick(cbox.completer()->popup(), Qt::Key_Tab);
+ QCOMPARE(cbox.completer()->currentCompletion(), QLatin1String("hux"));
+ QCOMPARE(activatedSpy.count(), 0);
+ QEXPECT_FAIL("", "QTBUG-52028 will not be fixed today.", Abort);
+ QCOMPARE(cbox.currentText(), QLatin1String("hux"));
+ QCOMPARE(activatedSpy.count(), 0);
+ QVERIFY(!le.hasFocus());
+}
+
+void tst_QCompleter::QTBUG_51889_activatedSentTwice()
+{
+ QStringList words;
+ words << "foobar1" << "foobar2" << "bar" <<"hux";
+
+ QWidget w;
+ w.setLayout(new QVBoxLayout);
+
+ QComboBox cbox;
+ setFrameless(&cbox);
+ cbox.setEditable(true);
+ cbox.setInsertPolicy(QComboBox::NoInsert);
+ cbox.addItems(words);
+
+ cbox.completer()->setCaseSensitivity(Qt::CaseInsensitive);
+ cbox.completer()->setCompletionMode(QCompleter::PopupCompletion);
+
+ w.layout()->addWidget(&cbox);
+
+ QLineEdit le;
+ w.layout()->addWidget(&le);
+
+ const auto pos = QApplication::desktop()->availableGeometry(&w).topLeft() + QPoint(200,200);
+ w.move(pos);
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated));
+
+ // Navigate + enter activates only once (first item)
+ cbox.lineEdit()->clear();
+ QTest::keyClick(&cbox, Qt::Key_F);
+ QVERIFY(cbox.completer()->popup());
+ QTRY_VERIFY(cbox.completer()->popup()->isVisible());
+ QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down);
+ QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return);
+ QTRY_COMPARE(activatedSpy.count(), 1);
+
+ // Navigate + enter activates only once (non-first item)
+ cbox.lineEdit()->clear();
+ activatedSpy.clear();
+ QTest::keyClick(&cbox, Qt::Key_H);
+ QVERIFY(cbox.completer()->popup());
+ QTRY_VERIFY(cbox.completer()->popup()->isVisible());
+ QTest::keyClick(cbox.completer()->popup(), Qt::Key_Down);
+ QTest::keyClick(cbox.completer()->popup(), Qt::Key_Return);
+ QTRY_COMPARE(activatedSpy.count(), 1);
+
+ // Full text + enter activates only once
+ cbox.lineEdit()->clear();
+ activatedSpy.clear();
+ QTest::keyClicks(&cbox, "foobar1");
+ QVERIFY(cbox.completer()->popup());
+ QTRY_VERIFY(cbox.completer()->popup()->isVisible());
+ QTest::keyClick(&cbox, Qt::Key_Return);
+ QTRY_COMPARE(activatedSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QCompleter)
#include "tst_qcompleter.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 9a0ca0565e..251a351cc1 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -39,6 +39,7 @@
#include <qstyleoption.h>
#include <QVBoxLayout>
#include <QLabel>
+#include <QPlainTextEdit>
#include <qscreen.h>
#include <qobject.h>
@@ -106,6 +107,7 @@ private slots:
void allowActiveAndDisabled();
#endif
+ void taskQTBUG56860_focus();
void check_endKey();
void check_homeKey();
@@ -710,6 +712,52 @@ void tst_QMenuBar::check_cursorKeys3()
}
#endif
+void tst_QMenuBar::taskQTBUG56860_focus()
+{
+#if defined(Q_OS_DARWIN)
+ QSKIP("Native key events are needed to test menu action activation on macOS.");
+#endif
+ QMainWindow w;
+ QMenuBar *mb = w.menuBar();
+
+ if (mb->platformMenuBar())
+ QSKIP("This test requires the Qt menubar.");
+
+ QMenu *em = mb->addMenu("&Edit");
+ em->setObjectName("EditMenu");
+ em->addAction("&Cut");
+ em->addAction("C&opy");
+ QPlainTextEdit *e = new QPlainTextEdit;
+ e->setObjectName("edit");
+
+ w.setCentralWidget(e);
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ QTRY_COMPARE(QApplication::focusWidget(), e);
+
+ // Open menu
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_E, Qt::AltModifier );
+ QTRY_COMPARE(QApplication::activePopupWidget(), em);
+ // key down to trigger focus
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ // and press ENTER to close
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ QTRY_COMPARE(QApplication::activePopupWidget(), nullptr);
+ // focus should have returned to the editor by now
+ QTRY_COMPARE(QApplication::focusWidget(), e);
+
+ // Now do it all over again...
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_E, Qt::AltModifier );
+ QTRY_COMPARE(QApplication::activePopupWidget(), em);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ QTRY_COMPARE(QApplication::activePopupWidget(), nullptr);
+ QTRY_COMPARE(QApplication::focusWidget(), e);
+
+}
+
/*!
If a popupmenu is active you can use home to go quickly to the first item in the menu.
*/
diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
index 5799b32b1c..507e2af708 100644
--- a/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
+++ b/tests/benchmarks/corelib/tools/qcryptographichash/main.cpp
@@ -79,6 +79,14 @@ const char *algoname(int i)
return "sha3_384-";
case QCryptographicHash::Sha3_512:
return "sha3_512-";
+ case QCryptographicHash::Keccak_224:
+ return "keccak_224-";
+ case QCryptographicHash::Keccak_256:
+ return "keccak_256-";
+ case QCryptographicHash::Keccak_384:
+ return "keccak_384-";
+ case QCryptographicHash::Keccak_512:
+ return "keccak_512-";
}
Q_UNREACHABLE();
return 0;