summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-01 10:27:41 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-02 09:24:11 +0100
commitd7e4980132057aa10e54137114bf65e06c455030 (patch)
tree9d6ae36efa0cf84a612bfec6cf3dd2ea7f7e3446 /tests
parent44c402b4bfba44480382244b8409fb3cf34d7ac1 (diff)
parenta732576a66ff2bbd9c0b41cd5f3505a4d2fbf043 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Blacklist tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted() on macOS. Conflicts: mkspecs/features/mac/default_post.prf mkspecs/features/mac/sdk.prf mkspecs/features/uikit/default_post.prf mkspecs/features/uikit/sdk.prf src/angle/src/libEGL/libEGL.pro src/platformsupport/fontdatabases/fontdatabases.pro src/platformsupport/platformsupport.pro src/plugins/platforms/cocoa/qnswindowdelegate.mm src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp src/plugins/platforms/ios/ios.pro src/plugins/platforms/ios/kernel.pro tests/auto/widgets/widgets/qmenubar/BLACKLIST tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp Task-number: QTBUG-56853 Change-Id: If58785210feee3550892fc7768cce90e75a2416c
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp2
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp13
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp21
-rw-r--r--tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp2
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp16
-rw-r--r--tests/auto/corelib/tools/qdate/tst_qdate.cpp1
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp26
-rw-r--r--tests/auto/corelib/tools/qtime/tst_qtime.cpp3
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp20
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp4
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp21
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp6
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp28
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp1
-rw-r--r--tests/auto/gui/text/qfontdatabase/qfontdatabase.pro4
-rw-r--r--tests/auto/gui/text/qfontdatabase/testdata.qrc2
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp69
-rw-r--r--tests/auto/network/access/http2/http2srv.cpp63
-rw-r--r--tests/auto/network/access/http2/http2srv.h4
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp148
-rw-r--r--tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp14
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp2
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp4
-rw-r--r--tests/auto/other/macnativeevents/BLACKLIST3
-rw-r--r--tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro7
-rw-r--r--tests/auto/shared/resources/testfont_condensed.ttfbin0 -> 66512 bytes
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp106
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp40
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp14
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp6
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp12
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp59
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp13
-rw-r--r--tests/auto/widgets/util/qundostack/tst_qundostack.cpp144
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp4
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/qmenubar.pro5
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp46
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm44
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp12
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp2
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp6
-rw-r--r--tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp2
-rw-r--r--tests/manual/lance/main.cpp2
-rw-r--r--tests/manual/qopenglcontext/qopenglcontext.pro2
-rw-r--r--tests/manual/qopenglcontext/qopenglcontextwindow.cpp2
-rw-r--r--tests/manual/textrendering/glyphshaping/main.cpp2
52 files changed, 821 insertions, 202 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 021d581aac..eeba882c70 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -3389,7 +3389,7 @@ void tst_QFile::autocloseHandle()
//file is closed, read should fail
char buf;
QCOMPARE((int)QT_READ(fd, &buf, 1), -1);
- QVERIFY(errno = EBADF);
+ QVERIFY(errno == EBADF);
}
{
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index b3527f5d27..7bdebd1593 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -756,6 +756,19 @@ void tst_QFileInfo::canonicalFilePath()
QDir::current().rmdir(linkTarget);
}
#endif
+
+#ifdef Q_OS_DARWIN
+ {
+ // Check if canonicalFilePath's result is in Composed normalization form.
+ QString path = QString::fromLatin1("caf\xe9");
+ QDir dir(QDir::tempPath());
+ dir.mkdir(path);
+ QString canonical = QFileInfo(dir.filePath(path)).canonicalFilePath();
+ QString roundtrip = QFile::decodeName(QFile::encodeName(canonical));
+ QCOMPARE(canonical, roundtrip);
+ dir.rmdir(path);
+ }
+#endif
}
void tst_QFileInfo::fileName_data()
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index fe2a1a562d..0ee7599b2c 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -73,6 +73,8 @@ private slots:
void signalsEmittedAfterFileMoved();
+ void watchUnicodeCharacters();
+
private:
QString m_tempDirPattern;
#endif // QT_NO_FILESYSTEMWATCHER
@@ -748,6 +750,25 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
QVERIFY2(changedSpy.count() <= fileCount, changedSpy.receivedFilesMessage());
QTRY_COMPARE(changedSpy.count(), fileCount);
}
+
+void tst_QFileSystemWatcher::watchUnicodeCharacters()
+{
+ QTemporaryDir temporaryDirectory(m_tempDirPattern);
+ QVERIFY2(temporaryDirectory.isValid(), qPrintable(temporaryDirectory.errorString()));
+
+ QDir testDir(temporaryDirectory.path());
+ const QString subDir(QString::fromLatin1("caf\xe9"));
+ QVERIFY(testDir.mkdir(subDir));
+ testDir = QDir(temporaryDirectory.path() + QDir::separator() + subDir);
+
+ QFileSystemWatcher watcher;
+ QVERIFY(watcher.addPath(testDir.path()));
+
+ FileSystemWatcherSpy changedSpy(&watcher, FileSystemWatcherSpy::SpyOnDirectoryChanged);
+ QCOMPARE(changedSpy.count(), 0);
+ QVERIFY(testDir.mkdir("creme"));
+ QTRY_COMPARE(changedSpy.count(), 1);
+}
#endif // QT_NO_FILESYSTEMWATCHER
QTEST_MAIN(tst_QFileSystemWatcher)
diff --git a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
index 7642604cfe..6ab24d2480 100644
--- a/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
+++ b/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp
@@ -35,7 +35,7 @@
# include <chrono>
#endif
-static const int minResolution = 100; // the minimum resolution for the tests
+static const int minResolution = 400; // the minimum resolution for the tests
Q_DECLARE_METATYPE(Qt::TimerType)
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 28df01cc16..fe97695d19 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -216,6 +216,16 @@ void tst_QTimer::remainingTimeDuringActivation()
}
}
+namespace {
+
+#if QT_HAS_INCLUDE(<chrono>)
+ template <typename T>
+ std::chrono::milliseconds to_ms(T t)
+ { return std::chrono::duration_cast<std::chrono::milliseconds>(t); }
+#endif
+
+} // unnamed namespace
+
void tst_QTimer::basic_chrono()
{
#if !QT_HAS_INCLUDE(<chrono>)
@@ -225,7 +235,7 @@ void tst_QTimer::basic_chrono()
using namespace std::chrono;
TimerHelper helper;
QTimer timer;
- timer.setInterval(nanoseconds(0));
+ timer.setInterval(to_ms(nanoseconds(0)));
timer.start();
QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(0));
QCOMPARE(timer.remainingTimeAsDuration().count(), milliseconds::rep(0));
@@ -248,7 +258,7 @@ void tst_QTimer::basic_chrono()
QVERIFY(helper.count > oldCount);
helper.count = 0;
- timer.start(microseconds(200000));
+ timer.start(to_ms(microseconds(200000)));
QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(200));
QTest::qWait(50);
QCOMPARE(helper.count, 0);
@@ -864,7 +874,7 @@ void tst_QTimer::singleShot_chrono()
QCOMPARE(nhelper.count, 1);
int count = 0;
- QTimer::singleShot(microseconds(0), CountedStruct(&count));
+ QTimer::singleShot(to_ms(microseconds(0)), CountedStruct(&count));
QCoreApplication::processEvents();
QCOMPARE(count, 1);
diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
index f22138b795..0e189ba7aa 100644
--- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp
@@ -1145,6 +1145,7 @@ void tst_QDate::toStringDateFormat_data()
QTest::newRow("year < 0") << QDate(-1,1,1) << Qt::ISODate << QString();
QTest::newRow("year > 9999") << QDate(-1,1,1) << Qt::ISODate << QString();
QTest::newRow("RFC2822Date") << QDate(1974,12,1) << Qt::RFC2822Date << QString("01 Dec 1974");
+ QTest::newRow("ISODateWithMs") << QDate(1974,12,1) << Qt::ISODateWithMs << QString("1974-12-01");
}
void tst_QDate::toStringDateFormat()
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 0404a276ff..4604e664b0 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -732,46 +732,56 @@ void tst_QDateTime::fromMSecsSinceEpoch()
void tst_QDateTime::toString_isoDate_data()
{
QTest::addColumn<QDateTime>("datetime");
+ QTest::addColumn<Qt::DateFormat>("format");
QTest::addColumn<QString>("expected");
QTest::newRow("localtime")
<< QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34))
- << QString("1978-11-09T13:28:34");
+ << Qt::ISODate << QString("1978-11-09T13:28:34");
QTest::newRow("UTC")
<< QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34), Qt::UTC)
- << QString("1978-11-09T13:28:34Z");
+ << Qt::ISODate << QString("1978-11-09T13:28:34Z");
QDateTime dt(QDate(1978, 11, 9), QTime(13, 28, 34));
dt.setOffsetFromUtc(19800);
QTest::newRow("positive OffsetFromUTC")
- << dt
+ << dt << Qt::ISODate
<< QString("1978-11-09T13:28:34+05:30");
dt.setUtcOffset(-7200);
QTest::newRow("negative OffsetFromUTC")
- << dt
+ << dt << Qt::ISODate
<< QString("1978-11-09T13:28:34-02:00");
dt.setUtcOffset(-900);
QTest::newRow("negative non-integral OffsetFromUTC")
- << dt
+ << dt << Qt::ISODate
<< QString("1978-11-09T13:28:34-00:15");
QTest::newRow("invalid")
<< QDateTime(QDate(-1, 11, 9), QTime(13, 28, 34), Qt::UTC)
- << QString();
+ << Qt::ISODate << QString();
+ QTest::newRow("without-ms")
+ << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34, 20))
+ << Qt::ISODate << QString("1978-11-09T13:28:34");
+ QTest::newRow("with-ms")
+ << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34, 20))
+ << Qt::ISODateWithMs << QString("1978-11-09T13:28:34.020");
}
void tst_QDateTime::toString_isoDate()
{
QFETCH(QDateTime, datetime);
+ QFETCH(Qt::DateFormat, format);
QFETCH(QString, expected);
QLocale oldLocale;
QLocale::setDefault(QLocale("en_US"));
- QString result = datetime.toString(Qt::ISODate);
+ QString result = datetime.toString(format);
QCOMPARE(result, expected);
- QDateTime resultDatetime = QDateTime::fromString(result, Qt::ISODate);
+ QDateTime resultDatetime = QDateTime::fromString(result, format);
// If expecting invalid result the datetime may still be valid, i.e. year < 0 or > 9999
if (!expected.isEmpty()) {
+ QEXPECT_FAIL("without-ms", "Qt::ISODate truncates milliseconds (QTBUG-56552)", Abort);
+
QCOMPARE(resultDatetime, datetime);
QCOMPARE(resultDatetime.date(), datetime.date());
QCOMPARE(resultDatetime.time(), datetime.time());
diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
index 45af10c3ab..059e1e519b 100644
--- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp
+++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp
@@ -675,6 +675,9 @@ void tst_QTime::toStringDateFormat_data()
QTest::newRow("Text 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::TextDate << QString("10:12:34");
QTest::newRow("ISO 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::ISODate << QString("10:12:34");
QTest::newRow("RFC2822Date") << QTime(10, 12, 34, 999) << Qt::RFC2822Date << QString("10:12:34");
+ QTest::newRow("ISOWithMs 10:12:34.000") << QTime(10, 12, 34, 0) << Qt::ISODateWithMs << QString("10:12:34.000");
+ QTest::newRow("ISOWithMs 10:12:34.020") << QTime(10, 12, 34, 20) << Qt::ISODateWithMs << QString("10:12:34.020");
+ QTest::newRow("ISOWithMs 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::ISODateWithMs << QString("10:12:34.999");
}
void tst_QTime::toStringDateFormat()
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index c349d0df09..895f68bbd7 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -262,7 +262,7 @@ void tst_QPixmap::fromImage()
image.fill(0x7f7f7f7f);
const QPixmap pixmap = QPixmap::fromImage(image);
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -486,7 +486,7 @@ void tst_QPixmap::fill()
else
pm = QPixmap(400, 400);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (!bitmap && pm.handle()->classId() == QPlatformPixmap::X11Class && !pm.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -516,7 +516,7 @@ void tst_QPixmap::fill()
void tst_QPixmap::fill_transparent()
{
QPixmap pixmap(10, 10);
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (pixmap.handle()->classId() == QPlatformPixmap::X11Class && !pixmap.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 45be8bf099..a08f1896bb 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -803,6 +803,24 @@ void tst_QWindow::isActive()
// child has focus
QVERIFY(window.isActive());
+ // test focus back to parent and then back to child (QTBUG-39362)
+ // also verify the cumulative FocusOut and FocusIn counts
+ // activate parent
+ window.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
+ QVERIFY(window.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(child.received(QEvent::FocusOut), 1);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+
+ // activate child again
+ child.requestActivate();
+ QTRY_COMPARE(QGuiApplication::focusWindow(), &child);
+ QVERIFY(child.isActive());
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.received(QEvent::FocusOut), 2);
+ QTRY_COMPARE(child.received(QEvent::FocusIn), 2);
+
Window dialog;
dialog.setTransientParent(&window);
dialog.setGeometry(QRect(m_availableTopLeft + QPoint(110, 100), m_testWindowSize));
@@ -827,7 +845,7 @@ void tst_QWindow::isActive()
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
QCoreApplication::processEvents();
QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1);
- QTRY_COMPARE(window.received(QEvent::FocusIn), 2);
+ QTRY_COMPARE(window.received(QEvent::FocusIn), 3);
QVERIFY(window.isActive());
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index ab893385e3..9dd9ab05e8 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -107,7 +107,7 @@ private slots:
void qrgba64Premultiply();
void qrgba64Equivalence();
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
void setallowX11ColorNames();
#endif
};
@@ -1403,7 +1403,7 @@ void tst_QColor::achromaticHslHue()
QCOMPARE(hsl.hslHue(), -1);
}
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
void tst_QColor::setallowX11ColorNames()
{
#if defined(Q_OS_IRIX)
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 1bd7f67810..254ab1f8ad 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -298,6 +298,8 @@ private slots:
void rotateImage_data();
void rotateImage();
+ void QTBUG56252();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -497,7 +499,7 @@ void tst_QPainter::drawPixmap_comp()
destPm.fill(c1);
srcPm.fill(c2);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (!destPm.x11PictureHandle())
QSKIP("Requires XRender support");
#endif
@@ -5120,6 +5122,23 @@ void tst_QPainter::rotateImage()
}
+void tst_QPainter::QTBUG56252()
+{
+ QImage sourceImage(1770, 1477, QImage::Format_RGB32);
+ QImage rotatedImage(1478, 1771, QImage::Format_RGB32);
+ QTransform transformCenter;
+ transformCenter.translate(739.0, 885.5);
+ transformCenter.rotate(270.0);
+ transformCenter.translate(-885.0, -738.5);
+ QPainter painter;
+ painter.begin(&rotatedImage);
+ painter.setTransform(transformCenter);
+ painter.drawImage(QPoint(0, 0),sourceImage);
+ painter.end();
+
+ // If no crash or illegal memory read, all is fine
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 6a297dbfc2..b20ad0f33c 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -33,7 +33,7 @@
#include <qbitmap.h>
#include <qpainter.h>
#include <qpolygon.h>
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
#include <private/qt_x11_p.h>
#endif
@@ -79,7 +79,7 @@ private slots:
void isEmpty_data();
void isEmpty();
-#if defined(Q_DEAD_CODE_FROM_QT4_X11) && defined(QT_BUILD_INTERNAL)
+#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL)
void clipRectangles();
#endif
@@ -893,7 +893,7 @@ void tst_QRegion::isEmpty()
QVERIFY(region.rects().isEmpty());
}
-#if defined(Q_DEAD_CODE_FROM_QT4_X11) && defined(QT_BUILD_INTERNAL)
+#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && defined(QT_BUILD_INTERNAL)
void tst_QRegion::clipRectangles()
{
QRegion region(30, 30, 30, 30);
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index ed48a4978a..44921f68aa 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -109,6 +109,7 @@ private slots:
void vaoCreate();
void bufferCreate();
void bufferMapRange();
+ void defaultQGLCurrentBuffer();
};
struct SharedResourceTracker
@@ -1520,6 +1521,33 @@ void tst_QOpenGL::bufferMapRange()
ctx->doneCurrent();
}
+void tst_QOpenGL::defaultQGLCurrentBuffer()
+{
+ QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
+ QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
+ ctx->create();
+ ctx->makeCurrent(surface.data());
+
+ // Bind default FBO on the current context, and record what's the current QGL FBO. It should
+ // be Q_NULLPTR because the default platform OpenGL FBO is not backed by a
+ // QOpenGLFramebufferObject.
+ QOpenGLFramebufferObject::bindDefault();
+ QOpenGLFramebufferObject *defaultQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+
+ // Create new FBO, bind it, and see that the QGL FBO points to the newly created FBO.
+ QScopedPointer<QOpenGLFramebufferObject> obj(new QOpenGLFramebufferObject(128, 128));
+ obj->bind();
+ QOpenGLFramebufferObject *customQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+ QVERIFY(defaultQFBO != customQFBO);
+
+ // Bind the default FBO, and check that the QGL FBO points to the original FBO object.
+ QOpenGLFramebufferObject::bindDefault();
+ QOpenGLFramebufferObject *finalQFBO = QOpenGLContextPrivate::get(ctx.data())->qgl_current_fbo;
+ QCOMPARE(defaultQFBO, finalQFBO);
+
+ ctx->doneCurrent();
+}
+
void tst_QOpenGL::nullTextureInitializtion()
{
QScopedPointer<QSurface> surface(createSurface(QSurface::Window));
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 45cfd6f43a..dbe5bf7cc6 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -844,6 +844,7 @@ void tst_QCssParser::colorValue_data()
QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
+ QTest::newRow("invalid3") << "color: rgb(21)" << QColor();
QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base);
QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText);
QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent);
diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
index 8a08cdc182..9d357a35f2 100644
--- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
+++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
@@ -4,7 +4,5 @@ SOURCES += tst_qfontdatabase.cpp
QT += testlib core-private gui-private
TESTDATA += LED_REAL.TTF
-android {
- RESOURCES += testdata.qrc
-}
+RESOURCES += testdata.qrc
diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc
index 8a8670bf17..81a0b5b0bf 100644
--- a/tests/auto/gui/text/qfontdatabase/testdata.qrc
+++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/">
<file>LED_REAL.TTF</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
+ <file alias="testfont_condensed.ttf">../../../shared/resources/testfont_condensed.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index f71d808390..c53792da99 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -64,20 +64,27 @@ private slots:
void aliases();
void fallbackFonts();
- void liberationFont();
+ void condensedFontWidth();
+ void condensedFontMatching();
private:
- const QString m_testFont;
+ QString m_ledFont;
+ QString m_testFont;
+ QString m_testFontCondensed;
};
tst_QFontDatabase::tst_QFontDatabase()
- : m_testFont(QFINDTESTDATA("LED_REAL.TTF"))
{
}
void tst_QFontDatabase::initTestCase()
{
+ m_ledFont = QFINDTESTDATA("LED_REAL.TTF");
+ m_testFont = QFINDTESTDATA("testfont.ttf");
+ m_testFontCondensed = QFINDTESTDATA("testfont_condensed.ttf");
+ QVERIFY(!m_ledFont.isEmpty());
QVERIFY(!m_testFont.isEmpty());
+ QVERIFY(!m_testFontCondensed.isEmpty());
}
void tst_QFontDatabase::styles_data()
@@ -209,13 +216,13 @@ void tst_QFontDatabase::addAppFont()
int id;
if (useMemoryFont) {
- QFile fontfile(m_testFont);
+ QFile fontfile(m_ledFont);
fontfile.open(QIODevice::ReadOnly);
QByteArray fontdata = fontfile.readAll();
QVERIFY(!fontdata.isEmpty());
id = QFontDatabase::addApplicationFontFromData(fontdata);
} else {
- id = QFontDatabase::addApplicationFont(m_testFont);
+ id = QFontDatabase::addApplicationFont(m_ledFont);
}
#if defined(Q_OS_HPUX) && defined(QT_NO_FONTCONFIG)
// Documentation says that X11 systems that don't have fontconfig
@@ -277,22 +284,54 @@ void tst_QFontDatabase::fallbackFonts()
}
}
-void tst_QFontDatabase::liberationFont()
+static QString testString()
{
- QString libSans("Liberation Sans");
- QString libSansNarrow("Liberation Sans Narrow");
+ return QStringLiteral("foo bar");
+}
+void tst_QFontDatabase::condensedFontWidth()
+{
QFontDatabase db;
- if (!db.hasFamily(libSans) || !db.hasFamily(libSansNarrow))
- QSKIP("Requires Liberation Sans installed");
+ QFontDatabase::addApplicationFont(m_testFont);
+ QFontDatabase::addApplicationFont(m_testFontCondensed);
+
+ QVERIFY(db.hasFamily("QtBidiTestFont"));
+ if (!db.hasFamily("QtBidiTestFontCondensed"))
+ QSKIP("This platform doesn't support font sub-family names (QTBUG-55625)");
- QFont fontLS(libSans);
- QFont fontLSN(libSansNarrow);
+ // Test we really get a condensed font, and a not renormalized one (QTBUG-48043):
+ QFont testFont("QtBidiTestFont");
+ QFont testFontCondensed("QtBidiTestFontCondensed");
+ QFontMetrics fmTF(testFont);
+ QFontMetrics fmTFC(testFontCondensed);
+ QVERIFY(fmTF.width(testString()) > fmTFC.width(testString()));
- QFontMetrics fmLS(fontLS);
- QFontMetrics fmLSN(fontLSN);
+}
- QVERIFY(fmLS.width(QStringLiteral("foo bar")) > fmLSN.width(QStringLiteral("foo bar")));
+void tst_QFontDatabase::condensedFontMatching()
+{
+ QFontDatabase db;
+ QFontDatabase::removeAllApplicationFonts();
+ QFontDatabase::addApplicationFont(m_testFontCondensed);
+ if (!db.hasFamily("QtBidiTestFont"))
+ QSKIP("This platform doesn't support preferred font family names (QTBUG-53478)");
+ QFontDatabase::addApplicationFont(m_testFont);
+
+ // Test we correctly get the condensed font using different font matching methods:
+ QFont tfcByStretch("QtBidiTestFont");
+ tfcByStretch.setStretch(QFont::Condensed);
+ QFont tfcByStyleName("QtBidiTestFont");
+ tfcByStyleName.setStyleName("Condensed");
+
+ QCOMPARE(QFontMetrics(tfcByStretch).width(testString()),
+ QFontMetrics(tfcByStyleName).width(testString()));
+
+ if (!db.hasFamily("QtBidiTestFontCondensed"))
+ QSKIP("This platform doesn't support font sub-family names (QTBUG-55625)");
+
+ QFont tfcBySubfamilyName("QtBidiTestFontCondensed");
+ QCOMPARE(QFontMetrics(tfcByStyleName).width(testString()),
+ QFontMetrics(tfcBySubfamilyName).width(testString()));
}
QTEST_MAIN(tst_QFontDatabase)
diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp
index f919937fc3..9d68b5c798 100644
--- a/tests/auto/network/access/http2/http2srv.cpp
+++ b/tests/auto/network/access/http2/http2srv.cpp
@@ -63,6 +63,16 @@ inline bool is_valid_client_stream(quint32 streamID)
return (streamID & 0x1) && streamID <= std::numeric_limits<qint32>::max();
}
+void fill_push_header(const HttpHeader &originalRequest, HttpHeader &promisedRequest)
+{
+ for (const auto &field : originalRequest) {
+ if (field.name == QByteArray(":authority") ||
+ field.name == QByteArray(":scheme")) {
+ promisedRequest.push_back(field);
+ }
+ }
+}
+
}
Http2Server::Http2Server(bool h2c, const Http2Settings &ss, const Http2Settings &cs)
@@ -96,6 +106,12 @@ Http2Server::~Http2Server()
{
}
+void Http2Server::enablePushPromise(bool pushEnabled, const QByteArray &path)
+{
+ pushPromiseEnabled = pushEnabled;
+ pushPath = path;
+}
+
void Http2Server::setResponseBody(const QByteArray &body)
{
responseBody = body;
@@ -112,7 +128,6 @@ void Http2Server::startServer()
emit serverStarted(serverPort());
}
-
void Http2Server::sendServerSettings()
{
Q_ASSERT(socket);
@@ -206,7 +221,7 @@ void Http2Server::incomingConnection(qintptr socketDescriptor)
if (clearTextHTTP2) {
socket.reset(new QTcpSocket);
const bool set = socket->setSocketDescriptor(socketDescriptor);
- Q_UNUSED(set) Q_ASSERT(set);
+ Q_ASSERT(set);
// Stop listening:
close();
QMetaObject::invokeMethod(this, "connectionEstablished",
@@ -531,6 +546,48 @@ void Http2Server::sendResponse(quint32 streamID, bool emptyBody)
{
Q_ASSERT(activeRequests.find(streamID) != activeRequests.end());
+ const quint32 maxFrameSize(clientSetting(Settings::MAX_FRAME_SIZE_ID,
+ Http2::maxFrameSize));
+
+ if (pushPromiseEnabled) {
+ // A real server supporting PUSH_PROMISE will probably first send
+ // PUSH_PROMISE and then a normal response (to a real request),
+ // so that a client parsing this response and discovering another
+ // resource it needs, will _already_ have this additional resource
+ // in PUSH_PROMISE.
+ lastPromisedStream += 2;
+
+ writer.start(FrameType::PUSH_PROMISE, FrameFlag::END_HEADERS, streamID);
+ writer.append(lastPromisedStream);
+
+ HttpHeader pushHeader;
+ fill_push_header(activeRequests[streamID], pushHeader);
+ pushHeader.push_back(HeaderField(":method", "GET"));
+ pushHeader.push_back(HeaderField(":path", pushPath));
+
+ // Now interesting part, let's make it into 'stream':
+ activeRequests[lastPromisedStream] = pushHeader;
+
+ HPack::BitOStream ostream(writer.outboundFrame().buffer);
+ const bool result = encoder.encodeRequest(ostream, pushHeader);
+ Q_ASSERT(result);
+
+ // Well, it's not HEADERS, it's PUSH_PROMISE with ... HEADERS block.
+ // Should work.
+ writer.writeHEADERS(*socket, maxFrameSize);
+ qDebug() << "server sent a PUSH_PROMISE on" << lastPromisedStream;
+
+ if (responseBody.isEmpty())
+ responseBody = QByteArray("I PROMISE (AND PUSH) YOU ...");
+
+ // Now we send this promised data as a normal response on our reserved
+ // stream (disabling PUSH_PROMISE for the moment to avoid recursion):
+ pushPromiseEnabled = false;
+ sendResponse(lastPromisedStream, false);
+ pushPromiseEnabled = true;
+ // Now we'll continue with _normal_ response.
+ }
+
writer.start(FrameType::HEADERS, FrameFlag::END_HEADERS, streamID);
if (emptyBody)
writer.addFlag(FrameFlag::END_STREAM);
@@ -544,9 +601,7 @@ void Http2Server::sendResponse(quint32 streamID, bool emptyBody)
HPack::BitOStream ostream(writer.outboundFrame().buffer);
const bool result = encoder.encodeResponse(ostream, header);
Q_ASSERT(result);
- Q_UNUSED(result)
- const quint32 maxFrameSize(clientSetting(Settings::MAX_FRAME_SIZE_ID, Http2::maxFrameSize));
writer.writeHEADERS(*socket, maxFrameSize);
if (!emptyBody) {
diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h
index 73b1d80f8e..15a4f212c9 100644
--- a/tests/auto/network/access/http2/http2srv.h
+++ b/tests/auto/network/access/http2/http2srv.h
@@ -68,6 +68,7 @@ public:
~Http2Server();
// To be called before server started:
+ void enablePushPromise(bool enabled, const QByteArray &path = QByteArray());
void setResponseBody(const QByteArray &body);
// Invokables, since we can call them from the main thread,
@@ -157,6 +158,9 @@ private:
QByteArray responseBody;
bool clearTextHTTP2 = false;
+ bool pushPromiseEnabled = false;
+ quint32 lastPromisedStream = 0;
+ QByteArray pushPath;
protected slots:
void ignoreErrorSlot();
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index 582a103b2e..771ddb01be 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -44,8 +44,8 @@
#endif // NO_OPENSSL
#endif // NO_SSL
-
#include <cstdlib>
+#include <string>
// At the moment our HTTP/2 imlpementation requires ALPN and this means OpenSSL.
#if !defined(QT_NO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_TLSEXT)
@@ -68,6 +68,7 @@ private slots:
void multipleRequests();
void flowControlClientSide();
void flowControlServerSide();
+ void pushPromise();
protected slots:
// Slots to listen to our in-process server:
@@ -90,8 +91,8 @@ private:
// small payload.
void runEventLoop(int ms = 5000);
void stopEventLoop();
- // TODO: different parameters like client/server settings ...
- Http2Server *newServer(const Http2Settings &serverSettings);
+ Http2Server *newServer(const Http2Settings &serverSettings,
+ const Http2Settings &clientSettings = defaultClientSettings);
// Send a get or post request, depending on a payload (empty or not).
void sendRequest(int streamNumber,
QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority,
@@ -105,15 +106,57 @@ private:
QTimer timer;
int nRequests = 0;
+ int nSentRequests = 0;
int windowUpdates = 0;
bool prefaceOK = false;
bool serverGotSettingsACK = false;
static const Http2Settings defaultServerSettings;
+ static const Http2Settings defaultClientSettings;
};
const Http2Settings tst_Http2::defaultServerSettings{{Http2::Settings::MAX_CONCURRENT_STREAMS_ID, 100}};
+const Http2Settings tst_Http2::defaultClientSettings{{Http2::Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)},
+ {Http2::Settings::ENABLE_PUSH_ID, quint32(0)}};
+
+namespace {
+
+// Our server lives/works on a different thread so we invoke its 'deleteLater'
+// instead of simple 'delete'.
+struct ServerDeleter
+{
+ static void cleanup(Http2Server *srv)
+ {
+ if (srv)
+ QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection);
+ }
+};
+
+using ServerPtr = QScopedPointer<Http2Server, ServerDeleter>;
+
+struct EnvVarGuard
+{
+ EnvVarGuard(const char *name, const QByteArray &value)
+ : varName(name),
+ prevValue(qgetenv(name))
+ {
+ Q_ASSERT(name);
+ qputenv(name, value);
+ }
+ ~EnvVarGuard()
+ {
+ if (prevValue.size())
+ qputenv(varName.c_str(), prevValue);
+ else
+ qunsetenv(varName.c_str());
+ }
+
+ const std::string varName;
+ const QByteArray prevValue;
+};
+
+} // unnamed namespace
tst_Http2::tst_Http2()
: workerThread(new QThread)
@@ -146,9 +189,9 @@ void tst_Http2::singleRequest()
serverPort = 0;
nRequests = 1;
- auto srv = newServer(defaultServerSettings);
+ ServerPtr srv(newServer(defaultServerSettings));
- QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection);
runEventLoop();
QVERIFY(serverPort != 0);
@@ -174,8 +217,6 @@ void tst_Http2::singleRequest()
QCOMPARE(reply->error(), QNetworkReply::NoError);
QVERIFY(reply->isFinished());
-
- QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection);
}
void tst_Http2::multipleRequests()
@@ -185,9 +226,9 @@ void tst_Http2::multipleRequests()
serverPort = 0;
nRequests = 10;
- auto srv = newServer(defaultServerSettings);
+ ServerPtr srv(newServer(defaultServerSettings));
- QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection);
runEventLoop();
QVERIFY(serverPort != 0);
@@ -198,8 +239,6 @@ void tst_Http2::multipleRequests()
QNetworkRequest::NormalPriority,
QNetworkRequest::LowPriority};
-
-
for (int i = 0; i < nRequests; ++i)
sendRequest(i, priorities[std::rand() % 3]);
@@ -208,8 +247,6 @@ void tst_Http2::multipleRequests()
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
QVERIFY(serverGotSettingsACK);
-
- QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection);
}
void tst_Http2::flowControlClientSide()
@@ -230,12 +267,12 @@ void tst_Http2::flowControlClientSide()
const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 3}};
- auto srv = newServer(serverSettings);
+ ServerPtr srv(newServer(serverSettings));
const QByteArray respond(int(Http2::defaultSessionWindowSize * 50), 'x');
srv->setResponseBody(respond);
- QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection);
runEventLoop();
QVERIFY(serverPort != 0);
@@ -249,8 +286,6 @@ void tst_Http2::flowControlClientSide()
QVERIFY(prefaceOK);
QVERIFY(serverGotSettingsACK);
QVERIFY(windowUpdates > 0);
-
- QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection);
}
void tst_Http2::flowControlServerSide()
@@ -270,11 +305,11 @@ void tst_Http2::flowControlServerSide()
const Http2Settings serverSettings = {{Settings::MAX_CONCURRENT_STREAMS_ID, 7}};
- auto srv = newServer(serverSettings);
+ ServerPtr srv(newServer(serverSettings));
const QByteArray payload(int(Http2::defaultSessionWindowSize * 500), 'x');
- QMetaObject::invokeMethod(srv, "startServer", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection);
runEventLoop();
QVERIFY(serverPort != 0);
@@ -287,9 +322,73 @@ void tst_Http2::flowControlServerSide()
QVERIFY(nRequests == 0);
QVERIFY(prefaceOK);
QVERIFY(serverGotSettingsACK);
+}
+
+void tst_Http2::pushPromise()
+{
+ // We will first send some request, the server should reply and also emulate
+ // PUSH_PROMISE sending us another response as promised.
+ using namespace Http2;
+
+ clearHTTP2State();
+
+ serverPort = 0;
+ nRequests = 1;
+
+ const EnvVarGuard env("QT_HTTP2_ENABLE_PUSH_PROMISE", "1");
+ const Http2Settings clientSettings{{Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)},
+ {Settings::ENABLE_PUSH_ID, quint32(1)}};
+
+ ServerPtr srv(newServer(defaultServerSettings, clientSettings));
+ srv->enablePushPromise(true, QByteArray("/script.js"));
- QMetaObject::invokeMethod(srv, "deleteLater", Qt::QueuedConnection);
- srv = nullptr;
+ QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection);
+ runEventLoop();
+
+ QVERIFY(serverPort != 0);
+
+ const QString urlAsString((clearTextHTTP2 ? QString("http://127.0.0.1:%1/")
+ : QString("https://127.0.0.1:%1/")).arg(serverPort));
+ const QUrl requestUrl(urlAsString + "index.html");
+
+ QNetworkRequest request(requestUrl);
+ request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
+
+ auto reply = manager.get(request);
+ connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
+ // Since we're using self-signed certificates, ignore SSL errors:
+ reply->ignoreSslErrors();
+
+ runEventLoop();
+
+ QVERIFY(nRequests == 0);
+ QVERIFY(prefaceOK);
+ QVERIFY(serverGotSettingsACK);
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(reply->isFinished());
+
+ // Now, the most interesting part!
+ nSentRequests = 0;
+ nRequests = 1;
+ // Create an additional request (let's say, we parsed reply and realized we
+ // need another resource):
+
+ const QUrl promisedUrl(urlAsString + "script.js");
+ QNetworkRequest promisedRequest(promisedUrl);
+ promisedRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true));
+ reply = manager.get(promisedRequest);
+ connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
+ reply->ignoreSslErrors();
+
+ runEventLoop();
+
+ // Let's check that NO request was actually made:
+ QCOMPARE(nSentRequests, 0);
+ // Decreased by replyFinished():
+ QCOMPARE(nRequests, 0);
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QVERIFY(reply->isFinished());
}
void tst_Http2::serverStarted(quint16 port)
@@ -318,12 +417,10 @@ void tst_Http2::stopEventLoop()
eventLoop.quit();
}
-Http2Server *tst_Http2::newServer(const Http2Settings &serverSettings)
+Http2Server *tst_Http2::newServer(const Http2Settings &serverSettings,
+ const Http2Settings &clientSettings)
{
using namespace Http2;
- // Client's settings are fixed by qhttp2protocolhandler.
- const Http2Settings clientSettings = {{Settings::MAX_FRAME_SIZE_ID, quint32(Http2::maxFrameSize)},
- {Settings::ENABLE_PUSH_ID, quint32(0)}};
auto srv = new Http2Server(clearTextHTTP2, serverSettings, clientSettings);
using Srv = Http2Server;
@@ -397,6 +494,7 @@ void tst_Http2::decompressionFailed(quint32 streamID)
void tst_Http2::receivedRequest(quint32 streamID)
{
+ ++nSentRequests;
qDebug() << " server got a request on stream" << streamID;
Http2Server *srv = qobject_cast<Http2Server *>(sender());
Q_ASSERT(srv);
diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index f9cc33fb26..a0459021be 100644
--- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -160,16 +160,16 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
result += cookie;
QTest::newRow("effective-tld1-accepted") << preset << cookie << "http://something.co.uk" << result << true;
- // 2. anything .mz is an effective TLD ('*.mz'), but 'teledata.mz' is an exception
+ // 2. anything .ck is an effective TLD ('*.ck'), but 'www.ck' is an exception
result.clear();
preset.clear();
- cookie.setDomain(".farmacia.mz");
- QTest::newRow("effective-tld2-denied") << preset << cookie << "http://farmacia.mz" << result << false;
- QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.farmacia.mz" << result << false;
- QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.farmacia.mz" << result << false;
- cookie.setDomain(".teledata.mz");
+ cookie.setDomain(".foo.ck");
+ QTest::newRow("effective-tld2-denied") << preset << cookie << "http://foo.ck" << result << false;
+ QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.foo.ck" << result << false;
+ QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.foo.ck" << result << false;
+ cookie.setDomain(".www.ck");
result += cookie;
- QTest::newRow("effective-tld2-accepted") << preset << cookie << "http://www.teledata.mz" << result << true;
+ QTest::newRow("effective-tld2-accepted") << preset << cookie << "http://www.www.ck" << result << true;
result.clear();
preset.clear();
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index b60be15754..ce895f734a 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -726,7 +726,7 @@ void tst_QGLThreads::painterOnPixmapInThread()
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL)
|| !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps))
QSKIP("No platformsupport for ThreadedOpenGL or ThreadedPixmaps");
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
QSKIP("Drawing text in threads onto X11 drawables currently crashes on some X11 servers.");
#endif
PaintThreadManager<PixmapWrapper> painterThreads(5);
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 8d6886a6c6..2e6cb09aa5 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -2393,7 +2393,7 @@ void PaintCommands::command_surface_begin(QRegExp re)
m_painter->fillRect(QRect(0, 0, qRound(w), qRound(h)), Qt::transparent);
m_painter->restore();
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
} else if (m_type == WidgetType) {
m_surface_pixmap = QPixmap(qRound(w), qRound(h));
m_surface_pixmap.fill(Qt::transparent);
@@ -2444,7 +2444,7 @@ void PaintCommands::command_surface_end(QRegExp)
m_painter->beginNativePainting();
m_painter->endNativePainting();
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
} else if (m_type == WidgetType) {
m_painter->drawPixmap(m_surface_rect.topLeft(), m_surface_pixmap);
m_surface_pixmap = QPixmap();
diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST
index 4129868022..3e68ba0cf0 100644
--- a/tests/auto/other/macnativeevents/BLACKLIST
+++ b/tests/auto/other/macnativeevents/BLACKLIST
@@ -2,8 +2,7 @@
[testDragWindow]
osx
[testMouseEnter]
-osx-10.9
-osx-10.8
+osx
[testChildDialogInFrontOfModalParent]
osx
[testChildWindowInFrontOfStaysOnTopParentWindow]
diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
index 10d950541a..5cb3f5902a 100644
--- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
+++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro
@@ -1,12 +1,7 @@
CONFIG += testcase
-include($$QT_SOURCE_TREE/src/platformsupport/accessibility/accessibility.pri)
-include($$QT_SOURCE_TREE/src/platformsupport/linuxaccessibility/linuxaccessibility.pri)
-
TARGET = tst_qaccessibilitylinux
SOURCES += tst_qaccessibilitylinux.cpp
-CONFIG += gui
-
-QT += gui-private widgets dbus testlib
+QT += gui-private widgets dbus testlib accessibility_support-private linuxaccessibility_support-private
diff --git a/tests/auto/shared/resources/testfont_condensed.ttf b/tests/auto/shared/resources/testfont_condensed.ttf
new file mode 100644
index 0000000000..6a6c536202
--- /dev/null
+++ b/tests/auto/shared/resources/testfont_condensed.ttf
Binary files differ
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 016835f142..2a629c3ff0 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -1598,28 +1598,44 @@ class SetPage : public Operation
wizard->next();
}
QString describe() const { return QLatin1String("set page ") + QString::number(page); }
- const int page;
+ int page;
public:
- SetPage(int page) : page(page) {}
+ static QSharedPointer<SetPage> create(int page)
+ {
+ QSharedPointer<SetPage> o = QSharedPointer<SetPage>::create();
+ o->page = page;
+ return o;
+ }
};
class SetStyle : public Operation
{
void apply(QWizard *wizard) const { wizard->setWizardStyle(style); }
QString describe() const { return QLatin1String("set style ") + QString::number(style); }
- const QWizard::WizardStyle style;
+ QWizard::WizardStyle style;
public:
- SetStyle(QWizard::WizardStyle style) : style(style) {}
+ static QSharedPointer<SetStyle> create(QWizard::WizardStyle style)
+ {
+ QSharedPointer<SetStyle> o = QSharedPointer<SetStyle>::create();
+ o->style = style;
+ return o;
+ }
};
class SetOption : public Operation
{
void apply(QWizard *wizard) const { wizard->setOption(option, on); }
QString describe() const;
- const QWizard::WizardOption option;
- const bool on;
+ QWizard::WizardOption option;
+ bool on;
public:
- SetOption(QWizard::WizardOption option, bool on) : option(option), on(on) {}
+ static QSharedPointer<SetOption> create(QWizard::WizardOption option, bool on)
+ {
+ QSharedPointer<SetOption> o = QSharedPointer<SetOption>::create();
+ o->option = option;
+ o->on = on;
+ return o;
+ }
};
class OptionInfo
@@ -1644,16 +1660,16 @@ class OptionInfo
tags[QWizard::HaveCustomButton3] = "15/CB3";
for (int i = 0; i < 2; ++i) {
- QMap<QWizard::WizardOption, Operation *> operations_;
+ QMap<QWizard::WizardOption, QSharedPointer<Operation> > operations_;
foreach (QWizard::WizardOption option, tags.keys())
- operations_[option] = new SetOption(option, i == 1);
+ operations_[option] = SetOption::create(option, i == 1);
operations << operations_;
}
}
OptionInfo(OptionInfo const&);
OptionInfo& operator=(OptionInfo const&);
QMap<QWizard::WizardOption, QString> tags;
- QList<QMap<QWizard::WizardOption, Operation *> > operations;
+ QList<QMap<QWizard::WizardOption, QSharedPointer<Operation> > > operations;
public:
static OptionInfo &instance()
{
@@ -1662,7 +1678,7 @@ public:
}
QString tag(QWizard::WizardOption option) const { return tags.value(option); }
- Operation * operation(QWizard::WizardOption option, bool on) const
+ QSharedPointer<Operation> operation(QWizard::WizardOption option, bool on) const
{ return operations.at(on).value(option); }
QList<QWizard::WizardOption> options() const { return tags.keys(); }
};
@@ -1673,10 +1689,7 @@ QString SetOption::describe() const
+ QLatin1Char(on ? '1' : '0');
}
-Q_DECLARE_METATYPE(Operation *)
-Q_DECLARE_METATYPE(SetPage *)
-Q_DECLARE_METATYPE(SetStyle *)
-Q_DECLARE_METATYPE(SetOption *)
+Q_DECLARE_METATYPE(QVector<QSharedPointer<Operation> >)
class TestGroup
{
@@ -1693,14 +1706,17 @@ public:
combinations.clear();
}
- QList<Operation *> &add()
- { combinations << new QList<Operation *>; return *(combinations.last()); }
+ QVector<QSharedPointer<Operation> > &add()
+ {
+ combinations.resize(combinations.size() + 1);
+ return combinations.last();
+ }
void createTestRows()
{
for (int i = 0; i < combinations.count(); ++i) {
QTest::newRow((name.toLatin1() + ", row " + QByteArray::number(i)).constData())
- << (i == 0) << (type == Equality) << *(combinations.at(i));
+ << (i == 0) << (type == Equality) << combinations.at(i);
++nRows_;
}
}
@@ -1711,7 +1727,7 @@ private:
QString name;
Type type;
int nRows_;
- QList<QList<Operation *> *> combinations;
+ QVector<QVector<QSharedPointer<Operation> > > combinations;
};
class IntroPage : public QWizardPage
@@ -1795,9 +1811,9 @@ public:
}
}
- void applyOperations(const QList<Operation *> &operations)
+ void applyOperations(const QVector<QSharedPointer<Operation> > &operations)
{
- foreach (Operation * op, operations) {
+ foreach (const QSharedPointer<Operation> &op, operations) {
if (op) {
op->apply(this);
opsDescr += QLatin1Char('(') + op->describe() + QLatin1String(") ");
@@ -1817,31 +1833,29 @@ public:
class CombinationsTestData
{
TestGroup testGroup;
- QList<Operation *> pageOps;
- QList<Operation *> styleOps;
- QMap<bool, QList<Operation *> *> setAllOptions;
+ QVector<QSharedPointer<Operation> > pageOps;
+ QVector<QSharedPointer<Operation> > styleOps;
+ QMap<bool, QVector<QSharedPointer<Operation> > > setAllOptions;
public:
CombinationsTestData()
{
QTest::addColumn<bool>("ref");
QTest::addColumn<bool>("testEquality");
- QTest::addColumn<QList<Operation *> >("operations");
- pageOps << new SetPage(0) << new SetPage(1) << new SetPage(2);
- styleOps << new SetStyle(QWizard::ClassicStyle) << new SetStyle(QWizard::ModernStyle)
- << new SetStyle(QWizard::MacStyle);
+ QTest::addColumn<QVector<QSharedPointer<Operation> > >("operations");
+ pageOps << SetPage::create(0) << SetPage::create(1) << SetPage::create(2);
+ styleOps << SetStyle::create(QWizard::ClassicStyle) << SetStyle::create(QWizard::ModernStyle)
+ << SetStyle::create(QWizard::MacStyle);
#define SETPAGE(page) pageOps.at(page)
#define SETSTYLE(style) styleOps.at(style)
#define OPT(option, on) OptionInfo::instance().operation(option, on)
#define CLROPT(option) OPT(option, false)
#define SETOPT(option) OPT(option, true)
- setAllOptions[false] = new QList<Operation *>;
- setAllOptions[true] = new QList<Operation *>;
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
- *setAllOptions.value(false) << CLROPT(option);
- *setAllOptions.value(true) << SETOPT(option);
+ setAllOptions[false] << CLROPT(option);
+ setAllOptions[true] << SETOPT(option);
}
-#define CLRALLOPTS *setAllOptions.value(false)
-#define SETALLOPTS *setAllOptions.value(true)
+#define CLRALLOPTS setAllOptions.value(false)
+#define SETALLOPTS setAllOptions.value(true)
}
int nRows() const { return testGroup.nRows(); }
@@ -1893,7 +1907,7 @@ public:
testGroup.createTestRows();
for (int i = 0; i < 2; ++i) {
- QList<Operation *> setOptions = *setAllOptions.value(i == 1);
+ QVector<QSharedPointer<Operation> > setOptions = setAllOptions.value(i == 1);
testGroup.reset("testAll 3.1");
testGroup.add() << setOptions;
@@ -1910,21 +1924,21 @@ public:
testGroup.createTestRows();
}
- foreach (Operation *pageOp, pageOps) {
+ foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
testGroup.reset("testAll 4.1");
testGroup.add() << pageOp;
testGroup.add() << pageOp << pageOp;
testGroup.createTestRows();
for (int i = 0; i < 2; ++i) {
- QList<Operation *> optionOps = *setAllOptions.value(i == 1);
+ QVector<QSharedPointer<Operation> > optionOps = setAllOptions.value(i == 1);
testGroup.reset("testAll 4.2");
testGroup.add() << optionOps << pageOp;
testGroup.add() << pageOp << optionOps;
testGroup.createTestRows();
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
- Operation *optionOp = OPT(option, i == 1);
+ QSharedPointer<Operation> optionOp = OPT(option, i == 1);
testGroup.reset("testAll 4.3");
testGroup.add() << optionOp << pageOp;
testGroup.add() << pageOp << optionOp;
@@ -1933,21 +1947,21 @@ public:
}
}
- foreach (Operation *styleOp, styleOps) {
+ foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
testGroup.reset("testAll 5.1");
testGroup.add() << styleOp;
testGroup.add() << styleOp << styleOp;
testGroup.createTestRows();
for (int i = 0; i < 2; ++i) {
- QList<Operation *> optionOps = *setAllOptions.value(i == 1);
+ QVector<QSharedPointer<Operation> > optionOps = setAllOptions.value(i == 1);
testGroup.reset("testAll 5.2");
testGroup.add() << optionOps << styleOp;
testGroup.add() << styleOp << optionOps;
testGroup.createTestRows();
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
- Operation *optionOp = OPT(option, i == 1);
+ QSharedPointer<Operation> optionOp = OPT(option, i == 1);
testGroup.reset("testAll 5.3");
testGroup.add() << optionOp << styleOp;
testGroup.add() << styleOp << optionOp;
@@ -1956,8 +1970,8 @@ public:
}
}
- foreach (Operation *pageOp, pageOps) {
- foreach (Operation *styleOp, styleOps) {
+ foreach (const QSharedPointer<Operation> &pageOp, pageOps) {
+ foreach (const QSharedPointer<Operation> &styleOp, styleOps) {
testGroup.reset("testAll 6.1");
testGroup.add() << pageOp;
@@ -1975,7 +1989,7 @@ public:
testGroup.createTestRows();
for (int i = 0; i < 2; ++i) {
- QList<Operation *> optionOps = *setAllOptions.value(i == 1);
+ QVector<QSharedPointer<Operation> > optionOps = setAllOptions.value(i == 1);
testGroup.reset("testAll 6.4");
testGroup.add() << optionOps << pageOp << styleOp;
testGroup.add() << pageOp << optionOps << styleOp;
@@ -1986,7 +2000,7 @@ public:
testGroup.createTestRows();
foreach (QWizard::WizardOption option, OptionInfo::instance().options()) {
- Operation *optionOp = OPT(option, i == 1);
+ QSharedPointer<Operation> optionOp = OPT(option, i == 1);
testGroup.reset("testAll 6.5");
testGroup.add() << optionOp << pageOp << styleOp;
testGroup.add() << pageOp << optionOp << styleOp;
@@ -2048,7 +2062,7 @@ void tst_QWizard::combinations()
{
QFETCH(bool, ref);
QFETCH(bool, testEquality);
- QFETCH(QList<Operation *>, operations);
+ QFETCH(QVector<QSharedPointer<Operation> >, operations);
TestWizard wizard;
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 76e3b43ce2..96a76d885d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -833,14 +833,14 @@ void tst_QGraphicsItem::parentItem()
void tst_QGraphicsItem::setParentItem()
{
QGraphicsScene scene;
- QGraphicsItem *item = scene.addRect(QRectF(0, 0, 10, 10));
+ const QScopedPointer<QGraphicsItem> item(scene.addRect(QRectF(0, 0, 10, 10)));
QCOMPARE(item->scene(), &scene);
- QGraphicsRectItem *child = new QGraphicsRectItem;
+ const QScopedPointer<QGraphicsRectItem> child(new QGraphicsRectItem);
QCOMPARE(child->scene(), (QGraphicsScene *)0);
// This implicitly adds the item to the parent's scene
- child->setParentItem(item);
+ child->setParentItem(item.data());
QCOMPARE(child->scene(), &scene);
// This just makes it a toplevel
@@ -848,8 +848,8 @@ void tst_QGraphicsItem::setParentItem()
QCOMPARE(child->scene(), &scene);
// Add the child back to the parent, then remove the parent from the scene
- child->setParentItem(item);
- scene.removeItem(item);
+ child->setParentItem(item.data());
+ scene.removeItem(item.data());
QCOMPARE(child->scene(), (QGraphicsScene *)0);
}
@@ -947,19 +947,19 @@ void tst_QGraphicsItem::flags()
QCOMPARE(item->pos(), QPointF(10, 10));
}
{
- QGraphicsItem* clippingParent = new QGraphicsRectItem;
+ const QScopedPointer<QGraphicsItem> clippingParent(new QGraphicsRectItem);
clippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
- QGraphicsItem* nonClippingParent = new QGraphicsRectItem;
+ const QScopedPointer<QGraphicsItem> nonClippingParent(new QGraphicsRectItem);
nonClippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
- QGraphicsItem* child = new QGraphicsRectItem(nonClippingParent);
+ QGraphicsItem* child = new QGraphicsRectItem(nonClippingParent.data());
QVERIFY(!child->isClipped());
- child->setParentItem(clippingParent);
+ child->setParentItem(clippingParent.data());
QVERIFY(child->isClipped());
- child->setParentItem(nonClippingParent);
+ child->setParentItem(nonClippingParent.data());
QVERIFY(!child->isClipped());
}
}
@@ -3118,7 +3118,8 @@ void tst_QGraphicsItem::isAncestorOf()
void tst_QGraphicsItem::commonAncestorItem()
{
- QGraphicsItem *ancestor = new QGraphicsRectItem;
+ QGraphicsRectItem ancestorItem;
+ QGraphicsItem *ancestor = &ancestorItem;
QGraphicsItem *grandMa = new QGraphicsRectItem;
QGraphicsItem *grandPa = new QGraphicsRectItem;
QGraphicsItem *brotherInLaw = new QGraphicsRectItem;
@@ -3618,7 +3619,7 @@ void tst_QGraphicsItem::setGroup()
QGraphicsItemGroup group1;
QGraphicsItemGroup group2;
- QGraphicsRectItem *rect = new QGraphicsRectItem;
+ const QScopedPointer<QGraphicsRectItem> rect(new QGraphicsRectItem);
QCOMPARE(rect->group(), (QGraphicsItemGroup *)0);
QCOMPARE(rect->parentItem(), (QGraphicsItem *)0);
rect->setGroup(&group1);
@@ -6813,8 +6814,8 @@ void tst_QGraphicsItem::opacity()
QFETCH(qreal, c2_effectiveOpacity);
QFETCH(qreal, c3_effectiveOpacity);
- QGraphicsRectItem *p = new QGraphicsRectItem;
- QGraphicsRectItem *c1 = new QGraphicsRectItem(p);
+ const QScopedPointer<QGraphicsRectItem> p(new QGraphicsRectItem);
+ QGraphicsRectItem *c1 = new QGraphicsRectItem(p.data());
QGraphicsRectItem *c2 = new QGraphicsRectItem(c1);
QGraphicsRectItem *c3 = new QGraphicsRectItem(c2);
@@ -7202,11 +7203,12 @@ void tst_QGraphicsItem::sceneTransformCache()
// Test that an item's scene transform is updated correctly when the
// parent is transformed.
QGraphicsScene scene;
- QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100);
+
+ const QScopedPointer<QGraphicsRectItem> rect(scene.addRect(0, 0, 100, 100));
rect->setPen(QPen(Qt::black, 0));
QGraphicsRectItem *rect2 = scene.addRect(0, 0, 100, 100);
rect2->setPen(QPen(Qt::black, 0));
- rect2->setParentItem(rect);
+ rect2->setParentItem(rect.data());
rect2->setTransform(QTransform().rotate(90), true);
rect->setTransform(QTransform::fromTranslate(0, 50), true);
QGraphicsView view(&scene);
@@ -7218,7 +7220,7 @@ void tst_QGraphicsItem::sceneTransformCache()
x.rotate(90);
QCOMPARE(rect2->sceneTransform(), x);
- scene.removeItem(rect);
+ scene.removeItem(rect.data());
//Crazy use case : rect4 child of rect3 so the transformation of rect4 will be cached.Good!
//We remove rect4 from the scene, then the validTransform bit flag is set to 0 and the index of the cache
@@ -10674,7 +10676,7 @@ void tst_QGraphicsItem::scenePosChange()
{
ScenePosChangeTester* root = new ScenePosChangeTester;
ScenePosChangeTester* child1 = new ScenePosChangeTester(root);
- ScenePosChangeTester* grandChild1 = new ScenePosChangeTester(child1);
+ const QScopedPointer<ScenePosChangeTester> grandChild1(new ScenePosChangeTester(child1));
ScenePosChangeTester* child2 = new ScenePosChangeTester(root);
ScenePosChangeTester* grandChild2 = new ScenePosChangeTester(child2);
@@ -10726,7 +10728,7 @@ void tst_QGraphicsItem::scenePosChange()
QCOMPARE(grandChild2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 3);
// remove
- scene.removeItem(grandChild1);
+ scene.removeItem(grandChild1.data());
delete grandChild2; grandChild2 = 0;
QCoreApplication::processEvents(); // QGraphicsScenePrivate::_q_updateScenePosDescendants()
root->moveBy(1.0, 1.0);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 01708d526c..d99c056abe 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -2775,7 +2775,7 @@ void tst_QGraphicsProxyWidget::windowOpacity()
// disabled on platforms without alpha channel support in QPixmap (e.g.,
// X11 without XRender).
int paints = 0;
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
paints = !X11->use_xrender;
#endif
QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 2ecc1120b9..2e76ea3bb3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -2900,6 +2900,9 @@ void tst_QGraphicsView::scrollBarRanges()
if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX");
+
+ QScopedPointer<QStyle> stylePtr;
+
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setRenderHint(QPainter::Antialiasing);
@@ -2907,9 +2910,10 @@ void tst_QGraphicsView::scrollBarRanges()
view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame);
if (style == QString("motif"))
- view.setStyle(new FauxMotifStyle);
+ stylePtr.reset(new FauxMotifStyle);
else
- view.setStyle(QStyleFactory::create(style));
+ stylePtr.reset(QStyleFactory::create(style));
+ view.setStyle(stylePtr.data());
view.setStyleSheet(" "); // enables style propagation ;-)
int adjust = 0;
@@ -3476,7 +3480,7 @@ void tst_QGraphicsView::task245469_itemsAtPointWithClip()
static QGraphicsView *createSimpleViewAndScene()
{
QGraphicsView *view = new QGraphicsView;
- QGraphicsScene *scene = new QGraphicsScene;
+ QGraphicsScene *scene = new QGraphicsScene(view);
view->setScene(scene);
view->setBackgroundBrush(Qt::blue);
@@ -3604,7 +3608,7 @@ void tst_QGraphicsView::moveItemWhileScrolling()
MoveItemScrollView()
{
setWindowFlags(Qt::X11BypassWindowManagerHint);
- setScene(new QGraphicsScene(0, 0, 1000, 1000));
+ setScene(new QGraphicsScene(0, 0, 1000, 1000, this));
rect = scene()->addRect(0, 0, 10, 10);
rect->setPos(50, 50);
rect->setPen(QPen(Qt::black, 0));
@@ -3670,7 +3674,7 @@ void tst_QGraphicsView::centerOnDirtyItem()
toplevel.setWindowFlags(view.windowFlags() | Qt::WindowStaysOnTopHint);
view.resize(200, 200);
- QGraphicsScene *scene = new QGraphicsScene;
+ QGraphicsScene *scene = new QGraphicsScene(&view);
view.setScene(scene);
view.setSceneRect(-1000, -1000, 2000, 2000);
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 30c1b9c44b..5567641dde 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1000,7 +1000,7 @@ void tst_QAbstractItemView::setItemDelegate()
centerOnScreen(&v);
moveCursorAway(&v);
v.show();
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
QCursor::setPos(v.geometry().center());
#endif
QApplication::setActiveWindow(&v);
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 7796627bd9..83e1850524 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -315,7 +315,7 @@ void tst_QAction::enabledVisibleInteraction()
void tst_QAction::task200823_tooltip()
{
- QAction *action = new QAction("foo", 0);
+ const QScopedPointer<QAction> action(new QAction("foo", Q_NULLPTR));
QString shortcut("ctrl+o");
action->setShortcut(shortcut);
@@ -329,8 +329,8 @@ void tst_QAction::task200823_tooltip()
void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{
// test without a group
- QAction *actionWithoutGroup = new QAction("Test", qApp);
- QSignalSpy spyWithoutGroup(actionWithoutGroup, SIGNAL(triggered(bool)));
+ const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", Q_NULLPTR));
+ QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool)));
QCOMPARE(spyWithoutGroup.count(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 411b925adb..d6f3728663 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -2155,8 +2155,8 @@ void tst_QApplication::noQuitOnHide()
{
int argc = 0;
QApplication app(argc, 0);
- QWidget *window1 = new NoQuitOnHideWidget;
- window1->show();
+ NoQuitOnHideWidget window1;
+ window1.show();
QCOMPARE(app.exec(), 1);
}
@@ -2190,12 +2190,12 @@ void tst_QApplication::abortQuitOnShow()
{
int argc = 0;
QApplication app(argc, 0);
- QWidget *window1 = new ShowCloseShowWidget(false);
- window1->show();
+ ShowCloseShowWidget window1(false);
+ window1.show();
QCOMPARE(app.exec(), 0);
- QWidget *window2 = new ShowCloseShowWidget(true);
- window2->show();
+ ShowCloseShowWidget window2(true);
+ window2.show();
QCOMPARE(app.exec(), 1);
}
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index b7ca5d21c7..01e3d7bac0 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -51,6 +51,44 @@ static inline void setFrameless(QWidget *w)
w->setWindowFlags(flags);
}
+struct QFormLayoutTakeRowResultHolder {
+ QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW
+ : labelItem(result.labelItem),
+ fieldItem(result.fieldItem)
+ {
+ }
+ ~QFormLayoutTakeRowResultHolder()
+ {
+ // re-use a QFormLayout to recursively reap the QLayoutItems:
+ QFormLayout disposer;
+ if (labelItem)
+ disposer.setItem(0, QFormLayout::LabelRole, labelItem);
+ if (fieldItem)
+ disposer.setItem(0, QFormLayout::FieldRole, fieldItem);
+ }
+ QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW
+ : labelItem(other.labelItem),
+ fieldItem(other.fieldItem)
+ {
+ other.labelItem = nullptr;
+ other.fieldItem = nullptr;
+ }
+ QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW
+ {
+ swap(other);
+ return *this;
+ }
+
+ void swap(QFormLayoutTakeRowResultHolder &other) Q_DECL_NOTHROW
+ {
+ qSwap(labelItem, other.labelItem);
+ qSwap(fieldItem, other.fieldItem);
+ }
+
+ QLayoutItem *labelItem;
+ QLayoutItem *fieldItem;
+};
+
class tst_QFormLayout : public QObject
{
Q_OBJECT
@@ -396,7 +434,8 @@ void tst_QFormLayout::setFormStyle()
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
- widget.setStyle(QStyleFactory::create("windows"));
+ const QScopedPointer<QStyle> windowsStyle(QStyleFactory::create("windows"));
+ widget.setStyle(windowsStyle.data());
QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@@ -407,14 +446,16 @@ void tst_QFormLayout::setFormStyle()
this test is cross platform.. so create dummy styles that
return all the right stylehints.
*/
- widget.setStyle(new DummyMacStyle());
+ DummyMacStyle macStyle;
+ widget.setStyle(&macStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
- widget.setStyle(new DummyQtopiaStyle());
+ DummyQtopiaStyle qtopiaStyle;
+ widget.setStyle(&qtopiaStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@@ -814,7 +855,7 @@ void tst_QFormLayout::takeRow()
QCOMPARE(layout->count(), 3);
QCOMPARE(layout->rowCount(), 2);
- QFormLayout::TakeRowResult result = layout->takeRow(1);
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(1);
QVERIFY(w2);
QVERIFY(result.fieldItem);
@@ -853,7 +894,7 @@ void tst_QFormLayout::takeRow_QWidget()
QCOMPARE(layout->count(), 3);
QCOMPARE(layout->rowCount(), 2);
- QFormLayout::TakeRowResult result = layout->takeRow(w1);
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(w1);
QVERIFY(w1);
QVERIFY(result.fieldItem);
@@ -898,7 +939,7 @@ void tst_QFormLayout::takeRow_QLayout()
QCOMPARE(layout->count(), 3);
QCOMPARE(layout->rowCount(), 2);
- QFormLayout::TakeRowResult result = layout->takeRow(l1);
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(l1);
QVERIFY(l1);
QVERIFY(w1);
@@ -1123,7 +1164,7 @@ void tst_QFormLayout::takeAt()
QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
- layout->takeAt(0);
+ delete layout->takeAt(0);
QCOMPARE(layout->count(), i);
}
}
@@ -1215,7 +1256,7 @@ void tst_QFormLayout::replaceWidget()
QFormLayout::ItemRole role;
// replace editor
- layout->replaceWidget(edit1, edit3);
+ delete layout->replaceWidget(edit1, edit3);
edit1->hide(); // Not strictly needed for the test, but for normal usage it is.
QCOMPARE(layout->indexOf(edit1), -1);
QCOMPARE(layout->indexOf(edit3), editIndex);
@@ -1226,7 +1267,7 @@ void tst_QFormLayout::replaceWidget()
QCOMPARE(rownum, 0);
QCOMPARE(role, QFormLayout::FieldRole);
- layout->replaceWidget(label1, label2);
+ delete layout->replaceWidget(label1, label2);
label1->hide();
QCOMPARE(layout->indexOf(label1), -1);
QCOMPARE(layout->indexOf(label2), labelIndex);
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 5f3fed1f66..0c25a01ba0 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -10245,14 +10245,13 @@ public slots:
bool eventFilter(QObject *o, QEvent *e)
{
- if (modal && modal->button && o == modal->button) {
- switch (e->type()) {
- case QEvent::Enter:
+ switch (e->type()) {
+ case QEvent::Enter:
+ if (modal && modal->button && o == modal->button)
enters++;
- break;
- default:
- break;
- }
+ break;
+ default:
+ break;
}
return QDialog::eventFilter(o, e);
}
diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
index 8573cea35f..a3e7219892 100644
--- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp
@@ -1200,6 +1200,150 @@ void tst_QUndoStack::setClean()
true, // undoChanged
true); // redoChanged
QCOMPARE(stack.cleanIndex(), -1);
+
+ stack.setClean();
+ QCOMPARE(str, QString());
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 1, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 0);
+
+ stack.resetClean();
+ QCOMPARE(str, QString());
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ stack.redo();
+ QCOMPARE(str, QString("foo"));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ false, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
+
+ stack.setClean();
+ QCOMPARE(str, QString("foo"));
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ true, // clean
+ 1, // count
+ 1, // index
+ true, // canUndo
+ "insert", // undoText
+ false, // canRedo
+ "", // redoText
+ true, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 1);
+
+ stack.undo();
+ QCOMPARE(str, QString());
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ true, // cleanChanged
+ true, // indexChanged
+ true, // undoChanged
+ true); // redoChanged
+ QCOMPARE(stack.cleanIndex(), 1);
+
+ stack.resetClean();
+ QCOMPARE(str, QString());
+ checkState(redoTextChangedSpy,
+ canRedoChangedSpy,
+ undoTextChangedSpy,
+ redoAction,
+ undoAction,
+ canUndoChangedSpy,
+ cleanChangedSpy,
+ indexChangedSpy,
+ stack,
+ false, // clean
+ 1, // count
+ 0, // index
+ false, // canUndo
+ "", // undoText
+ true, // canRedo
+ "insert", // redoText
+ false, // cleanChanged
+ false, // indexChanged
+ false, // undoChanged
+ false); // redoChanged
+ QCOMPARE(stack.cleanIndex(), -1);
}
void tst_QUndoStack::clear()
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 30e4f63aa1..680fea27dd 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -861,6 +861,10 @@ void tst_QMainWindow::takeCentralWidget() {
QVERIFY(!mw.centralWidget());
+ // verify that we don't crash when trying to take a non-set
+ // central widget but just return a null pointer instead
+ QVERIFY(!mw.takeCentralWidget());
+
mw.setCentralWidget(w1);
QWidget *oldCentralWidget = mw.takeCentralWidget();
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 2b8f3032bf..52d7a39406 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -474,7 +474,7 @@ void tst_QMdiArea::subWindowActivated2()
// Check that we only emit _one_ signal and the active window
// is unchanged after hide/show.
mdiArea.hide();
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
qt_x11_wait_for_window_manager(&mdiArea);
#endif
QTest::qWait(100);
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 76c3ac4143..a9d8c48d63 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -49,7 +49,7 @@
#include <QSizeGrip>
QT_BEGIN_NAMESPACE
-#if !defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 1 // Used to be excluded in Qt4 for Q_WS_WIN
extern bool qt_tab_all_widgets();
#endif
QT_END_NAMESPACE
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 4f9508266c..d5c3bdb93f 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -5,3 +5,5 @@ ubuntu-14.04
redhatenterpriselinuxworkstation-6.6
[task256322_highlight]
osx
+[taskQTBUG46812_doNotLeaveMenubarHighlighted]
+osx
diff --git a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro
index 3fb6ae61a8..e680cf4d7d 100644
--- a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro
+++ b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro
@@ -2,3 +2,8 @@ CONFIG += testcase
TARGET = tst_qmenubar
QT += widgets testlib
SOURCES += tst_qmenubar.cpp
+
+macos: {
+ OBJECTIVE_SOURCES += tst_qmenubar_mac.mm
+ LIBS += -framework AppKit
+}
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 5e27f5e80f..52e631ef57 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -131,6 +131,11 @@ private slots:
void cornerWidgets();
void taskQTBUG53205_crashReparentNested();
void taskQTBUG46812_doNotLeaveMenubarHighlighted();
+#ifdef Q_OS_MACOS
+ void taskQTBUG56275_reinsertMenuInParentlessQMenuBar();
+#endif
+
+ void platformMenu();
protected slots:
void onSimpleActivated( QAction*);
@@ -1493,6 +1498,25 @@ void tst_QMenuBar::taskQTBUG53205_crashReparentNested()
testMenus.actions[0]->trigger();
}
+// QTBUG-56526
+void tst_QMenuBar::platformMenu()
+{
+ QMenuBar menuBar;
+ QPlatformMenuBar *platformMenuBar = menuBar.platformMenuBar();
+ if (!platformMenuBar)
+ QSKIP("No platform menubar implementation available on this platform.");
+
+ // QMenu must not create a platform menu instance at creation time, because
+ // on Unity the type of the platform menu instance must be different (QGtk3Menu
+ // vs. QDbusPlatformMenu) depending on whether the menu is in the global menubar
+ // or a standalone context menu.
+ QMenu *menu = new QMenu(&menuBar);
+ QVERIFY(!menu->platformMenu());
+
+ menuBar.addMenu(menu);
+ QVERIFY(menu->platformMenu());
+}
+
void tst_QMenuBar::slotForTaskQTBUG53205()
{
QWidget *parent = taskQTBUG53205MenuBar->parentWidget();
@@ -1532,6 +1556,28 @@ void tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted()
QCOMPARE(m_simpleActivatedCount, 2);
}
+#ifdef Q_OS_MACOS
+extern bool tst_qmenubar_taskQTBUG56275(QMenuBar *);
+
+void tst_QMenuBar::taskQTBUG56275_reinsertMenuInParentlessQMenuBar()
+{
+ QMenuBar menubar;
+
+ QMenu *menu = new QMenu("menu", &menubar);
+ QMenu* submenu = menu->addMenu("submenu");
+ submenu->addAction("action1");
+ submenu->addAction("action2");
+ menu->addAction("action3");
+ menubar.addMenu(menu);
+
+ QTest::qWait(100);
+ menubar.clear();
+ menubar.addMenu(menu);
+ QTest::qWait(100);
+
+ QVERIFY(tst_qmenubar_taskQTBUG56275(&menubar));
+}
+#endif // Q_OS_MACOS
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm
new file mode 100644
index 0000000000..4645de4d7a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#include <QMenuBar>
+#include <QTest>
+
+bool tst_qmenubar_taskQTBUG56275(QMenuBar *menubar)
+{
+ NSMenu *mainMenu = menubar->toNSMenu();
+ return mainMenu.numberOfItems == 2
+ && [[mainMenu itemAtIndex:1].title isEqualToString:@"menu"];
+}
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index da38ed254b..8a5c8ec1df 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -770,22 +770,22 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
QVERIFY(file.open(QIODevice::ReadOnly));
QXmlSimpleReader xmlReader;
{
- QXmlInputSource *source = new QXmlInputSource(&file);
+ QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
- QVERIFY(!xmlReader.parse(source));
+ QVERIFY(!xmlReader.parse(&source));
}
file.close();
file.setFileName(QFINDTESTDATA("xmldocs/1-levels-nested-dtd.xml"));
QVERIFY(file.open(QIODevice::ReadOnly));
{
- QXmlInputSource *source = new QXmlInputSource(&file);
+ QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
- QVERIFY(!xmlReader.parse(source));
+ QVERIFY(!xmlReader.parse(&source));
// The error wasn't because of the recursion limit being reached,
// it was because the document is not valid.
QVERIFY(handler.recursionCount < 2);
@@ -795,11 +795,11 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
file.setFileName(QFINDTESTDATA("xmldocs/internal-entity-polynomial-attribute.xml"));
QVERIFY(file.open(QIODevice::ReadOnly));
{
- QXmlInputSource *source = new QXmlInputSource(&file);
+ QXmlInputSource source(&file);
TestHandler handler;
xmlReader.setDeclHandler(&handler);
xmlReader.setErrorHandler(&handler);
- QVERIFY(!xmlReader.parse(source));
+ QVERIFY(!xmlReader.parse(&source));
QCOMPARE(handler.recursionCount, 2);
}
}
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
index 70b9134718..de4e9e5ad7 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp
@@ -30,7 +30,7 @@
#include <QtGui>
-#ifdef Q_DEAD_CODE_FROM_QT4_WIN
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
#define CALLGRIND_START_INSTRUMENTATION {}
#define CALLGRIND_STOP_INSTRUMENTATION {}
#else
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
index 957ad06783..6c97f94683 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/moveItems/main.cpp
@@ -27,14 +27,14 @@
****************************************************************************/
#include <QtGui>
-#ifdef Q_DEAD_CODE_FROM_QT4_WIN
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
#define CALLGRIND_START_INSTRUMENTATION {}
#define CALLGRIND_STOP_INSTRUMENTATION {}
#else
#include "valgrind/callgrind.h"
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
extern void qt_x11_wait_for_window_manager(QWidget *);
#endif
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
View view(&scene, item);
view.resize(300, 300);
view.show();
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
index 5b6083d5ac..1fbb229cd8 100644
--- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
+++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/scrolltest/main.cpp
@@ -27,7 +27,7 @@
****************************************************************************/
#include <QtGui>
-#ifdef Q_DEAD_CODE_FROM_QT4_WIN
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
#define CALLGRIND_START_INSTRUMENTATION {}
#define CALLGRIND_STOP_INSTRUMENTATION {}
#else
diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp
index 5d7edc0a99..c1ace138f9 100644
--- a/tests/manual/lance/main.cpp
+++ b/tests/manual/lance/main.cpp
@@ -327,7 +327,7 @@ int main(int argc, char **argv)
checkers_background = false;
}
} else {
-#if defined (Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
QString input = QString::fromLocal8Bit(argv[i]);
if (input.indexOf('*') >= 0) {
QFileInfo info(input);
diff --git a/tests/manual/qopenglcontext/qopenglcontext.pro b/tests/manual/qopenglcontext/qopenglcontext.pro
index c5943809c6..08a9ab407c 100644
--- a/tests/manual/qopenglcontext/qopenglcontext.pro
+++ b/tests/manual/qopenglcontext/qopenglcontext.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = qopenglcontext
-QT += gui-private platformsupport-private
+QT += gui-private egl_support-private
HEADERS += $$PWD/qopenglcontextwindow.h
diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
index f49908ca28..0763d7244c 100644
--- a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
+++ b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
@@ -33,7 +33,7 @@
#include <QtGui/QMatrix4x4>
#include <qpa/qplatformnativeinterface.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
QOpenGLContextWindow::QOpenGLContextWindow()
diff --git a/tests/manual/textrendering/glyphshaping/main.cpp b/tests/manual/textrendering/glyphshaping/main.cpp
index 62d2475462..c3acda953d 100644
--- a/tests/manual/textrendering/glyphshaping/main.cpp
+++ b/tests/manual/textrendering/glyphshaping/main.cpp
@@ -160,7 +160,7 @@ bool dumpHtml(const QString &pathName)
QString platformName = QString::fromLatin1(
#if defined(Q_OS_WIN)
"Win32"
-#elif defined(Q_DEAD_CODE_FROM_QT4_X11)
+#elif 0 // Used to be included in Qt4 for Q_WS_X11
"X11"
#else
""