summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-06-07 12:05:33 +0200
committerLiang Qi <liang.qi@qt.io>2017-06-07 14:02:43 +0200
commit7cbee5629604aa49c618829c8e3e55fc64e94df7 (patch)
treed12041105160c1cb21226b365edb9653d87b5853 /tests/auto
parente400b7e326c554ccd819448866265953d2a0f24d (diff)
parent5f0ce2333f7e11a3ffb5d16a27cd9303efa712d5 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/widgets/widgets/qmenu.cpp Change-Id: I6d3baf56eb24501cddb129a3cb6b958ccc25a308
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp26
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp2
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp22
-rw-r--r--tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp9
-rw-r--r--tests/auto/corelib/kernel/qtimer/BLACKLIST2
-rw-r--r--tests/auto/corelib/thread/qsemaphore/BLACKLIST1
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp19
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp8
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp6
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp2
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp8
-rw-r--r--tests/auto/other/lancelot/lancelot.pro2
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp9
-rw-r--r--tests/auto/other/lancelot/paintcommands.h5
-rw-r--r--tests/auto/other/lancelot/scripts/porter_duff.qps12
-rw-r--r--tests/auto/other/lancelot/scripts/porter_duff2.qps12
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp10
-rw-r--r--tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp7
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp41
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp21
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp50
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp4
23 files changed, 244 insertions, 36 deletions
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index 66fc578d5f..09abb953ba 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -97,17 +97,33 @@ void tst_QGetPutEnv::intValue_data()
QTest::addColumn<int>("expected");
QTest::addColumn<bool>("ok");
- // most non-success cases already tested in getSetCheck()
+ // some repetition from what is tested in getSetCheck()
+ QTest::newRow("empty") << QByteArray() << 0 << false;
+ QTest::newRow("spaces-heading") << QByteArray(" 1") << 1 << true;
+ QTest::newRow("spaces-trailing") << QByteArray("1 ") << 0 << false;
#define ROW(x, i, b) \
QTest::newRow(#x) << QByteArray(#x) << (i) << (b)
ROW(auto, 0, false);
+ ROW(1auto, 0, false);
ROW(0, 0, true);
+ ROW(+0, 0, true);
ROW(1, 1, true);
+ ROW(+1, 1, true);
+ ROW(09, 0, false);
ROW(010, 8, true);
ROW(0x10, 16, true);
+ ROW(0x, 0, false);
+ ROW(0xg, 0, false);
+ ROW(0x1g, 0, false);
+ ROW(000000000000000000000000000000000000000000000000001, 0, false);
+ ROW(+000000000000000000000000000000000000000000000000001, 0, false);
+ ROW(000000000000000000000000000000000000000000000000001g, 0, false);
+ ROW(-0, 0, true);
ROW(-1, -1, true);
ROW(-010, -8, true);
+ ROW(-000000000000000000000000000000000000000000000000001, 0, false);
+ ROW(2147483648, 0, false);
// ROW(0xffffffff, -1, true); // could be expected, but not how QByteArray::toInt() works
ROW(0xffffffff, 0, false);
const int bases[] = {10, 8, 16};
@@ -125,6 +141,7 @@ void tst_QGetPutEnv::intValue_data()
void tst_QGetPutEnv::intValue()
{
+ const int maxlen = (sizeof(int) * CHAR_BIT + 2) / 3;
const char varName[] = "should_not_exist";
QFETCH(QByteArray, value);
@@ -133,6 +150,13 @@ void tst_QGetPutEnv::intValue()
bool actualOk = !ok;
+ // Self-test: confirm that it was like the docs said it should be
+ if (value.length() < maxlen) {
+ QCOMPARE(value.toInt(&actualOk, 0), expected);
+ QCOMPARE(actualOk, ok);
+ }
+
+ actualOk = !ok;
QVERIFY(qputenv(varName, value));
QCOMPARE(qEnvironmentVariableIntValue(varName), expected);
QCOMPARE(qEnvironmentVariableIntValue(varName, &actualOk), expected);
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index bb8bb6cc21..3465385ba7 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -100,11 +100,11 @@ tst_qmessagehandler::tst_qmessagehandler()
void tst_qmessagehandler::initTestCase()
{
+#if QT_CONFIG(process)
m_appDir = QFINDTESTDATA("app");
QVERIFY2(!m_appDir.isEmpty(), qPrintable(
QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath())));
-#if QT_CONFIG(process)
m_baseEnvironment = QProcess::systemEnvironment();
for (int i = 0; i < m_baseEnvironment.count(); ++i) {
if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) {
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 9b12aa9616..f97501e8a6 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -412,8 +412,10 @@ static QByteArray msgFileDoesNotExist(const QString &name)
void tst_QFile::initTestCase()
{
QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
+#if QT_CONFIG(process)
m_stdinProcessDir = QFINDTESTDATA("stdinprocess");
QVERIFY(!m_stdinProcessDir.isEmpty());
+#endif
m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp");
QVERIFY(!m_testSourceFile.isEmpty());
m_testLogFile = QFINDTESTDATA("testlog.txt");
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index dcd9eda4bb..9f67ccd9c9 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -101,6 +101,7 @@ private slots:
void testRoleNames();
void testDragActions();
+ void dragActionsFallsBackToDropActions();
void testFunctionPointerSignalConnection();
@@ -2157,6 +2158,27 @@ void tst_QAbstractItemModel::testDragActions()
QVERIFY(actions & Qt::MoveAction);
}
+class OverrideDropActions : public QStringListModel
+{
+ Q_OBJECT
+public:
+ OverrideDropActions(QObject *parent = 0)
+ : QStringListModel(parent)
+ {
+ }
+ Qt::DropActions supportedDropActions() const override
+ {
+ return Qt::MoveAction;
+ }
+};
+
+void tst_QAbstractItemModel::dragActionsFallsBackToDropActions()
+{
+ QAbstractItemModel *model = new OverrideDropActions(this);
+ QCOMPARE(model->supportedDragActions(), Qt::MoveAction);
+ QCOMPARE(model->supportedDropActions(), Qt::MoveAction);
+}
+
class SignalConnectionTester : public QObject
{
Q_OBJECT
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
index f99241da3b..adc8c59bf7 100644
--- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
@@ -80,6 +80,8 @@ private slots:
void setData_emits_both_roles_data();
void setData_emits_both_roles();
+
+ void supportedDragDropActions();
};
void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data()
@@ -250,5 +252,12 @@ void tst_QStringListModel::setData_emits_both_roles()
expected);
}
+void tst_QStringListModel::supportedDragDropActions()
+{
+ QStringListModel model;
+ QCOMPARE(model.supportedDragActions(), Qt::CopyAction | Qt::MoveAction);
+ QCOMPARE(model.supportedDropActions(), Qt::CopyAction | Qt::MoveAction);
+}
+
QTEST_MAIN(tst_QStringListModel)
#include "tst_qstringlistmodel.moc"
diff --git a/tests/auto/corelib/kernel/qtimer/BLACKLIST b/tests/auto/corelib/kernel/qtimer/BLACKLIST
index e5136624d8..b355bc22c2 100644
--- a/tests/auto/corelib/kernel/qtimer/BLACKLIST
+++ b/tests/auto/corelib/kernel/qtimer/BLACKLIST
@@ -1,3 +1,5 @@
[remainingTime]
windows
osx
+[basic_chrono]
+osx ci
diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
index c198b90253..eb83b03556 100644
--- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST
+++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST
@@ -3,3 +3,4 @@ windows
osx-10.12
[tryAcquireWithTimeout:2s]
windows
+osx-10.12
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index 7850478602..442d4d089c 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -43,6 +43,10 @@
#include <stdlib.h>
#include <time.h>
+#ifdef Q_OS_UNIX
+#include <sys/resource.h>
+#endif
+
QT_BEGIN_NAMESPACE
namespace QtSharedPointer {
Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
@@ -54,6 +58,7 @@ class tst_QSharedPointer: public QObject
Q_OBJECT
private slots:
+ void initTestCase();
void basics_data();
void basics();
void operators();
@@ -118,6 +123,20 @@ public:
}
};
+void tst_QSharedPointer::initTestCase()
+{
+#if defined(Q_OS_UNIX)
+ // The tests create a lot of threads, which require file descriptors. On systems like
+ // OS X low defaults such as 256 as the limit for the number of simultaneously
+ // open files is not sufficient.
+ struct rlimit numFiles;
+ if (getrlimit(RLIMIT_NOFILE, &numFiles) == 0 && numFiles.rlim_cur < 1024) {
+ numFiles.rlim_cur = qMin(rlim_t(1024), numFiles.rlim_max);
+ setrlimit(RLIMIT_NOFILE, &numFiles);
+ }
+#endif
+}
+
template<typename T> static inline
QtSharedPointer::ExternalRefCountData *refCountData(const QSharedPointer<T> &b)
{
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index dca718a6d8..cff26be7bb 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -125,6 +125,7 @@ private slots:
void itemRoleNames();
void getMimeDataWithInvalidModelIndex();
+ void supportedDragDropActions();
private:
QAbstractItemModel *m_model;
@@ -1666,5 +1667,12 @@ void tst_QStandardItemModel::getMimeDataWithInvalidModelIndex()
QVERIFY(!data);
}
+void tst_QStandardItemModel::supportedDragDropActions()
+{
+ QStandardItemModel model;
+ QCOMPARE(model.supportedDragActions(), Qt::CopyAction | Qt::MoveAction);
+ QCOMPARE(model.supportedDropActions(), Qt::CopyAction | Qt::MoveAction);
+}
+
QTEST_MAIN(tst_QStandardItemModel)
#include "tst_qstandarditemmodel.moc"
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 757e4d16e4..16215714f3 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -699,9 +699,11 @@ void tst_QPainterPath::testOperatorDatastream()
path.addRect(0, 0, 100, 100);
path.setFillRule(Qt::WindingFill);
+ QTemporaryDir tempDir(QDir::tempPath() + "/tst_qpainterpath.XXXXXX");
+ QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
// Write out
{
- QFile data("data");
+ QFile data(tempDir.path() + "/data");
bool ok = data.open(QFile::WriteOnly);
QVERIFY(ok);
QDataStream stream(&data);
@@ -711,7 +713,7 @@ void tst_QPainterPath::testOperatorDatastream()
QPainterPath other;
// Read in
{
- QFile data("data");
+ QFile data(tempDir.path() + "/data");
bool ok = data.open(QFile::ReadOnly);
QVERIFY(ok);
QDataStream stream(&data);
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 1f826c01cf..7d230d3bb3 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -515,7 +515,7 @@ void tst_QFont::defaultFamily_data()
QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace").split(","));
QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive").split(","));
QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy").split(","));
- QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif").split(","));
+ QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << "Segoe UI" << getPlatformGenericFont("sans-serif").split(","));
}
void tst_QFont::defaultFamily()
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
index 9a604e5d04..b476fdd334 100644
--- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
@@ -1553,9 +1553,17 @@ void tst_QUdpSocket::linkLocalIPv6()
//Windows preallocates link local addresses to interfaces that are down.
//These may or may not work depending on network driver
if (iface.flags() & QNetworkInterface::IsUp) {
+#if defined(Q_OS_WIN)
// Do not add the Teredo Tunneling Pseudo Interface on Windows.
if (iface.humanReadableName().contains("Teredo"))
continue;
+#elif defined(Q_OS_DARWIN)
+ // Do not add "utun" interfaces on macOS: nothing ever gets received
+ // (we don't know why)
+ if (iface.name().startsWith("utun"))
+ continue;
+#endif
+
foreach (QNetworkAddressEntry addressEntry, iface.addressEntries()) {
QHostAddress addr(addressEntry.ip());
if (!addr.scopeId().isEmpty() && addr.isInSubnet(localMask, 64)) {
diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro
index 73c12e67a2..6ece7315ed 100644
--- a/tests/auto/other/lancelot/lancelot.pro
+++ b/tests/auto/other/lancelot/lancelot.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_lancelot
-QT += testlib
+QT += testlib gui-private
SOURCES += tst_lancelot.cpp \
paintcommands.cpp
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index c28812e120..8419f93e3b 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -36,6 +36,7 @@
#include <qtextlayout.h>
#include <qdebug.h>
#include <QStaticText>
+#include <private/qimage_p.h>
#ifndef QT_NO_OPENGL
#include <QOpenGLFramebufferObjectFormat>
@@ -2402,7 +2403,13 @@ void PaintCommands::command_surface_begin(QRegExp re)
m_painter = new QPainter(&m_surface_pixmap);
#endif
} else {
- m_surface_image = QImage(qRound(w), qRound(h), QImage::Format_ARGB32_Premultiplied);
+ QImage::Format surface_format;
+ if (QImage::toPixelFormat(m_format).alphaUsage() != QPixelFormat::UsesAlpha)
+ surface_format = qt_alphaVersion(m_format);
+ else
+ surface_format = m_format;
+
+ m_surface_image = QImage(qRound(w), qRound(h), surface_format);
m_surface_image.fill(0);
m_painter = new QPainter(&m_surface_image);
}
diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h
index 4113fd6881..fc7496ce11 100644
--- a/tests/auto/other/lancelot/paintcommands.h
+++ b/tests/auto/other/lancelot/paintcommands.h
@@ -68,9 +68,10 @@ class PaintCommands
{
public:
// construction / initialization
- PaintCommands(const QStringList &cmds, int w, int h)
+ PaintCommands(const QStringList &cmds, int w, int h, QImage::Format format)
: m_painter(0)
, m_surface_painter(0)
+ , m_format(format)
, m_commands(cmds)
, m_gradientSpread(QGradient::PadSpread)
, m_gradientCoordinate(QGradient::LogicalMode)
@@ -246,8 +247,8 @@ private:
// attributes
QPainter *m_painter;
QPainter *m_surface_painter;
+ QImage::Format m_format;
QImage m_surface_image;
- QPixmap m_surface_pixmap;
QRectF m_surface_rect;
QStringList m_commands;
QString m_currentCommand;
diff --git a/tests/auto/other/lancelot/scripts/porter_duff.qps b/tests/auto/other/lancelot/scripts/porter_duff.qps
index 166e48a57f..94e9c68522 100644
--- a/tests/auto/other/lancelot/scripts/porter_duff.qps
+++ b/tests/auto/other/lancelot/scripts/porter_duff.qps
@@ -184,7 +184,7 @@ repeat_block postdraw
surface_end
-# Multiply
+# ColorBurn
surface_begin 100 300 100 100
repeat_block predraw
setCompositionMode ColorBurn
@@ -192,7 +192,7 @@ repeat_block postdraw
surface_end
-# Screen
+# HardLight
surface_begin 200 300 100 100
repeat_block predraw
setCompositionMode HardLight
@@ -200,7 +200,7 @@ repeat_block postdraw
surface_end
-# Overlay
+# SoftLight
surface_begin 300 300 100 100
repeat_block predraw
setCompositionMode SoftLight
@@ -208,7 +208,7 @@ repeat_block postdraw
surface_end
-# Darken
+# Difference
surface_begin 400 300 100 100
repeat_block predraw
setCompositionMode Difference
@@ -216,7 +216,7 @@ repeat_block postdraw
surface_end
-# Lighten
+# Exclusion
surface_begin 500 300 100 100
repeat_block predraw
setCompositionMode Exclusion
@@ -248,4 +248,4 @@ drawText 100 500 "ColorBurn"
drawText 200 500 "HardLight"
drawText 300 500 "SoftLight"
drawText 400 500 "Difference"
-drawText 500 500 "Exclusion" \ No newline at end of file
+drawText 500 500 "Exclusion"
diff --git a/tests/auto/other/lancelot/scripts/porter_duff2.qps b/tests/auto/other/lancelot/scripts/porter_duff2.qps
index a792d9b278..f538371ca1 100644
--- a/tests/auto/other/lancelot/scripts/porter_duff2.qps
+++ b/tests/auto/other/lancelot/scripts/porter_duff2.qps
@@ -194,7 +194,7 @@ repeat_block postdraw
surface_end
-# Multiply
+# ColorBurn
surface_begin 100 300 100 100
repeat_block predraw
setCompositionMode ColorBurn
@@ -202,7 +202,7 @@ repeat_block postdraw
surface_end
-# Screen
+# HardLight
surface_begin 200 300 100 100
repeat_block predraw
setCompositionMode HardLight
@@ -210,7 +210,7 @@ repeat_block postdraw
surface_end
-# Overlay
+# SoftLight
surface_begin 300 300 100 100
repeat_block predraw
setCompositionMode SoftLight
@@ -218,7 +218,7 @@ repeat_block postdraw
surface_end
-# Darken
+# Difference
surface_begin 400 300 100 100
repeat_block predraw
setCompositionMode Difference
@@ -226,7 +226,7 @@ repeat_block postdraw
surface_end
-# Lighten
+# Exclusion
surface_begin 500 300 100 100
repeat_block predraw
setCompositionMode Exclusion
@@ -258,4 +258,4 @@ drawText 100 500 "ColorBurn"
drawText 200 500 "HardLight"
drawText 300 500 "SoftLight"
drawText 400 500 "Difference"
-drawText 500 500 "Exclusion" \ No newline at end of file
+drawText 500 500 "Exclusion"
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index 63c62bab86..79d0f7c6cf 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -54,7 +54,7 @@ private:
void setupTestSuite(const QStringList& blacklist = QStringList());
void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat());
- void paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath);
+ void paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath);
QStringList qpsFiles;
QHash<QString, QStringList> scripts;
@@ -318,7 +318,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
if (engine == Raster) {
QImage img(800, 800, format);
- paint(&img, engine, script, QFileInfo(filePath).absoluteFilePath());
+ paint(&img, engine, format, script, QFileInfo(filePath).absoluteFilePath());
rendered = img;
#ifndef QT_NO_OPENGL
} else if (engine == OpenGL) {
@@ -336,7 +336,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
QOpenGLFramebufferObject fbo(800, 800, fmt);
fbo.bind();
QOpenGLPaintDevice pdv(800, 800);
- paint(&pdv, engine, script, QFileInfo(filePath).absoluteFilePath());
+ paint(&pdv, engine, format, script, QFileInfo(filePath).absoluteFilePath());
rendered = fbo.toImage().convertToFormat(format);
#endif
}
@@ -344,10 +344,10 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
QBASELINE_TEST(rendered);
}
-void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath)
+void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, QImage::Format format, const QStringList &script, const QString &filePath)
{
QPainter p(device);
- PaintCommands pcmd(script, 800, 800);
+ PaintCommands pcmd(script, 800, 800, format);
//pcmd.setShouldDrawText(false);
switch (engine) {
case OpenGL:
diff --git a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp
index 79c910cb5b..bb3624a51d 100644
--- a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp
+++ b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp
@@ -31,14 +31,17 @@
#include <qcoreapplication.h>
#include <qdebug.h>
+#include <QtPrintSupport/qtprintsupportglobal.h>
+#if QT_CONFIG(printdialog)
#include <qabstractprintdialog.h>
#include <qprinter.h>
+#endif
class tst_QAbstractPrintDialog : public QObject
{
Q_OBJECT
-#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG)
+#if !QT_CONFIG(printdialog)
public slots:
void initTestCase();
#else
@@ -49,7 +52,7 @@ private slots:
#endif
};
-#if defined(QT_NO_PRINTER) || defined(QT_NO_PRINTDIALOG)
+#if !QT_CONFIG(printdialog)
void tst_QAbstractPrintDialog::initTestCase()
{
QSKIP("This test requires printing and print dialog support");
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 44cb5a5bf8..05410f4a0f 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -144,6 +144,7 @@ private slots:
#endif
void rejectModalDialogs();
void QTBUG49600_nativeIconProviderCrash();
+ void focusObjectDuringDestruction();
// NOTE: Please keep widgetlessNativeDialog() as the LAST test!
//
@@ -1463,18 +1464,15 @@ class DialogRejecter : public QObject
public:
DialogRejecter()
{
- QTimer *timer = new QTimer(this);
- timer->setInterval(1000);
- connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog);
- timer->start();
+ connect(qApp, &QApplication::focusChanged, this, &DialogRejecter::rejectFileDialog);
}
public slots:
- void rejectFileDialog()
+ virtual void rejectFileDialog()
{
if (QWidget *w = QApplication::activeModalWidget())
if (QDialog *d = qobject_cast<QDialog *>(w))
- d->reject();
+ QTest::keyClick(d, Qt::Key_Escape);
}
};
@@ -1514,5 +1512,36 @@ void tst_QFiledialog::QTBUG49600_nativeIconProviderCrash()
fd.iconProvider();
}
+class qtbug57193DialogRejecter : public DialogRejecter
+{
+public:
+ void rejectFileDialog() override
+ {
+ QCOMPARE(QGuiApplication::topLevelWindows().size(), 1);
+ const QWindow *window = QGuiApplication::topLevelWindows().constFirst();
+
+ const QFileDialog *fileDialog = qobject_cast<QFileDialog*>(QApplication::activeModalWidget());
+ QVERIFY(fileDialog);
+
+ // The problem in QTBUG-57193 was from a platform input context plugin that was
+ // connected to QWindow::focusObjectChanged(), and consequently accessed the focus
+ // object (the QFileDialog) that was in the process of being destroyed. This test
+ // checks that the QFileDialog is never set as the focus object after its destruction process begins.
+ connect(window, &QWindow::focusObjectChanged, [=](QObject *focusObject) {
+ QVERIFY(focusObject != fileDialog);
+ });
+ DialogRejecter::rejectFileDialog();
+ }
+};
+
+void tst_QFiledialog::focusObjectDuringDestruction()
+{
+ QTRY_VERIFY(QGuiApplication::topLevelWindows().isEmpty());
+
+ qtbug57193DialogRejecter dialogRejecter;
+
+ QFileDialog::getOpenFileName(nullptr, QString(), QString(), QString(), nullptr);
+}
+
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index a1cb729849..4d289dcb02 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -52,6 +52,7 @@ private slots:
void boundingRect2();
void draw();
void opacity();
+ void nestedOpaqueOpacity();
void grayscale();
void colorize();
void drawPixmapItem();
@@ -407,6 +408,26 @@ void tst_QGraphicsEffect::opacity()
QCOMPARE(effect->m_opacity, qreal(0.5));
}
+void tst_QGraphicsEffect::nestedOpaqueOpacity()
+{
+ // QTBUG-60231: Nesting widgets with a QGraphicsEffect on a toplevel with
+ // QGraphicsOpacityEffect caused crashes due to constructing several
+ // QPainter instances on a device in the fast path for
+ // QGraphicsOpacityEffect::opacity=1
+ QWidget topLevel;
+ topLevel.setWindowTitle(QTest::currentTestFunction());
+ topLevel.resize(QApplication::desktop()->screenGeometry(&topLevel).size() / 8);
+ QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect;
+ opacityEffect->setOpacity(1);
+ topLevel.setGraphicsEffect(opacityEffect);
+ QWidget *child = new QWidget(&topLevel);
+ child->resize(topLevel.size() / 2);
+ QGraphicsDropShadowEffect *childEffect = new QGraphicsDropShadowEffect;
+ child->setGraphicsEffect(childEffect);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+}
+
void tst_QGraphicsEffect::grayscale()
{
if (qApp->desktop()->depth() < 24)
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 7bfec2831d..b13e7b2f33 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -171,6 +171,7 @@ private slots:
void saveRestore();
void restoreQt4State();
void restoreToMoreColumns();
+ void restoreToMoreColumnsNoMovedColumns();
void restoreBeforeSetModel();
void defaultSectionSizeTest();
void defaultSectionSizeTestStyles();
@@ -1690,6 +1691,55 @@ void tst_QHeaderView::restoreToMoreColumns()
QCOMPARE(h4.hiddenSectionCount(), 1);
QCOMPARE(h4.sortIndicatorSection(), 2);
QCOMPARE(h4.sortIndicatorOrder(), Qt::DescendingOrder);
+ QCOMPARE(h4.logicalIndex(0), 2);
+ QCOMPARE(h4.logicalIndex(1), 1);
+ QCOMPARE(h4.logicalIndex(2), 0);
+ QCOMPARE(h4.visualIndex(0), 2);
+ QCOMPARE(h4.visualIndex(1), 1);
+ QCOMPARE(h4.visualIndex(2), 0);
+
+ // Repainting shouldn't crash
+ h4.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&h4));
+}
+
+void tst_QHeaderView::restoreToMoreColumnsNoMovedColumns()
+{
+ // Given a model with 2 columns, for saving state
+ QHeaderView h1(Qt::Horizontal);
+ QStandardItemModel model1(1, 2);
+ h1.setModel(&model1);
+ QCOMPARE(h1.visualIndex(0), 0);
+ QCOMPARE(h1.visualIndex(1), 1);
+ QCOMPARE(h1.logicalIndex(0), 0);
+ QCOMPARE(h1.logicalIndex(1), 1);
+ const QByteArray savedState = h1.saveState();
+
+ // And a model with 3 columns, to apply that state upon
+ QHeaderView h2(Qt::Horizontal);
+ QStandardItemModel model2(1, 3);
+ h2.setModel(&model2);
+ QCOMPARE(h2.visualIndex(0), 0);
+ QCOMPARE(h2.visualIndex(1), 1);
+ QCOMPARE(h2.visualIndex(2), 2);
+ QCOMPARE(h2.logicalIndex(0), 0);
+ QCOMPARE(h2.logicalIndex(1), 1);
+ QCOMPARE(h2.logicalIndex(2), 2);
+
+ // When calling restoreState()
+ QVERIFY(h2.restoreState(savedState));
+
+ // Then the index mapping should still be as default
+ QCOMPARE(h2.visualIndex(0), 0);
+ QCOMPARE(h2.visualIndex(1), 1);
+ QCOMPARE(h2.visualIndex(2), 2);
+ QCOMPARE(h2.logicalIndex(0), 0);
+ QCOMPARE(h2.logicalIndex(1), 1);
+ QCOMPARE(h2.logicalIndex(2), 2);
+
+ // And repainting shouldn't crash
+ h2.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&h2));
}
void tst_QHeaderView::restoreBeforeSetModel()
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 08f6a8e7e4..1f4d2e262d 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -8528,8 +8528,8 @@ void tst_QWidget::translucentWidget()
else
#endif
widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size()));
- QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
- QImage expected = pm.toImage().convertToFormat(QImage::Format_RGB32);
+ const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
+ const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size());
QCOMPARE(actual.size(),expected.size());
QCOMPARE(actual,expected);
}