summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-26 08:27:02 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-26 08:27:02 +0100
commit8f1acd29e4d39383752899d6d05d484eb9d7935b (patch)
treee749c4bebdd49ff702dfaa062902cbb6016cfd82 /tests
parent945198fd237a83348feb4537d811565a2c2cd8e0 (diff)
parent2fedce8ed8451fd9b14bc214dc26e79b0d5ab7bd (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp5
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp3
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp45
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h3
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro4
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp68
-rw-r--r--tests/auto/corelib/serialization/serialization.pro1
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp4
-rw-r--r--tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp9
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp29
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp2
11 files changed, 166 insertions, 7 deletions
diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index 262c6dd9c8..c76052a38b 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -32,10 +32,13 @@
#include <QStandardItemModel>
#include <QStringListModel>
#include <QTest>
+#include <QLoggingCategory>
#include "dynamictreemodel.h"
#include "qidentityproxymodel.h"
+Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels")
+
class DataChangedModel : public QAbstractListModel
{
public:
@@ -390,7 +393,7 @@ void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex
for (auto row = 0; row < model->rowCount(parent); ++row)
{
auto idx = model->index(row, 0, parent);
- qDebug() << (indent + idx.data().toString());
+ qCDebug(lcItemModels) << (indent + idx.data().toString());
dump(model, indent + "- ", idx);
}
}
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index da13b9f33f..b9deb7b6a9 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -125,6 +125,7 @@ private:
tst_QItemModel::tst_QItemModel()
{
qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
+ qRegisterMetaType<QList<QPersistentModelIndex>>();
}
void tst_QItemModel::init()
@@ -181,7 +182,7 @@ void tst_QItemModel::nonDestructiveBasicTest()
currentModel->hasChildren(QModelIndex());
currentModel->hasIndex(0, 0);
currentModel->headerData(0, Qt::Horizontal);
- currentModel->index(0,0), QModelIndex();
+ currentModel->index(0,0);
currentModel->itemData(QModelIndex());
QVariant cache;
currentModel->match(QModelIndex(), -1, cache);
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
index 82cd26971b..ccce5a44e5 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp
@@ -38,6 +38,8 @@
#include <qdebug.h>
+Q_LOGGING_CATEGORY(lcItemModels, "qt.corelib.tests.itemmodels")
+
// Testing get/set functions
void tst_QSortFilterProxyModel::getSetCheck()
{
@@ -2361,6 +2363,45 @@ void tst_QSortFilterProxyModel::match()
QCOMPARE(indexes.at(i).row(), expectedProxyItems.at(i));
}
+QList<QStandardItem *> createStandardItemList(const QString &prefix, int n)
+{
+ QList<QStandardItem *> result;
+ for (int i = 0; i < n; ++i)
+ result.append(new QStandardItem(prefix + QString::number(i)));
+ return result;
+}
+
+// QTBUG-73864, recursive search in a tree model.
+
+void tst_QSortFilterProxyModel::matchTree()
+{
+ QStandardItemModel model(0, 2);
+ // Header00 Header01
+ // Header10 Header11
+ // Item00 Item01
+ // Item10 Item11
+ model.appendRow(createStandardItemList(QLatin1String("Header0"), 2));
+ auto headerRow = createStandardItemList(QLatin1String("Header1"), 2);
+ model.appendRow(headerRow);
+ headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item0"), 2));
+ headerRow.first()->appendRow(createStandardItemList(QLatin1String("Item1"), 2));
+
+ auto item11 = model.match(model.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20,
+ Qt::MatchRecursive).value(0);
+ QVERIFY(item11.isValid());
+ QCOMPARE(item11.data().toString(), QLatin1String("Item11"));
+
+ // Repeat in proxy model
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ auto proxyItem11 = proxy.match(proxy.index(1, 1), Qt::DisplayRole, QLatin1String("Item11"), 20,
+ Qt::MatchRecursive).value(0);
+ QVERIFY(proxyItem11.isValid());
+ QCOMPARE(proxyItem11.data().toString(), QLatin1String("Item11"));
+
+ QCOMPARE(proxy.mapToSource(proxyItem11).internalId(), item11.internalId());
+}
+
void tst_QSortFilterProxyModel::insertIntoChildrenlessItem()
{
QStandardItemModel model;
@@ -4277,7 +4318,7 @@ public:
QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override
{
// QTBUG-44962: Would we always expect the parent to belong to the model
- qDebug() << parent.model() << this;
+ qCDebug(lcItemModels) << parent.model() << this;
Q_ASSERT(!parent.isValid() || parent.model() == this);
quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
@@ -4363,7 +4404,7 @@ void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes()
// The use of qDebug here makes sufficient use of the heap to
// cause corruption at runtime with normal use on linux (before
// the fix). valgrind confirms the fix.
- qDebug() << persistentIndex.parent();
+ qCDebug(lcItemModels) << persistentIndex.parent();
QVERIFY(persistentIndex.parent().isValid());
}
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
index 82d4b7344e..8ae97165b8 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_common/tst_qsortfilterproxymodel.h
@@ -109,6 +109,7 @@ private slots:
void selectionFilteredOut();
void match_data();
void match();
+ void matchTree();
void insertIntoChildrenlessItem();
void invalidateMappedChildren();
void insertRowIntoFilteredParent();
@@ -186,4 +187,6 @@ private:
Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint)
+Q_DECLARE_LOGGING_CATEGORY(lcItemModels)
+
#endif // TST_QSORTFILTERPROXYMODEL_H
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
new file mode 100644
index 0000000000..7e003304af
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/qdatastream_core_pixmap.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qdatastream_core_pixmap
+QT += testlib
+SOURCES = tst_qdatastream_core_pixmap.cpp
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
new file mode 100644
index 0000000000..c931016a61
--- /dev/null
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** 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 <QtTest/QtTest>
+#include <QtGui/QBitmap>
+#include <QtGui/QPalette>
+#include <QtGui/QPixmap>
+#include <QtGui/QPicture>
+#include <QtGui/QTextLength>
+#include <QtGui/QPainter>
+#include <QtGui/QPen>
+
+class tst_QDataStream : public QObject
+{
+Q_OBJECT
+
+private slots:
+ void stream_with_pixmap();
+
+};
+
+void tst_QDataStream::stream_with_pixmap()
+{
+ // This is a QVariantMap with a 3x3 red QPixmap and two strings inside
+ const QByteArray ba = QByteArray::fromBase64("AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5HDQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBhAAAACgAAAAAKAGgAZQBsAGwAbw==");
+ QImage dummy; // Needed to make sure qtGui is loaded
+
+ QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
+
+ QVariantMap map;
+ QDataStream d(ba);
+ d.setVersion(QDataStream::Qt_5_12);
+ d >> map;
+
+ QCOMPARE(map["a"].toString(), QString("hello"));
+ QCOMPARE(map["p"].value<QPixmap>(), QPixmap()); // the pixmap is null because this is not a QGuiApplication
+ QCOMPARE(map["z"].toString(), QString("there"));
+}
+
+QTEST_GUILESS_MAIN(tst_QDataStream)
+
+#include "tst_qdatastream_core_pixmap.moc"
+
diff --git a/tests/auto/corelib/serialization/serialization.pro b/tests/auto/corelib/serialization/serialization.pro
index 9187de1bc5..9638178cdc 100644
--- a/tests/auto/corelib/serialization/serialization.pro
+++ b/tests/auto/corelib/serialization/serialization.pro
@@ -6,6 +6,7 @@ SUBDIRS = \
qcborvalue \
qcborvalue_json \
qdatastream \
+ qdatastream_core_pixmap \
qtextstream \
qxmlstream
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index a25fd39693..eff9835776 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -539,6 +539,8 @@ void tst_QTimeZone::checkOffset_data()
int year, month, day, hour, min, sec;
int std, dst;
} table[] = {
+ // Zone with no transitions (QTBUG-74614, when TZ backend uses minimalist data)
+ { "Etc/UTC", "epoch", 1970, 1, 1, 0, 0, 0, 0, 0 },
// Kiev: regression test for QTBUG-64122 (on MS):
{ "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
{ "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
@@ -551,6 +553,8 @@ void tst_QTimeZone::checkOffset_data()
<< QDateTime(QDate(entry.year, entry.month, entry.day),
QTime(entry.hour, entry.min, entry.sec), zone)
<< entry.dst + entry.std << entry.std << entry.dst;
+ } else {
+ qWarning("Skipping %s@%s test as zone is invalid", entry.zone, entry.nick);
}
}
}
diff --git a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index 0da42b8b87..b8d9adf7a1 100644
--- a/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/network/access/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -251,9 +251,14 @@ void tst_QAbstractNetworkCache::cacheControl_data()
QTest::newRow("200-1") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol-expire.cgi" << false;
QTest::newRow("200-2") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << AlwaysFalse;
- QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << false;
+ QTest::newRow("200-3") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-cache" << true;
QTest::newRow("200-4") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;
- QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << false;
+ QTest::newRow("200-5") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-cache" << true;
+
+ QTest::newRow("200-6") << QNetworkRequest::AlwaysNetwork << "httpcachetest_cachecontrol.cgi?no-store" << AlwaysFalse;
+ QTest::newRow("200-7") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?no-store" << false;
+ QTest::newRow("200-8") << QNetworkRequest::AlwaysCache << "httpcachetest_cachecontrol.cgi?no-store" << false;
+ QTest::newRow("200-9") << QNetworkRequest::PreferCache << "httpcachetest_cachecontrol.cgi?no-store" << false;
QTest::newRow("304-0") << QNetworkRequest::PreferNetwork << "httpcachetest_cachecontrol.cgi?max-age=1000" << true;
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 0d6828797a..8627a37e12 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -3976,7 +3976,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
"HTTP/1.0 200\r\n"
"Connection: keep-alive\r\n"
"Content-Type: text/plain\r\n"
- "Cache-control: no-cache\r\n"
+ "Cache-control: no-store\r\n"
"Content-length: 8\r\n"
"\r\n"
"Reloaded";
@@ -4002,6 +4002,33 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data()
content.second = "Not-reloaded";
content.first.setLastModified(past);
+ // "no-cache"
+ rawHeaders.clear();
+ rawHeaders << QNetworkCacheMetaData::RawHeader("Date", QLocale::c().toString(past, dateFormat).toLatin1())
+ << QNetworkCacheMetaData::RawHeader("Cache-control", "no-cache");
+ content.first.setRawHeaders(rawHeaders);
+ content.first.setLastModified(past);
+ content.first.setExpirationDate(future);
+
+ // "no-cache" does not mean "no cache", just that we must consult remote first
+ QTest::newRow("no-cache,200,always-network")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::AlwaysNetwork) << QStringList() << false << true;
+ QTest::newRow("no-cache,200,prefer-network")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true;
+ QTest::newRow("no-cache,200,prefer-cache")
+ << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << false << true;
+ // We're not allowed by the spec to deliver cached data without checking if it is still
+ // up-to-date.
+ QTest::newRow("no-cache,200,always-cache")
+ << reply200 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
+
+ QTest::newRow("no-cache,304,prefer-network")
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << true << true;
+ QTest::newRow("no-cache,304,prefer-cache")
+ << reply304 << "Not-reloaded" << content << int(QNetworkRequest::PreferCache) << QStringList() << true << true;
+ QTest::newRow("no-cache,304,always-cache")
+ << reply304 << QString() << content << int(QNetworkRequest::AlwaysCache) << QStringList() << false << false;
+
//
// Set to expired
//
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 1acf07301c..ea96322654 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -1343,8 +1343,10 @@ void tst_QMainWindow::restoreState()
{
QMainWindow mw;
QToolBar tb(&mw);
+ tb.setObjectName(QLatin1String("toolBar"));
mw.addToolBar(Qt::TopToolBarArea, &tb);
QDockWidget dw(&mw);
+ dw.setObjectName(QLatin1String("dock"));
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
QByteArray state;