summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-24 13:37:06 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-11-24 13:39:13 +0100
commit34aba4724f196e34ed02cf50073f41968f119bb6 (patch)
tree0ebdfcabda989ab76ee6de53c6461553c7a767a5 /tests
parentb86b2a742afae118bf974c82ba966ddb0cae4afb (diff)
parentb1cf07f495e10c93e53651ac03e46ebdaea0a97e (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/corelib/io/qiodevice.cpp src/plugins/bearer/linux_common/qofonoservice_linux.cpp src/plugins/bearer/linux_common/qofonoservice_linux_p.h src/plugins/platforms/android/qandroidplatformtheme.cpp src/tools/bootstrap/bootstrap.pro src/widgets/styles/qmacstyle_mac.mm Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp4
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp12
-rw-r--r--tests/auto/corelib/io/qsettings/bom.ini4
-rw-r--r--tests/auto/corelib/io/qsettings/qsettings.qrc17
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp10
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp10
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp9
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp130
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp52
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp19
-rw-r--r--tests/auto/corelib/kernel/qvariant/qvariant.pro1
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp12
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp22
-rw-r--r--tests/auto/corelib/tools/qversionnumber/qversionnumber.pro2
-rw-r--r--tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp2
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp11
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp28
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpgbin0 -> 910 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpgbin0 -> 910 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpgbin0 -> 988 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpgbin0 -> 995 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpgbin0 -> 912 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpgbin0 -> 911 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpgbin0 -> 987 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpgbin0 -> 991 bytes
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp18
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp27
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp3
-rw-r--r--tests/auto/network/access/qnetworkreply/BLACKLIST3
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/BLACKLIST4
-rw-r--r--tests/auto/network/ssl/ssl.pro8
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp90
-rw-r--r--tests/auto/other/qaccessibility/BLACKLIST2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp38
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp20
-rw-r--r--tests/auto/tools/moc/parse-defines.h2
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro1
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp2
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp9
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp4
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp4
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp10
-rw-r--r--[-rwxr-xr-x]tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro0
-rw-r--r--[-rwxr-xr-x]tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp101
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp8
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2
-rw-r--r--tests/manual/diaglib/README.txt34
-rw-r--r--tests/manual/diaglib/diaglib.pri43
-rw-r--r--tests/manual/diaglib/eventfilter.cpp113
-rw-r--r--tests/manual/diaglib/eventfilter.h77
-rw-r--r--tests/manual/diaglib/glinfo.cpp112
-rw-r--r--tests/manual/diaglib/glinfo.h48
-rw-r--r--tests/manual/diaglib/nativewindowdump.cpp46
-rw-r--r--tests/manual/diaglib/nativewindowdump.h46
-rw-r--r--tests/manual/diaglib/nativewindowdump_win.cpp207
-rw-r--r--tests/manual/diaglib/qwidgetdump.cpp94
-rw-r--r--tests/manual/diaglib/qwidgetdump.h45
-rw-r--r--tests/manual/diaglib/qwindowdump.cpp176
-rw-r--r--tests/manual/diaglib/qwindowdump.h63
-rw-r--r--tests/manual/manual.pro1
-rw-r--r--tests/manual/touch/main.cpp209
-rw-r--r--tests/manual/touch/touch.pro5
65 files changed, 1935 insertions, 89 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
index 4e3d5c64bc..df2f97ce0e 100644
--- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
@@ -1996,6 +1996,10 @@ void tst_QTextCodec::codecForHtml_data()
"auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: "
"none;\">&#x37b</span>\000";
QTest::newRow("greek text UTF-8") << html << 106 << 106;
+
+ html = "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=unicode\">"
+ "<head/><body><p>bla</p></body></html>"; // QTBUG-41998, ICU will return UTF-16.
+ QTest::newRow("legacy unicode UTF-8") << html << 106 << 106;
}
void tst_QTextCodec::codecForHtml()
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 35bd518b3a..0a55da5b7e 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -886,25 +886,25 @@ void tst_qmessagehandler::formatLogMessage_data()
#define BA QByteArrayLiteral
QTest::newRow("basic") << "%{type} %{file} %{line} %{function} %{message}"
- << "debug main.cpp 1 func msg\n"
+ << "debug main.cpp 1 func msg"
<< QtDebugMsg << BA("main.cpp") << 1 << BA("func") << BA("") << "msg";
// test the if conditions
QString format = "[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}";
QTest::newRow("if-debug")
- << format << "[D] msg\n"
+ << format << "[D] msg"
<< QtDebugMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
QTest::newRow("if_warning")
- << format << "[W] msg\n"
+ << format << "[W] msg"
<< QtWarningMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
QTest::newRow("if_critical")
- << format << "[C] msg\n"
+ << format << "[C] msg"
<< QtCriticalMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
QTest::newRow("if_fatal")
- << format << "[F] msg\n"
+ << format << "[F] msg"
<< QtFatalMsg << BA("") << 0 << BA("func") << QByteArray() << "msg";
QTest::newRow("if_cat")
- << format << "[F] cat: msg\n"
+ << format << "[F] cat: msg"
<< QtFatalMsg << BA("") << 0 << BA("func") << BA("cat") << "msg";
}
diff --git a/tests/auto/corelib/io/qsettings/bom.ini b/tests/auto/corelib/io/qsettings/bom.ini
new file mode 100644
index 0000000000..8d46ee8d91
--- /dev/null
+++ b/tests/auto/corelib/io/qsettings/bom.ini
@@ -0,0 +1,4 @@
+[section1]
+foo1=bar1
+[section2]
+foo2=bar2
diff --git a/tests/auto/corelib/io/qsettings/qsettings.qrc b/tests/auto/corelib/io/qsettings/qsettings.qrc
index 587c22ebe3..c0be7e013f 100644
--- a/tests/auto/corelib/io/qsettings/qsettings.qrc
+++ b/tests/auto/corelib/io/qsettings/qsettings.qrc
@@ -1,9 +1,10 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>resourcefile.ini</file>
- <file>resourcefile2.ini</file>
- <file>resourcefile3.ini</file>
- <file>resourcefile4.ini</file>
- <file>resourcefile5.ini</file>
-</qresource>
+<RCC>
+ <qresource prefix="/">
+ <file>resourcefile.ini</file>
+ <file>resourcefile2.ini</file>
+ <file>resourcefile3.ini</file>
+ <file>resourcefile4.ini</file>
+ <file>resourcefile5.ini</file>
+ <file>bom.ini</file>
+ </qresource>
</RCC>
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 3e68e4859f..c89923f159 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -161,6 +161,7 @@ private slots:
void testByteArray_data();
void testByteArray();
void iniCodec();
+ void bom();
private:
const bool m_canWriteNativeSystemSettings;
@@ -730,6 +731,15 @@ void tst_QSettings::iniCodec()
}
+void tst_QSettings::bom()
+{
+ QSettings s(":/bom.ini", QSettings::IniFormat);
+ QStringList allkeys = s.allKeys();
+ QCOMPARE(allkeys.size(), 2);
+ QVERIFY(allkeys.contains("section1/foo1"));
+ QVERIFY(allkeys.contains("section2/foo2"));
+}
+
void tst_QSettings::testErrorHandling_data()
{
QTest::addColumn<int>("filePerms"); // -1 means file should not exist
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index e07dda250f..3abbb71960 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -154,6 +154,11 @@ void tst_QStorageInfo::tempFile()
QVERIFY(file.open());
QStorageInfo storage1(file.fileName());
+#ifdef Q_OS_LINUX
+ if (storage1.fileSystemType() == "btrfs")
+ QSKIP("This test doesn't work on btrfs, probably due to a btrfs bug");
+#endif
+
qint64 free = storage1.bytesFree();
file.write(QByteArray(1024*1024, '1'));
@@ -170,6 +175,11 @@ void tst_QStorageInfo::caching()
QVERIFY(file.open());
QStorageInfo storage1(file.fileName());
+#ifdef Q_OS_LINUX
+ if (storage1.fileSystemType() == "btrfs")
+ QSKIP("This test doesn't work on btrfs, probably due to a btrfs bug");
+#endif
+
qint64 free = storage1.bytesFree();
QStorageInfo storage2(storage1);
QVERIFY(free == storage2.bytesFree());
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 5b5161e24a..6d801f75c1 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1179,6 +1179,12 @@ void tst_QUrl::toLocalFile_data()
QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt");
QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt");
+ QTest::newRow("data4a") << QString::fromLatin1("webdavs://somewebdavhost/somedir/somefile")
+#ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only.
+ << QString::fromLatin1("//somewebdavhost@SSL/somedir/somefile");
+#else
+ << QString();
+#endif
#ifdef Q_OS_WIN
QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt");
#else
@@ -1227,6 +1233,9 @@ void tst_QUrl::fromLocalFile_data()
QTest::newRow("data3") << QString::fromLatin1("c:/a.txt") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt");
QTest::newRow("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile")
<< QString::fromLatin1("/somedir/somefile");
+ QTest::newRow("data4a") << QString::fromLatin1("//somewebdavhost@SSL/somedir/somefile")
+ << QString::fromLatin1("webdavs://somewebdavhost/somedir/somefile")
+ << QString::fromLatin1("/somedir/somefile");
QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost")
<< QString::fromLatin1("");
QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/")
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index ed84c111c6..d05ed6c20f 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -95,6 +95,7 @@ private slots:
void changeFilter();
void changeSourceData_data();
void changeSourceData();
+ void changeSourceDataKeepsStableSorting_qtbug1548();
void sortFilterRole();
void selectionFilteredOut();
void match_data();
@@ -143,6 +144,7 @@ private slots:
void noMapAfterSourceDelete();
void forwardDropApi();
+ void canDropMimeData();
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
@@ -2009,6 +2011,79 @@ void tst_QSortFilterProxyModel::changeSourceData()
}
}
+// Checks that the model is a table, and that each and every row is like this:
+// i-th row: ( rows.at(i), i )
+static void checkSortedTableModel(const QAbstractItemModel *model, const QStringList &rows)
+{
+ QCOMPARE(model->rowCount(), rows.length());
+ QCOMPARE(model->columnCount(), 2);
+
+ for (int row = 0; row < model->rowCount(); ++row) {
+ const QString column0 = model->index(row, 0).data().toString();
+ const int column1 = model->index(row, 1).data().toString().toInt();
+
+ QCOMPARE(column0, rows.at(row));
+ QCOMPARE(column1, row);
+ }
+}
+
+void tst_QSortFilterProxyModel::changeSourceDataKeepsStableSorting_qtbug1548()
+{
+ // Check that emitting dataChanged from the source model
+ // for a change of a role which is not the sorting role
+ // doesn't alter the sorting. In this case, we sort on the DisplayRole,
+ // and play with other roles.
+
+ static const QStringList rows
+ = QStringList() << "a" << "b" << "b" << "b" << "c" << "c" << "x";
+
+ // Build a table of pairs (string, #row) in each row
+ QStandardItemModel model(0, 2);
+
+ for (int rowNumber = 0; rowNumber < rows.length(); ++rowNumber) {
+ QStandardItem *column0 = new QStandardItem(rows.at(rowNumber));
+ column0->setCheckable(true);
+ column0->setCheckState(Qt::Unchecked);
+
+ QStandardItem *column1 = new QStandardItem(QString::number(rowNumber));
+
+ const QList<QStandardItem *> row
+ = QList<QStandardItem *>() << column0 << column1;
+
+ model.appendRow(row);
+ }
+
+ checkSortedTableModel(&model, rows);
+
+ // Build the proxy model
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&model);
+ proxy.setDynamicSortFilter(true);
+ proxy.sort(0);
+
+ // The proxy is now sorted by the first column, check that the sorting
+ // * is correct (the input is already sorted, so it must not have changed)
+ // * was stable (by looking at the second column)
+ checkSortedTableModel(&model, rows);
+
+ // Change the check status of an item. That must not break the stable sorting
+ // changes the middle "b"
+ model.item(2)->setCheckState(Qt::Checked);
+ checkSortedTableModel(&model, rows);
+
+ // changes the starting "a"
+ model.item(0)->setCheckState(Qt::Checked);
+ checkSortedTableModel(&model, rows);
+
+ // change the background color of the first "c"
+ model.item(4)->setBackground(Qt::red);
+ checkSortedTableModel(&model, rows);
+
+ // change the background color of the second "c"
+ model.item(5)->setBackground(Qt::red);
+ checkSortedTableModel(&model, rows);
+}
+
void tst_QSortFilterProxyModel::sortFilterRole()
{
QStandardItemModel model;
@@ -3835,6 +3910,36 @@ void tst_QSortFilterProxyModel::chainedProxyModelRoleNames()
QVERIFY(proxy2.roleNames().value(Qt::UserRole + 1) == "custom");
}
+// A source model with ABABAB rows, where only A rows accept drops.
+// It will then be sorted by a QSFPM.
+class DropOnOddRows : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ DropOnOddRows(QObject *parent = 0) : QAbstractListModel(parent) {}
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole)
+ return (index.row() % 2 == 0) ? "A" : "B";
+ return QVariant();
+ }
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const
+ {
+ Q_UNUSED(parent);
+ return 10;
+ }
+
+ bool canDropMimeData(const QMimeData *, Qt::DropAction,
+ int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE
+ {
+ Q_UNUSED(row);
+ Q_UNUSED(column);
+ return parent.row() % 2 == 0;
+ }
+};
+
class SourceAssertion : public QSortFilterProxyModel
{
Q_OBJECT
@@ -3899,5 +4004,30 @@ void tst_QSortFilterProxyModel::forwardDropApi()
QVERIFY(model.dropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex()));
}
+static QString rowTexts(QAbstractItemModel *model) {
+ QString str;
+ for (int row = 0 ; row < model->rowCount(); ++row)
+ str += model->index(row, 0).data().toString();
+ return str;
+}
+
+void tst_QSortFilterProxyModel::canDropMimeData()
+{
+ // Given a source model which only supports dropping on even rows
+ DropOnOddRows sourceModel;
+ QCOMPARE(rowTexts(&sourceModel), QString("ABABABABAB"));
+
+ // and a proxy model that sorts the rows
+ QSortFilterProxyModel proxy;
+ proxy.setSourceModel(&sourceModel);
+ proxy.sort(0, Qt::AscendingOrder);
+ QCOMPARE(rowTexts(&proxy), QString("AAAAABBBBB"));
+
+ // the proxy should correctly map canDropMimeData to the source model,
+ // i.e. accept drops on the first 5 rows and refuse drops on the next 5.
+ for (int row = 0; row < proxy.rowCount(); ++row)
+ QCOMPARE(proxy.canDropMimeData(0, Qt::CopyAction, -1, -1, proxy.index(row, 0)), row < 5);
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index 5cfbce0d7a..befd45018a 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -40,6 +40,7 @@
#include <private/qeventloop_p.h>
#if defined(Q_OS_UNIX)
#include <private/qeventdispatcher_unix_p.h>
+ #include <QtCore/private/qcore_unix_p.h>
#if defined(HAVE_GLIB)
#include <private/qeventdispatcher_glib_p.h>
#endif
@@ -172,7 +173,9 @@ private slots:
void execAfterExit();
void wakeUp();
void quit();
+#if defined(Q_OS_UNIX)
void processEventsExcludeSocket();
+#endif
void processEventsExcludeTimers();
void deliverInDefinedOrder();
@@ -383,6 +386,7 @@ void tst_QEventLoop::customEvent(QEvent *e)
}
}
+#if defined(Q_OS_UNIX)
class SocketEventsTester: public QObject
{
Q_OBJECT
@@ -391,8 +395,10 @@ public:
{
socket = 0;
server = 0;
- dataArrived = false;
+ dataSent = false;
+ dataReadable = false;
testResult = false;
+ dataArrived = false;
}
~SocketEventsTester()
{
@@ -415,8 +421,10 @@ public:
QTcpSocket *socket;
QTcpServer *server;
- bool dataArrived;
+ bool dataSent;
+ bool dataReadable;
bool testResult;
+ bool dataArrived;
public slots:
void sendAck()
{
@@ -428,12 +436,26 @@ public slots:
qint64 size = sizeof(data);
QTcpSocket *serverSocket = server->nextPendingConnection();
+ QCoreApplication::processEvents();
serverSocket->write(data, size);
- serverSocket->flush();
- QTest::qSleep(200); //allow the TCP/IP stack time to loopback the data, so our socket is ready to read
- QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
- testResult = dataArrived;
- QCoreApplication::processEvents(); //check the deferred event is processed
+ dataSent = serverSocket->waitForBytesWritten(-1);
+
+ if (dataSent) {
+ fd_set fdread;
+ int fd = socket->socketDescriptor();
+ FD_ZERO(&fdread);
+ FD_SET(fd, &fdread);
+ dataReadable = (1 == qt_safe_select(fd + 1, &fdread, 0, 0, 0));
+ }
+
+ if (!dataReadable) {
+ testResult = dataArrived;
+ } else {
+ QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
+ testResult = dataArrived;
+ // to check if the deferred event is processed
+ QCoreApplication::processEvents();
+ }
serverSocket->close();
QThread::currentThread()->exit(0);
}
@@ -449,12 +471,16 @@ public:
SocketEventsTester *tester = new SocketEventsTester();
if (tester->init())
exec();
+ dataSent = tester->dataSent;
+ dataReadable = tester->dataReadable;
testResult = tester->testResult;
dataArrived = tester->dataArrived;
delete tester;
}
- bool testResult;
- bool dataArrived;
+ bool dataSent;
+ bool dataReadable;
+ bool testResult;
+ bool dataArrived;
};
void tst_QEventLoop::processEventsExcludeSocket()
@@ -462,9 +488,17 @@ void tst_QEventLoop::processEventsExcludeSocket()
SocketTestThread thread;
thread.start();
QVERIFY(thread.wait());
+ QVERIFY(thread.dataSent);
+ QVERIFY(thread.dataReadable);
+ #if defined(HAVE_GLIB)
+ QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher();
+ if (qobject_cast<QEventDispatcherGlib *>(eventDispatcher))
+ QEXPECT_FAIL("", "ExcludeSocketNotifiers is currently broken in the Glib dispatchers", Continue);
+ #endif
QVERIFY(!thread.testResult);
QVERIFY(thread.dataArrived);
}
+#endif
class TimerReceiver : public QObject
{
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index 78c75b44e8..5833123dfe 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -642,18 +642,25 @@ struct CountedStruct
QThread *thread;
};
-static QEventLoop _e;
+static QScopedPointer<QEventLoop> _e;
static QThread *_t = Q_NULLPTR;
class StaticEventLoop
{
public:
- static void quitEventLoop() { _e.quit(); if (_t) QCOMPARE(QThread::currentThread(), _t); }
+ static void quitEventLoop()
+ {
+ QVERIFY(!_e.isNull());
+ _e->quit();
+ if (_t)
+ QCOMPARE(QThread::currentThread(), _t);
+ }
};
void tst_QTimer::singleShotToFunctors()
{
int count = 0;
+ _e.reset(new QEventLoop);
QEventLoop e;
QTimer::singleShot(0, CountedStruct(&count));
@@ -661,7 +668,7 @@ void tst_QTimer::singleShotToFunctors()
QCOMPARE(count, 1);
QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
- QCOMPARE(_e.exec(), 0);
+ QCOMPARE(_e->exec(), 0);
QThread t1;
QObject c1;
@@ -687,7 +694,7 @@ void tst_QTimer::singleShotToFunctors()
QCOMPARE(e.exec(), 0);
QTimer::singleShot(0, &c2, &StaticEventLoop::quitEventLoop);
- QCOMPARE(_e.exec(), 0);
+ QCOMPARE(_e->exec(), 0);
_t->quit();
_t->wait();
@@ -721,8 +728,10 @@ void tst_QTimer::singleShotToFunctors()
thread.quit();
thread.wait();
#endif
-}
+ _e.reset();
+ _t = Q_NULLPTR;
+}
class DontBlockEvents : public QObject
{
diff --git a/tests/auto/corelib/kernel/qvariant/qvariant.pro b/tests/auto/corelib/kernel/qvariant/qvariant.pro
index f8d054f70c..39178ba9e6 100644
--- a/tests/auto/corelib/kernel/qvariant/qvariant.pro
+++ b/tests/auto/corelib/kernel/qvariant/qvariant.pro
@@ -6,3 +6,4 @@ INCLUDEPATH += $$PWD/../../../other/qvariant_common
SOURCES = tst_qvariant.cpp
RESOURCES += qvariant.qrc
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+contains(QT_CONFIG, c++11): CONFIG += c++11
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index eae6311854..301db37233 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -3840,11 +3840,10 @@ struct ContainerAPI<Container, QByteArray>
}
};
-// We have no built-in defines to check the stdlib features.
-// #define TEST_FORWARD_LIST
-
-#ifdef TEST_FORWARD_LIST
-#include <forward_list>
+#ifdef __has_include
+# if __has_include(<forward_list>)
+# define TEST_FORWARD_LIST
+# include <forward_list>
Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(std::forward_list)
@@ -3898,7 +3897,8 @@ struct ContainerAPI<std::forward_list<QString> >
return variant == value;
}
};
-#endif
+# endif // __has_include(<forward_list>)
+#endif // __has_include
template<typename Container>
struct KeyGetter
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 57473021aa..e001440045 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -4447,6 +4447,28 @@ void tst_QString::section_data()
<< QString("o") << 1 << 2
<< int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep)
<< QString("o1o2o") << false;
+ QTest::newRow( "range1" ) << QString("o1o2o")
+ << QString("o") << -5 << -5
+ << int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep)
+ << QString() << false;
+ QTest::newRow( "range2" ) << QString("oo1o2o")
+ << QString("o") << -5 << 1
+ << int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep
+ |QString::SectionSkipEmpty)
+ << QString("oo1o2o") << false;
+ QTest::newRow( "range3" ) << QString("o1o2o")
+ << QString("o") << 2 << 1
+ << int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep)
+ << QString() << false;
+ QTest::newRow( "range4" ) << QString("o1o2o")
+ << QString("o") << 4 << 4
+ << int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep)
+ << QString() << false;
+ QTest::newRow( "range5" ) << QString("o1oo2o")
+ << QString("o") << -2 << -1
+ << int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep
+ |QString::SectionSkipEmpty)
+ << QString("o1oo2o") << false;
QTest::newRow( "rx1" ) << QString("o1o2o")
<< QString("[a-z]") << 0 << 0
<< int(QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep)
diff --git a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
index 08ee0dd3d9..1e74d42bbd 100644
--- a/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
+++ b/tests/auto/corelib/tools/qversionnumber/qversionnumber.pro
@@ -1,4 +1,4 @@
CONFIG += testcase parallel_test
TARGET = tst_qversionnumber
-QT = core testlib
+QT = core-private testlib
SOURCES = tst_qversionnumber.cpp
diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
index 18bc86620a..f97b8a4df8 100644
--- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
+++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp
@@ -33,7 +33,7 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <qversionnumber.h>
+#include <private/qversionnumber_p.h>
class tst_QVersionNumber : public QObject
{
diff --git a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp
index 5263d431d0..b4c16c6fa3 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp
+++ b/tests/auto/dbus/qdbusabstractadaptor/qmyserver/qmyserver.cpp
@@ -75,6 +75,11 @@ public slots:
return m_conn.isConnected();
}
+ Q_NOREPLY void requestSync(const QString &seq)
+ {
+ emit syncReceived(seq);
+ }
+
void emitSignal(const QString& interface, const QString& name, const QDBusVariant& parameter)
{
if (interface.endsWith('2'))
@@ -126,10 +131,14 @@ public slots:
valueSpy.clear();
}
+signals:
+ Q_SCRIPTABLE void syncReceived(const QString &sequence);
+
private slots:
- void handleConnection(const QDBusConnection& con)
+ void handleConnection(QDBusConnection con)
{
m_conn = con;
+ con.registerObject(objectPath, this, QDBusConnection::ExportScriptableSignals);
}
private:
diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
index 6d25bf2213..9fe6bc790e 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
+++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
@@ -338,6 +338,24 @@ void registerMyObjectPeer(const QString & path, QDBusConnection::RegisterOptions
QDBusMessage reply = QDBusConnection::sessionBus().call(req);
}
+void syncPeer()
+{
+ static int counter = 0;
+ QString reqId = QString::number(++counter);
+
+ // wait for the sync signal with the right ID
+ QEventLoop loop;
+ QDBusConnection con("peer");
+ con.connect(serviceName, objectPath, interfaceName, "syncReceived",
+ QStringList() << reqId, QString(), &loop, SLOT(quit()));
+
+ QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "requestSync");
+ req << reqId;
+ QDBusConnection::sessionBus().send(req);
+
+ loop.exec();
+}
+
void emitSignalPeer(const QString &interface, const QString &name, const QVariant &parameter)
{
if (parameter.isValid())
@@ -1159,6 +1177,8 @@ void tst_QDBusAbstractAdaptor::signalEmissionsPeer()
// connect all signals and emit only one
{
+ syncPeer();
+
QDBusSignalSpy spy;
con.connect(QString(), "/", "local.Interface2", "signal",
&spy, SLOT(slot(QDBusMessage)));
@@ -1186,6 +1206,8 @@ void tst_QDBusAbstractAdaptor::signalEmissionsPeer()
// connect one signal and emit them all
{
+ syncPeer();
+
QDBusSignalSpy spy;
con.connect(QString(), "/", interface, name, &spy, SLOT(slot(QDBusMessage)));
emitSignalPeer("local.Interface2", "signal", QVariant());
@@ -1214,6 +1236,7 @@ void tst_QDBusAbstractAdaptor::sameSignalDifferentPathsPeer()
registerMyObjectPeer("/p1");
registerMyObjectPeer("/p2");
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/p1", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
emitSignalPeer("local.Interface2", QString(), QVariant());
@@ -1241,6 +1264,7 @@ void tst_QDBusAbstractAdaptor::sameObjectDifferentPathsPeer()
registerMyObjectPeer("/p1");
registerMyObjectPeer("/p2", 0); // don't export anything
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/p1", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
con.connect(QString(), "/p2", "local.Interface2", "signal", &spy, SLOT(slot(QDBusMessage)));
@@ -1263,6 +1287,7 @@ void tst_QDBusAbstractAdaptor::scriptableSignalOrNotPeer()
registerMyObjectPeer("/p1", QDBusConnection::ExportScriptableSignals);
registerMyObjectPeer("/p2", 0); // don't export anything
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/p1", "local.MyObject", "scriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
con.connect(QString(), "/p2", "local.MyObject", "scriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
@@ -1286,6 +1311,7 @@ void tst_QDBusAbstractAdaptor::scriptableSignalOrNotPeer()
registerMyObjectPeer("/p2", QDBusConnection::ExportScriptableSignals
| QDBusConnection::ExportNonScriptableSignals);
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/p1", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
con.connect(QString(), "/p2", "local.MyObject", "nonScriptableSignalVoid", &spy, SLOT(slot(QDBusMessage)));
@@ -1338,6 +1364,7 @@ void tst_QDBusAbstractAdaptor::overloadedSignalEmissionPeer()
// connect all signals and emit only one
{
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/", "local.Interface4", "signal", "",
&spy, SLOT(slot(QDBusMessage)));
@@ -1358,6 +1385,7 @@ void tst_QDBusAbstractAdaptor::overloadedSignalEmissionPeer()
QFETCH(QString, signature);
// connect one signal and emit them all
{
+ syncPeer();
QDBusSignalSpy spy;
con.connect(QString(), "/", interface, name, signature, &spy, SLOT(slot(QDBusMessage)));
emitSignalPeer("local.Interface4", "signal", QVariant());
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg
new file mode 100644
index 0000000000..aaa4ac4e10
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_1.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg
new file mode 100644
index 0000000000..a61d2723d7
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_2.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg
new file mode 100644
index 0000000000..43e56dcef7
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_3.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg
new file mode 100644
index 0000000000..d5d06f7409
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_4.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg
new file mode 100644
index 0000000000..1886f3775e
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_5.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg
new file mode 100644
index 0000000000..5cec757354
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_6.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg
new file mode 100644
index 0000000000..b3dcc466a9
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_7.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg
new file mode 100644
index 0000000000..8bc390e2b9
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/jpeg_exif_orientation_value_8.jpg
Binary files differ
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 4cb70612ea..676f8084a1 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -173,6 +173,8 @@ private slots:
void invertPixelsRGB_data();
void invertPixelsRGB();
+ void exifOrientation();
+
void cleanupFunctions();
private:
@@ -2639,6 +2641,22 @@ void tst_QImage::invertPixelsRGB()
QCOMPARE(qBlue(pixel) >> 4, (255 - 96) >> 4);
}
+void tst_QImage::exifOrientation()
+{
+ for (unsigned int i = 1; i <= 8; ++i) {
+ QImage img;
+ QRgb px;
+
+ QVERIFY(img.load(m_prefix + QString::fromLatin1("jpeg_exif_orientation_value_%1.jpg").arg(i)));
+
+ px = img.pixel(0, 0);
+ QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5);
+
+ px = img.pixel(img.width() - 1, 0);
+ QVERIFY(qRed(px) < 5 && qGreen(px) < 5 && qBlue(px) > 250);
+ }
+}
+
static void cleanupFunction(void* info)
{
bool *called = static_cast<bool*>(info);
diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
index e08af2491d..a63183e5fc 100644
--- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
+++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -59,30 +59,39 @@ void tst_QDoubleValidator::validateThouSep_data()
{
QTest::addColumn<QString>("localeName");
QTest::addColumn<QString>("value");
+ QTest::addColumn<bool>("rejectGroupSeparator");
QTest::addColumn<QValidator::State>("result");
- QTest::newRow("1,000C") << "C" << QString("1,000") << ACC;
- QTest::newRow("1.000C") << "C" << QString("1.000") << ACC;
+ QTest::newRow("1,000C") << "C" << QString("1,000") << false << ACC;
+ QTest::newRow("1,000.1C") << "C" << QString("1,000.1") << false << ACC;
+ QTest::newRow("1,000.1C_reject") << "C" << QString("1,000.1") << true << INV;
+ QTest::newRow("1.000C") << "C" << QString("1.000") << false << ACC;
- QTest::newRow("1,000de") << "de" << QString("1,000") << ACC;
- QTest::newRow("1.000de") << "de" << QString("1.000") << ACC;
+ QTest::newRow("1,000de") << "de" << QString("1,000") << false << ACC;
+ QTest::newRow("1.000de") << "de" << QString("1.000") << false << ACC;
- QTest::newRow(".C") << "C" << QString(".") << ITM;
- QTest::newRow(".de") << "de" << QString(".") << INV;
- QTest::newRow(",C") << "C" << QString(",") << INV;
- QTest::newRow(",de") << "de" << QString(",") << ITM;
+ QTest::newRow(".C") << "C" << QString(".") << false << ITM;
+ QTest::newRow(".de") << "de" << QString(".") << false << INV;
+ QTest::newRow("1.000,1de") << "de" << QString("1.000,1") << false << ACC;
+ QTest::newRow("1.000,1de_reject") << "de" << QString("1.000,1") << true << INV;
+ QTest::newRow(",C") << "C" << QString(",") << false << INV;
+ QTest::newRow(",de") << "de" << QString(",") << false << ITM;
}
void tst_QDoubleValidator::validateThouSep()
{
QFETCH(QString, localeName);
QFETCH(QString, value);
+ QFETCH(bool, rejectGroupSeparator);
QFETCH(QValidator::State, result);
int dummy = 0;
QDoubleValidator iv(-10000, 10000, 3, 0);
iv.setNotation(QDoubleValidator::ScientificNotation);
- iv.setLocale(QLocale(localeName));
+ QLocale locale(localeName);
+ if (rejectGroupSeparator)
+ locale.setNumberOptions(QLocale::RejectGroupSeparator);
+ iv.setLocale(locale);
QCOMPARE(iv.validate(value, dummy), result);
}
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
index 31853f7015..eff07ad07f 100644
--- a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
+++ b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
@@ -74,6 +74,9 @@ void tst_QRegularExpressionValidator::validate_data()
QTest::newRow("data14") << QRegularExpression("\\w\\d\\d") << QString("E5") << QValidator::Intermediate;
QTest::newRow("data15") << QRegularExpression("\\w\\d\\d") << QString("+9") << QValidator::Invalid;
+ QTest::newRow("emptystr1") << QRegularExpression("[T][e][s][t]") << QString("") << QValidator::Intermediate;
+ QTest::newRow("emptystr2") << QRegularExpression("[T][e][s][t]") << QString() << QValidator::Intermediate;
+
QTest::newRow("empty01") << QRegularExpression() << QString() << QValidator::Acceptable;
QTest::newRow("empty02") << QRegularExpression() << QString("test") << QValidator::Acceptable;
}
diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST
index fbd72492d8..7792e05e0f 100644
--- a/tests/auto/network/access/qnetworkreply/BLACKLIST
+++ b/tests/auto/network/access/qnetworkreply/BLACKLIST
@@ -7,3 +7,6 @@ osx
[SslHandshakeFailedError]
osx
[httpAbort]
+*
+[backgroundRequestInterruption:ftp, bg, nobg]
+*
diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
new file mode 100644
index 0000000000..bf4afa8c45
--- /dev/null
+++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST
@@ -0,0 +1,4 @@
+[udpTest]
+*
+[passwordAuth]
+*
diff --git a/tests/auto/network/ssl/ssl.pro b/tests/auto/network/ssl/ssl.pro
index 0cf910df73..4e30a9cded 100644
--- a/tests/auto/network/ssl/ssl.pro
+++ b/tests/auto/network/ssl/ssl.pro
@@ -5,19 +5,21 @@ SUBDIRS=\
qsslerror \
qsslkey \
-contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked):
+contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
contains(QT_CONFIG, private_tests) {
SUBDIRS += \
qsslsocket \
qsslsocket_onDemandCertificates_member \
qsslsocket_onDemandCertificates_static \
}
+}
winrt: SUBDIRS -= \
qsslsocket_onDemandCertificates_member \
qsslsocket_onDemandCertificates_static \
-contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked):
+contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
contains(QT_CONFIG, private_tests) {
- SUBDIRS += qasn1element
+ SUBDIRS += qasn1element
+ }
}
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index 0ba464a82c..56198ceb65 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -42,6 +42,8 @@
#include <qglcolormap.h>
#include <qpaintengine.h>
#include <qopenglfunctions.h>
+#include <qopenglframebufferobject.h>
+#include <qopenglpaintdevice.h>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
@@ -78,6 +80,7 @@ private slots:
void glWidgetRendering();
void glFBOSimpleRendering();
void glFBORendering();
+ void currentFboSync();
void multipleFBOInterleavedRendering();
void glFBOUseInGLWidget();
void glPBufferRendering();
@@ -1138,6 +1141,93 @@ void tst_QGL::glFBORendering()
qt_opengl_check_test_pattern(fb);
}
+class QOpenGLFramebufferObjectPaintDevice : public QOpenGLPaintDevice
+{
+public:
+ QOpenGLFramebufferObjectPaintDevice(int width, int height)
+ : QOpenGLPaintDevice(width, height)
+ , m_fbo(width, height, QOpenGLFramebufferObject::CombinedDepthStencil)
+ {
+ }
+
+ void ensureActiveTarget()
+ {
+ m_fbo.bind();
+ }
+
+ QImage toImage() const
+ {
+ return m_fbo.toImage();
+ }
+
+private:
+ QOpenGLFramebufferObject m_fbo;
+};
+
+void tst_QGL::currentFboSync()
+{
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QGLFramebufferObject not supported on this platform");
+
+#if defined(Q_OS_QNX)
+ QSKIP("Reading the QGLFramebufferObject is unsupported on this platform");
+#endif
+
+ QGLWidget glw;
+ glw.makeCurrent();
+
+ {
+ QGLFramebufferObject fbo1(256, 256, QGLFramebufferObject::CombinedDepthStencil);
+
+ QOpenGLFramebufferObjectPaintDevice fbo2(256, 256);
+
+ QImage sourceImage(256, 256, QImage::Format_ARGB32_Premultiplied);
+ QPainter sourcePainter(&sourceImage);
+ qt_opengl_draw_test_pattern(&sourcePainter, 256, 256);
+
+ QPainter fbo1Painter(&fbo1);
+
+ QPainter fbo2Painter(&fbo2);
+ fbo2Painter.drawImage(0, 0, sourceImage);
+ fbo2Painter.end();
+
+ QImage fbo2Image = fbo2.toImage();
+
+ fbo1Painter.drawImage(0, 0, sourceImage);
+ fbo1Painter.end();
+
+ QGLFramebufferObject::bindDefault();
+
+ QCOMPARE(fbo1.toImage(), fbo2Image);
+ }
+
+ {
+ QGLFramebufferObject fbo1(512, 512, QGLFramebufferObject::CombinedDepthStencil);
+
+ QOpenGLFramebufferObjectPaintDevice fbo2(256, 256);
+
+ QImage sourceImage(256, 256, QImage::Format_ARGB32_Premultiplied);
+ QPainter sourcePainter(&sourceImage);
+ qt_opengl_draw_test_pattern(&sourcePainter, 256, 256);
+
+ QPainter fbo2Painter(&fbo2);
+ fbo2Painter.drawImage(0, 0, sourceImage);
+ QImage fbo2Image1 = fbo2.toImage();
+ fbo2Painter.fillRect(0, 0, 256, 256, Qt::white);
+
+ QPainter fbo1Painter(&fbo1);
+ fbo1Painter.drawImage(0, 0, sourceImage);
+ fbo1Painter.end();
+
+ // check that the OpenGL paint engine now knows it needs to sync
+ fbo2Painter.drawImage(0, 0, sourceImage);
+ QImage fbo2Image2 = fbo2.toImage();
+
+ fbo2Painter.end();
+
+ QCOMPARE(fbo2Image1, fbo2Image2);
+ }
+}
// Tests multiple QPainters active on different FBOs at the same time, with
// interleaving painting. Performance-wise, this is sub-optimal, but it still
diff --git a/tests/auto/other/qaccessibility/BLACKLIST b/tests/auto/other/qaccessibility/BLACKLIST
deleted file mode 100644
index 11598aece6..0000000000
--- a/tests/auto/other/qaccessibility/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[abstractScrollAreaTest]
-osx
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 1c8121f142..af0a0b446e 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2648,57 +2648,67 @@ void tst_QAccessibility::abstractScrollAreaTest()
// Horizontal scrollBar.
abstractScrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- QCOMPARE(interface->childCount(), 2);
QWidget *horizontalScrollBar = abstractScrollArea.horizontalScrollBar();
+
+ // On OS X >= 10.9 the scrollbar will be hidden unless explicitly enabled in the preferences
+ bool scrollBarsVisible = !horizontalScrollBar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, horizontalScrollBar);
+ int childCount = scrollBarsVisible ? 2 : 1;
+ QCOMPARE(interface->childCount(), childCount);
QWidget *horizontalScrollBarContainer = horizontalScrollBar->parentWidget();
- QVERIFY(verifyChild(horizontalScrollBarContainer, interface, 1, globalGeometry));
+ if (scrollBarsVisible)
+ QVERIFY(verifyChild(horizontalScrollBarContainer, interface, 1, globalGeometry));
// Horizontal scrollBar widgets.
QLabel *secondLeftLabel = new QLabel(QLatin1String("L2"));
abstractScrollArea.addScrollBarWidget(secondLeftLabel, Qt::AlignLeft);
- QCOMPARE(interface->childCount(), 2);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *firstLeftLabel = new QLabel(QLatin1String("L1"));
abstractScrollArea.addScrollBarWidget(firstLeftLabel, Qt::AlignLeft);
- QCOMPARE(interface->childCount(), 2);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *secondRightLabel = new QLabel(QLatin1String("R2"));
abstractScrollArea.addScrollBarWidget(secondRightLabel, Qt::AlignRight);
- QCOMPARE(interface->childCount(), 2);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *firstRightLabel = new QLabel(QLatin1String("R1"));
abstractScrollArea.addScrollBarWidget(firstRightLabel, Qt::AlignRight);
- QCOMPARE(interface->childCount(), 2);
+ QCOMPARE(interface->childCount(), childCount);
// Vertical scrollBar.
abstractScrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- QCOMPARE(interface->childCount(), 3);
+ if (scrollBarsVisible)
+ ++childCount;
+ QCOMPARE(interface->childCount(), childCount);
QWidget *verticalScrollBar = abstractScrollArea.verticalScrollBar();
QWidget *verticalScrollBarContainer = verticalScrollBar->parentWidget();
- QVERIFY(verifyChild(verticalScrollBarContainer, interface, 2, globalGeometry));
+ if (scrollBarsVisible)
+ QVERIFY(verifyChild(verticalScrollBarContainer, interface, 2, globalGeometry));
// Vertical scrollBar widgets.
QLabel *secondTopLabel = new QLabel(QLatin1String("T2"));
abstractScrollArea.addScrollBarWidget(secondTopLabel, Qt::AlignTop);
- QCOMPARE(interface->childCount(), 3);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *firstTopLabel = new QLabel(QLatin1String("T1"));
abstractScrollArea.addScrollBarWidget(firstTopLabel, Qt::AlignTop);
- QCOMPARE(interface->childCount(), 3);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *secondBottomLabel = new QLabel(QLatin1String("B2"));
abstractScrollArea.addScrollBarWidget(secondBottomLabel, Qt::AlignBottom);
- QCOMPARE(interface->childCount(), 3);
+ QCOMPARE(interface->childCount(), childCount);
QLabel *firstBottomLabel = new QLabel(QLatin1String("B1"));
abstractScrollArea.addScrollBarWidget(firstBottomLabel, Qt::AlignBottom);
- QCOMPARE(interface->childCount(), 3);
+ QCOMPARE(interface->childCount(), childCount);
// CornerWidget.
+ ++childCount;
abstractScrollArea.setCornerWidget(new QLabel(QLatin1String("C")));
- QCOMPARE(interface->childCount(), 4);
+ QCOMPARE(interface->childCount(), childCount);
QWidget *cornerWidget = abstractScrollArea.cornerWidget();
- QVERIFY(verifyChild(cornerWidget, interface, 3, globalGeometry));
+ if (scrollBarsVisible)
+ QVERIFY(verifyChild(cornerWidget, interface, 3, globalGeometry));
QCOMPARE(verifyHierarchy(interface), 0);
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 1be570e4b8..e3a72f4ab4 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -1103,9 +1103,7 @@ void tst_QPrinter::fontEmbedding()
{
// fontEmbeddingEnabled() / setFontEmbeddingEnabled() / PPK_FontEmbedding
// PdfFormat: Supported, default true
- // NativeFormat, Cups: Supported, default true
- // NativeFormat, Win: Unsupported, always false
- // NativeFormat, Mac: Unsupported, always false
+ // NativeFormat: Supported, default true
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
@@ -1116,25 +1114,17 @@ void tst_QPrinter::fontEmbedding()
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
-#if defined Q_OS_MAC || defined Q_OS_WIN
- QCOMPARE(native.fontEmbeddingEnabled(), false);
-#else
QCOMPARE(native.fontEmbeddingEnabled(), true);
-#endif // Q_OS_MAC || Q_OS_WIN
// Test set/get
- bool expected = true;
- native.setFontEmbeddingEnabled(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = false;
-#endif // Q_OS_MAC || Q_OS_WIN
- QCOMPARE(native.fontEmbeddingEnabled(), expected);
+ native.setFontEmbeddingEnabled(true);
+ QCOMPARE(native.fontEmbeddingEnabled(), true);
// Test value preservation
native.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(native.fontEmbeddingEnabled(), expected);
+ QCOMPARE(native.fontEmbeddingEnabled(), true);
native.setOutputFormat(QPrinter::NativeFormat);
- QCOMPARE(native.fontEmbeddingEnabled(), expected);
+ QCOMPARE(native.fontEmbeddingEnabled(), true);
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h
index c9b5d13b1f..9a00955846 100644
--- a/tests/auto/tools/moc/parse-defines.h
+++ b/tests/auto/tools/moc/parse-defines.h
@@ -77,6 +77,8 @@
#define DEFINE_CMDLINE_SIGNAL void cmdlineSignal(const QMap<int, int> &i)
#endif
+#define HASH_SIGN #
+
PD_BEGIN_NAMESPACE
class DEFINE_CMDLINE_EMPTY PD_CLASSNAME DEFINE_CMDLINE_EMPTY
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 965a16e7c2..fe6ad6637a 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1565,7 +1565,7 @@ public slots:
void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); }
-#if defined(Q_MOC_RUN) || (defined(Q_COMPILER_AUTO_TYPE) && !(defined(Q_CC_CLANG) && (__clang_major__ * 100) + __clang_minor__) < 304)
+#if defined(Q_MOC_RUN) || (defined(Q_COMPILER_AUTO_TYPE) && !(defined(Q_CC_CLANG) && Q_CC_CLANG < 304))
// There is no Q_COMPILER_>> but if compiler support auto, it should also support >>
void performSomething(QVector<QList<QString>> e = QVector<QList<QString>>(8 < 1),
QHash<int, QVector<QString>> h = QHash<int, QVector<QString>>())
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
index 5239614fc7..fb432a7d21 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
+++ b/tests/auto/widgets/dialogs/qfiledialog2/qfiledialog2.pro
@@ -20,4 +20,3 @@ wince* {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
}
-macx:CONFIG += insignificant_test # QTBUG-39183
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 2ffb81a751..241e6d0e7e 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -448,6 +448,8 @@ void tst_QFileDialog2::task180459_lastDirectory_data()
void tst_QFileDialog2::task180459_lastDirectory()
{
+ if (qApp->platformName().toLower() == QStringLiteral("cocoa"))
+ QSKIP("Insignificant on OSX"); //QTBUG-39183
//first visit the temp directory and close the dialog
QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", tempDir.path());
QFileSystemModel *model = dlg->findChild<QFileSystemModel*>("qt_filesystem_model");
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
index 833494f25e..bdf610e426 100644
--- a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
@@ -71,6 +71,7 @@ tst_QGestureRecognizer::tst_QGestureRecognizer()
: m_fingerDistance(qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch() / 2.0))
, m_touchDevice(new QTouchDevice)
{
+ qputenv("QT_PAN_TOUCHPOINTS", "2"); // Prevent device detection of pan touch point count.
}
void tst_QGestureRecognizer::initTestCase()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro
index 201085aecd..d1f9bede0b 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro
@@ -9,5 +9,4 @@ SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp
HEADERS += tst_qgraphicsview.h
DEFINES += QT_NO_CAST_TO_ASCII
-mac:CONFIG+=insignificant_test # QTBUG-26580
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 8171277f36..04852721db 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -143,6 +143,10 @@ class tst_QGraphicsView : public QObject
{
Q_OBJECT
+public:
+ tst_QGraphicsView()
+ : platformName(qApp->platformName().toLower())
+ { }
private slots:
void initTestCase();
void cleanup();
@@ -272,6 +276,7 @@ private:
#if defined Q_OS_BLACKBERRY
QScopedPointer<QWidget> rootWindow;
#endif
+ QString platformName;
};
void tst_QGraphicsView::initTestCase()
@@ -2827,6 +2832,8 @@ void tst_QGraphicsView::scrollBarRanges()
if (style == QLatin1String("GTK+") && useStyledPanel)
QSKIP("GTK + style test skipped, see QTBUG-29002");
+ if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa"))
+ QSKIP("Insignificant on OSX");
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setRenderHint(QPainter::Antialiasing);
@@ -4733,6 +4740,8 @@ public:
void tst_QGraphicsView::hoverLeave()
{
+ if (platformName == QStringLiteral("cocoa"))
+ QSKIP("Insignificant on OSX");
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
QGraphicsScene scene;
QGraphicsView view(&scene);
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 766065acda..f000907e0e 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -782,10 +782,8 @@ void tst_QItemDelegate::dateTimeEditor()
widget.setFocus();
widget.editItem(item2);
- QTestEventLoop::instance().enterLoop(1);
-
+ QTRY_VERIFY(widget.viewport()->findChild<QDateEdit *>());
QDateEdit *dateEditor = widget.viewport()->findChild<QDateEdit *>();
- QVERIFY(dateEditor);
QCOMPARE(dateEditor->date(), date);
dateEditor->setDate(date.addDays(60));
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 565eac2cba..389ff6572d 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -434,7 +434,7 @@ public:
{
QTableView::setModel(model);
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- this, SLOT(currentChanged(QModelIndex,QModelIndex)));
+ this, SLOT(slotCurrentChanged(QModelIndex,QModelIndex)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(itemSelectionChanged(QItemSelection,QItemSelection)));
}
@@ -495,7 +495,7 @@ public:
bool checkSignalOrder;
public slots:
- void currentChanged(QModelIndex , QModelIndex ) {
+ void slotCurrentChanged(QModelIndex, QModelIndex) {
hasCurrentChanged++;
if (checkSignalOrder)
QVERIFY(hasCurrentChanged > hasSelectionChanged);
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 7904848faf..4b7e2a7198 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -61,6 +61,7 @@ private slots:
void setText();
void setIconText_data() { setText_data(); }
void setIconText();
+ void setUnknownFont();
void actionEvent();
void setStandardKeys();
void alternateShortcuts();
@@ -184,6 +185,15 @@ void tst_QAction::setIconText()
QCOMPARE(action.text(), textFromIconText);
}
+void tst_QAction::setUnknownFont() // QTBUG-42728
+{
+ QAction action(0);
+ QFont font("DoesNotExist", 11);
+ action.setFont(font);
+
+ QMenu menu;
+ menu.addAction(&action); // should not crash
+}
void tst_QAction::updateState(QActionEvent *e)
{
diff --git a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
index d61681d5cb..d61681d5cb 100755..100644
--- a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
+++ b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index c6c7464194..36791293ab 100755..100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -95,6 +95,8 @@ private slots:
void tst_updateWinId_QTBUG40681();
void tst_recreateWindow_QTBUG40817();
+ void tst_resize_count();
+ void tst_move_count();
};
void tst_QWidget_window::initTestCase()
@@ -660,6 +662,105 @@ void tst_QWidget_window::tst_recreateWindow_QTBUG40817()
tab.setCurrentIndex(1);
}
+class ResizeWidget : public QWidget
+{
+Q_OBJECT
+public:
+ ResizeWidget(QWidget *parent = 0)
+ : QWidget(parent)
+ , resizeCount(0)
+ { }
+
+ int resizeCount;
+
+protected:
+ void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE
+ {
+ resizeCount++;
+ }
+};
+
+void tst_QWidget_window::tst_resize_count()
+{
+ {
+ ResizeWidget resize;
+ resize.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&resize));
+ QCOMPARE(resize.resizeCount, 1);
+ resize.resizeCount = 0;
+ QSize size = resize.size();
+ size.rwidth() += 10;
+ resize.resize(size);
+ QGuiApplication::sync();
+ QTRY_COMPARE(resize.resizeCount, 1);
+
+ resize.resizeCount = 0;
+
+ ResizeWidget child(&resize);
+ child.resize(200,200);
+ child.winId();
+ child.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+ QGuiApplication::sync();
+ QTRY_COMPARE(child.resizeCount, 1);
+ child.resizeCount = 0;
+ size = child.size();
+ size.rwidth() += 10;
+ child.resize(size);
+ QGuiApplication::sync();
+ QCOMPARE(resize.resizeCount, 0);
+ QCOMPARE(child.resizeCount, 1);
+ }
+ {
+ ResizeWidget parent;
+ ResizeWidget child(&parent);
+ child.resize(200,200);
+ child.winId();
+ parent.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ parent.resizeCount = 0;
+ QGuiApplication::sync();
+ QTRY_COMPARE(child.resizeCount, 1);
+ child.resizeCount = 0;
+ QSize size = child.size();
+ size.rwidth() += 10;
+ child.resize(size);
+ QGuiApplication::sync();
+ QCOMPARE(parent.resizeCount, 0);
+ QCOMPARE(child.resizeCount, 1);
+ }
+
+}
+
+class MoveWidget : public QWidget
+{
+Q_OBJECT
+public:
+ MoveWidget(QWidget *parent = 0)
+ : QWidget(parent)
+ , moveCount(0)
+ { }
+
+ void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE
+ {
+ moveCount++;
+ }
+
+ int moveCount;
+};
+
+void tst_QWidget_window::tst_move_count()
+{
+ MoveWidget move;
+ move.move(500,500);
+ move.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&move));
+ QTRY_VERIFY(move.moveCount >= 1);
+ move.moveCount = 0;
+
+ move.move(220,250);
+ QTRY_VERIFY(move.moveCount >= 1);
+}
QTEST_MAIN(tst_QWidget_window)
#include "tst_qwidget_window.moc"
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 27c803b43d..751a16c59d 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -104,6 +104,7 @@ public:
tst_QMainWindow();
private slots:
+ void cleanup();
void getSetCheck();
void constructor();
void iconSize();
@@ -147,6 +148,12 @@ private slots:
void QTBUG21378_animationFinished();
};
+
+void tst_QMainWindow::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
// Testing get/set functions
void tst_QMainWindow::getSetCheck()
{
@@ -854,6 +861,7 @@ void tst_QMainWindow::takeCentralWidget() {
QVERIFY(!w2.isNull());
QCOMPARE(w2.data(), hopefullyW2);
+ delete w2;
}
void tst_QMainWindow::corner()
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index f457955657..ff9bc7c4a2 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -104,7 +104,7 @@ static bool tabBetweenSubWindowsIn(QMdiArea *mdiArea, int tabCount = -1, bool re
if (tabCount > 1)
QTest::qWait(500);
if (walkThrough) {
- QRubberBand *rubberBand = mdiArea->viewport()->findChild<QRubberBand *>();
+ QRubberBand *rubberBand = mdiArea->findChild<QRubberBand *>();
if (!rubberBand) {
qWarning("No rubber band");
return false;
diff --git a/tests/manual/diaglib/README.txt b/tests/manual/diaglib/README.txt
new file mode 100644
index 0000000000..13387f5a2a
--- /dev/null
+++ b/tests/manual/diaglib/README.txt
@@ -0,0 +1,34 @@
+This is a collection of functions and classes helpful for diagnosing bugs
+in Qt 4 and Qt 5. It can be included in the application's .pro file by
+adding:
+
+include([path to Qt sources]/tests/manual/diaglib/diaglib.pri)
+
+For Qt 4, the environment variable QTDIR may be used:
+include($$(QTDIR)/tests/manual/diaglib/diaglib.pri)
+
+The .pri file adds the define QT_DIAG_LIB, so, diagnostic
+code can be enlosed within #ifdef to work without it as well.
+
+All functions and classes are in the QtDiag namespace.
+
+class EventFilter (eventfilter.h):
+ An event filter that logs Qt events to qDebug() depending on
+ configured categories (for example mouse, keyboard, etc).
+
+function glInfo() (glinfo.h):
+ Returns a string describing the Open GL configuration (obtained
+ by querying GL_VENDOR and GL_RENDERER). Available only
+ when the QT qmake variable contains opengl.
+
+functions dumpNativeWindows(), dumpNativeQtTopLevels():
+ These functions du,p out the hierarchy of native Windows. Currently
+ implemented for Windows only.
+
+function dumpAllWidgets() (qwidgetdump.h):
+ Dumps the hierarchy of QWidgets including information about flags,
+ visibility, geometry, etc.
+
+function dumpAllWindows() (qwindowdump.h):
+ Dumps the hierarchy of QWindows including information about flags,
+ visibility, geometry, etc.
diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri
new file mode 100644
index 0000000000..138660f85e
--- /dev/null
+++ b/tests/manual/diaglib/diaglib.pri
@@ -0,0 +1,43 @@
+INCLUDEPATH += $$PWD
+SOURCES += \
+ $$PWD/eventfilter.cpp \
+ $$PWD/qwindowdump.cpp \
+
+HEADERS += \
+ $$PWD/eventfilter.h \
+ $$PWD/qwindowdump.h \
+ $$PWD/nativewindowdump.h
+
+win32 {
+ SOURCES += $$PWD/nativewindowdump_win.cpp
+ LIBS *= -luser32
+} else {
+ SOURCES += $$PWD/nativewindowdump.cpp
+}
+
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += gui-private core-private
+ contains(QT, widgets) {
+ HEADERS += \
+ $$PWD/$$PWD/qwidgetdump.h
+
+ SOURCES += \
+ $$PWD/qwidgetdump.cpp
+ }
+} else {
+ HEADERS += \
+ $$PWD/$$PWD/qwidgetdump.h
+
+ SOURCES += \
+ $$PWD/qwidgetdump.cpp
+}
+
+contains(QT, opengl) {
+HEADERS += \
+ $$PWD/glinfo.h
+
+SOURCES += \
+ $$PWD/glinfo.cpp
+}
+
+DEFINES += QT_DIAG_LIB
diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp
new file mode 100644
index 0000000000..f0573975f6
--- /dev/null
+++ b/tests/manual/diaglib/eventfilter.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "eventfilter.h"
+#include <QtGui/QMouseEvent>
+#include <QtCore/QDebug>
+#include <QtCore/QTextStream>
+
+namespace QtDiag {
+
+EventFilter::EventFilter(EventCategories eventCategories, QObject *p)
+ : QObject(p)
+{
+ init(eventCategories);
+}
+
+EventFilter::EventFilter(QObject *p)
+ : QObject(p)
+{
+ init(EventCategories(0xFFFFFFF));
+}
+
+void EventFilter::init(EventCategories eventCategories)
+{
+ if (eventCategories & MouseEvents) {
+ m_eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease
+ << QEvent::MouseButtonDblClick << QEvent::NonClientAreaMouseButtonPress
+ << QEvent::NonClientAreaMouseButtonRelease
+ << QEvent::NonClientAreaMouseButtonDblClick
+ << QEvent::Enter << QEvent::Leave;
+ }
+ if (eventCategories & MouseMoveEvents)
+ m_eventTypes << QEvent::MouseMove << QEvent::NonClientAreaMouseMove;
+ if (eventCategories & TouchEvents) {
+ m_eventTypes << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd;
+#if QT_VERSION >= 0x050000
+ m_eventTypes << QEvent::TouchCancel;
+#endif
+ }
+ if (eventCategories & TabletEvents) {
+ m_eventTypes << QEvent::TabletEnterProximity << QEvent::TabletLeaveProximity
+ << QEvent::TabletMove << QEvent::TabletPress << QEvent::TabletRelease;
+ }
+ if (eventCategories & DragAndDropEvents) {
+ m_eventTypes << QEvent::DragEnter << QEvent::DragMove << QEvent::DragLeave
+ << QEvent::Drop << QEvent::DragResponse;
+ }
+ if (eventCategories & KeyEvents) {
+ m_eventTypes << QEvent::KeyPress << QEvent::KeyRelease << QEvent::ShortcutOverride
+ << QEvent::Shortcut;
+ }
+ if (eventCategories & GeometryEvents)
+ m_eventTypes << QEvent::Move << QEvent::Resize;
+ if (eventCategories & PaintEvents) {
+ m_eventTypes << QEvent::UpdateRequest << QEvent::Paint
+ << QEvent::Show << QEvent::Hide;
+#if QT_VERSION >= 0x050000
+ m_eventTypes << QEvent::Expose;
+#endif
+ }
+ if (eventCategories & TimerEvents)
+ m_eventTypes << QEvent::Timer << QEvent::ZeroTimerEvent;
+ if (eventCategories & ObjectEvents) {
+ m_eventTypes << QEvent::ChildAdded << QEvent::ChildPolished
+ << QEvent::ChildRemoved << QEvent::Create << QEvent::Destroy;
+ }
+}
+
+bool EventFilter::eventFilter(QObject *o, QEvent *e)
+{
+ static int n = 0;
+ if (m_eventTypes.contains(e->type())) {
+ QDebug debug = qDebug().nospace();
+ const QString on = o->objectName();
+ debug << '#' << n++ << ' ' << o->metaObject()->className();
+ if (!on.isEmpty())
+ debug << '/' << on;
+ debug << ' ' << e;
+ }
+ return false;
+}
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/eventfilter.h b/tests/manual/diaglib/eventfilter.h
new file mode 100644
index 0000000000..d87ac68b07
--- /dev/null
+++ b/tests/manual/diaglib/eventfilter.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _EVENTFILTER_
+#define _EVENTFILTER_
+
+#include <QtCore/QObject>
+#include <QtCore/QEvent>
+#include <QtCore/QList>
+
+namespace QtDiag {
+
+// Event filter that can for example be installed on QApplication
+// to log relevant events.
+
+class EventFilter : public QObject {
+public:
+ enum EventCategory {
+ MouseEvents = 0x00001,
+ MouseMoveEvents = 0x00002,
+ TouchEvents = 0x00004,
+ TabletEvents = 0x00008,
+ DragAndDropEvents = 0x00010,
+ KeyEvents = 0x00020,
+ GeometryEvents = 0x00040,
+ PaintEvents = 0x00080,
+ TimerEvents = 0x00100,
+ ObjectEvents = 0x00200
+ };
+ Q_DECLARE_FLAGS(EventCategories, EventCategory)
+
+ explicit EventFilter(EventCategories eventCategories, QObject *p = 0);
+ explicit EventFilter(QObject *p = 0);
+
+ bool eventFilter(QObject *, QEvent *);
+
+private:
+ void init(EventCategories eventCategories);
+
+ QList<QEvent::Type> m_eventTypes;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(EventFilter::EventCategories)
+
+} // namespace QtDiag
+
+#endif
diff --git a/tests/manual/diaglib/glinfo.cpp b/tests/manual/diaglib/glinfo.cpp
new file mode 100644
index 0000000000..cd30e46b45
--- /dev/null
+++ b/tests/manual/diaglib/glinfo.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "glinfo.h"
+
+#include <QtOpenGL/QGLFunctions>
+#include <QtOpenGL/QGLWidget>
+#if QT_VERSION > 0x050000
+# if QT_VERSION >= 0x050400
+# include <QtWidgets/QOpenGLWidget>
+# include <QtGui/QOpenGLWindow>
+# else // 5.4
+# include <QtGui/QWindow>
+# endif // 5.0..5.4
+# include <QtGui/QOpenGLContext>
+# include <QtGui/QOpenGLFunctions>
+# include <QtGui/QWindow>
+#endif
+#include <QtCore/QDebug>
+#include <QtCore/QString>
+#include <QtCore/QTimer>
+
+namespace QtDiag {
+
+#if QT_VERSION > 0x050000
+
+static QString getGlString(const QOpenGLContext *ctx, GLenum name)
+{
+ if (const GLubyte *p = ctx->functions()->glGetString(name))
+ return QString::fromLatin1(reinterpret_cast<const char *>(p));
+ return QString();
+}
+
+static QString glInfo(const QOpenGLContext *ctx)
+{
+ return getGlString(ctx, GL_VENDOR)
+ + QLatin1Char('\n')
+ + getGlString(ctx, GL_RENDERER);
+}
+
+static QString glInfo(const QGLContext *ctx)
+{
+ return glInfo(ctx->contextHandle());
+}
+
+QString glInfo(const QObject *o)
+{
+# if QT_VERSION >= 0x050400
+ if (o->isWindowType()) {
+ if (const QOpenGLWindow *oglw = qobject_cast<const QOpenGLWindow *>(o))
+ return glInfo(oglw->context());
+ return QString();
+ }
+# endif // 5.4
+ if (o->isWidgetType()) {
+ if (const QGLWidget *g = qobject_cast<const QGLWidget *>(o))
+ return glInfo(g->context());
+# if QT_VERSION >= 0x050400
+ if (const QOpenGLWidget *g = qobject_cast<const QOpenGLWidget *>(o))
+ return glInfo(g->context());
+# endif // 5.4
+ }
+ return QString();
+}
+
+#else // Qt4:
+
+static QString getGlString(GLenum name)
+{
+ if (const GLubyte *p = glGetString(name))
+ return QString::fromLatin1(reinterpret_cast<const char *>(p));
+ return QString();
+}
+
+QString glInfo(const QWidget *)
+{
+ return getGlString(GL_VENDOR) + QLatin1Char('\n') + getGlString(GL_RENDERER);
+}
+
+#endif
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/glinfo.h b/tests/manual/diaglib/glinfo.h
new file mode 100644
index 0000000000..1f515267f2
--- /dev/null
+++ b/tests/manual/diaglib/glinfo.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _GLINFO_
+#define _GLINFO_
+
+#include <QtCore/QtGlobal>
+
+QT_FORWARD_DECLARE_CLASS(QObject)
+QT_FORWARD_DECLARE_CLASS(QString)
+
+namespace QtDiag {
+
+QString glInfo(const QObject *o);
+
+} // namespace QtDiag
+
+#endif
diff --git a/tests/manual/diaglib/nativewindowdump.cpp b/tests/manual/diaglib/nativewindowdump.cpp
new file mode 100644
index 0000000000..a6c741a085
--- /dev/null
+++ b/tests/manual/diaglib/nativewindowdump.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "nativewindowdump.h"
+
+namespace QtDiag {
+
+void dumpNativeWindows(WId)
+{
+}
+
+void dumpNativeQtTopLevels()
+{
+}
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/nativewindowdump.h b/tests/manual/diaglib/nativewindowdump.h
new file mode 100644
index 0000000000..405998feea
--- /dev/null
+++ b/tests/manual/diaglib/nativewindowdump.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _NATIVEWINDOWDUMP_
+#define _NATIVEWINDOWDUMP_
+
+#include <QtGui/qwindowdefs.h>
+
+namespace QtDiag {
+
+void dumpNativeWindows(WId root = 0);
+void dumpNativeQtTopLevels();
+
+} // namespace QtDiag
+
+#endif
diff --git a/tests/manual/diaglib/nativewindowdump_win.cpp b/tests/manual/diaglib/nativewindowdump_win.cpp
new file mode 100644
index 0000000000..814b580f4b
--- /dev/null
+++ b/tests/manual/diaglib/nativewindowdump_win.cpp
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "nativewindowdump.h"
+#include "qwindowdump.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QSharedPointer>
+#include <QtCore/QDebug>
+#include <QtCore/QVector>
+
+#include <QtCore/qt_windows.h>
+
+namespace QtDiag {
+
+struct DumpContext {
+ DumpContext() : indentation(0) {}
+
+ int indentation;
+ QSharedPointer<QTextStream> stream;
+};
+
+#define debugWinStyle(str, style, styleConstant) \
+if (style & styleConstant) \
+ str << ' ' << #styleConstant;
+
+static void formatNativeWindow(HWND hwnd, QTextStream &str)
+{
+ str << hex << showbase << quintptr(hwnd) << noshowbase << dec;
+ RECT rect;
+ if (GetWindowRect(hwnd, &rect)) {
+ str << ' ' << (rect.right - rect.left) << 'x' << (rect.bottom - rect.top)
+ << '+' << rect.left << '+' << rect.top;
+ }
+ if (IsWindowVisible(hwnd))
+ str << " [visible]";
+
+ str << hex << showbase;
+ if (const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE)) {
+ str << " style=" << style;
+ debugWinStyle(str, style, WS_OVERLAPPED)
+ debugWinStyle(str, style, WS_POPUP)
+ debugWinStyle(str, style, WS_MINIMIZE)
+ debugWinStyle(str, style, WS_CHILD)
+ debugWinStyle(str, style, WS_VISIBLE)
+ debugWinStyle(str, style, WS_DISABLED)
+ debugWinStyle(str, style, WS_CLIPSIBLINGS)
+ debugWinStyle(str, style, WS_CLIPCHILDREN)
+ debugWinStyle(str, style, WS_MAXIMIZE)
+ debugWinStyle(str, style, WS_CAPTION)
+ debugWinStyle(str, style, WS_BORDER)
+ debugWinStyle(str, style, WS_DLGFRAME)
+ debugWinStyle(str, style, WS_VSCROLL)
+ debugWinStyle(str, style, WS_HSCROLL)
+ debugWinStyle(str, style, WS_SYSMENU)
+ debugWinStyle(str, style, WS_THICKFRAME)
+ debugWinStyle(str, style, WS_GROUP)
+ debugWinStyle(str, style, WS_TABSTOP)
+ debugWinStyle(str, style, WS_MINIMIZEBOX)
+ debugWinStyle(str, style, WS_MAXIMIZEBOX)
+ }
+ if (const LONG_PTR exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE)) {
+ str << " exStyle=" << exStyle;
+ debugWinStyle(str, exStyle, WS_EX_DLGMODALFRAME)
+ debugWinStyle(str, exStyle, WS_EX_NOPARENTNOTIFY)
+ debugWinStyle(str, exStyle, WS_EX_TOPMOST)
+ debugWinStyle(str, exStyle, WS_EX_ACCEPTFILES)
+ debugWinStyle(str, exStyle, WS_EX_TRANSPARENT)
+ debugWinStyle(str, exStyle, WS_EX_MDICHILD)
+ debugWinStyle(str, exStyle, WS_EX_TOOLWINDOW)
+ debugWinStyle(str, exStyle, WS_EX_WINDOWEDGE)
+ debugWinStyle(str, exStyle, WS_EX_CLIENTEDGE)
+ debugWinStyle(str, exStyle, WS_EX_CONTEXTHELP)
+ debugWinStyle(str, exStyle, WS_EX_RIGHT)
+ debugWinStyle(str, exStyle, WS_EX_LEFT)
+ debugWinStyle(str, exStyle, WS_EX_RTLREADING)
+ debugWinStyle(str, exStyle, WS_EX_LTRREADING)
+ debugWinStyle(str, exStyle, WS_EX_LEFTSCROLLBAR)
+ debugWinStyle(str, exStyle, WS_EX_RIGHTSCROLLBAR)
+ debugWinStyle(str, exStyle, WS_EX_CONTROLPARENT)
+ debugWinStyle(str, exStyle, WS_EX_STATICEDGE)
+ debugWinStyle(str, exStyle, WS_EX_APPWINDOW)
+ debugWinStyle(str, exStyle, WS_EX_LAYERED)
+ debugWinStyle(str, exStyle, WS_EX_NOINHERITLAYOUT)
+ debugWinStyle(str, exStyle, WS_EX_NOREDIRECTIONBITMAP)
+ debugWinStyle(str, exStyle, WS_EX_LAYOUTRTL)
+ debugWinStyle(str, exStyle, WS_EX_COMPOSITED)
+ debugWinStyle(str, exStyle, WS_EX_NOACTIVATE)
+ }
+ str << noshowbase << dec;
+
+ wchar_t buf[512];
+ if (GetWindowText(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << " title=\"" << QString::fromWCharArray(buf) << '"';
+ if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0])))
+ str << " class=\"" << QString::fromWCharArray(buf) << '"';
+ str << '\n';
+}
+
+static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc);
+
+BOOL CALLBACK dumpWindowEnumChildProc(HWND hwnd, LPARAM lParam)
+{
+ dumpNativeWindowRecursion(hwnd, reinterpret_cast<DumpContext *>(lParam));
+ return TRUE;
+}
+
+static void dumpNativeWindowRecursion(HWND hwnd, DumpContext *dc)
+{
+ indentStream(*dc->stream, dc->indentation);
+ formatNativeWindow(hwnd, *dc->stream);
+ DumpContext nextLevel = *dc;
+ nextLevel.indentation += 2;
+ EnumChildWindows(hwnd, dumpWindowEnumChildProc, reinterpret_cast<LPARAM>(&nextLevel));
+}
+
+/* recurse by Z order, same result */
+static void dumpNativeWindowRecursionByZ(HWND hwnd, DumpContext *dc)
+{
+ indentStream(*dc->stream, dc->indentation);
+ formatNativeWindow(hwnd, *dc->stream);
+ if (const HWND topChild = GetTopWindow(hwnd)) {
+ DumpContext nextLevel = *dc;
+ nextLevel.indentation += 2;
+ for (HWND child = topChild; child ; child = GetNextWindow(child, GW_HWNDNEXT))
+ dumpNativeWindowRecursionByZ(child, &nextLevel);
+ }
+}
+
+typedef QVector<WId> WIdVector;
+
+static void dumpNativeWindows(const WIdVector& wins)
+{
+ DumpContext dc;
+ QString s;
+ dc.stream = QSharedPointer<QTextStream>(new QTextStream(&s));
+ foreach (WId win, wins)
+ dumpNativeWindowRecursion(reinterpret_cast<HWND>(win), &dc);
+#if QT_VERSION > 0x050000
+ qDebug().noquote() << s;
+#else
+ qDebug("%s", qPrintable(s));
+#endif
+}
+
+void dumpNativeWindows(WId rootIn)
+{
+ const WId root = rootIn ? rootIn : reinterpret_cast<WId>(GetDesktopWindow());
+ dumpNativeWindows(WIdVector(1, root));
+}
+
+BOOL CALLBACK findQtTopLevelEnumChildProc(HWND hwnd, LPARAM lParam)
+{
+ WIdVector *v = reinterpret_cast<WIdVector *>(lParam);
+ wchar_t buf[512];
+ if (GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0]))) {
+ if (wcsstr(buf, L"Qt"))
+ v->append(reinterpret_cast<WId>(hwnd));
+ }
+ return TRUE;
+}
+
+static WIdVector findQtTopLevels()
+{
+ WIdVector result;
+ EnumChildWindows(GetDesktopWindow(),
+ findQtTopLevelEnumChildProc,
+ reinterpret_cast<LPARAM>(&result));
+ return result;
+}
+
+void dumpNativeQtTopLevels()
+{
+ dumpNativeWindows(findQtTopLevels());
+}
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp
new file mode 100644
index 0000000000..d4f985c7c8
--- /dev/null
+++ b/tests/manual/diaglib/qwidgetdump.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetdump.h"
+
+#include <QWidget>
+#if QT_VERSION > 0x050000
+# include <QtGui/QScreen>
+# include <QtGui/QWindow>
+#endif
+#include <QApplication>
+#include <QtCore/QMetaObject>
+#include <QtCore/QDebug>
+#include <QtCore/QTextStream>
+
+namespace QtDiag {
+
+static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
+ FormatWindowOptions options, int depth = 0)
+{
+ indentStream(str, 2 * depth);
+ formatObject(str, w);
+ str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ");
+ if (const WId nativeWinId = w->internalWinId())
+ str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] ";
+ if (w->isWindow())
+ str << "[top] ";
+ str << (w->testAttribute(Qt::WA_Mapped) ? "[mapped] " : "[not mapped] ");
+ if (w->testAttribute(Qt::WA_DontCreateNativeAncestors))
+ str << "[NoNativeAncestors] ";
+ formatRect(str, w->geometry());
+ if (!(options & DontPrintWindowFlags)) {
+ str << ' ';
+ formatWindowFlags(str, w->windowFlags());
+ }
+ str << '\n';
+#if QT_VERSION > 0x050000
+ if (const QWindow *win = w->windowHandle()) {
+ indentStream(str, 2 * (1 + depth));
+ formatWindow(str, win, options);
+ str << '\n';
+ }
+#endif // Qt 5
+ foreach (const QObject *co, w->children()) {
+ if (co->isWidgetType())
+ dumpWidgetRecursion(str, static_cast<const QWidget *>(co), options, depth + 1);
+ }
+}
+
+void dumpAllWidgets(FormatWindowOptions options)
+{
+ QString d;
+ QTextStream str(&d);
+ str << "### QWidgets:\n";
+ foreach (QWidget *tw, QApplication::topLevelWidgets())
+ dumpWidgetRecursion(str, tw, options);
+#if QT_VERSION > 0x050000
+ qDebug().noquote() << d;
+#else
+ qDebug("%s", qPrintable(d));
+#endif
+}
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwidgetdump.h b/tests/manual/diaglib/qwidgetdump.h
new file mode 100644
index 0000000000..f9615b5d2f
--- /dev/null
+++ b/tests/manual/diaglib/qwidgetdump.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _WIDGETDUMP_
+#define _WIDGETDUMP_
+
+#include "qwindowdump.h"
+
+namespace QtDiag {
+
+void dumpAllWidgets(FormatWindowOptions options = 0);
+
+} // namespace QtDiag
+
+#endif
diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp
new file mode 100644
index 0000000000..2ecc52ca77
--- /dev/null
+++ b/tests/manual/diaglib/qwindowdump.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowdump.h"
+
+#if QT_VERSION > 0x050000
+# include <QtGui/QGuiApplication>
+# include <QtGui/QScreen>
+# include <QtGui/QWindow>
+# include <qpa/qplatformwindow.h>
+#endif
+#include <QtCore/QMetaObject>
+#include <QtCore/QRect>
+#include <QtCore/QDebug>
+#include <QtCore/QTextStream>
+
+namespace QtDiag {
+
+void indentStream(QTextStream &s, int indent)
+{
+ for (int i = 0; i < indent; ++i)
+ s << ' ';
+}
+
+void formatObject(QTextStream &str, const QObject *o)
+{
+ str << o->metaObject()->className();
+ const QString on = o->objectName();
+ if (!on.isEmpty())
+ str << "/\"" << on << '"';
+}
+
+void formatRect(QTextStream &str, const QRect &geom)
+{
+ str << geom.width() << 'x' << geom.height()
+ << forcesign << geom.x() << geom.y() << noforcesign;
+}
+
+#define debugType(s, type, typeConstant) \
+if ((type & typeConstant) == typeConstant) \
+ s << ' ' << #typeConstant;
+
+#define debugFlag(s, flags, flagConstant) \
+if (flags & flagConstant) \
+ s << ' ' << #flagConstant;
+
+void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags)
+{
+ str << showbase << hex << unsigned(flags) << dec << noshowbase;
+ const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
+ debugFlag(str, flags, Qt::Window)
+ debugType(str, windowType, Qt::Dialog)
+ debugType(str, windowType, Qt::Sheet)
+ debugType(str, windowType, Qt::Drawer)
+ debugType(str, windowType, Qt::Popup)
+ debugType(str, windowType, Qt::Tool)
+ debugType(str, windowType, Qt::ToolTip)
+ debugType(str, windowType, Qt::SplashScreen)
+ debugType(str, windowType, Qt::Desktop)
+ debugType(str, windowType, Qt::SubWindow)
+#if QT_VERSION > 0x050000
+ debugType(str, windowType, Qt::ForeignWindow)
+ debugType(str, windowType, Qt::CoverWindow)
+#endif
+ debugFlag(str, flags, Qt::MSWindowsFixedSizeDialogHint)
+ debugFlag(str, flags, Qt::MSWindowsOwnDC)
+ debugFlag(str, flags, Qt::X11BypassWindowManagerHint)
+ debugFlag(str, flags, Qt::FramelessWindowHint)
+ debugFlag(str, flags, Qt::WindowTitleHint)
+ debugFlag(str, flags, Qt::WindowSystemMenuHint)
+ debugFlag(str, flags, Qt::WindowMinimizeButtonHint)
+ debugFlag(str, flags, Qt::WindowMaximizeButtonHint)
+ debugFlag(str, flags, Qt::WindowContextHelpButtonHint)
+ debugFlag(str, flags, Qt::WindowShadeButtonHint)
+ debugFlag(str, flags, Qt::WindowStaysOnTopHint)
+ debugFlag(str, flags, Qt::CustomizeWindowHint)
+#if QT_VERSION > 0x050000
+ debugFlag(str, flags, Qt::WindowTransparentForInput)
+ debugFlag(str, flags, Qt::WindowOverridesSystemGestures)
+ debugFlag(str, flags, Qt::WindowDoesNotAcceptFocus)
+ debugFlag(str, flags, Qt::NoDropShadowWindowHint)
+ debugFlag(str, flags, Qt::WindowFullscreenButtonHint)
+#endif
+ debugFlag(str, flags, Qt::WindowStaysOnBottomHint)
+ debugFlag(str, flags, Qt::MacWindowToolBarButtonHint)
+ debugFlag(str, flags, Qt::BypassGraphicsProxyWidget)
+ debugFlag(str, flags, Qt::WindowOkButtonHint)
+ debugFlag(str, flags, Qt::WindowCancelButtonHint)
+}
+
+#if QT_VERSION > 0x050000
+
+void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options)
+{
+ const QPlatformWindow *pw = w->handle();
+ formatObject(str, w);
+ str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ");
+ if (const WId nativeWinId = pw ? pw->winId() : WId(0))
+ str << "[native: " << hex << showbase << nativeWinId << dec << noshowbase << "] ";
+ if (w->isTopLevel())
+ str << "[top] ";
+ if (w->isExposed())
+ str << "[exposed] ";
+ formatRect(str, w->geometry());
+ if (!(options & DontPrintWindowFlags)) {
+ str << ' ';
+ formatWindowFlags(str, w->flags());
+ }
+ str << '\n';
+}
+
+static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
+ FormatWindowOptions options = 0, int depth = 0)
+{
+ indentStream(str, 2 * depth);
+ formatWindow(str, w);
+ foreach (const QObject *co, w->children()) {
+ if (co->isWindowType())
+ dumpWindowRecursion(str, static_cast<const QWindow *>(co), options, depth + 1);
+ }
+}
+
+void dumpAllWindows(FormatWindowOptions options)
+{
+ QString d;
+ QTextStream str(&d);
+ str << "### QWindows:\n";
+ foreach (QWindow *w, QGuiApplication::topLevelWindows())
+ dumpWindowRecursion(str, w, options);
+ qDebug().noquote() << d;
+}
+
+#else // Qt 5
+class QWindow {};
+
+void formatWindow(QTextStream &, const QWindow *, FormatWindowOptions)
+{
+}
+
+void dumpAllWindows(FormatWindowOptions options)
+{
+}
+
+#endif // Qt 4
+
+} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwindowdump.h b/tests/manual/diaglib/qwindowdump.h
new file mode 100644
index 0000000000..ab7c0243e9
--- /dev/null
+++ b/tests/manual/diaglib/qwindowdump.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _WINDOWDUMP_
+#define _WINDOWDUMP_
+
+#include <QtCore/qnamespace.h>
+
+QT_FORWARD_DECLARE_CLASS(QRect)
+QT_FORWARD_DECLARE_CLASS(QObject)
+QT_FORWARD_DECLARE_CLASS(QWindow)
+QT_FORWARD_DECLARE_CLASS(QTextStream)
+
+namespace QtDiag {
+
+enum FormatWindowOption {
+ DontPrintWindowFlags = 0x001
+};
+
+Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption)
+Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions)
+
+void indentStream(QTextStream &s, int indent);
+void formatObject(QTextStream &str, const QObject *o);
+void formatRect(QTextStream &str, const QRect &geom);
+void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags);
+
+void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0);
+void dumpAllWindows(FormatWindowOptions options = 0);
+
+} // namespace QtDiag
+
+#endif
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index e593756a7d..fe3e624bfe 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -29,6 +29,7 @@ qtabletevent \
qtexteditlist \
qtbug-8933 \
qtouchevent \
+touch \
qwidget_zorder \
repaint \
socketengine \
diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp
new file mode 100644
index 0000000000..6b06db614c
--- /dev/null
+++ b/tests/manual/touch/main.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QLabel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QAction>
+#include <QMainWindow>
+#include <QSplitter>
+#include <QVector>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QPlainTextEdit>
+#include <QPaintEvent>
+#include <QScreen>
+#include <QDebug>
+#include <QTextStream>
+
+QDebug operator<<(QDebug debug, const QTouchDevice *d)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QTouchDevice(" << d->name() << ',';
+ switch (d->type()) {
+ case QTouchDevice::TouchScreen:
+ debug << "TouchScreen";
+ break;
+ case QTouchDevice::TouchPad:
+ debug << "TouchPad";
+ break;
+ }
+ debug << ", capabilities=" << d->capabilities()
+ << ", maximumTouchPoints=" << d->maximumTouchPoints() << ')';
+ return debug;
+}
+
+typedef QVector<QEvent::Type> EventTypeVector;
+
+class EventFilter : public QObject {
+ Q_OBJECT
+public:
+ explicit EventFilter(const EventTypeVector &types, QObject *p) : QObject(p), m_types(types) {}
+
+ bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+
+signals:
+ void eventReceived(const QString &);
+
+private:
+ const EventTypeVector m_types;
+};
+
+bool EventFilter::eventFilter(QObject *o, QEvent *e)
+{
+ static int n = 0;
+ if (m_types.contains(e->type())) {
+ QString message;
+ QDebug(&message) << '#' << n++ << ' ' << o->objectName() << ' ' << e;
+ emit eventReceived(message);
+ }
+ return false;
+}
+
+class TouchTestWidget : public QWidget {
+public:
+ explicit TouchTestWidget(QWidget *parent = 0) : QWidget(parent)
+ {
+ setAttribute(Qt::WA_AcceptTouchEvents);
+ }
+
+ bool event(QEvent *event) Q_DECL_OVERRIDE
+ {
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ event->accept();
+ return true;
+ default:
+ break;
+ }
+ return QWidget::event(event);
+ }
+};
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow();
+ QWidget *touchWidget() const { return m_touchWidget; }
+
+public slots:
+ void appendToLog(const QString &text) { m_logTextEdit->appendPlainText(text); }
+ void dumpTouchDevices();
+
+private:
+ QWidget *m_touchWidget;
+ QPlainTextEdit *m_logTextEdit;
+};
+
+MainWindow::MainWindow()
+ : m_touchWidget(new TouchTestWidget)
+ , m_logTextEdit(new QPlainTextEdit)
+{
+ setWindowTitle(QStringLiteral("Touch Event Tester ") + QT_VERSION_STR);
+
+ setObjectName("MainWin");
+ QMenu *fileMenu = menuBar()->addMenu("File");
+ QAction *da = fileMenu->addAction(QStringLiteral("Dump devices"));
+ da->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
+ connect(da, SIGNAL(triggered()), this, SLOT(dumpTouchDevices()));
+ QAction *qa = fileMenu->addAction(QStringLiteral("Quit"));
+ qa->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
+ connect(qa, SIGNAL(triggered()), this, SLOT(close()));
+
+ QSplitter *mainSplitter = new QSplitter(Qt::Vertical);
+
+ m_touchWidget->setObjectName(QStringLiteral("TouchWidget"));
+ const QSize screenSize = QGuiApplication::primaryScreen()->availableGeometry().size();
+ m_touchWidget->setMinimumSize(screenSize / 2);
+ mainSplitter->addWidget(m_touchWidget);
+
+ m_logTextEdit->setObjectName(QStringLiteral("LogTextEdit"));
+ m_logTextEdit->setMinimumHeight(screenSize.height() / 4);
+ mainSplitter->addWidget(m_logTextEdit);
+ setCentralWidget(mainSplitter);
+
+ dumpTouchDevices();
+}
+
+void MainWindow::dumpTouchDevices()
+{
+ QString message;
+ QDebug debug(&message);
+ const QList<const QTouchDevice *> devices = QTouchDevice::devices();
+ debug << devices.size() << "Device(s):\n";
+ for (int i = 0; i < devices.size(); ++i)
+ debug << "Device #" << i << devices.at(i) << '\n';
+ appendToLog(message);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QStringLiteral("Touch/Mouse tester"));
+ parser.addHelpOption();
+ const QCommandLineOption mouseMoveOption(QStringLiteral("mousemove"),
+ QStringLiteral("Log mouse move events"));
+ parser.addOption(mouseMoveOption);
+ const QCommandLineOption globalFilterOption(QStringLiteral("global"),
+ QStringLiteral("Global event filter"));
+ parser.addOption(globalFilterOption);
+ parser.process(QApplication::arguments());
+
+ MainWindow w;
+ w.show();
+ const QSize pos = QGuiApplication::primaryScreen()->availableGeometry().size() - w.size();
+ w.move(pos.width() / 2, pos.height() / 2);
+
+ EventTypeVector eventTypes;
+ eventTypes << QEvent::MouseButtonPress << QEvent::MouseButtonRelease
+ << QEvent::MouseButtonDblClick
+ << QEvent::TouchBegin << QEvent::TouchUpdate << QEvent::TouchEnd;
+ if (parser.isSet(mouseMoveOption))
+ eventTypes << QEvent::MouseMove;
+ QObject *filterTarget = parser.isSet(globalFilterOption)
+ ? static_cast<QObject *>(&a)
+ : static_cast<QObject *>(w.touchWidget());
+ EventFilter *filter = new EventFilter(eventTypes, filterTarget);
+ filterTarget->installEventFilter(filter);
+ QObject::connect(filter, SIGNAL(eventReceived(QString)), &w, SLOT(appendToLog(QString)));
+
+ return a.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/touch/touch.pro b/tests/manual/touch/touch.pro
new file mode 100644
index 0000000000..fcb3c47f43
--- /dev/null
+++ b/tests/manual/touch/touch.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+QT = core gui
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+CONFIG -= app_bundle
+SOURCES += main.cpp