summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cmake/CMakeLists.txt12
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt30
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.cpp43
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.h52
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.ui34
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/res.qrc4
-rw-r--r--tests/auto/corelib/global/qflags/tst_qflags.cpp12
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp24
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp68
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp8
-rw-r--r--tests/auto/network/access/qnetworkreply/BLACKLIST2
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp38
-rw-r--r--tests/auto/network/socket/qtcpsocket/BLACKLIST2
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp9
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp122
-rw-r--r--tests/auto/network/ssl/qsslsocket/BLACKLIST2
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp7
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp49
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp144
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp2
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.h2
21 files changed, 516 insertions, 150 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 0e6da23c09..40c86132e9 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -157,7 +157,13 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS)
expect_pass(test_interface)
endif()
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
- expect_pass(test_interface_link_libraries)
- expect_pass(test_moc_macro_target)
+expect_pass(test_interface_link_libraries)
+expect_pass(test_moc_macro_target)
+
+if (NOT CMAKE_VERSION VERSION_LESS 3.8)
+ # With earlier CMake versions, this test would simply run moc multiple times and lead to:
+ # /usr/bin/ld: error: CMakeFiles/mywidget.dir/mywidget_automoc.cpp.o: multiple definition of 'MyWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)'
+ # /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here
+ # Reason: SKIP_* properties were added in CMake 3.8 only
+ expect_pass(test_QTBUG-63422)
endif()
diff --git a/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt
new file mode 100644
index 0000000000..a0b82caee4
--- /dev/null
+++ b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 2.8)
+project(test_dependent_modules)
+
+find_package(Qt5Widgets REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# make sure CMP0071 warnings cause a test failure
+set(CMAKE_SUPPRESS_DEVELOPER_ERRORS FALSE CACHE INTERNAL "" FORCE)
+
+qt5_wrap_cpp(moc_files mywidget.h)
+qt5_wrap_ui(ui_files mywidget.ui)
+qt5_add_resources(qrc_files res.qrc)
+
+add_executable(mywidget
+ # source files
+ mywidget.cpp
+ mywidget.h
+ mywidget.ui
+ res.qrc
+
+ # generated files
+ ${moc_files}
+ ${ui_files}
+ ${qrc_files}
+)
+target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES})
diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
new file mode 100644
index 0000000000..7bc42537d5
--- /dev/null
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@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$
+**
+****************************************************************************/
+
+#include "mywidget.h"
+#include "ui_mywidget.h"
+
+MyWidget::MyWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ emit someSignal();
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ MyWidget myWidget;
+ return 0;
+}
diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.h b/tests/auto/cmake/test_QTBUG-63422/mywidget.h
new file mode 100644
index 0000000000..d0c79c0538
--- /dev/null
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@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$
+**
+****************************************************************************/
+
+#ifndef MYWIDGET_H
+#define MYWIDGET_H
+
+#include <QWidget>
+
+namespace Ui
+{
+class MyWidget;
+}
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ MyWidget(QWidget *parent = nullptr);
+
+signals:
+ void someSignal();
+
+private:
+ Ui::MyWidget *ui = nullptr;
+};
+
+#endif
diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.ui b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui
new file mode 100644
index 0000000000..ac42ac4dc2
--- /dev/null
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="textEdit"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_QTBUG-63422/res.qrc b/tests/auto/cmake/test_QTBUG-63422/res.qrc
new file mode 100644
index 0000000000..4ca9cd5837
--- /dev/null
+++ b/tests/auto/cmake/test_QTBUG-63422/res.qrc
@@ -0,0 +1,4 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+</qresource>
+</RCC>
diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp
index 7dd1a1be01..2f1b56629a 100644
--- a/tests/auto/corelib/global/qflags/tst_qflags.cpp
+++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp
@@ -290,6 +290,18 @@ void tst_QFlags::testSetFlags()
btn.setFlag(Qt::LeftButton, false);
QVERIFY(!btn.testFlag(Qt::LeftButton));
QVERIFY(!btn.testFlag(Qt::MidButton));
+
+ MyStrictFlags flags;
+ flags.setFlag(MyStrictEnum::StrictOne);
+ flags.setFlag(MyStrictEnum::StrictTwo, true);
+ QVERIFY(flags.testFlag(MyStrictEnum::StrictOne));
+ QVERIFY(flags.testFlag(MyStrictEnum::StrictTwo));
+ QVERIFY(!flags.testFlag(MyStrictEnum::StrictFour));
+
+ flags.setFlag(MyStrictEnum::StrictTwo, false);
+ QVERIFY(flags.testFlag(MyStrictEnum::StrictOne));
+ QVERIFY(!flags.testFlag(MyStrictEnum::StrictTwo));
+ QVERIFY(!flags.testFlag(MyStrictEnum::StrictFour));
}
// (statically) check QTypeInfo for QFlags instantiations:
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 1643eed3d2..15c63d4acd 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -197,10 +197,22 @@ private slots:
// Check whether QT_LOGGING_CONF is picked up from environment
//
- qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
+ Q_ASSERT(!qApp); // Rules should not require an app to resolve
- QLoggingRegistry registry;
- registry.init();
+ qputenv("QT_LOGGING_RULES", "qt.foo.bar=true");
+ QLoggingCategory qtEnabledByLoggingRule("qt.foo.bar");
+ QCOMPARE(qtEnabledByLoggingRule.isDebugEnabled(), true);
+ QLoggingCategory qtDisabledByDefault("qt.foo.baz");
+ QCOMPARE(qtDisabledByDefault.isDebugEnabled(), false);
+
+ QLoggingRegistry &registry = *QLoggingRegistry::instance();
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 1);
+
+ qunsetenv("QT_LOGGING_RULES");
+ qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
+ registry.initalizeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0);
QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0);
@@ -208,7 +220,7 @@ private slots:
// check that QT_LOGGING_RULES take precedence
qputenv("QT_LOGGING_RULES", "Digia.*=true");
- registry.init();
+ registry.initalizeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 2);
QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled, true);
}
@@ -234,7 +246,7 @@ private slots:
file.close();
QLoggingRegistry registry;
- registry.init();
+ registry.initalizeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 1);
// remove file again
@@ -300,6 +312,6 @@ private slots:
}
};
-QTEST_MAIN(tst_QLoggingRegistry)
+QTEST_APPLESS_MAIN(tst_QLoggingRegistry)
#include "tst_qloggingregistry.moc"
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 094c6ed0a5..1092216fb7 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -95,6 +95,7 @@ private slots:
void stackSize();
void stressTest();
void takeAllAndIncreaseMaxThreadCount();
+ void waitForDoneAfterTake();
private:
QMutex m_functionTestMutex;
@@ -1267,5 +1268,72 @@ void tst_QThreadPool::takeAllAndIncreaseMaxThreadCount() {
delete task3;
}
+void tst_QThreadPool::waitForDoneAfterTake()
+{
+ class Task : public QRunnable
+ {
+ public:
+ Task(QSemaphore *mainBarrier, QSemaphore *threadBarrier)
+ : m_mainBarrier(mainBarrier)
+ , m_threadBarrier(threadBarrier)
+ {}
+
+ void run()
+ {
+ m_mainBarrier->release();
+ m_threadBarrier->acquire();
+ }
+
+ private:
+ QSemaphore *m_mainBarrier = nullptr;
+ QSemaphore *m_threadBarrier = nullptr;
+ };
+
+ int threadCount = 4;
+
+ // Blocks the main thread from releasing the threadBarrier before all run() functions have started
+ QSemaphore mainBarrier;
+ // Blocks the tasks from completing their run function
+ QSemaphore threadBarrier;
+
+ QThreadPool manager;
+ manager.setMaxThreadCount(threadCount);
+
+ // Fill all the threads with runnables that wait for the threadBarrier
+ for (int i = 0; i < threadCount; i++) {
+ auto *task = new Task(&mainBarrier, &threadBarrier);
+ manager.start(task);
+ }
+
+ QVERIFY(manager.activeThreadCount() == manager.maxThreadCount());
+
+ // Add runnables that are immediately removed from the pool queue.
+ // This sets the queue elements to nullptr in QThreadPool and we want to test that
+ // the threads keep going through the queue after encountering a nullptr.
+ for (int i = 0; i < threadCount; i++) {
+ QRunnable *runnable = createTask(emptyFunct);
+ manager.start(runnable);
+ QVERIFY(manager.tryTake(runnable));
+ }
+
+ // Add another runnable that will not be removed
+ manager.start(createTask(emptyFunct));
+
+ // Wait for the first runnables to start
+ mainBarrier.acquire(threadCount);
+
+ QVERIFY(mainBarrier.available() == 0);
+ QVERIFY(threadBarrier.available() == 0);
+
+ // Release runnables that are waiting and expect all runnables to complete
+ threadBarrier.release(threadCount);
+
+ // Using qFatal instead of QVERIFY to force exit if threads are still running after timeout.
+ // Otherwise, QCoreApplication will still wait for the stale threads and never exit the test.
+ if (!manager.waitForDone(5 * 60 * 1000))
+ qFatal("waitForDone returned false. Aborting to stop background threads.");
+
+}
+
QTEST_MAIN(tst_QThreadPool);
#include "tst_qthreadpool.moc"
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 374fec221e..6975452d76 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -245,6 +245,7 @@ private slots:
void qhashInt() const { qhash<int>(); }
void qhashMovable() const { qhash<Movable>(); }
void qhashCustom() const { qhash<Custom>(); }
+ void removeAllWithAlias() const;
void removeInt() const;
void removeMovable() const;
void removeCustom() const;
@@ -1722,6 +1723,13 @@ void tst_QVector::prependCustom() const
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
+void tst_QVector::removeAllWithAlias() const
+{
+ QVector<QString> strings;
+ strings << "One" << "Two" << "Three" << "One" /* must be distinct, but equal */;
+ QCOMPARE(strings.removeAll(strings.front()), 2); // will trigger asan/ubsan
+}
+
template<typename T>
void tst_QVector::remove() const
{
diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST
index d6fc717e37..1052239797 100644
--- a/tests/auto/network/access/qnetworkreply/BLACKLIST
+++ b/tests/auto/network/access/qnetworkreply/BLACKLIST
@@ -32,6 +32,8 @@ linux
windows
[putToFtp]
windows ci
+[putToFtpWithInvalidCredentials]
+windows ci
[putWithServerClosingConnectionImmediately]
windows
[qtbug28035browserDoesNotLoadQtProjectOrgCorrectly]
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index fffe853c14..a2e602e4c5 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -622,7 +622,7 @@ protected:
Q_ASSERT(!client.isNull());
// we need to emulate the bytesWrittenSlot call if the data is empty.
if (dataToTransmit.size() == 0) {
- QMetaObject::invokeMethod(this, "bytesWrittenSlot", Qt::QueuedConnection);
+ emit client->bytesWritten(0);
} else {
client->write(dataToTransmit);
// FIXME: For SSL connections, if we don't flush the socket, the
@@ -659,22 +659,26 @@ private slots:
#ifndef QT_NO_SSL
void slotSslErrors(const QList<QSslError>& errors)
{
- Q_ASSERT(!client.isNull());
- qDebug() << "slotSslErrors" << client->errorString() << errors;
+ QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
+ Q_ASSERT(currentClient);
+ qDebug() << "slotSslErrors" << currentClient->errorString() << errors;
}
#endif
void slotError(QAbstractSocket::SocketError err)
{
- if (client.isNull())
- qDebug() << "slotError" << err;
- else
- qDebug() << "slotError" << err << client->errorString();
+ QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
+ Q_ASSERT(currentClient);
+ qDebug() << "slotError" << err << currentClient->errorString();
}
public slots:
void readyReadSlot()
{
- Q_ASSERT(!client.isNull());
+ QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
+ Q_ASSERT(currentClient);
+ if (currentClient != client)
+ client = currentClient;
+
receivedData += client->readAll();
const int doubleEndlPos = receivedData.indexOf("\r\n\r\n");
@@ -8290,11 +8294,23 @@ void tst_QNetworkReply::ioHttpRedirectErrors()
QNetworkReplyPtr reply(manager.get(request));
if (localhost.scheme() == "https")
reply.data()->ignoreSslErrors();
- QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
- QCOMPARE(waitForFinish(reply), int(Failure));
+ QEventLoop eventLoop;
+ QTimer watchDog;
+ watchDog.setSingleShot(true);
- QCOMPARE(spy.count(), 1);
+ reply->connect(reply.data(), QOverload<QNetworkReply::NetworkError>().of(&QNetworkReply::error),
+ [&eventLoop](QNetworkReply::NetworkError){
+ eventLoop.exit(Failure);
+ });
+
+ watchDog.connect(&watchDog, &QTimer::timeout, [&eventLoop](){
+ eventLoop.exit(Timeout);
+ });
+
+ watchDog.start(5000);
+
+ QCOMPARE(eventLoop.exec(), int(Failure));
QCOMPARE(reply->error(), error);
}
diff --git a/tests/auto/network/socket/qtcpsocket/BLACKLIST b/tests/auto/network/socket/qtcpsocket/BLACKLIST
index 5fc2589323..96e59e5678 100644
--- a/tests/auto/network/socket/qtcpsocket/BLACKLIST
+++ b/tests/auto/network/socket/qtcpsocket/BLACKLIST
@@ -6,8 +6,6 @@ windows
windows
[invalidProxy:socks5-on-http]
windows
-[disconnectWhileLookingUp]
-windows
[timeoutConnect:ip]
windows
]
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index d7c8c8c378..e45eda2940 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -1445,8 +1445,15 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
}
// let anything queued happen
+
QEventLoop loop;
- QTimer::singleShot(50, &loop, SLOT(quit()));
+ // If 'doClose' is false then we called '::waitForDisconnected' earlier, meaning
+ // we are already 'Unconnected'. So we don't need to wait for any potentially slow host lookups.
+ QTimer::singleShot(doClose ? 4000 : 50, &loop, SLOT(quit()));
+ connect(socket, &QTcpSocket::stateChanged, [&loop](QAbstractSocket::SocketState state) {
+ if (state == QAbstractSocket::UnconnectedState)
+ loop.exit(); // we don't need to wait for the timer to expire; we're done.
+ });
loop.exec();
// recheck
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 0f46caa7c2..6dff9f3420 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -47,12 +47,6 @@
#include "../../../network-settings.h"
#include "emulationdetector.h"
-#ifndef QT_NO_BEARERMANAGEMENT
-#include <QtNetwork/qnetworkconfigmanager.h>
-#include <QtNetwork/qnetworkconfiguration.h>
-#include <QtNetwork/qnetworksession.h>
-#endif
-
#if defined(Q_OS_LINUX)
#define SHOULD_CHECK_SYSCALL_SUPPORT
#include <netinet/in.h>
@@ -130,11 +124,6 @@ private:
bool m_skipUnsupportedIPv6Tests;
QList<QHostAddress> allAddresses;
-#ifndef QT_NO_BEARERMANAGEMENT
- QNetworkConfigurationManager *netConfMan;
- QNetworkConfiguration networkConfiguration;
- QSharedPointer<QNetworkSession> networkSession;
-#endif
QUdpSocket *m_asyncSender;
QUdpSocket *m_asyncReceiver;
};
@@ -210,16 +199,6 @@ void tst_QUdpSocket::initTestCase_data()
if (!newTestServer)
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
#endif
-
-#ifndef QT_NO_BEARERMANAGEMENT
- netConfMan = new QNetworkConfigurationManager(this);
- networkConfiguration = netConfMan->defaultConfiguration();
- networkSession = QSharedPointer<QNetworkSession>::create(networkConfiguration);
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
- }
-#endif
}
void tst_QUdpSocket::initTestCase()
@@ -261,9 +240,6 @@ void tst_QUdpSocket::cleanup()
void tst_QUdpSocket::constructing()
{
QUdpSocket socket;
-#ifdef FORCE_SESSION
- socket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(socket.isSequential());
QVERIFY(!socket.isOpen());
@@ -281,9 +257,6 @@ void tst_QUdpSocket::constructing()
void tst_QUdpSocket::unconnectedServerAndClientTest()
{
QUdpSocket serverSocket;
-#ifdef FORCE_SESSION
- serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
@@ -296,9 +269,6 @@ void tst_QUdpSocket::unconnectedServerAndClientTest()
QHostAddress serverAddress = makeNonAny(serverSocket.localAddress());
for (int i = 0; i < 3; ++i) {
QUdpSocket clientSocket;
-#ifdef FORCE_SESSION
- clientSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QCOMPARE(int(clientSocket.writeDatagram(message[i], strlen(message[i]),
serverAddress, serverSocket.localPort())),
int(strlen(message[i])));
@@ -352,9 +322,6 @@ void tst_QUdpSocket::broadcasting()
QSKIP("No interface can broadcast");
for (int i = 0; i < 4; ++i) {
QUdpSocket serverSocket;
-#ifdef FORCE_SESSION
- serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(serverSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0), serverSocket.errorString().toLatin1().constData());
quint16 serverPort = serverSocket.localPort();
@@ -363,9 +330,6 @@ void tst_QUdpSocket::broadcasting()
connect(&serverSocket, SIGNAL(readyRead()), SLOT(empty_readyReadSlot()));
QUdpSocket broadcastSocket;
-#ifdef FORCE_SESSION
- broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0);
for (int j = 0; j < 10; ++j) {
@@ -444,10 +408,6 @@ void tst_QUdpSocket::loop()
QUdpSocket peter;
QUdpSocket paul;
-#ifdef FORCE_SESSION
- peter.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- paul.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// make sure we bind to IPv4
QHostAddress localhost = QHostAddress::LocalHost;
@@ -518,10 +478,6 @@ void tst_QUdpSocket::ipv6Loop()
QUdpSocket peter;
QUdpSocket paul;
-#ifdef FORCE_SESSION
- peter.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- paul.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
int peterPort;
int paulPort;
@@ -745,10 +701,6 @@ void tst_QUdpSocket::connectToHost()
{
QUdpSocket socket1;
QUdpSocket socket2;
-#ifdef FORCE_SESSION
- socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData());
@@ -763,11 +715,6 @@ void tst_QUdpSocket::bindAndConnectToHost()
QUdpSocket socket1;
QUdpSocket socket2;
QUdpSocket dummysocket;
-#ifdef FORCE_SESSION
- socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- dummysocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// we use the dummy socket to use up a file descriptor
dummysocket.bind();
@@ -791,16 +738,10 @@ void tst_QUdpSocket::bindAndConnectToHost()
void tst_QUdpSocket::pendingDatagramSize()
{
QUdpSocket server;
-#ifdef FORCE_SESSION
- server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = makeNonAny(server.localAddress());
QUdpSocket client;
-#ifdef FORCE_SESSION
- client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(client.writeDatagram("this is", 7, serverAddress, server.localPort()) == 7);
QVERIFY(client.writeDatagram(0, 0, serverAddress, server.localPort()) == 0);
QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10);
@@ -839,16 +780,10 @@ void tst_QUdpSocket::pendingDatagramSize()
void tst_QUdpSocket::writeDatagram()
{
QUdpSocket server;
-#ifdef FORCE_SESSION
- server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = makeNonAny(server.localAddress());
QUdpSocket client;
-#ifdef FORCE_SESSION
- client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
@@ -886,16 +821,10 @@ void tst_QUdpSocket::performance()
QByteArray arr(8192, '@');
QUdpSocket server;
-#ifdef FORCE_SESSION
- server.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
QHostAddress serverAddress = makeNonAny(server.localAddress());
QUdpSocket client;
-#ifdef FORCE_SESSION
- client.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
client.connectToHost(serverAddress, server.localPort());
QVERIFY(client.waitForConnected(10000));
@@ -932,14 +861,8 @@ void tst_QUdpSocket::bindMode()
}
QUdpSocket socket;
-#ifdef FORCE_SESSION
- socket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData());
QUdpSocket socket2;
-#ifdef FORCE_SESSION
- socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(!socket2.bind(socket.localPort()));
#if defined(Q_OS_UNIX)
QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
@@ -991,9 +914,6 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer()
quint16 peerPort = 33533 + int(bind);
QUdpSocket sUdp;
-#ifdef FORCE_SESSION
- sUdp.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QSignalSpy sReadyReadSpy(&sUdp, SIGNAL(readyRead()));
if (bind)
QVERIFY(sUdp.bind());
@@ -1026,9 +946,6 @@ void tst_QUdpSocket::writeToNonExistingPeer()
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
QUdpSocket sConnected;
-#ifdef FORCE_SESSION
- sConnected.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QSignalSpy sConnectedReadyReadSpy(&sConnected, SIGNAL(readyRead()));
QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(error(QAbstractSocket::SocketError)));
sConnected.connectToHost(peerAddress, peerPort, QIODevice::ReadWrite);
@@ -1198,18 +1115,12 @@ void tst_QUdpSocket::zeroLengthDatagram()
return;
QUdpSocket receiver;
-#ifdef FORCE_SESSION
- receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(receiver.bind());
QVERIFY(!receiver.waitForReadyRead(100));
QVERIFY(!receiver.hasPendingDatagrams());
QUdpSocket sender;
-#ifdef FORCE_SESSION
- sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QCOMPARE(sender.writeDatagram(QNetworkDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort())), qint64(0));
QVERIFY2(receiver.waitForReadyRead(1000), QtNetworkSettings::msgSocketError(receiver).constData());
@@ -1262,9 +1173,6 @@ void tst_QUdpSocket::multicastTtlOption()
}
QUdpSocket udpSocket;
-#ifdef FORCE_SESSION
- udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// bind, but ignore the result, we are only interested in initializing the socket
(void) udpSocket.bind(bindAddress, 0);
udpSocket.setSocketOption(QUdpSocket::MulticastTtlOption, ttl);
@@ -1315,9 +1223,6 @@ void tst_QUdpSocket::multicastLoopbackOption()
}
QUdpSocket udpSocket;
-#ifdef FORCE_SESSION
- udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// bind, but ignore the result, we are only interested in initializing the socket
(void) udpSocket.bind(bindAddress, 0);
udpSocket.setSocketOption(QUdpSocket::MulticastLoopbackOption, loopback);
@@ -1341,9 +1246,6 @@ void tst_QUdpSocket::multicastJoinBeforeBind()
QFETCH(QHostAddress, groupAddress);
QUdpSocket udpSocket;
-#ifdef FORCE_SESSION
- udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// cannot join group before binding
QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::joinMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState");
QVERIFY(!udpSocket.joinMulticastGroup(groupAddress));
@@ -1376,9 +1278,6 @@ void tst_QUdpSocket::multicastLeaveAfterClose()
}
QUdpSocket udpSocket;
-#ifdef FORCE_SESSION
- udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QHostAddress bindAddress = QHostAddress::AnyIPv4;
if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol)
bindAddress = QHostAddress::AnyIPv6;
@@ -1487,9 +1386,6 @@ void tst_QUdpSocket::multicast()
}
QUdpSocket receiver;
-#ifdef FORCE_SESSION
- receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
// bind first, then verify that we can join the multicast group
QVERIFY2(receiver.bind(bindAddress, 0) == bindResult,
@@ -1515,9 +1411,6 @@ void tst_QUdpSocket::multicast()
<< QByteArray("cdef");
QUdpSocket sender;
-#ifdef FORCE_SESSION
- sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
sender.bind();
foreach (const QByteArray &datagram, datagrams) {
QCOMPARE(int(sender.writeDatagram(datagram, groupAddress, receiver.localPort())),
@@ -1563,9 +1456,6 @@ void tst_QUdpSocket::echo()
QHostAddress remote = info.addresses().first();
QUdpSocket sock;
-#ifdef FORCE_SESSION
- sock.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
if (connect) {
sock.connectToHost(remote, 7);
QVERIFY(sock.waitForConnected(10000));
@@ -1785,10 +1675,6 @@ void tst_QUdpSocket::readyRead()
char buf[1];
QUdpSocket sender, receiver;
-#ifdef FORCE_SESSION
- sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0));
quint16 port = receiver.localPort();
@@ -1839,10 +1725,6 @@ void tst_QUdpSocket::readyReadForEmptyDatagram()
return;
QUdpSocket sender, receiver;
-#ifdef FORCE_SESSION
- sender.setProperty("_q_networksession", QVariant::fromValue(networkSession));
- receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0));
quint16 port = receiver.localPort();
@@ -1891,10 +1773,6 @@ void tst_QUdpSocket::asyncReadDatagram()
m_asyncSender = new QUdpSocket;
m_asyncReceiver = new QUdpSocket;
-#ifdef FORCE_SESSION
- m_asyncSender->setProperty("_q_networksession", QVariant::fromValue(networkSession));
- m_asyncReceiver->setProperty("_q_networksession", QVariant::fromValue(networkSession));
-#endif
QVERIFY(m_asyncReceiver->bind(QHostAddress(QHostAddress::AnyIPv4), 0));
quint16 port = m_asyncReceiver->localPort();
diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST
index 52c023b78f..a9ecc69f50 100644
--- a/tests/auto/network/ssl/qsslsocket/BLACKLIST
+++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST
@@ -1,6 +1,4 @@
windows
-[waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth]
-*
[protocolServerSide:ssl3-any]
rhel-7.2
[protocolServerSide:tls1.0-any]
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 12588c5e29..4de77a9080 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1601,7 +1601,12 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead()
QFETCH_GLOBAL(bool, setProxy);
if (setProxy && !socket->waitForEncrypted(10000))
QSKIP("Skipping flaky test - See QTBUG-29941");
- QVERIFY(socket->waitForReadyRead(10000));
+
+ // We only do this if we have no bytes available to read already because readyRead will
+ // not be emitted again.
+ if (socket->bytesAvailable() == 0)
+ QVERIFY(socket->waitForReadyRead(10000));
+
QVERIFY(!socket->peerCertificate().isNull());
QVERIFY(!socket->peerCertificateChain().isEmpty());
}
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index fa543ae2c3..90019a1798 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -210,6 +210,7 @@ private slots:
void QTBUG12268_hiddenMovedSectionSorting();
void QTBUG14242_hideSectionAutoSize();
void QTBUG50171_visualRegionForSwappedItems();
+ void QTBUG53221_assertShiftHiddenRow();
void ensureNoIndexAtLength();
void offsetConsistent();
@@ -2384,6 +2385,54 @@ void tst_QHeaderView::QTBUG50171_visualRegionForSwappedItems()
headerView.testVisualRegionForSelection();
}
+class QTBUG53221_Model : public QAbstractItemModel
+{
+public:
+ void insertRowAtBeginning()
+ {
+ Q_EMIT layoutAboutToBeChanged();
+ m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count()));
+ // Rows are always inserted at the beginning, so move all others.
+ foreach (const QModelIndex &persIndex, persistentIndexList())
+ {
+ // The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning.
+ changePersistentIndex(persIndex, index(persIndex.row() + 1, persIndex.column(), persIndex.parent()));
+ }
+ Q_EMIT layoutChanged();
+ }
+
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ return (role == Qt::DisplayRole) ? m_displayNames.at(index.row()) : QVariant();
+ }
+
+ QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); }
+ QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const override { return m_displayNames.count(); }
+ int columnCount(const QModelIndex &) const override { return 1; }
+
+private:
+ QStringList m_displayNames;
+};
+
+void tst_QHeaderView::QTBUG53221_assertShiftHiddenRow()
+{
+ QTableView tableView;
+ QTBUG53221_Model modelTableView;
+ tableView.setModel(&modelTableView);
+
+ modelTableView.insertRowAtBeginning();
+ tableView.setRowHidden(0, true);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), true);
+ modelTableView.insertRowAtBeginning();
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), true);
+ modelTableView.insertRowAtBeginning();
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), false);
+ QCOMPARE(tableView.verticalHeader()->isSectionHidden(2), true);
+}
+
void protected_QHeaderView::testVisualRegionForSelection()
{
QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2)));
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 929b80ba15..b2e1a2d9b5 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -196,6 +196,7 @@ private slots:
void taskQTBUG_37813_crash();
void taskQTBUG_45697_crash();
void taskQTBUG_7232_AllowUserToControlSingleStep();
+ void taskQTBUG_8376();
void testInitialFocus();
};
@@ -1086,6 +1087,103 @@ void tst_QTreeView::keyboardSearch()
// The item that starts with B is selected.
view.keyboardSearch(QLatin1String("B"));
QVERIFY(view.selectionModel()->isSelected(model.index(1, 0)));
+
+ // Test that it wraps round
+ model.appendRow(new QStandardItem("Andy"));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(3, 0)));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(0, 0)));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(3, 0)));
+
+ // Test that it handles the case where the first item is hidden correctly
+ model.insertRow(0, new QStandardItem("Hidden item"));
+ view.setRowHidden(0, QModelIndex(), true);
+
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(1, 0)));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(4, 0)));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(1, 0)));
+
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ model.clear();
+ view.setCurrentIndex(QModelIndex());
+ QList<QStandardItem *> items = { new QStandardItem("Andreas"), new QStandardItem("Alicia") };
+ model.appendRow(items);
+ items = { new QStandardItem("Baldrian"), new QStandardItem("Belinda") };
+ model.appendRow(items);
+ items = { new QStandardItem("Cecilie"), new QStandardItem("Claire") };
+ model.appendRow(items);
+ QVERIFY(!view.selectionModel()->hasSelection());
+ QVERIFY(!view.selectionModel()->isSelected(model.index(0, 0)));
+
+ // We want to search on the 2nd column so we have to force it to have
+ // an index in that column as a starting point
+ view.setCurrentIndex(QModelIndex(model.index(0, 1)));
+ // Second item in first row is selected
+ view.keyboardSearch(QLatin1String("A"));
+ QTRY_VERIFY(view.selectionModel()->isSelected(model.index(0, 1)));
+ QVERIFY(view.currentIndex() == model.index(0, 1));
+
+ // Second item in first row is still selected
+ view.keyboardSearch(QLatin1String("l"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(0, 1)));
+ QCOMPARE(view.currentIndex(), model.index(0, 1));
+
+ // No "AnB" item - keep the same selection.
+ view.keyboardSearch(QLatin1String("B"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(0, 1)));
+ QCOMPARE(view.currentIndex(), model.index(0, 1));
+
+ // Wait a bit.
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+
+ // The item that starts with B is selected.
+ view.keyboardSearch(QLatin1String("B"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(1, 1)));
+ QCOMPARE(view.currentIndex(), model.index(1, 1));
+
+ // Test that it wraps round
+ items = { new QStandardItem("Andy"), new QStandardItem("Adele") };
+ model.appendRow(items);
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(3, 1)));
+ QCOMPARE(view.currentIndex(), model.index(3, 1));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(0, 1)));
+ QCOMPARE(view.currentIndex(), model.index(0, 1));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(3, 1)));
+ QCOMPARE(view.currentIndex(), model.index(3, 1));
+
+ // Test that it handles the case where the first item is hidden correctly
+ model.insertRow(0, new QStandardItem("Hidden item"));
+ view.setRowHidden(0, QModelIndex(), true);
+
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(1, 1)));
+ QCOMPARE(view.currentIndex(), model.index(1, 1));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(4, 1)));
+ QCOMPARE(view.currentIndex(), model.index(4, 1));
+ QTest::qWait(QApplication::keyboardInputInterval() * 2);
+ view.keyboardSearch(QLatin1String("A"));
+ QVERIFY(view.selectionModel()->isSelected(model.index(1, 1)));
+ QCOMPARE(view.currentIndex(), model.index(1, 1));
}
void tst_QTreeView::keyboardSearchMultiColumn()
@@ -4466,5 +4564,51 @@ void tst_QTreeView::statusTip()
QTest::mouseMove(mw.windowHandle(), centerPoint);
QTRY_COMPARE(mw.statusBar()->currentMessage(), QLatin1String("Header 0 -- Status"));
}
+
+static void fillModeltaskQTBUG_8376(QAbstractItemModel &model)
+{
+ model.insertRow(0);
+ model.insertColumn(0);
+ model.insertColumn(1);
+ QModelIndex index = model.index(0, 0);
+ model.setData(index, "Level0");
+ {
+ model.insertRow(0, index);
+ model.insertRow(1, index);
+ model.insertColumn(0, index);
+ model.insertColumn(1, index);
+
+ QModelIndex idx;
+ idx = model.index(0, 0, index);
+ model.setData(idx, "Level1");
+
+ idx = model.index(0, 1, index);
+ model.setData(idx, "very\nvery\nhigh\ncell");
+ }
+}
+
+void tst_QTreeView::taskQTBUG_8376()
+{
+ QTreeView tv;
+ QStandardItemModel model;
+ fillModeltaskQTBUG_8376(model);
+ tv.setModel(&model);
+ tv.expandAll(); // init layout
+
+ QModelIndex idxLvl0 = model.index(0, 0);
+ QModelIndex idxLvl1 = model.index(0, 1, idxLvl0);
+ const int rowHeightLvl0 = tv.rowHeight(idxLvl0);
+ const int rowHeightLvl1Visible = tv.rowHeight(idxLvl1);
+ QVERIFY(rowHeightLvl0 < rowHeightLvl1Visible);
+
+ tv.hideColumn(1);
+ const int rowHeightLvl1Hidden = tv.rowHeight(idxLvl1);
+ QCOMPARE(rowHeightLvl0, rowHeightLvl1Hidden);
+
+ tv.showColumn(1);
+ const int rowHeightLvl1Visible2 = tv.rowHeight(idxLvl1);
+ QCOMPARE(rowHeightLvl1Visible, rowHeightLvl1Visible2);
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp
index acd44565eb..4cd741000e 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.cpp
+++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp
@@ -28,7 +28,7 @@
#include "menuramaapplication.h"
-MenuramaApplication::MenuramaApplication(int argc, char **argv)
+MenuramaApplication::MenuramaApplication(int &argc, char **argv)
: QApplication (argc, argv)
{
#if 0
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h
index 1a5a55e0ff..2d836832fa 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.h
+++ b/tests/manual/cocoa/menurama/menuramaapplication.h
@@ -36,7 +36,7 @@
class MenuramaApplication : public QApplication
{
public:
- MenuramaApplication(int argc, char **argv);
+ MenuramaApplication(int &argc, char **argv);
void addDynMenu(QLatin1String title, QMenu *parentMenu);
QAction *findAction(QLatin1String title, QMenu *parentMenu);