summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-20 13:46:21 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-05-23 21:09:46 +0200
commit56d6e000f7487c59172330ebd23a718268c508f1 (patch)
tree1494432583b1569816075091a8075b31d795f77c /tests/auto
parent9fd407fc6a29c94b4568dd042a05c208255179e0 (diff)
parentc276aa51303b7c6f8e4cd854aadf8344a906e50f (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: mkspecs/wince80colibri-armv7-msvc2012/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/corelib/global/qnamespace.h src/corelib/global/qnamespace.qdoc src/corelib/io/qfsfileengine_win.cpp src/corelib/tools/tools.pri src/network/ssl/qsslconfiguration_p.h src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp src/plugins/platforms/windows/windows.pri src/src.pro src/tools/bootstrap/bootstrap.pro src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/dialogs/qfilesystemmodel.cpp tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt Change-Id: I4d2ac78f0dcc97f008186bbbc769c6fe588ab0e5
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp35
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp10
-rw-r--r--tests/auto/corelib/tools/qarraydata/simplevector.h2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp30
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp2
-rw-r--r--tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp4
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp6
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp4
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp22
-rw-r--r--tests/auto/dbus/dbus.pro1
-rw-r--r--tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp137
-rw-r--r--tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h7
-rw-r--r--tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro7
-rw-r--r--tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp57
-rw-r--r--tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp2
-rw-r--r--tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp8
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp47
-rw-r--r--tests/auto/gui/image/qimagewriter/images/App.icobin0 -> 318 bytes
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp3
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp156
-rw-r--r--tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp16
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp5
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.lightxml4
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.teamcity2
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.txt4
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xml4
-rw-r--r--tests/auto/testlib/selftests/expected_cmptest.xunitxml4
-rw-r--r--tests/auto/tools/moc/backslash-newlines.h2
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp16
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp21
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp5
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp17
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp36
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST16
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp115
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp59
37 files changed, 575 insertions, 293 deletions
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index 802bbe9963..8b1aa105de 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -27,14 +27,18 @@
****************************************************************************/
#include <QtTest/QtTest>
-
#include <QStorageInfo>
+#include <stdarg.h>
+
+#include "../../../../manual/qstorageinfo/printvolumes.cpp"
+
class tst_QStorageInfo : public QObject
{
Q_OBJECT
private slots:
void defaultValues();
+ void dump();
void operatorEqual();
#ifndef Q_OS_WINRT
void operatorNotEqual();
@@ -61,6 +65,33 @@ void tst_QStorageInfo::defaultValues()
QCOMPARE(storage.bytesAvailable(), -1);
}
+static int qInfoPrinter(const char *format, ...)
+{
+ static char buf[1024];
+ static size_t bufuse = 0;
+
+ va_list ap;
+ va_start(ap, format); // use variable arg list
+ int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap);
+ va_end(ap);
+
+ bufuse += n;
+ if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') {
+ // flush
+ QtMessageHandler qt_message_print = qInstallMessageHandler(0);
+ qInstallMessageHandler(qt_message_print); // restore the handler
+ qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf));
+ bufuse = 0;
+ }
+
+ return 1;
+}
+
+void tst_QStorageInfo::dump()
+{
+ printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter);
+}
+
void tst_QStorageInfo::operatorEqual()
{
{
@@ -157,6 +188,7 @@ void tst_QStorageInfo::tempFile()
#endif
qint64 free = storage1.bytesFree();
+ QVERIFY(free != -1);
file.write(QByteArray(1024*1024, '1'));
file.flush();
@@ -180,6 +212,7 @@ void tst_QStorageInfo::caching()
qint64 free = storage1.bytesFree();
QStorageInfo storage2(storage1);
QCOMPARE(free, storage2.bytesFree());
+ QVERIFY(free != -1);
file.write(QByteArray(1024*1024, '\0'));
file.flush();
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 7f6e26eecb..262d8ad44b 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -4659,6 +4659,16 @@ template<typename Enum> void testVariant(Enum value, bool *ok)
QVERIFY(var2.convert(QMetaType::Int));
QCOMPARE(var2.value<int>(), static_cast<int>(value));
+ if (static_cast<qint64>(value) <= INT_MAX) {
+ int intValue = static_cast<int>(value);
+ QVariant intVar = intValue;
+ QVERIFY(intVar.canConvert<Enum>());
+ QCOMPARE(intVar.value<Enum>(), value);
+ }
+ qint64 longValue = static_cast<qint64>(value);
+ QVERIFY(QVariant(longValue).canConvert<Enum>());
+ QCOMPARE(QVariant(longValue).value<Enum>(), value);
+
*ok = true;
}
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h
index 90e86dca4e..9dd8b05796 100644
--- a/tests/auto/corelib/tools/qarraydata/simplevector.h
+++ b/tests/auto/corelib/tools/qarraydata/simplevector.h
@@ -88,7 +88,7 @@ public:
bool isStatic() const { return d->ref.isStatic(); }
bool isShared() const { return d->ref.isShared(); }
bool isSharedWith(const SimpleVector &other) const { return d == other.d; }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
bool isSharable() const { return d->ref.isSharable(); }
void setSharable(bool sharable) { d.setSharable(sharable); }
#endif
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 0732a55063..0c41f66357 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -39,7 +39,7 @@ struct SharedNullVerifier
{
Q_ASSERT(QArrayData::shared_null[0].ref.isStatic());
Q_ASSERT(QArrayData::shared_null[0].ref.isShared());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
Q_ASSERT(QArrayData::shared_null[0].ref.isSharable());
#endif
}
@@ -96,7 +96,7 @@ void tst_QArrayData::referenceCounting()
QCOMPARE(array.ref.atomic.load(), 1);
QVERIFY(!array.ref.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(array.ref.isSharable());
#endif
@@ -118,7 +118,7 @@ void tst_QArrayData::referenceCounting()
// Now would be a good time to free/release allocated data
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
// Reference counting initialized to 0 (non-sharable)
QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 };
@@ -146,7 +146,7 @@ void tst_QArrayData::referenceCounting()
QCOMPARE(array.ref.atomic.load(), -1);
QVERIFY(array.ref.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(array.ref.isSharable());
#endif
@@ -173,7 +173,7 @@ void tst_QArrayData::sharedNullEmpty()
QCOMPARE(null->ref.atomic.load(), -1);
QCOMPARE(empty->ref.atomic.load(), -1);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(null->ref.isSharable());
QVERIFY(empty->ref.isSharable());
#endif
@@ -304,7 +304,7 @@ void tst_QArrayData::simpleVector()
QVERIFY(!v7.isShared());
QVERIFY(!v8.isShared());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v1.isSharable());
QVERIFY(v2.isSharable());
QVERIFY(v3.isSharable());
@@ -497,7 +497,7 @@ void tst_QArrayData::simpleVector()
for (int i = 0; i < 120; ++i)
QCOMPARE(v1[i], v8[i % 10]);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
v7.setSharable(true);
QVERIFY(v7.isSharable());
@@ -667,7 +667,7 @@ void tst_QArrayData::allocate_data()
QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0);
QVERIFY(shared_empty);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable);
QVERIFY(unsharable_empty);
#endif
@@ -681,7 +681,7 @@ void tst_QArrayData::allocate_data()
} options[] = {
{ "Default", QArrayData::Default, false, true, shared_empty },
{ "Reserved", QArrayData::CapacityReserved, true, true, shared_empty },
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{ "Reserved | Unsharable",
QArrayData::CapacityReserved | QArrayData::Unsharable, true, false,
unsharable_empty },
@@ -731,7 +731,7 @@ void tst_QArrayData::allocate()
else
QCOMPARE(data->alloc, uint(capacity));
QCOMPARE(data->capacityReserved, uint(isCapacityReserved));
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(bool, isSharable);
QCOMPARE(data->ref.isSharable(), isSharable);
#endif
@@ -1311,7 +1311,7 @@ static inline bool arrayIsFilledWith(const QArrayDataPointer<int> &array,
void tst_QArrayData::setSharable_data()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QTest::addColumn<QArrayDataPointer<int> >("array");
QTest::addColumn<size_t>("size");
QTest::addColumn<size_t>("capacity");
@@ -1357,7 +1357,7 @@ void tst_QArrayData::setSharable_data()
void tst_QArrayData::setSharable()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(QArrayDataPointer<int>, array);
QFETCH(size_t, size);
QFETCH(size_t, capacity);
@@ -1487,7 +1487,7 @@ void fromRawData_impl()
QVERIFY((const T *)raw.constBegin() != array);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
// Immutable, unsharable
SimpleVector<T> raw = SimpleVector<T>::fromRawData(array,
@@ -1573,7 +1573,7 @@ void tst_QArrayData::literals()
QVERIFY(v.isStatic());
#endif
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v.isSharable());
#endif
QCOMPARE((void*)(const char*)(v.constBegin() + v.size()), (void*)(const char*)v.constEnd());
@@ -1624,7 +1624,7 @@ void tst_QArrayData::variadicLiterals()
QVERIFY(v.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v.isSharable());
#endif
QCOMPARE((const int *)(v.constBegin() + v.size()), (const int *)v.constEnd());
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 1ec0924254..cfd2bdc6f7 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -1184,7 +1184,7 @@ void tst_QHash::noNeedlessRehashes()
void tst_QHash::const_shared_null()
{
QHash<int, QString> hash2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QHash<int, QString> hash1;
hash1.setSharable(false);
QVERIFY(hash1.isDetached());
diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
index 4c4cb4879b..f17d6695f0 100644
--- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
+++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
@@ -1022,7 +1022,7 @@ template<typename T>
void tst_QLinkedList::constSharedNull() const
{
QLinkedList<T> list2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QLinkedList<T> list1;
list1.setSharable(false);
QVERIFY(list1.isDetached());
@@ -1054,7 +1054,7 @@ void tst_QLinkedList::constSharedNullComplex() const
void tst_QLinkedList::setSharableInt() const
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QLinkedList<int> orglist;
orglist << 0 << 1 << 2 << 3 << 4 << 5;
int size = 6;
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index bae8ece303..b3f8130d27 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -1887,7 +1887,7 @@ template<typename T>
void tst_QList::constSharedNull() const
{
QList<T> list2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QList<T> list1;
list1.setSharable(false);
QVERIFY(list1.isDetached());
@@ -1921,7 +1921,7 @@ void tst_QList::constSharedNullComplex() const
template <class T>
void generateSetSharableData()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QTest::addColumn<QList<T> >("list");
QTest::addColumn<int>("size");
@@ -1933,7 +1933,7 @@ void generateSetSharableData()
template <class T>
void runSetSharableTest()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(QList<T>, list);
QFETCH(int, size);
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 0898c10ea6..8aa7a3e518 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -1007,7 +1007,7 @@ void tst_QMap::qmultimap_specific()
void tst_QMap::const_shared_null()
{
QMap<int, QString> map2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QMap<int, QString> map1;
map1.setSharable(false);
QVERIFY(map1.isDetached());
@@ -1104,7 +1104,7 @@ const T &const_(const T &t)
void tst_QMap::setSharable()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QMap<int, QString> map;
map.insert(1, "um");
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index eb37d6b8e6..825cb05d74 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -426,7 +426,7 @@ void tst_QVector::copyConstructor() const
QVector<T> v2(v1);
QCOMPARE(v1, v2);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v1;
@@ -590,7 +590,7 @@ void tst_QVector::append() const
QVERIFY(v.size() == 3);
QCOMPARE(v.at(v.size() - 1), SimpleValue<T>::at(0));
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v(2);
@@ -926,7 +926,7 @@ void tst_QVector::eraseEmpty() const
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v;
@@ -965,7 +965,7 @@ void tst_QVector::eraseEmptyReserved() const
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v;
@@ -1081,7 +1081,7 @@ void tst_QVector::erase(bool shared) const
if (shared)
QCOMPARE(SimpleValue<T>::vector(12), *svc.copy);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v = SimpleValue<T>::vector(10);
@@ -1168,7 +1168,7 @@ template<typename T> void tst_QVector::eraseReserved() const
v.erase(v.begin() + 1, v.end() - 1);
QCOMPARE(v.size(), 2);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v(10);
@@ -1903,7 +1903,7 @@ void tst_QVector::resizePOD_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<int> nullNotShared;
QVector<int> emptyNotShared(0, 5);
@@ -1978,7 +1978,7 @@ void tst_QVector::resizeComplexMovable_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<Movable> nullNotShared;
QVector<Movable> emptyNotShared(0, 'Q');
@@ -2057,7 +2057,7 @@ void tst_QVector::resizeComplex_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<Custom> nullNotShared;
QVector<Custom> emptyNotShared(0, '0');
@@ -2498,7 +2498,7 @@ void tst_QVector::initializeListCustom()
void tst_QVector::const_shared_null()
{
QVector<int> v2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<int> v1;
v1.setSharable(false);
@@ -2509,7 +2509,7 @@ void tst_QVector::const_shared_null()
QVERIFY(!v2.isDetached());
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
template<typename T>
void tst_QVector::setSharable_data() const
diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro
index 67cbc4bfef..c5cddee5f5 100644
--- a/tests/auto/dbus/dbus.pro
+++ b/tests/auto/dbus/dbus.pro
@@ -11,6 +11,7 @@ SUBDIRS+=\
qdbusconnection_no_app \
qdbusconnection_no_bus \
qdbusconnection_no_libdbus \
+ qdbusconnection_spyhook \
qdbuscontext \
qdbusinterface \
qdbuslocalcalls \
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
index 0163f44a36..851ef6cc1f 100644
--- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
+++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp
@@ -50,6 +50,31 @@ void MyObjectWithoutInterface::method(const QDBusMessage &msg)
//qDebug() << msg;
}
+int tst_QDBusConnection::hookCallCount;
+tst_QDBusConnection::tst_QDBusConnection()
+{
+#ifdef HAS_HOOKSETUPFUNCTION
+# define QCOMPARE_HOOKCOUNT(n) QCOMPARE(hookCallCount, n); hookCallCount = 0
+# define QVERIFY_HOOKCALLED() QCOMPARE(hookCallCount, 1); hookCallCount = 0
+ hookSetupFunction();
+#else
+# define QCOMPARE_HOOKCOUNT(n) qt_noop()
+# define QVERIFY_HOOKCALLED() qt_noop()
+#endif
+}
+
+// called before each testcase
+void tst_QDBusConnection::init()
+{
+ hookCallCount = 0;
+}
+
+void tst_QDBusConnection::cleanup()
+{
+ QVERIFY2(!hookCallCount, "Unchecked call");
+}
+
+
void tst_QDBusConnection::noConnection()
{
QDBusConnection con = QDBusConnection::connectToBus("unix:path=/dev/null", "testconnection");
@@ -354,9 +379,11 @@ void tst_QDBusConnection::registerObject()
QCOMPARE(con.objectRegisteredAt(path), static_cast<QObject *>(&obj));
QVERIFY(callMethod(con, path));
QCOMPARE(obj.path, path);
+ QVERIFY_HOOKCALLED();
}
// make sure it's gone
QVERIFY(!callMethod(con, path));
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::registerObjectWithInterface_data()
@@ -388,9 +415,11 @@ void tst_QDBusConnection::registerObjectWithInterface()
QVERIFY(callMethod(con, path, interface));
QCOMPARE(obj.path, path);
QCOMPARE(obj.interface, interface);
+ QVERIFY_HOOKCALLED();
}
// make sure it's gone
QVERIFY(!callMethod(con, path, interface));
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::registerObjectPeer_data()
@@ -427,6 +456,7 @@ void tst_QDBusConnection::registerObjectPeer()
MyObject obj;
QVERIFY(callMethodPeer(con, path));
QCOMPARE(obj.path, path);
+ QVERIFY_HOOKCALLED();
}
QDBusConnection::connectToPeer(server.address(), "afterFoo");
@@ -436,6 +466,7 @@ void tst_QDBusConnection::registerObjectPeer()
QDBusConnection con("foo");
QVERIFY(con.isConnected());
QVERIFY(callMethodPeer(con, path));
+ QVERIFY_HOOKCALLED();
}
server.unregisterObject();
@@ -444,6 +475,7 @@ void tst_QDBusConnection::registerObjectPeer()
QDBusConnection con("foo");
QVERIFY(con.isConnected());
QVERIFY(!callMethodPeer(con, path));
+ QVERIFY_HOOKCALLED();
}
server.registerObject();
@@ -452,6 +484,7 @@ void tst_QDBusConnection::registerObjectPeer()
QDBusConnection con("foo");
QVERIFY(con.isConnected());
QVERIFY(callMethodPeer(con, path));
+ QVERIFY_HOOKCALLED();
}
QDBusConnection::disconnectFromPeer("foo");
@@ -473,10 +506,15 @@ void tst_QDBusConnection::registerObject2()
// make sure nothing is using our paths:
QVERIFY(!callMethod(con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p2"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/q"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/q/r"));
+ QVERIFY_HOOKCALLED();
{
// register one object at root:
@@ -484,76 +522,99 @@ void tst_QDBusConnection::registerObject2()
QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethod(con, "/"));
QCOMPARE(obj.path, QString("/"));
+ QVERIFY_HOOKCALLED();
}
// make sure it's gone
QVERIFY(!callMethod(con, "/"));
+ QVERIFY_HOOKCALLED();
{
// register one at an element:
MyObject obj;
QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethod(con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1"));
QCOMPARE(obj.path, QString("/p1"));
+ QVERIFY_HOOKCALLED();
// re-register it somewhere else
QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethod(con, "/p1"));
QCOMPARE(obj.path, QString("/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p2"));
QCOMPARE(obj.path, QString("/p2"));
+ QVERIFY_HOOKCALLED();
}
// make sure it's gone
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p2"));
+ QVERIFY_HOOKCALLED();
{
// register at a deep path
MyObject obj;
QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethod(con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/q"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1/q/r"));
QCOMPARE(obj.path, QString("/p1/q/r"));
+ QVERIFY_HOOKCALLED();
}
+
// make sure it's gone
QVERIFY(!callMethod(con, "/p1/q/r"));
+ QVERIFY_HOOKCALLED();
{
MyObject obj;
QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethod(con, "/p1/q2"));
QCOMPARE(obj.path, QString("/p1/q2"));
+ QVERIFY_HOOKCALLED();
// try unregistering
con.unregisterObject("/p1/q2");
QVERIFY(!callMethod(con, "/p1/q2"));
+ QVERIFY_HOOKCALLED();
// register it again
QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethod(con, "/p1/q2"));
QCOMPARE(obj.path, QString("/p1/q2"));
+ QVERIFY_HOOKCALLED();
// now try removing things around it:
con.unregisterObject("/p2");
QVERIFY(callMethod(con, "/p1/q2")); // unrelated object shouldn't affect
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1");
QVERIFY(callMethod(con, "/p1/q2")); // unregistering just the parent shouldn't affect it
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/q2/r");
QVERIFY(callMethod(con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/q");
QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (before) shouldn't affect
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/r");
QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (after) shouldn't affect
+ QVERIFY_HOOKCALLED();
// now remove it:
con.unregisterObject("/p1", QDBusConnection::UnregisterTree);
QVERIFY(!callMethod(con, "/p1/q2")); // we removed the full tree
+ QVERIFY_HOOKCALLED();
}
}
@@ -572,10 +633,15 @@ void tst_QDBusConnection::registerObjectPeer2()
// make sure nothing is using our paths:
QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p2"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/q"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/q/r"));
+ QVERIFY_HOOKCALLED();
{
// register one object at root:
@@ -583,76 +649,101 @@ void tst_QDBusConnection::registerObjectPeer2()
QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethodPeer(srv_con, "/"));
QCOMPARE(obj.path, QString("/"));
+ QVERIFY_HOOKCALLED();
}
+
// make sure it's gone
QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY_HOOKCALLED();
{
// register one at an element:
MyObject obj;
QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1"));
QCOMPARE(obj.path, QString("/p1"));
+ QVERIFY_HOOKCALLED();
// re-register it somewhere else
QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethodPeer(srv_con, "/p1"));
QCOMPARE(obj.path, QString("/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p2"));
QCOMPARE(obj.path, QString("/p2"));
+ QVERIFY_HOOKCALLED();
}
+
// make sure it's gone
QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p2"));
+ QVERIFY_HOOKCALLED();
{
// register at a deep path
MyObject obj;
QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(!callMethodPeer(srv_con, "/"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/q"));
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1/q/r"));
QCOMPARE(obj.path, QString("/p1/q/r"));
+ QVERIFY_HOOKCALLED();
}
+
// make sure it's gone
QVERIFY(!callMethodPeer(srv_con, "/p1/q/r"));
+ QVERIFY_HOOKCALLED();
{
MyObject obj;
QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethodPeer(srv_con, "/p1/q2"));
QCOMPARE(obj.path, QString("/p1/q2"));
+ QVERIFY_HOOKCALLED();
// try unregistering
con.unregisterObject("/p1/q2");
QVERIFY(!callMethodPeer(srv_con, "/p1/q2"));
+ QVERIFY_HOOKCALLED();
// register it again
QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots));
QVERIFY(callMethodPeer(srv_con, "/p1/q2"));
QCOMPARE(obj.path, QString("/p1/q2"));
+ QVERIFY_HOOKCALLED();
// now try removing things around it:
con.unregisterObject("/p2");
QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unrelated object shouldn't affect
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1");
QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering just the parent shouldn't affect it
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/q2/r");
QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/q");
QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (before) shouldn't affect
+ QVERIFY_HOOKCALLED();
con.unregisterObject("/p1/r");
QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (after) shouldn't affect
+ QVERIFY_HOOKCALLED();
// now remove it:
con.unregisterObject("/p1", QDBusConnection::UnregisterTree);
QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); // we removed the full tree
+ QVERIFY_HOOKCALLED();
}
QDBusConnection::disconnectFromPeer("foo");
@@ -664,6 +755,7 @@ void tst_QDBusConnection::registerQObjectChildren()
// make sure no one is there
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
{
MyObject obj, *a, *b, *c, *cc;
@@ -686,32 +778,47 @@ void tst_QDBusConnection::registerQObjectChildren()
// make calls
QVERIFY(callMethod(con, "/p1"));
QCOMPARE(obj.callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1/a"));
QCOMPARE(a->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1/b"));
QCOMPARE(b->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1/c"));
QCOMPARE(c->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethod(con, "/p1/c/cc"));
QCOMPARE(cc->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/d"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/c/abc"));
+ QVERIFY_HOOKCALLED();
// pull an object, see if it goes away:
delete b;
QVERIFY(!callMethod(con, "/p1/b"));
+ QVERIFY_HOOKCALLED();
delete c;
QVERIFY(!callMethod(con, "/p1/c"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/c/cc"));
+ QVERIFY_HOOKCALLED();
}
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/a"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/b"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/c"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethod(con, "/p1/c/cc"));
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::registerQObjectChildrenPeer()
@@ -729,6 +836,7 @@ void tst_QDBusConnection::registerQObjectChildrenPeer()
QDBusConnection srv_con = server.connection();
QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY_HOOKCALLED();
{
MyObject obj, *a, *b, *c, *cc;
@@ -751,32 +859,47 @@ void tst_QDBusConnection::registerQObjectChildrenPeer()
// make calls
QVERIFY(callMethodPeer(srv_con, "/p1"));
QCOMPARE(obj.callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1/a"));
QCOMPARE(a->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1/b"));
QCOMPARE(b->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1/c"));
QCOMPARE(c->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(callMethodPeer(srv_con, "/p1/c/cc"));
QCOMPARE(cc->callCount, 1);
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/d"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/c/abc"));
+ QVERIFY_HOOKCALLED();
// pull an object, see if it goes away:
delete b;
QVERIFY(!callMethodPeer(srv_con, "/p1/b"));
+ QVERIFY_HOOKCALLED();
delete c;
QVERIFY(!callMethodPeer(srv_con, "/p1/c"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc"));
+ QVERIFY_HOOKCALLED();
}
QVERIFY(!callMethodPeer(srv_con, "/p1"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/a"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/b"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/c"));
+ QVERIFY_HOOKCALLED();
QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc"));
+ QVERIFY_HOOKCALLED();
QDBusConnection::disconnectFromPeer("foo");
}
@@ -822,20 +945,25 @@ void tst_QDBusConnection::callSelf()
QVERIFY(connection.registerService(serviceName()));
QDBusInterface interface(serviceName(), "/test");
QVERIFY(interface.isValid());
+ QVERIFY_HOOKCALLED();
interface.call(QDBus::Block, "test0");
QCOMPARE(testObject.func, QString("test0"));
+ QVERIFY_HOOKCALLED();
interface.call(QDBus::Block, "test1", 42);
QCOMPARE(testObject.func, QString("test1 42"));
+ QVERIFY_HOOKCALLED();
QDBusMessage reply = interface.call(QDBus::Block, "test2");
QCOMPARE(testObject.func, QString("test2"));
QCOMPARE(reply.arguments().value(0).toInt(), 43);
+ QVERIFY_HOOKCALLED();
QDBusMessage msg = QDBusMessage::createMethodCall(serviceName(), "/test",
QString(), "test3");
msg << 44;
reply = connection.call(msg);
QCOMPARE(reply.arguments().value(0).toInt(), 45);
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::callSelfByAnotherName_data()
@@ -903,12 +1031,14 @@ void tst_QDBusConnection::callSelfByAnotherName()
QDBusMessage reply = con.call(msg, QDBus::Block, 1000);
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::multipleInterfacesInQObject()
{
QDBusConnection con = QDBusConnection::sessionBus();
QVERIFY(!callMethod(con, "/p1"));
+ QVERIFY_HOOKCALLED();
MyObject obj;
con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots);
@@ -919,6 +1049,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject()
QDBusMessage reply = con.call(msg, QDBus::Block);
QCOMPARE(reply.type(), QDBusMessage::ReplyMessage);
QCOMPARE(reply.arguments().count(), 0);
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::slotsWithLessParameters()
@@ -976,6 +1107,7 @@ void tst_QDBusConnection::nestedCallWithCallback()
QTestEventLoop::instance().enterLoop(15);
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(signalsReceived, 1);
+ QCOMPARE_HOOKCOUNT(2);
}
void tst_QDBusConnection::serviceRegistrationRaceCondition()
@@ -1140,6 +1272,7 @@ void tst_QDBusConnection::callVirtualObject()
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY_HOOKCALLED();
QCOMPARE(obj.callCount, 1);
QCOMPARE(obj.lastMessage.service(), con2.baseService());
@@ -1157,6 +1290,7 @@ void tst_QDBusConnection::callVirtualObject()
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY_HOOKCALLED();
QCOMPARE(obj.callCount, 2);
QCOMPARE(obj.lastMessage.service(), con2.baseService());
@@ -1174,6 +1308,7 @@ void tst_QDBusConnection::callVirtualObject()
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY_HOOKCALLED();
QTest::qWait(100);
QVERIFY(errorReply.isError());
QCOMPARE(errorReply.reply().errorName(), QString("org.freedesktop.DBus.Error.UnknownObject"));
@@ -1202,6 +1337,7 @@ void tst_QDBusConnection::callVirtualObjectLocal()
QCOMPARE(obj.lastMessage.interface(), QString());
QCOMPARE(obj.lastMessage.path(), path);
QCOMPARE(obj.replyArguments, reply.arguments());
+ QVERIFY_HOOKCALLED();
obj.replyArguments << QString("alien abduction");
QDBusMessage subPathMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "hello");
@@ -1211,6 +1347,7 @@ void tst_QDBusConnection::callVirtualObjectLocal()
QCOMPARE(obj.lastMessage.interface(), QString());
QCOMPARE(obj.lastMessage.path(), childPath);
QCOMPARE(obj.replyArguments, subPathReply.arguments());
+ QVERIFY_HOOKCALLED();
}
void tst_QDBusConnection::pendingCallWhenDisconnected()
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h
index 0402889c6e..b9eb0d9db7 100644
--- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h
+++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h
@@ -74,11 +74,18 @@ class tst_QDBusConnection: public QObject
Q_OBJECT
int signalsReceived;
+public:
+ static int hookCallCount;
+ tst_QDBusConnection();
+
public slots:
void oneSlot() { ++signalsReceived; }
void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); }
void secondCallWithCallback();
+ void init();
+ void cleanup();
+
private slots:
void noConnection();
void connectToBus();
diff --git a/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro
new file mode 100644
index 0000000000..020d30380d
--- /dev/null
+++ b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qdbusconnection_spyhook
+QT = core dbus testlib
+SOURCES += tst_qdbusconnection_spyhook.cpp
+HEADERS += ../qdbusconnection/tst_qdbusconnection.h
+DEFINES += SRCDIR=\\\"$$PWD/\\\" tst_QDBusConnection=tst_QDBusConnection_SpyHook
+include(../dbus-testcase.pri)
diff --git a/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp
new file mode 100644
index 0000000000..fa1c19920a
--- /dev/null
+++ b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDBus/QDBusMessage>
+
+#define HAS_HOOKSETUPFUNCTION 1
+static void hookSetupFunction();
+
+// Ugly hack, look away
+#include "../qdbusconnection/tst_qdbusconnection.cpp"
+
+QT_BEGIN_NAMESPACE
+extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*Hook)(const QDBusMessage&));
+QT_END_NAMESPACE
+
+static void hookFunction(const QDBusMessage &)
+{
+// qDebug() << "hook called";
+ ++tst_QDBusConnection::hookCallCount;
+}
+
+static void hookSetupFunction()
+{
+ QT_PREPEND_NAMESPACE(qDBusAddSpyHook)(hookFunction);
+}
+
+QTEST_MAIN(tst_QDBusConnection_SpyHook)
diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
index 799ae3379d..5494959aaf 100644
--- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
@@ -402,6 +402,7 @@ public:
VirtualObject() :success(true) {}
QString introspect(const QString &path) const {
+ Q_ASSERT(QThread::currentThread() == thread());
if (path == "/some/path/superNode")
return "zitroneneis";
if (path == "/some/path/superNode/foo")
@@ -412,6 +413,7 @@ public:
}
bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) {
+ Q_ASSERT(QThread::currentThread() == thread());
++callCount;
lastMessage = message;
diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
index c614110b66..c5117228d3 100644
--- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -37,6 +37,11 @@
#include <QtDBus/private/qdbusconnection_p.h>
#include <QtDBus/private/qdbus_symbols_p.h>
+#ifndef DBUS_TYPE_UNIX_FD
+# define DBUS_TYPE_UNIX_FD int('h')
+# define DBUS_TYPE_UNIX_FD_AS_STRING "h"
+#endif
+
static const char serviceName[] = "org.qtproject.autotests.qpong";
static const char objectPath[] = "/org/qtproject/qpong";
static const char *interfaceName = serviceName;
@@ -1084,9 +1089,6 @@ static bool canSendUnixFd(DBusConnection *connection)
can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type");
#endif
-#ifndef DBUS_TYPE_UNIX_FD
-# define DBUS_TYPE_UNIX_FD int('h')
-#endif
return can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD);
}
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index ac9dadee47..2dbb078ae0 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -50,6 +50,8 @@ private slots:
void nextImageDelay();
void pngCompression_data();
void pngCompression();
+ void write_data();
+ void write();
private:
QString m_IconPath;
@@ -296,6 +298,51 @@ void tst_QIcoImageFormat::pngCompression()
QCOMPARE(image.height(), height);
}
+void tst_QIcoImageFormat::write_data()
+{
+ QTest::addColumn<QSize>("inSize");
+ QTest::addColumn<QSize>("outSize");
+
+ QTest::newRow("64x64") << QSize(64, 64) << QSize(64, 64);
+ QTest::newRow("128x200") << QSize(128, 200) << QSize(128, 200);
+ QTest::newRow("256x256") << QSize(256, 256) << QSize(256, 256);
+ QTest::newRow("400x400") << QSize(400, 400) << QSize(256, 256);
+}
+
+void tst_QIcoImageFormat::write()
+{
+ QFETCH(QSize, inSize);
+ QFETCH(QSize, outSize);
+
+ QImage inImg;
+ {
+ QImageReader reader(m_IconPath + "/valid/Qt.ico");
+ reader.jumpToImage(4);
+ reader.setScaledSize(inSize);
+ inImg = reader.read();
+ QVERIFY(!inImg.isNull());
+ QCOMPARE(inImg.size(), inSize);
+ }
+
+ QBuffer buf;
+ {
+ buf.open(QIODevice::WriteOnly);
+ QImageWriter writer(&buf, "ico");
+ QVERIFY(writer.write(inImg));
+ buf.close();
+ }
+ {
+ buf.open(QIODevice::ReadOnly);
+ QImageReader reader(&buf);
+ QVERIFY(reader.canRead());
+ QCOMPARE(reader.format(), QByteArray("ico"));
+ QImage outImg = reader.read();
+ QVERIFY(!outImg.isNull());
+ QCOMPARE(outImg.size(), outSize);
+ buf.close();
+ }
+}
+
QTEST_MAIN(tst_QIcoImageFormat)
#include "tst_qicoimageformat.moc"
diff --git a/tests/auto/gui/image/qimagewriter/images/App.ico b/tests/auto/gui/image/qimagewriter/images/App.ico
new file mode 100644
index 0000000000..03b80a68f8
--- /dev/null
+++ b/tests/auto/gui/image/qimagewriter/images/App.ico
Binary files differ
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index f48fab4f0a..9e747f8b11 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -179,6 +179,7 @@ void tst_QImageWriter::writeImage_data()
QTest::newRow("PBM: ship63") << QString("ship63.pbm") << true << QByteArray("pbm");
QTest::newRow("XBM: gnus") << QString("gnus.xbm") << false << QByteArray("xbm");
QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg");
+ QTest::newRow("ICO: App") << QString("App.ico") << true << QByteArray("ico");
}
void tst_QImageWriter::writeImage()
@@ -240,7 +241,7 @@ void tst_QImageWriter::writeImage2_data()
QTest::addColumn<QImage>("image");
const QStringList formats = QStringList() << "bmp" << "xpm" << "png"
- << "ppm"; //<< "jpeg";
+ << "ppm" << "ico"; //<< "jpeg";
QImage image0(70, 70, QImage::Format_ARGB32);
image0.fill(QColor(Qt::red).rgb());
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 188c35c14c..894b197968 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -110,158 +110,10 @@ void tst_QFont::exactMatch()
// Check if a non-existing font hasn't an exact match
font = QFont( "BogusFont", 33 );
QVERIFY( !font.exactMatch() );
-
-#ifdef Q_OS_WIN
- QSKIP("Exact matching on windows misses a lot because of the sample chars");
-#endif
-
-
- if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) {
- QVERIFY(QFont("sans").exactMatch());
- QVERIFY(QFont("sans-serif").exactMatch());
- QVERIFY(QFont("serif").exactMatch());
- QVERIFY(QFont("monospace").exactMatch());
- }
-
- QSKIP("This test is bogus on Unix with support for font aliases in fontconfig");
-
- QFontDatabase fdb;
-
- QList<QFontDatabase::WritingSystem> systems = fdb.writingSystems();
- for (int system = 0; system < systems.count(); ++system) {
- QStringList families = fdb.families(systems[system]);
- if (families.isEmpty())
- return;
-
- QStringList::ConstIterator f_it, f_end = families.end();
- for (f_it = families.begin(); f_it != f_end; ++f_it) {
- const QString &family = *f_it;
- if (family.contains('['))
- continue;
-
- QStringList styles = fdb.styles(family);
- QVERIFY(!styles.isEmpty());
- QStringList::ConstIterator s_it, s_end = styles.end();
- for (s_it = styles.begin(); s_it != s_end; ++s_it) {
- const QString &style = *s_it;
-
- if (fdb.isSmoothlyScalable(family, style)) {
- // smoothly scalable font... don't need to load every pointsize
- font = fdb.font(family, style, 12);
- QFontInfo fontinfo(font);
-
- if (! fontinfo.exactMatch()) {
- // Unfortunately, this can fail, since
- // QFontDatabase does not fill in all font
- // properties. Check to make sure that the
- // test didn't fail for obvious reasons
-
- if (fontinfo.family().isEmpty()
- && fontinfo.pointSize() == 0) {
- // this is a box rendering engine... this can happen from
- // time to time, especially on X11 with iso10646-1 or
- // unknown font encodings
- continue;
- }
-
-#ifdef Q_OS_WIN
- if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) {
- /* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s",
- font.family().latin1(), fontinfo.family().latin1());
- */
- } else
-#endif
- {
- if (!(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty())) {
- qDebug("Test about to fail for font: %s, fontinfo: %s",
- font.family().toLatin1().constData(),
- fontinfo.family().toLatin1().constData());
- }
- QVERIFY(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty());
- }
- if (font.pointSize() != -1) {
- QCOMPARE(font.pointSize(), fontinfo.pointSize());
- } else {
- QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
- }
- QCOMPARE(font.italic(), fontinfo.italic());
- if (font.weight() != fontinfo.weight()) {
- qDebug("font is %s", font.toString().toLatin1().constData());
- }
- QCOMPARE(font.weight(), fontinfo.weight());
- } else {
- font.setFixedPitch(!fontinfo.fixedPitch());
- QFontInfo fontinfo1(font);
- QVERIFY( !fontinfo1.exactMatch() );
-
- font.setFixedPitch(fontinfo.fixedPitch());
- QFontInfo fontinfo2(font);
- QVERIFY( fontinfo2.exactMatch() );
- }
- }
-#if 0
- // ############## can only work if we have float point sizes in QFD
- else {
- QList<int> sizes = fdb.pointSizes(family, style);
- QVERIFY(!sizes.isEmpty());
- QList<int>::ConstIterator z_it, z_end = sizes.end();
- for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
- const int size = *z_it;
-
- // Initialize the font, and check if it is an exact match
- font = fdb.font(family, style, size);
- QFontInfo fontinfo(font, (QFont::Script) script);
-
- if (! fontinfo.exactMatch()) {
- // Unfortunately, this can fail, since
- // QFontDatabase does not fill in all font
- // properties. Check to make sure that the
- // test didn't fail for obvious reasons
-
- if (fontinfo.family().isEmpty()
- && fontinfo.pointSize() == 0) {
- // this is a box rendering engine... this can happen from
- // time to time, especially on X11 with iso10646-1 or
- // unknown font encodings
- continue;
- }
-
- // no need to skip MS-fonts here it seems
- if (!(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty())) {
- qDebug("Test about to fail for font: %s, fontinfo: %s",
- font.family().latin1(), fontinfo.family().latin1());
- }
- QVERIFY(font.family() == fontinfo.family()
- || fontinfo.family().contains(font.family())
- || fontinfo.family().isEmpty());
- if (font.pointSize() != -1) {
- QCOMPARE(font.pointSize(), fontinfo.pointSize());
- } else {
- QCOMPARE(font.pixelSize(), fontinfo.pixelSize());
- }
- QCOMPARE(font.italic(), fontinfo.italic());
- QCOMPARE(font.weight(), fontinfo.weight());
- } else {
- font.setFixedPitch(!fontinfo.fixedPitch());
- QFontInfo fontinfo1(font, (QFont::Script) script);
- QVERIFY( !fontinfo1.exactMatch() );
-
- font.setFixedPitch(fontinfo.fixedPitch());
- QFontInfo fontinfo2(font, (QFont::Script) script);
- QVERIFY( fontinfo2.exactMatch() );
- }
- }
- }
-#endif
- }
- }
- }
+ QVERIFY(!QFont("sans").exactMatch());
+ QVERIFY(!QFont("sans-serif").exactMatch());
+ QVERIFY(!QFont("serif").exactMatch());
+ QVERIFY(!QFont("monospace").exactMatch());
}
void tst_QFont::italicOblique()
diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
index 6c4399e96e..55053842dc 100644
--- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
+++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
@@ -47,6 +47,8 @@ private Q_SLOTS:
void ntlmAuth_data();
void ntlmAuth();
+
+ void equalityOperators();
};
tst_QAuthenticator::tst_QAuthenticator()
@@ -147,6 +149,20 @@ void tst_QAuthenticator::ntlmAuth()
QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM "));
}
+void tst_QAuthenticator::equalityOperators()
+{
+ QAuthenticator s1, s2;
+ QVERIFY(s2 == s1);
+ QVERIFY(s1 == s2);
+ QVERIFY(!(s1 != s2));
+ QVERIFY(!(s2 != s1));
+ s1.setUser("User");
+ QVERIFY(!(s2 == s1));
+ QVERIFY(!(s1 == s2));
+ QVERIFY(s1 != s2);
+ QVERIFY(s2 != s1);
+}
+
QTEST_MAIN(tst_QAuthenticator);
#include "tst_qauthenticator.moc"
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 3a8d27631e..ccc31cf2d3 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -160,8 +160,9 @@ void tst_Cmptest::compare_unregistered_enums()
void tst_Cmptest::compare_registered_enums()
{
- QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor);
- QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor);
+ // use an enum that doesn't start at 0
+ QCOMPARE(Qt::Monday, Qt::Monday);
+ QCOMPARE(Qt::Monday, Qt::Sunday);
}
void tst_Cmptest::compare_class_enums()
diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml
index 73ef7be9f7..89055a3a91 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.lightxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml
@@ -16,8 +16,8 @@
<TestFunction name="compare_registered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="164">
<Description><![CDATA[Compared values are not the same
- Actual (Qt::ArrowCursor): ArrowCursor
- Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+ Actual (Qt::Monday): Monday
+ Expected (Qt::Sunday): Sunday]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity
index cfef152f0b..035907ab63 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.teamcity
+++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity
@@ -5,7 +5,7 @@
##teamcity[testFailed name='compare_unregistered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(158)|]' details='Compared values are not the same']
##teamcity[testFinished name='compare_unregistered_enums()']
##teamcity[testStarted name='compare_registered_enums()']
-##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(164)|]' details='Compared values are not the same|n Actual (Qt::ArrowCursor): ArrowCursor|n Expected (Qt::BusyCursor) : BusyCursor']
+##teamcity[testFailed name='compare_registered_enums()' message='Failure! |[Loc: tst_cmptest.cpp(164)|]' details='Compared values are not the same|n Actual (Qt::Monday): Monday|n Expected (Qt::Sunday): Sunday']
##teamcity[testFinished name='compare_registered_enums()']
##teamcity[testStarted name='compare_class_enums()']
##teamcity[testFailed name='compare_class_enums()' message='Failure! |[Loc: tst_cmptest.cpp(170)|]' details='Compared values are not the same|n Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1|n Expected (MyClassEnum::MyClassEnumValue2): MyClassEnumValue2']
diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt
index 8d403f4a8d..9d125b3602 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.txt
+++ b/tests/auto/testlib/selftests/expected_cmptest.txt
@@ -4,8 +4,8 @@ PASS : tst_Cmptest::initTestCase()
FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same
Loc: [tst_cmptest.cpp(158)]
FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same
- Actual (Qt::ArrowCursor): ArrowCursor
- Expected (Qt::BusyCursor) : BusyCursor
+ Actual (Qt::Monday): Monday
+ Expected (Qt::Sunday): Sunday
Loc: [tst_cmptest.cpp(164)]
FAIL! : tst_Cmptest::compare_class_enums() Compared values are not the same
Actual (MyClassEnum::MyClassEnumValue1): MyClassEnumValue1
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml
index 18807008d7..776560f639 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xml
@@ -18,8 +18,8 @@
<TestFunction name="compare_registered_enums">
<Incident type="fail" file="tst_cmptest.cpp" line="164">
<Description><![CDATA[Compared values are not the same
- Actual (Qt::ArrowCursor): ArrowCursor
- Expected (Qt::BusyCursor) : BusyCursor]]></Description>
+ Actual (Qt::Monday): Monday
+ Expected (Qt::Sunday): Sunday]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
index 925c725924..4299b99846 100644
--- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml
+++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml
@@ -11,8 +11,8 @@
</testcase>
<testcase result="fail" name="compare_registered_enums">
<failure message="Compared values are not the same
- Actual (Qt::ArrowCursor): ArrowCursor
- Expected (Qt::BusyCursor) : BusyCursor" result="fail"/>
+ Actual (Qt::Monday): Monday
+ Expected (Qt::Sunday): Sunday" result="fail"/>
</testcase>
<testcase result="fail" name="compare_class_enums">
<failure message="Compared values are not the same
diff --git a/tests/auto/tools/moc/backslash-newlines.h b/tests/auto/tools/moc/backslash-newlines.h
index 20e9571c00..081d80dc7a 100644
--- a/tests/auto/tools/moc/backslash-newlines.h
+++ b/tests/auto/tools/moc/backslash-newlines.h
@@ -52,3 +52,5 @@ public slots:
#undef value
#endif // BACKSLASH_NEWLINES_H
+
+// ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \ \ No newline at end of file
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index b836cdf00b..7d4fe2d499 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -547,6 +547,22 @@ void tst_QFiledialog::completer()
if (expectedFile.startsWith(input, caseSensitivity))
++expected;
}
+ // The temporary dir may create a node in QFileSystemModel
+ // which will bypass filters. If the path to the temporary
+ // dir contains an element which should be a subdirectory
+ // of x dir, but which is not listed, then take it into
+ // accont.
+ if (!tempDir.isNull()) {
+ QString xPath = x.absolutePath();
+ if (!xPath.endsWith(QLatin1Char('/')))
+ xPath.append(QLatin1Char('/'));
+ QString tmpPath = tempDir->path();
+ if (tmpPath.startsWith(xPath)) {
+ QString bypassedDirName = tmpPath.mid(xPath.size()).section(QLatin1Char('/'), 0, 0);
+ if (!expectedFiles.contains(bypassedDirName))
+ ++expected;
+ }
+ }
}
QTRY_COMPARE(cModel->rowCount(), expected);
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 53d7cae837..5f314cddc4 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -121,6 +121,8 @@ private slots:
void doNotUnwatchOnFailedRmdir();
void specialFiles();
+ void fileInfo();
+
protected:
bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList());
@@ -1106,6 +1108,25 @@ void tst_QFileSystemModel::specialFiles()
QTRY_VERIFY(!fileListUnderIndex(&model, rootIndex).contains(testFileName));
}
+void tst_QFileSystemModel::fileInfo()
+{
+ QFileSystemModel model;
+ QModelIndex idx;
+
+ QVERIFY(model.fileInfo(idx).filePath().isEmpty());
+
+ const QString dirPath = flatDirTestPath;
+ QDir dir(dirPath);
+ const QString subdir = QStringLiteral("subdir");
+ QVERIFY(dir.mkdir(subdir));
+ const QString subdirPath = dir.absoluteFilePath(subdir);
+
+ idx = model.setRootPath(subdirPath);
+ QCOMPARE(model.fileInfo(idx), QFileInfo(subdirPath));
+ idx = model.setRootPath(dirPath);
+ QCOMPARE(model.fileInfo(idx), QFileInfo(dirPath));
+}
+
QTEST_MAIN(tst_QFileSystemModel)
#include "tst_qfilesystemmodel.moc"
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 6b964bc776..a5aaf62855 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -188,11 +188,14 @@ void tst_QFontDialog::task256466_wrongStyle()
for (int i = 0; i < familyList->model()->rowCount(); ++i) {
QModelIndex currentFamily = familyList->model()->index(i, 0);
familyList->setCurrentIndex(currentFamily);
+ int expectedSize = sizeList->currentIndex().data().toInt();
const QFont current = dialog.currentFont(),
expected = fdb.font(currentFamily.data().toString(),
- styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt());
+ styleList->currentIndex().data().toString(), expectedSize);
QCOMPARE(current.family(), expected.family());
QCOMPARE(current.style(), expected.style());
+ if (expectedSize == 0 && !QFontDatabase().isScalable(current.family(), current.styleName()))
+ QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue);
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
}
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 4cf602a548..8908b83f11 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -3667,16 +3667,19 @@ static QByteArray msgPointMismatch(const QPoint &actual, const QPoint &expected)
void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
{
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
- const QSize size = availableGeometry.size() / 5;
+ const QSize size = availableGeometry.size() / 4;
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform.
view.setWindowTitle(QTest::currentTestFunction());
view.resize(size);
view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100));
- QWidget *embeddedWidget = new QWidget;
- embeddedWidget->setFixedSize(size / 2);
- QWidget *childWidget = new QWidget(embeddedWidget);
+ QWidget *embeddedWidget = new QGroupBox(QLatin1String("Embedded"));
+ embeddedWidget->setStyleSheet(QLatin1String("background-color: \"yellow\"; "));
+ embeddedWidget->setFixedSize((size - QSize(10, 10)) / 2);
+ QWidget *childWidget = new QGroupBox(QLatin1String("Child"), embeddedWidget);
childWidget->setStyleSheet(QLatin1String("background-color: \"red\"; "));
childWidget->resize(embeddedWidget->size() / 2);
childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget
@@ -3690,18 +3693,16 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
// This should be equivalent to the view center give or take rounding
// errors due to odd window margins
const QPoint viewCenter = view.geometry().center();
- QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2,
+ QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 3,
msgPointMismatch(embeddedCenterGlobal, viewCenter).constData());
- // Same test with child centered on embeddedWidget. The correct
- // mapping is not implemented yet, but at least make sure
+ // Same test with child centered on embeddedWidget. Also make sure
// the roundtrip maptoGlobal()/mapFromGlobal() returns the same
// point since that is important for mouse event handling (QTBUG-50030,
// QTBUG-50136).
const QPoint childCenter = childWidget->rect().center();
const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter);
QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter);
- QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue);
QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4,
msgPointMismatch(childCenterGlobal, viewCenter).constData());
}
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 445e5e7ac7..cf8ee310d3 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -188,6 +188,7 @@ private slots:
void taskQTBUG_8777_scrollToSpans();
void taskQTBUG_10169_sizeHintForRow();
void taskQTBUG_30653_doItemsLayout();
+ void taskQTBUG_50171_selectRowAfterSwapColumns();
#ifndef QT_NO_WHEELEVENT
void mouseWheel_data();
@@ -4475,5 +4476,40 @@ void tst_QTableView::taskQTBUG_7232_AllowUserToControlSingleStep()
QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep());
}
+void tst_QTableView::taskQTBUG_50171_selectRowAfterSwapColumns()
+{
+ {
+ QtTestTableView tableView;
+ QtTestTableModel model(2, 3);
+ tableView.setModel(&model);
+
+ tableView.horizontalHeader()->swapSections(1, 2);
+ tableView.horizontalHeader()->hideSection(0);
+ tableView.selectRow(1);
+
+ QItemSelectionModel* tableSelectionModel = tableView.selectionModel();
+ QCOMPARE(tableSelectionModel->isRowSelected(1, QModelIndex()), true);
+ QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 0)), false);
+ QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 1)), false);
+ QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 2)), false);
+ }
+
+ {
+ QtTestTableView tableView;
+ QtTestTableModel model(3, 2);
+ tableView.setModel(&model);
+
+ tableView.verticalHeader()->swapSections(1, 2);
+ tableView.verticalHeader()->hideSection(0);
+ tableView.selectColumn(1);
+
+ QItemSelectionModel* sModel = tableView.selectionModel();
+ QCOMPARE(sModel->isColumnSelected(1, QModelIndex()), true);
+ QCOMPARE(sModel->isSelected(tableView.model()->index(0, 0)), false);
+ QCOMPARE(sModel->isSelected(tableView.model()->index(1, 0)), false);
+ QCOMPARE(sModel->isSelected(tableView.model()->index(2, 0)), false);
+ }
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 0a344cd52d..98a4caf49e 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -1,10 +1,8 @@
# OSX QTBUG-25300 QTBUG-45502
[normalGeometry]
ubuntu-14.04
-osx
[saveRestoreGeometry]
ubuntu-14.04
-osx
[restoreVersion1Geometry]
ubuntu-14.04
osx
@@ -21,20 +19,12 @@ ubuntu-14.04
ubuntu-14.04
[largerThanScreen_QTBUG30142]
ubuntu-14.04
-[windowState]
-osx
[showMaximized]
osx
[setGeometry]
osx
-[stackUnder]
-osx
[raise]
osx
-[widgetAt]
-osx
-[sheetOpacity]
-osx
[resizeEvent]
osx
[setWindowGeometry]
@@ -51,12 +41,6 @@ osx
osx
[render_systemClip]
osx
-[update]
-osx
-[doubleRepaint]
-osx
-[childAt_unifiedToolBar]
-osx
[showMinimizedKeepsFocus]
osx-10.10
[moveWindowInShowEvent:1]
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index fc6c66de2e..78fbae768a 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -221,7 +221,6 @@ private slots:
void widgetAt();
#ifdef Q_OS_OSX
- void sheetOpacity();
void setMask();
#endif
void optimizedResizeMove();
@@ -381,7 +380,6 @@ private slots:
void movedAndResizedAttributes();
void childAt();
#ifdef Q_OS_OSX
- void childAt_unifiedToolBar();
void taskQTBUG_11373();
#endif
void taskQTBUG_17333_ResizeInfiniteRecursion();
@@ -1750,6 +1748,10 @@ void tst_QWidget::activation()
void tst_QWidget::windowState()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("xcb"))
QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail.");
if (m_platform == QStringLiteral("wayland"))
@@ -1957,6 +1959,10 @@ void tst_QWidget::showMaximized()
void tst_QWidget::showFullScreen()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
QWidget plain;
@@ -2312,6 +2318,10 @@ void tst_QWidget::reparent()
// Qt/Embedded does it differently.
void tst_QWidget::icon()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
QPixmap p(20,20);
p.fill(Qt::red);
QScopedPointer<QWidget> testWidget(new QWidget);
@@ -2374,6 +2384,10 @@ void tst_QWidget::hideWhenFocusWidgetIsChild()
void tst_QWidget::normalGeometry()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
QWidget parent;
@@ -2721,8 +2735,6 @@ void tst_QWidget::raise()
}
}
-// Cocoa has no Z-Order for views, we hack it, but it results in paint events.
-#ifndef QT_OS_MAC
void tst_QWidget::lower()
{
QScopedPointer<QWidget> parent(new QWidget);
@@ -2784,12 +2796,13 @@ void tst_QWidget::lower()
list2 << child4 << child1 << child2 << child3;
QCOMPARE(parent->children(), list2);
}
-#endif
-// Cocoa has no Z-Order for views, we hack it, but it results in paint events.
-#ifndef QT_OS_MAC
void tst_QWidget::stackUnder()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974: Cocoa has no Z-Order for views, we hack it, but it results in paint events.");
+#endif
+
QScopedPointer<QWidget> parent(new QWidget);
parent->setObjectName(QLatin1String("stackUnder"));
parent->setWindowTitle(parent->objectName());
@@ -2867,7 +2880,6 @@ void tst_QWidget::stackUnder()
child->reset();
}
}
-#endif
void drawPolygon(QPaintDevice *dev, int w, int h)
{
@@ -2956,6 +2968,10 @@ void tst_QWidget::testContentsPropagation()
void tst_QWidget::saveRestoreGeometry()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
const QPoint position = m_availableTopLeft + QPoint(100, 100);
@@ -3181,6 +3197,10 @@ void tst_QWidget::restoreVersion1Geometry()
void tst_QWidget::widgetAt()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
Q_CHECK_PAINTEVENTS
@@ -3388,17 +3408,6 @@ void tst_QWidget::testDeletionInEventHandlers()
}
#ifdef Q_OS_OSX
-void tst_QWidget::sheetOpacity()
-{
- QWidget tmpWindow;
- QWidget sheet(&tmpWindow, Qt::Sheet);
- tmpWindow.show();
- sheet.show();
- QCOMPARE(int(sheet.windowOpacity() * 255), 242); // 95%
- sheet.setParent(0, Qt::Dialog);
- QCOMPARE(int(sheet.windowOpacity() * 255), 255);
-}
-
class MaskedPainter : public QWidget
{
public:
@@ -4036,6 +4045,10 @@ void tst_QWidget::showHideEventWhileMinimize()
void tst_QWidget::update()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
QTest::qWait(10); // Wait for the initStuff to do it's stuff.
Q_CHECK_PAINTEVENTS
@@ -5021,10 +5034,13 @@ void tst_QWidget::showAndMoveChild()
VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), Qt::red);
}
-// Cocoa only has rect granularity.
-#ifndef QT_OS_MAC
+
void tst_QWidget::subtractOpaqueSiblings()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974: Cocoa only has rect granularity.");
+#endif
+
QWidget w;
w.setGeometry(50, 50, 300, 300);
@@ -5057,7 +5073,6 @@ void tst_QWidget::subtractOpaqueSiblings()
QRegion(medium->geometry().translated(large->pos()))
- tall->geometry());
}
-#endif
void tst_QWidget::deleteStyle()
{
@@ -5099,6 +5114,10 @@ public slots:
void tst_QWidget::multipleToplevelFocusCheck()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
TopLevelFocusCheck w1;
@@ -7757,6 +7776,10 @@ void tst_QWidget::sendUpdateRequestImmediately()
void tst_QWidget::doubleRepaint()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974");
+#endif
+
#if defined(Q_OS_OSX)
if (!macHasAccessToWindowsServer())
QSKIP("Not having window server access causes the wrong number of repaints to be issues");
@@ -9269,10 +9292,6 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy()
void tst_QWidget::movedAndResizedAttributes()
{
-#if defined (Q_OS_OSX)
- QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort);
- QVERIFY(false);
-#else
// Use Qt::Tool as fully decorated windows have a minimum width of 160 on
QWidget w(0, Qt::Tool);
w.show();
@@ -9318,7 +9337,6 @@ void tst_QWidget::movedAndResizedAttributes()
w.resize(100, 100);
QVERIFY(w.testAttribute(Qt::WA_Moved));
QVERIFY(w.testAttribute(Qt::WA_Resized));
-#endif
}
void tst_QWidget::childAt()
@@ -9377,46 +9395,11 @@ void tst_QWidget::childAt()
}
#ifdef Q_OS_OSX
-void tst_QWidget::childAt_unifiedToolBar()
-{
- QLabel *label = new QLabel(QLatin1String("foo"));
- QToolBar *toolBar = new QToolBar;
- toolBar->addWidget(new QLabel("dummy"));
- toolBar->addWidget(label);
-
- QMainWindow mainWindow;
- mainWindow.addToolBar(toolBar);
- mainWindow.show();
-
- // Calculate the top-left corner of the tool bar and the label (in mainWindow's coordinates).
- QPoint labelTopLeft = label->mapTo(&mainWindow, QPoint());
- QPoint toolBarTopLeft = toolBar->mapTo(&mainWindow, QPoint());
-
- QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast<QWidget *>(toolBar));
- QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
-
- // Enable unified tool bars.
- mainWindow.setUnifiedTitleAndToolBarOnMac(true);
- QTest::qWait(50);
-
- // The tool bar is now in the "non-client" area of QMainWindow, i.e.
- // outside the mainWindow's rect(), and since mapTo et al. doesn't work
- // in that case (see commit 35667fd45ada49269a5987c235fdedfc43e92bb8),
- // we use mapToGlobal/mapFromGlobal to re-calculate the corners.
- QPoint oldToolBarTopLeft = toolBarTopLeft;
- toolBarTopLeft = mainWindow.mapFromGlobal(toolBar->mapToGlobal(QPoint()));
- QVERIFY2(toolBarTopLeft != oldToolBarTopLeft,
- msgComparisonFailed(toolBarTopLeft, "!=", oldToolBarTopLeft));
- QVERIFY2(toolBarTopLeft.y() < 0,
- msgComparisonFailed(toolBarTopLeft.y(), "<", 0));
- labelTopLeft = mainWindow.mapFromGlobal(label->mapToGlobal(QPoint()));
-
- QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast<QWidget *>(toolBar));
- QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
-}
void tst_QWidget::taskQTBUG_11373()
{
+ QSKIP("QTBUG-52974");
+
QScopedPointer<QMainWindow> myWindow(new QMainWindow);
QWidget * center = new QWidget();
myWindow -> setCentralWidget(center);
@@ -9432,6 +9415,7 @@ void tst_QWidget::taskQTBUG_11373()
// The drawer should still not be visible, since we haven't shown it.
QCOMPARE(drawer->isVisible(), false);
}
+
#endif
void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
@@ -10279,6 +10263,9 @@ public:
// when mousing over it.
void tst_QWidget::taskQTBUG_27643_enterEvents()
{
+#ifdef Q_OS_OSX
+ QSKIP("QTBUG-52974: this test can crash!");
+#endif
// Move the mouse cursor to a safe location so it won't interfere
QCursor::setPos(m_safeCursorPos);
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index a5a94f109a..2b8f3032bf 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -486,7 +486,7 @@ void tst_QMdiArea::subWindowActivated2()
mdiArea.show();
mdiArea.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_VERIFY(!spy.isEmpty()); // Normally 1, but 2 events might be received on some X11 window managers
QVERIFY(mdiArea.currentSubWindow());
QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow);
spy.clear();
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 436a8331f0..e9f5175466 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -127,10 +127,12 @@ private slots:
void closeOnSecondClickAndOpenOnThirdClick();
void cornerWidgets_data();
void cornerWidgets();
+ void taskQTBUG53205_crashReparentNested();
protected slots:
void onSimpleActivated( QAction*);
void onComplexActionTriggered();
+ void slotForTaskQTBUG53205();
private:
TestMenu initSimpleMenuBar(QMenuBar *mb);
@@ -143,6 +145,7 @@ private:
QAction* m_lastSimpleAcceleratorId;
int m_simpleActivatedCount;
int m_complexTriggerCount[int('k')];
+ QMenuBar* taskQTBUG53205MenuBar;
};
// Testing get/set functions
@@ -1438,5 +1441,61 @@ void tst_QMenuBar::cornerWidgets()
delete cornerLabel;
}
+
+void tst_QMenuBar::taskQTBUG53205_crashReparentNested()
+{
+ // This test was largely inspired by the test case submitted for the bug
+ QMainWindow mainWindow;
+ mainWindow.resize(300, 200);
+ centerOnScreen(&mainWindow);
+ const TestMenu testMenus = initWindowWithComplexMenuBar(mainWindow);
+ QApplication::setActiveWindow(&mainWindow);
+
+ // they can't be windows
+ QWidget hiddenParent(&mainWindow, 0);
+ //this one is going to be moved around
+ QWidget movingParent(&hiddenParent, 0);
+
+ //set up the container widget
+ QWidget containerWidget(&movingParent,0);
+
+ //set the new parent, a window
+ QScopedPointer<QWidget> windowedParent;
+ windowedParent.reset(new QWidget(Q_NULLPTR, Qt::WindowFlags()));
+ windowedParent->setGeometry(400, 10, 300, 300);
+
+ windowedParent->show();
+ QVERIFY(QTest::qWaitForWindowExposed(windowedParent.data()));
+
+ //set the "container", can't be a window
+ QWidget containedWidget(&containerWidget, 0);
+
+ taskQTBUG53205MenuBar = new QMenuBar(&containedWidget);
+
+ connect(testMenus.actions[0], &QAction::triggered, this, &tst_QMenuBar::slotForTaskQTBUG53205);
+ //now, move things around
+ //from : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar
+ //to windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar
+ movingParent.setParent(windowedParent.data(),0);
+ // this resets the parenting and the menu bar's window
+ taskQTBUG53205MenuBar->setParent(Q_NULLPTR);
+ taskQTBUG53205MenuBar->setParent(&containedWidget);
+ //from windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar
+ //to : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar
+ movingParent.setParent(&hiddenParent,0);
+ windowedParent.reset(); //make the old window invalid
+ // trigger the aciton, reset the menu bar's window, this used to crash here.
+ testMenus.actions[0]->trigger();
+}
+
+void tst_QMenuBar::slotForTaskQTBUG53205()
+{
+ QWidget *parent = taskQTBUG53205MenuBar->parentWidget();
+ taskQTBUG53205MenuBar->setParent(Q_NULLPTR);
+ taskQTBUG53205MenuBar->setParent(parent);
+}
+
+
+
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"