summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-11-30 08:28:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-11-30 09:16:58 +0100
commit87204c856ae3d8495c41af998ac196a12fe1c779 (patch)
tree5af64eaa3acde506d19fe4ab1c88b028a2197adf /tests
parent498ef7f9d77fca75bcba2f657aaac38c8dc78aea (diff)
parentd0812cbdabcff4d388334c499c23992cce98d4da (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/corelib/thread/qsemaphore.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Id35b535e88df63fdfe4007ea92ed4a39c4b6d707
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/qsemaphore/tst_qsemaphore.cpp63
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp68
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp37
-rw-r--r--tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp4
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp2
-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/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.cpp143
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp2
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.h2
21 files changed, 570 insertions, 31 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/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
index ba470a77c9..a67ecc2471 100644
--- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
+++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp
@@ -41,6 +41,8 @@ private slots:
void tryAcquireWithTimeout_data();
void tryAcquireWithTimeout();
void tryAcquireWithTimeoutStarvation();
+ void tryAcquireWithTimeoutForever_data();
+ void tryAcquireWithTimeoutForever();
void producerConsumer();
void raii();
};
@@ -156,21 +158,25 @@ void tst_QSemaphore::tryAcquire()
semaphore.release();
QCOMPARE(semaphore.available(), 1);
QVERIFY(!semaphore.tryAcquire(2));
+ QVERIFY(!semaphore.tryAcquire(2, 0));
QCOMPARE(semaphore.available(), 1);
semaphore.release();
QCOMPARE(semaphore.available(), 2);
QVERIFY(!semaphore.tryAcquire(3));
+ QVERIFY(!semaphore.tryAcquire(3, 0));
QCOMPARE(semaphore.available(), 2);
semaphore.release(10);
QCOMPARE(semaphore.available(), 12);
QVERIFY(!semaphore.tryAcquire(100));
+ QVERIFY(!semaphore.tryAcquire(100, 0));
QCOMPARE(semaphore.available(), 12);
semaphore.release(10);
QCOMPARE(semaphore.available(), 22);
QVERIFY(!semaphore.tryAcquire(100));
+ QVERIFY(!semaphore.tryAcquire(100, 0));
QCOMPARE(semaphore.available(), 22);
QVERIFY(semaphore.tryAcquire());
@@ -179,23 +185,38 @@ void tst_QSemaphore::tryAcquire()
QVERIFY(semaphore.tryAcquire());
QCOMPARE(semaphore.available(), 20);
+ semaphore.release(2);
+ QVERIFY(semaphore.tryAcquire(1, 0));
+ QCOMPARE(semaphore.available(), 21);
+
+ QVERIFY(semaphore.tryAcquire(1, 0));
+ QCOMPARE(semaphore.available(), 20);
+
QVERIFY(semaphore.tryAcquire(10));
QCOMPARE(semaphore.available(), 10);
+ semaphore.release(10);
+ QVERIFY(semaphore.tryAcquire(10, 0));
+ QCOMPARE(semaphore.available(), 10);
+
QVERIFY(semaphore.tryAcquire(10));
QCOMPARE(semaphore.available(), 0);
// should not be able to acquire more
QVERIFY(!semaphore.tryAcquire());
+ QVERIFY(!semaphore.tryAcquire(1, 0));
QCOMPARE(semaphore.available(), 0);
QVERIFY(!semaphore.tryAcquire());
+ QVERIFY(!semaphore.tryAcquire(1, 0));
QCOMPARE(semaphore.available(), 0);
QVERIFY(!semaphore.tryAcquire(10));
+ QVERIFY(!semaphore.tryAcquire(10, 0));
QCOMPARE(semaphore.available(), 0);
QVERIFY(!semaphore.tryAcquire(10));
+ QVERIFY(!semaphore.tryAcquire(10, 0));
QCOMPARE(semaphore.available(), 0);
}
@@ -345,6 +366,48 @@ void tst_QSemaphore::tryAcquireWithTimeoutStarvation()
QVERIFY(consumer.wait());
}
+void tst_QSemaphore::tryAcquireWithTimeoutForever_data()
+{
+ QTest::addColumn<int>("timeout");
+ QTest::newRow("-1") << -1;
+
+ // tryAcquire is documented to take any negative value as "forever"
+ QTest::newRow("INT_MIN") << INT_MIN;
+}
+
+void tst_QSemaphore::tryAcquireWithTimeoutForever()
+{
+ enum { WaitTime = 1000 };
+ struct Thread : public QThread {
+ QSemaphore sem;
+
+ void run() override
+ {
+ QTest::qWait(WaitTime);
+ sem.release(2);
+ }
+ };
+
+ QFETCH(int, timeout);
+ Thread t;
+
+ // sanity check it works if we can immediately acquire
+ t.sem.release(11);
+ QVERIFY(t.sem.tryAcquire(1, timeout));
+ QVERIFY(t.sem.tryAcquire(10, timeout));
+
+ // verify that we do wait for at least WaitTime if we can't acquire immediately
+ QElapsedTimer timer;
+ timer.start();
+ t.start();
+ QVERIFY(t.sem.tryAcquire(1, timeout));
+ QVERIFY(timer.elapsed() >= WaitTime);
+
+ QVERIFY(t.wait());
+
+ QCOMPARE(t.sem.available(), 1);
+}
+
const char alphabet[] = "ACGTH";
const int AlphabetSize = sizeof(alphabet) - 1;
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/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index df68d4fcd5..69bd78a4f0 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -630,7 +630,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
@@ -667,23 +667,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");
@@ -8307,11 +8310,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/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp
index 7874221da9..e302fe8c74 100644
--- a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp
+++ b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp
@@ -43,7 +43,7 @@ private slots:
void tst_QDnsLookup_Appless::noApplication()
{
QTest::ignoreMessage(QtWarningMsg, "QDnsLookup requires a QCoreApplication");
- QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org");
+ QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org");
dns.lookup();
}
@@ -53,7 +53,7 @@ void tst_QDnsLookup_Appless::recreateApplication()
char **argv = 0;
for (int i = 0; i < 10; ++i) {
QCoreApplication app(argc, argv);
- QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org");
+ QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org");
dns.lookup();
if (!dns.isFinished()) {
QObject::connect(&dns, SIGNAL(finished()),
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index f5f5146eb5..82825f608c 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -72,7 +72,7 @@
#include "../../../network-settings.h"
-#define TEST_DOMAIN ".test.macieira.org"
+#define TEST_DOMAIN ".test.qt-project.org"
class tst_QHostInfo : public QObject
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 396ce62536..fc92ed6cbc 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/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 2d5c27a57b..8324a9c8fa 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 f2279ea4d4..273e90e110 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 1d82081bec..f870605d7d 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -197,6 +197,7 @@ private slots:
void taskQTBUG_37813_crash();
void taskQTBUG_45697_crash();
void taskQTBUG_7232_AllowUserToControlSingleStep();
+ void taskQTBUG_8376();
void testInitialFocus();
};
@@ -1087,6 +1088,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()
@@ -4511,5 +4609,50 @@ void tst_QTreeView::fetchMoreOnScroll()
QCOMPARE(im.item(19)->rowCount(), 20);
}
+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 5fb2041ae4..1506fe7d19 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);