From dbe9a8c9696428529cacb9dd4e004db99914b56e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 12 Apr 2016 16:05:10 +0200 Subject: Don't copy the functor object for each signal emission The behavior was different in the variadic template code and in the C++98 code. The code without variadic template support was not copying the functor object (e.g. a lambda) before calling it. However, in the variadic template section, QtPrivate::FunctorCall::call took the functor by value instead of by reference resulting in a copy. QtPrivate::FunctorCall::call is a helper function for QtPrivate::FunctionPointer::call which is only needed for variadic template expension. [ChangeLog][QtCore][QObject] If the compiler supports variadic templates, no longer copy functor connected to a signal each time the signal is emitted. Restoring the C++98 behavior. Task-number: QTBUG-52542 Change-Id: I3ca20ef6910893b8a288e70af7de4c7b69502173 Reviewed-by: Thiago Macieira --- tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f3334b1222..5b89ef3792 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -147,6 +147,7 @@ private slots: void qmlConnect(); void exceptions(); void noDeclarativeParentChangedOnDestruction(); + void mutableFunctor(); }; struct QObjectCreatedOnShutdown @@ -6420,6 +6421,24 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction() #endif } +struct MutableFunctor { + int count; + MutableFunctor() : count(0) {} + int operator()() { return ++count; } +}; + +void tst_QObject::mutableFunctor() +{ + ReturnValue o; + MutableFunctor functor; + QCOMPARE(functor.count, 0); + connect(&o, &ReturnValue::returnInt, functor); + QCOMPARE(emit o.returnInt(0), 1); + QCOMPARE(emit o.returnInt(0), 2); // each emit should increase the internal count + + QCOMPARE(functor.count, 0); // but the original object should have been copied at connect time +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro::Value); -- cgit v1.2.3 From 7ab0829823024dd07d15ff6786e3648388d4f28d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Apr 2016 13:38:18 -0700 Subject: Fix parsing of empty port sections in URLs The RFC does allow it. It even has examples showing them as valid. In section 6.2.3, it shows: http://example.com http://example.com/ http://example.com:/ http://example.com:80/ Change-Id: Id75834dab9ed466e94c7ffff1444b7195ad21cab Reviewed-by: Frederik Gladhorn Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index b284e5fc9c..eba058a13c 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -148,6 +148,8 @@ private slots: void hostFlags_data(); void hostFlags(); void setPort(); + void port_data(); + void port(); void toEncoded_data(); void toEncoded(); void setAuthority_data(); @@ -2205,8 +2207,6 @@ void tst_QUrl::strictParser_data() // FIXME: add some tests for prohibited BiDi (RFC 3454 section 6) // port errors happen in TolerantMode too - QTest::newRow("empty-port-1") << "http://example.com:" << "Port field was empty"; - QTest::newRow("empty-port-2") << "http://example.com:/" << "Port field was empty"; QTest::newRow("invalid-port-1") << "http://example.com:-1" << "Invalid port"; QTest::newRow("invalid-port-2") << "http://example.com:abc" << "Invalid port"; QTest::newRow("invalid-port-3") << "http://example.com:9a" << "Invalid port"; @@ -2783,6 +2783,31 @@ void tst_QUrl::setPort() } } +void tst_QUrl::port_data() +{ + QTest::addColumn("input"); + QTest::addColumn("port"); + + QTest::newRow("no-port-1") << "http://example.com" << -1; + QTest::newRow("no-port-2") << "http://example.com/" << -1; + QTest::newRow("empty-port-1") << "http://example.com:" << -1; + QTest::newRow("empty-port-2") << "http://example.com:/" << -1; + QTest::newRow("zero-port-1") << "http://example.com:0" << 0; + QTest::newRow("zero-port-2") << "http://example.com:0/" << 0; + QTest::newRow("set-port-1") << "http://example.com:80" << 80; + QTest::newRow("set-port-2") << "http://example.com:80/" << 80; +} + +void tst_QUrl::port() +{ + QFETCH(QString, input); + QFETCH(int, port); + + QUrl url(input); + QVERIFY(url.isValid()); + QCOMPARE(url.port(), port); +} + void tst_QUrl::toEncoded_data() { QTest::addColumn("url"); -- cgit v1.2.3 From 77fb9ca271e515f6a147d3dc7025bf3501c70fa0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Apr 2016 14:46:04 -0700 Subject: Fix encoding of IDN hostnames with QUrl::host When the formatting parameter wasn't exactly QUrl::EncodeUnicode, it wouldn't encode, despite having to. Change-Id: Id75834dab9ed466e94c7ffff1444bacc08dd109b Reviewed-by: Frederik Gladhorn Reviewed-by: Edward Welbourne --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index eba058a13c..ef210d4a64 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1749,6 +1749,9 @@ void tst_QUrl::symmetry() QUrl url(QString::fromUtf8("http://www.räksmörgås.se/pub?a=b&a=dø&a=f#vræl")); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.host(), QString::fromUtf8("www.räksmörgås.se")); + QCOMPARE(url.host(QUrl::EncodeSpaces), QString::fromUtf8("www.räksmörgås.se")); + QCOMPARE(url.host(QUrl::EncodeUnicode), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); + QCOMPARE(url.host(QUrl::EncodeUnicode | QUrl::EncodeSpaces), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); QCOMPARE(url.path(), QString::fromLatin1("/pub")); // this will be encoded ... QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData()); -- cgit v1.2.3 From 7094466f7d0c2176eb3080021a4ea5d220555df9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 30 Mar 2016 13:15:02 +0200 Subject: Interpret fixed CSS line-height as minimum rather than absolute The QTextBlockFormat::FixedHeight overrides the line height regardless of its calculated height. If the line contains objects or text which is higher than the specified line height, using FixedHeight will cause them to overlap with the previous line. This is not what happens in normal web browsers. The expected behavior is that the line height given in CSS is the minimum height, but that we still reserve space needed to display everything without overlaps. To make it possible for people to retain the old behavior, we introduce the -qt-line-height-type property, which allows them to override the default. This also fixes output from toHtml() to use the new property rather than set the minimum height of the paragraph or the "line-spacing" property, which does not exist in either CSS nor in Qt. [ChangeLog][QtGui][Important Behavior Changes] When line height is specified in pixels, this is now interpreted as the minimum line height rather than an absolute line height to avoid overlaps. To get the old behavior, use the -qt-line-height-type property in CSS and set it to "fixed". Task-number: QTBUG-51962 Change-Id: Ic2dde649b69209672170dad4c2de1e1c432a1078 Reviewed-by: Lars Knoll --- .../gui/text/qtextdocument/tst_qtextdocument.cpp | 88 +++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 04e6bba91e..1869139a98 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -183,6 +183,8 @@ private slots: void textCursorUsageWithinContentsChange(); void cssInheritance(); + + void lineHeightType(); private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); void buildRegExpData(); @@ -3191,7 +3193,7 @@ void tst_QTextDocument::cssInheritance() "

Foo

Bar

Baz

"); QTextBlock block = td.begin(); QTextBlockFormat fmt = block.blockFormat(); - QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::MinimumHeight)); QCOMPARE(fmt.lineHeight(), qreal(40)); block = block.next(); fmt = block.blockFormat(); @@ -3276,5 +3278,89 @@ void tst_QTextDocument::cssInheritance() } } +void tst_QTextDocument::lineHeightType() +{ + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::SingleHeight)); + QCOMPARE(format.lineHeight(), 0.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::MinimumHeight)); + QCOMPARE(format.lineHeight(), 40.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 200.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::SingleHeight)); + QCOMPARE(format.lineHeight(), 200.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(format.lineHeight(), 40.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(format.lineHeight(), 10.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::MinimumHeight)); + QCOMPARE(format.lineHeight(), 33.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(format.lineHeight(), 200.0); + } + + { + QTextDocument td; + td.setHtml("Foobar"); + QTextBlock block = td.begin(); + QTextBlockFormat format = block.blockFormat(); + QCOMPARE(int(format.lineHeightType()), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(format.lineHeight(), 200.0); + } +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" -- cgit v1.2.3 From 072485048fc8360b822e35b4cc43b0728e04cc1b Mon Sep 17 00:00:00 2001 From: Vyacheslav Grigoryev Date: Mon, 4 Apr 2016 01:03:20 +0300 Subject: QHeaderView: fixing selection of reordered rows and columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code incorrectly calculated visual region for a selection (specified by QItemSelection object) in case of reordered / swapped rows or columns. It used the leftmost and rightmost (upmost and downmost for vertical mode) logical indexes directly. However some middle logical index (in case of reorder) may be the leftmost or rightmost visual index. In such cases the repainting didn't work properly. This fix first checks whether reordering / swapping is in use. If it isn't (ie visual=logical) we use code similar to the old code. Otherwise the new code scans all selected logical indexes, translates them into visual ones and gets the correct leftmost and rightmost indexes. [ChangeLog][QtWidgets][QHeaderView] Fixed a repainting issue when items had been reordered. Task-number: QTBUG-50171 Change-Id: If6afabebf445cf32a8e0afe262b6ee149e7c4b2b Reviewed-by: Thorbjørn Lund Martsum --- .../itemviews/qheaderview/tst_qheaderview.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 55fcf04846..4736aa5c12 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -77,6 +77,7 @@ public: void testEvent(); void testhorizontalOffset(); void testverticalOffset(); + void testVisualRegionForSelection(); friend class tst_QHeaderView; }; @@ -211,6 +212,7 @@ private slots: void QTBUG8650_crashOnInsertSections(); void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); + void QTBUG50171_visualRegionForSwappedItems(); void ensureNoIndexAtLength(); void offsetConsistent(); @@ -2282,6 +2284,24 @@ void tst_QHeaderView::QTBUG14242_hideSectionAutoSize() QCOMPARE(calced_length, afterlength); } +void tst_QHeaderView::QTBUG50171_visualRegionForSwappedItems() +{ + protected_QHeaderView headerView(Qt::Horizontal); + QtTestModel model; + model.rows = 2; + model.cols = 3; + headerView.setModel(&model); + headerView.swapSections(1, 2); + headerView.hideSection(0); + headerView.testVisualRegionForSelection(); +} + +void protected_QHeaderView::testVisualRegionForSelection() +{ + QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2))); + QCOMPARE(r.boundingRect().contains(QRect(1, 1, length() - 2, 1)), true); +} + void tst_QHeaderView::ensureNoIndexAtLength() { QTableView qtv; -- cgit v1.2.3 From ccfe33dc670a1491d9e1daa2ae17f5fe30484276 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Apr 2016 11:22:32 +0200 Subject: QWidget::grab(): Use device pixel ratio. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return pixmaps with device pixel ratio similar to QScreen::grabWindow(), cf c0963486ce689e778d59dafd26d36d8ef9e3ee74. Adapt kernel tests accordingly. Task-number: QTBUG-52137 Change-Id: I9ce276d5e2d87ae0d39c8639267d1ac283fed854 Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 1c2a74109f..b9fe40e64c 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -3035,8 +3035,23 @@ protected: QSize sizeHint() const { return QSize(500, 500); } }; +// Scale to remove devicePixelRatio should scaling be active. +static QPixmap grabFromWidget(QWidget *w, const QRect &rect) +{ + QPixmap pixmap = w->grab(rect); + const qreal devicePixelRatio = pixmap.devicePixelRatioF(); + if (!qFuzzyCompare(devicePixelRatio, qreal(1))) { + pixmap = pixmap.scaled((QSizeF(pixmap.size()) / devicePixelRatio).toSize(), + Qt::KeepAspectRatio, Qt::SmoothTransformation); + pixmap.setDevicePixelRatio(1); + } + return pixmap; +} + void tst_QWidget::testContentsPropagation() { + if (!qFuzzyCompare(qApp->devicePixelRatio(), qreal(1))) + QSKIP("This test does not work with scaling."); ContentsPropagationWidget widget; widget.setFixedSize(500, 500); widget.setContentsPropagation(false); @@ -9208,7 +9223,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() QPixmap correct(main.size()); correct.fill(Qt::green); - const QPixmap mainPixmap = main.grab(QRect(QPoint(0, 0), QSize(-1, -1))); + const QPixmap mainPixmap = grabFromWidget(&main, QRect(QPoint(0, 0), QSize(-1, -1))); QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32), correct.toImage().convertToFormat(QImage::Format_RGB32)); @@ -9672,10 +9687,10 @@ void tst_QWidget::grab() p.drawTiledPixmap(0, 0, 128, 128, pal.brush(QPalette::Window).texture(), 0, 0); p.end(); - QPixmap actual = widget.grab(QRect(64, 64, 64, 64)); + QPixmap actual = grabFromWidget(&widget, QRect(64, 64, 64, 64)); QVERIFY(lenientCompare(actual, expected)); - actual = widget.grab(QRect(64, 64, -1, -1)); + actual = grabFromWidget(&widget, QRect(64, 64, -1, -1)); QVERIFY(lenientCompare(actual, expected)); // Make sure a widget that is not yet shown is grabbed correctly. -- cgit v1.2.3 From e27fae353ca9a2d4d5054d32bb3a2622ccf9d889 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 14 Apr 2016 18:57:14 +0300 Subject: QFileSystemModel: fix updating QFileInfo for a node after a file rename Use the correct parent path for the renamed file when creating QFileInfo. It must be a path to the parent directory, not to the root directory of the model. Modify tst_QFileSystemModel::setData() to test renames in subdirs of the root directory of the model. Change-Id: I69d9e3a937616857a81617791ed118af3f6eea05 Task-number: QTBUG-52561 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index d370a647b4..19b1d0e7c8 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -697,6 +697,7 @@ void tst_QFileSystemModel::nameFilters() } void tst_QFileSystemModel::setData_data() { + QTest::addColumn("subdirName"); QTest::addColumn("files"); QTest::addColumn("oldFileName"); QTest::addColumn("newFileName"); @@ -706,7 +707,15 @@ void tst_QFileSystemModel::setData_data() << QDir::temp().absolutePath() + '/' + "a" << false; */ - QTest::newRow("in current dir") << (QStringList() << "a" << "b" << "c") + QTest::newRow("in current dir") + << QString() + << (QStringList() << "a" << "b" << "c") + << "a" + << "d" + << true; + QTest::newRow("in subdir") + << "s" + << (QStringList() << "a" << "b" << "c") << "a" << "d" << true; @@ -715,15 +724,25 @@ void tst_QFileSystemModel::setData_data() void tst_QFileSystemModel::setData() { QSignalSpy spy(model, SIGNAL(fileRenamed(QString,QString,QString))); - QString tmp = flatDirTestPath; + QFETCH(QString, subdirName); QFETCH(QStringList, files); QFETCH(QString, oldFileName); QFETCH(QString, newFileName); QFETCH(bool, success); + QString tmp = flatDirTestPath; + if (!subdirName.isEmpty()) { + QDir dir(tmp); + QVERIFY(dir.mkdir(subdirName)); + tmp.append('/' + subdirName); + } QVERIFY(createFiles(tmp, files)); - QModelIndex root = model->setRootPath(tmp); - QTRY_COMPARE(model->rowCount(root), files.count()); + QModelIndex tmpIdx = model->setRootPath(flatDirTestPath); + if (!subdirName.isEmpty()) { + tmpIdx = model->index(tmp); + model->fetchMore(tmpIdx); + } + QTRY_COMPARE(model->rowCount(tmpIdx), files.count()); QModelIndex idx = model->index(tmp + '/' + oldFileName); QCOMPARE(idx.isValid(), true); @@ -731,16 +750,21 @@ void tst_QFileSystemModel::setData() model->setReadOnly(false); QCOMPARE(model->setData(idx, newFileName), success); + model->setReadOnly(true); if (success) { QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName); + QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName); QCOMPARE(model->index(arguments.at(0).toString()), model->index(tmp)); QCOMPARE(arguments.at(1).toString(), oldFileName); QCOMPARE(arguments.at(2).toString(), newFileName); QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true); } - QTRY_COMPARE(model->rowCount(root), files.count()); + QTRY_COMPARE(model->rowCount(tmpIdx), files.count()); + // cleanup + if (!subdirName.isEmpty()) + QVERIFY(QDir(tmp).removeRecursively()); } void tst_QFileSystemModel::sortPersistentIndex() -- cgit v1.2.3 From 84a49594d0bde29668fb66187ac1ef2c842393a3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Apr 2016 14:09:08 +0200 Subject: Windows/tst_QTcpServer: Suppress crash notification of crashingServer. Suppress message dialog of the test helper as does QTestlib. Task-number: QTBUG-52714 Change-Id: I5efd7d72f77c7689500ecaccf46f1f9dfb312140 Reviewed-by: Timur Pocheptsov --- tests/auto/network/socket/qtcpserver/crashingServer/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp index b53842e6ca..2b00af218a 100644 --- a/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp +++ b/tests/auto/network/socket/qtcpserver/crashingServer/main.cpp @@ -34,9 +34,16 @@ #include #include +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) +# include +#endif int main(int argc, char *argv[]) { + // Windows: Suppress crash notification dialog. +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) && defined(Q_CC_MSVC) + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); +#endif QCoreApplication app(argc, argv); QTcpServer server; -- cgit v1.2.3 From 16fa29352b7402c82624d6367231f67de836d17e Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 22 Apr 2016 13:51:31 +0200 Subject: QMimeDatabase: fix mimeTypeForUrl for mailto URLs The "path" of a mailto URL isn't a file, so we shouldn't try to do glob-based matching. I was getting application/x-ms-dos-executable for a .com domain and application/x-perl for a .pl domain... Change-Id: Ifc346c3bba83ba1a8476db3202492f4c2e4d52bb Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 1b4dc020f2..bbc086b048 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -518,6 +518,8 @@ void tst_QMimeDatabase::mimeTypeForUrl() QVERIFY(db.mimeTypeForUrl(QUrl::fromEncoded("http://foo/bar.png")).isDefault()); // HTTP can't know before downloading QCOMPARE(db.mimeTypeForUrl(QUrl::fromEncoded("ftp://foo/bar.png")).name(), QString::fromLatin1("image/png")); QCOMPARE(db.mimeTypeForUrl(QUrl::fromEncoded("ftp://foo/bar")).name(), QString::fromLatin1("application/octet-stream")); // unknown extension + QCOMPARE(db.mimeTypeForUrl(QUrl("mailto:something@example.com")).name(), QString::fromLatin1("application/octet-stream")); // unknown + QCOMPARE(db.mimeTypeForUrl(QUrl("mailto:something@polish.pl")).name(), QString::fromLatin1("application/octet-stream")); // unknown, NOT perl ;) } void tst_QMimeDatabase::mimeTypeForData_data() -- cgit v1.2.3 From 3a8f895d3529d59b7a1ea35705f86a2fcdeb35e4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Apr 2016 13:24:02 +0200 Subject: tst_QWidget/XCB: Use bottom/right corner of screen as safe cursor position. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pushing the mouse rapidly to the top left corner causes KDE / KWin to switch to "Present all Windows" (Ctrl+F9) mode, showing all windows. This has been observed to be triggered programmatically by QCursor::setPos(0, 0) if there is no other window beneath and apparently depending on the perceived mouse "speed". Suppress this by using the bottom right corner for XCB. Change-Id: Id18d2f45a095ed4d4f365f010cf45a20b0d9435e Reviewed-by: Tony Sarajärvi --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b9fe40e64c..55b6aff237 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -470,6 +470,7 @@ private: const QString m_platform; QSize m_testWidgetSize; QPoint m_availableTopLeft; + QPoint m_safeCursorPos; const bool m_windowsAnimationsEnabled; }; @@ -627,6 +628,7 @@ void tst_QWidget::getSetCheck() tst_QWidget::tst_QWidget() : m_platform(QGuiApplication::platformName().toLower()) + , m_safeCursorPos(0, 0) , m_windowsAnimationsEnabled(windowsAnimationsEnabled()) { if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild() @@ -669,7 +671,13 @@ void tst_QWidget::initTestCase() // to avoid Windows warnings about minimum size for decorated windows. int width = 200; const QScreen *screen = QGuiApplication::primaryScreen(); - m_availableTopLeft = screen->availableGeometry().topLeft(); + const QRect availableGeometry = screen->availableGeometry(); + m_availableTopLeft = availableGeometry.topLeft(); + // XCB: Determine "safe" cursor position at bottom/right corner of screen. + // Pushing the mouse rapidly to the top left corner can trigger KDE / KWin's + // "Present all Windows" (Ctrl+F9) feature also programmatically. + if (m_platform == QLatin1String("xcb")) + m_safeCursorPos = availableGeometry.bottomRight() - QPoint(40, 40); const int screenWidth = screen->geometry().width(); if (screenWidth > 2000) width = 100 * ((screenWidth + 500) / 1000); @@ -5669,7 +5677,7 @@ void tst_QWidget::setToolTip() // Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform. #ifndef Q_OS_WINCE_WM for (int pass = 0; pass < 2; ++pass) { - QCursor::setPos(0, 0); + QCursor::setPos(m_safeCursorPos); QScopedPointer popup(new QWidget(0, Qt::Popup)); popup->setObjectName(QString::fromLatin1("tst_qwidget setToolTip #%1").arg(pass)); popup->setWindowTitle(popup->objectName()); @@ -6020,7 +6028,7 @@ void tst_QWidget::childEvents() // Move away the cursor; otherwise it might result in an enter event if it's // inside the widget when the widget is shown. - QCursor::setPos(qApp->desktop()->availableGeometry().bottomRight()); + QCursor::setPos(m_safeCursorPos); QTest::qWait(100); { @@ -8883,7 +8891,7 @@ void tst_QWidget::syntheticEnterLeave() int numLeaveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(m_safeCursorPos); MyWidget window; window.setWindowFlags(Qt::WindowStaysOnTopHint); @@ -9003,7 +9011,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() int numEnterEvents, numMouseMoveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(m_safeCursorPos); SELParent parent; parent.move(200, 200); @@ -10179,7 +10187,7 @@ void tst_QWidget::destroyedSignal() void tst_QWidget::underMouse() { // Move the mouse cursor to a safe location - QCursor::setPos(0,0); + QCursor::setPos(m_safeCursorPos); ColorWidget topLevelWidget(0, Qt::FramelessWindowHint, Qt::blue); ColorWidget childWidget1(&topLevelWidget, Qt::Widget, Qt::yellow); @@ -10435,7 +10443,7 @@ public: void tst_QWidget::taskQTBUG_27643_enterEvents() { // Move the mouse cursor to a safe location so it won't interfere - QCursor::setPos(0,0); + QCursor::setPos(m_safeCursorPos); EnterTestMainDialog dialog; QPushButton button(&dialog); -- cgit v1.2.3 From 6e306e8d942464d969c3792e6299aa014a2d2b8f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Apr 2016 22:23:54 -0700 Subject: Disallow non-character Unicode codepoints in QUrl/QUrlQuery Since they are non-characters and should not be used for text interchange, it stands to reason that they should not appear in unencoded for in a URL. To change the behavior, we just need to toggle a simple flag for QUtf8Functions. This behavior also matches the recommendation from RFC 3987. We do not usually follow recommendations from that RFC (as it is generally believed to be a bad RFC), but this one seems like a good idea. Change-Id: Ifea6e497f11a461db432ffff1447486c623c12bd Reviewed-by: David Faure --- tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index 9af4345029..f5835ec5f4 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -998,7 +998,9 @@ void tst_QUrlInternal::encodingRecodeInvalidUtf8_data() QTest::addColumn("utf16"); extern void loadInvalidUtf8Rows(); + extern void loadNonCharactersRows(); loadInvalidUtf8Rows(); + loadNonCharactersRows(); QTest::newRow("utf8-mix-4") << QByteArray("\xE0.A2\x80"); QTest::newRow("utf8-mix-5") << QByteArray("\xE0\xA2.80"); -- cgit v1.2.3 From 3df159ba174c1775a0e77d2305a639eeab1ea71d Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 30 Jan 2016 10:18:25 +0400 Subject: Improve the script itemization algorithm to match Unicode 8.0 Override preceding Common-s with a subsequent non-Inherited, non-Common script. This produces longer script runs, which automagically improves the shaping quality (as we don't lose the context anymore), the shaping performance (as we're typically shape a fewer runs), and the fallback font selection (when the font supports more than just a single language/script). Task-number: QTBUG-29930 Change-Id: I1c55af30bd397871d7f1f6e062605517f5a7e5a1 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qtextscriptengine/tst_qtextscriptengine.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 18012fd347..e9e243f7ed 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1225,29 +1225,21 @@ void tst_QTextScriptEngine::thaiWithZWJ() QTextLayout layout(s, font); QTextEngine *e = layout.engine(); e->itemize(); - QCOMPARE(e->layoutData->items.size(), 11); + QCOMPARE(e->layoutData->items.size(), 3); for (int item = 0; item < e->layoutData->items.size(); ++item) e->shape(item); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script - QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a separate item - QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis - QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote - QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented - QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character - QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree - QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(15)); // Thai, Inherited and Common + QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Japanese: Kanji for tree + QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type //A quick sanity check - check all the characters are individual clusters unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 7; i++) + for (int i = 0; i < 15; i++) QCOMPARE(logClusters[i], ushort(i)); - for (int i = 0; i < 10; i++) - QCOMPARE(logClusters[i+7], ushort(0)); + for (int i = 0; i < 3; i++) + QCOMPARE(logClusters[i+15], ushort(0)); // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. // The current implementation hides them, so we test for that. -- cgit v1.2.3 From adac71c04454219bdca79cbace5a1d9c18ce05c4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Nov 2015 18:34:07 -0800 Subject: tst_compiler: Expand the attribute test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not exhaustive, but was enough to discover ICEs. Change-Id: Ib60be1d298a66b72e3eb9b75ad538f0bf15b5f62 Reviewed-by: Maurice Kalinowski Reviewed-by: Simo Fält Reviewed-by: Thiago Macieira --- tests/auto/other/compiler/tst_compiler.cpp | 90 ++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index af0fa4682d..540c155fd8 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -684,25 +684,105 @@ void tst_Compiler::cxx11_atomics() #endif } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wignored-attributes") +QT_WARNING_DISABLE_CLANG("-Wunused-local-typedefs") +QT_WARNING_DISABLE_GCC("-Wattributes") +QT_WARNING_DISABLE_GCC("-Wunused-local-typedefs") + +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif +#ifdef Q_COMPILER_ATTRIBUTES +[[noreturn]] void attribute_f1(); +void attribute_f2 [[noreturn]] (); +# if (defined(__cpp_namespace_attributes) && __cpp_namespace_attributes >= 201411) && __has_cpp_attribute(deprecated) +namespace NS [[deprecated]] { } +# endif +#endif + void tst_Compiler::cxx11_attributes() { #ifndef Q_COMPILER_ATTRIBUTES QSKIP("Compiler does not support C++11 feature"); #else - struct [[deprecated]] C {}; + // Attributes in function parameters and using clauses cause MSVC 2015 to crash + // https://connect.microsoft.com/VisualStudio/feedback/details/2011594 +# if (!defined(Q_CC_MSVC) || _MSC_FULL_VER >= 190023811) && !defined(Q_CC_INTEL) + void f([[ ]] int); + [[ ]] using namespace QtPrivate; + [[ ]] try { + } catch ([[]] int) { + } +# endif + + struct [[ ]] A { }; + struct B : A { + [[ ]] int m_i : 32; + [[noreturn]] void f() const { ::exit(0); } + +# ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS + [[ ]] ~B() = default; + [[ ]] B(const B &) = delete; +# endif + }; +# if __has_cpp_attribute(deprecated) + struct [[deprecated]] C { }; +# endif + enum [[ ]] E { }; + [[ ]] void [[ ]] * [[ ]] * [[ ]] ptr = 0; + int B::* [[ ]] pmm = 0; + +# if __has_cpp_attribute(deprecated) + enum [[deprecated]] E2 { +# if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411 + value [[deprecated]] = 0 +# endif + }; +# endif +# ifdef Q_COMPILER_LAMBDA + []()[[ ]] {}(); +# endif +# ifdef Q_COMPILER_TEMPLATE_ALIAS + using B2 [[ ]] = B; +# endif + + [[ ]] goto end; +# ifdef Q_CC_GNU + // Attributes in gnu:: namespace + [[gnu::unused]] end: + ; [[gnu::unused]] struct D {} d; - [[noreturn]] void f(); struct D e [[gnu::used, gnu::unused]]; - [[gnu::aligned(8)]] int i; + [[gnu::aligned(8)]] int i [[ ]]; + int array[][[]] = { 1 }; +# else + // Non GNU, so use an empty attribute + [[ ]] end: + ; + [[ ]] struct D {} d; + struct D e [[ ]]; + [[ ]] int i [[ ]]; + int array[][[]] = { 1 }; +# endif -[[gnu::unused]] end: - ; + int & [[ ]] lref = i; + int && [[ ]] rref = 1; + [[ ]] (void)1; + [[ ]] for (i = 0; i < 2; ++i) + ; + Q_UNUSED(ptr); + Q_UNUSED(pmm); Q_UNUSED(d); Q_UNUSED(e); Q_UNUSED(i); + Q_UNUSED(array); + Q_UNUSED(lref); + Q_UNUSED(rref); #endif } +QT_WARNING_POP #ifdef Q_COMPILER_AUTO_FUNCTION auto autoFunction() -> unsigned -- cgit v1.2.3 From 9be4ee52021bbb3227611979319ab5e3106063b2 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Thu, 3 Mar 2016 21:56:53 -0800 Subject: QtDBus: finish all pending call with error if disconnected libdbus will send a local signal if connection gets disconnected. When this happens, end all pending calls with QDBusError::Disconnected. Task-number: QTBUG-51649 Change-Id: I5c7d2a468bb5da746d0c0e53e458c1e376f186a9 Reviewed-by: Thiago Macieira --- .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 21 +++++++++++++++++++++ .../auto/dbus/qdbusconnection/tst_qdbusconnection.h | 1 + 2 files changed, 22 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index e91f87d6c8..f378091c58 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1218,6 +1218,27 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.replyArguments, subPathReply.arguments()); } +void tst_QDBusConnection::pendingCallWhenDisconnected() +{ + if (!QCoreApplication::instance()) + QSKIP("Test requires a QCoreApplication"); + + QDBusServer *server = new QDBusServer; + QDBusConnection con = QDBusConnection::connectToPeer(server->address(), "disconnect"); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(con.isConnected()); + QDBusMessage message = QDBusMessage::createMethodCall("", "/", QString(), "method"); + QDBusPendingCall reply = con.asyncCall(message); + + delete server; + + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!con.isConnected()); + QVERIFY(reply.isFinished()); + QVERIFY(reply.isError()); + QVERIFY(reply.error().type() == QDBusError::Disconnected); +} + QString MyObject::path; QString MyObjectWithoutInterface::path; QString MyObjectWithoutInterface::interface; diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h index a53ba320f8..720e484cc2 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -121,6 +121,7 @@ private slots: void registerVirtualObject(); void callVirtualObject(); void callVirtualObjectLocal(); + void pendingCallWhenDisconnected(); public: QString serviceName() const { return "org.qtproject.Qt.Autotests.QDBusConnection"; } -- cgit v1.2.3 From ab2f768a8f1e1e43e70de4129b2ca9422f5f2dce Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 28 Apr 2016 22:35:14 -0700 Subject: Autotest: fix the QTimeZone::tzTest failure when database contains LMT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some operating systems, tzdata files carry the Local Mean Time (LMT) for the city in question, which better represents how time was tracked before standard, hourly timezones were introduced in the early 20th century. The test was asking for the data for 1653-02-09 and assumed that it would find the first Central European Time (CET) rule, which Germany didn't start using until 1893-04-01. This fix allows us to remove the blacklist that had been applied to this test without investigation. It wasn't related to OpenSUSE, aside from the fact that OpenSUSE tzdata carries the LMT data. Change-Id: Id5480807d25e49e78b79ffff1449bdaf46901367 Reviewed-by: Simon Hausmann Reviewed-by: Tony Sarajärvi --- tests/auto/corelib/tools/qtimezone/BLACKLIST | 2 -- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 tests/auto/corelib/tools/qtimezone/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/tools/qtimezone/BLACKLIST deleted file mode 100644 index 665e78bc08..0000000000 --- a/tests/auto/corelib/tools/qtimezone/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[tzTest] -opensuse-13.1 diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index 32bb2aa394..ea835108ee 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -767,16 +767,22 @@ void tst_QTimeZone::tzTest() // Warning: This could vary depending on age of TZ file! // Test low date uses first rule found + // Note: Depending on the OS in question, the database may be carrying the + // Local Mean Time. which for Berlin is 0:53:28 QTimeZonePrivate::Data dat = tzp.data(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-9999999999999); - QCOMPARE(dat.standardTimeOffset, 3600); QCOMPARE(dat.daylightTimeOffset, 0); + if (dat.abbreviation == "LMT") { + QCOMPARE(dat.standardTimeOffset, 3208); + } else { + QCOMPARE(dat.standardTimeOffset, 3600); - // Test previous to low value is invalid - dat = tzp.previousTransition(-9999999999999); - QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits::min()); - QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); - QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); + // Test previous to low value is invalid + dat = tzp.previousTransition(-9999999999999); + QCOMPARE(dat.atMSecsSinceEpoch, std::numeric_limits::min()); + QCOMPARE(dat.standardTimeOffset, std::numeric_limits::min()); + QCOMPARE(dat.daylightTimeOffset, std::numeric_limits::min()); + } dat = tzp.nextTransition(-9999999999999); QCOMPARE(dat.atMSecsSinceEpoch, (qint64)-2422054408000); -- cgit v1.2.3 From 91f536dd71cd154675264c27273020f4de310ec2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Apr 2016 14:11:28 +0200 Subject: tst_QMdiArea::subWindowActivated2(): Add activateWindow(). The widget is hidden, reshown and tested for active window, which is flaky. Add a call to activateWindow() which increases the chances of it becoming the active window should another window appear. Change-Id: Ibbecdbc43e2ac9638aec497c47fffaaffa1855af Reviewed-by: Simon Hausmann --- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index aa86e02465..57be110c15 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -497,6 +497,7 @@ void tst_QMdiArea::subWindowActivated2() spy.clear(); mdiArea.show(); + mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); QTRY_COMPARE(spy.count(), 1); QVERIFY(mdiArea.currentSubWindow()); -- cgit v1.2.3 From 002112e80516a29efbb6cef721d74c5fc39fc19d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 28 Apr 2016 14:28:08 +0200 Subject: Fix scroll regression near scroll-view ends Fix regression in a7b0cb467ca5c4a9447d049910c9e3f0abc5897c which caused it to be hard to start scrolling at the ends of a scroll-view if using fine grained scrolling events. Change-Id: I55f3210150b993281545c3ad5a7356d892fa30b5 Reviewed-by: Simon Hausmann --- .../qabstractslider/tst_qabstractslider.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 3c150e77b9..5e461d6a7d 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -82,6 +82,8 @@ private slots: #ifndef QT_NO_WHEELEVENT void wheelEvent_data(); void wheelEvent(); + void fineGrainedWheelEvent_data(); + void fineGrainedWheelEvent(); #endif void sliderPressedReleased_data(); void sliderPressedReleased(); @@ -897,6 +899,55 @@ void tst_QAbstractSlider::wheelEvent() if (expectedSignalCount) QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp); } + +void tst_QAbstractSlider::fineGrainedWheelEvent_data() +{ + QTest::addColumn("invertedControls"); + QTest::newRow("invertedControls=false") << false; + QTest::newRow("invertedControls=true") << true; +} + +void tst_QAbstractSlider::fineGrainedWheelEvent() +{ + QFETCH(bool, invertedControls); + + QCoreApplication *applicationInstance = QCoreApplication::instance(); + QVERIFY(applicationInstance != 0); + QApplication::setWheelScrollLines(3); + + slider->setRange(0, 10); + slider->setSingleStep(1); + slider->setPageStep(10); + slider->setInvertedControls(invertedControls); + slider->setOrientation(Qt::Vertical); + slider->setSliderPosition(0); + + const int singleStepDelta = invertedControls ? (-WHEEL_DELTA / 3) : (WHEEL_DELTA / 3); + + QWheelEvent eventDown(slider->rect().bottomRight(), singleStepDelta / 2, + Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 1); + + QWheelEvent eventUp(slider->rect().bottomRight(), -singleStepDelta / 2, + Qt::NoButton, Qt::NoModifier, Qt::Vertical); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 1); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventUp)); + QCOMPARE(slider->sliderPosition(), 0); + + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 0); + QVERIFY(applicationInstance->sendEvent(slider,&eventDown)); + QCOMPARE(slider->sliderPosition(), 1); +} + #endif // !QT_NO_WHEELEVENT void tst_QAbstractSlider::sliderPressedReleased_data() -- cgit v1.2.3 From a954ba83154f6ad080e96dd7277c8f250e62f8db Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 28 Apr 2016 03:01:34 +0400 Subject: Enable some tests previously disabled due to different results with HB-NG As of 5.7, HB-NG is the default shaper engine. Change-Id: Ia5400444a5e387fa6b56de47fabc6f1c2c166f85 Reviewed-by: Lars Knoll --- tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index e9e243f7ed..0beea6528b 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1075,8 +1075,6 @@ void tst_QTextScriptEngine::mirroredChars() void tst_QTextScriptEngine::controlInSyllable_qtbug14204() { - QSKIP("Result differs for HarfBuzz-NG, skip test."); - QFontDatabase db; if (!db.families().contains(QStringLiteral("Aparajita"))) QSKIP("couldn't find 'Aparajita' font"); @@ -1101,13 +1099,13 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204() QCOMPARE(fe->fontDef.family, font.family()); e->shape(0); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2)); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3)); const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); QCOMPARE(log_clusters[0], ushort(0)); QCOMPARE(log_clusters[1], ushort(0)); - QCOMPARE(log_clusters[2], ushort(0)); - QCOMPARE(log_clusters[3], ushort(0)); + QCOMPARE(log_clusters[2], ushort(1)); + QCOMPARE(log_clusters[3], ushort(2)); } void tst_QTextScriptEngine::combiningMarks_qtbug15675_data() -- cgit v1.2.3 From a4d26cf522b966056e47e47a004b7e4d668e3a2d Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 8 Apr 2016 16:55:39 +0300 Subject: QWindowsPipeWriter: ensure validity of the write buffer QWindowsPipeWriter uses asynchronous API to perform writing. Once a cycle has been started, the write buffer must remain valid until the write operation is completed. To avoid data corruption and possibly undefined behavior, this patch makes QWindowsPipeWriter::write() take a QByteArray, which it keeps alive for the duration of the write cycle. Autotest-by: Thomas Hartmann Task-number: QTBUG-52401 Change-Id: Ia35faee735c4e684267daa1f6bd689512b670cd2 Reviewed-by: Joerg Bornemann --- .../socket/qlocalsocket/tst_qlocalsocket.cpp | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 99f40ca215..6e55b15a18 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -78,6 +79,9 @@ private slots: void readBufferOverflow(); + void simpleCommandProtocol1(); + void simpleCommandProtocol2(); + void fullPath(); void hitMaximumConnections_data(); @@ -630,6 +634,110 @@ void tst_QLocalSocket::readBufferOverflow() QCOMPARE(client.bytesAvailable(), 0); } +static qint64 writeCommand(const QVariant &command, QIODevice *device, int commandCounter) +{ + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out << qint64(0); + out << commandCounter; + out << command; + out.device()->seek(0); + out << qint64(block.size() - sizeof(qint64)); + return device->write(block); +} + +static QVariant readCommand(QIODevice *ioDevice, int *readCommandCounter, bool readSize = true) +{ + QDataStream in(ioDevice); + qint64 blockSize; + int commandCounter; + if (readSize) + in >> blockSize; + in >> commandCounter; + *readCommandCounter = commandCounter; + + QVariant command; + in >> command; + + return command; +} + +void tst_QLocalSocket::simpleCommandProtocol1() +{ + QLocalServer server; + server.listen(QStringLiteral("simpleProtocol")); + + QLocalSocket localSocketWrite; + localSocketWrite.connectToServer(server.serverName()); + QVERIFY(server.waitForNewConnection()); + QLocalSocket *localSocketRead = server.nextPendingConnection(); + QVERIFY(localSocketRead); + + int readCounter = 0; + for (int i = 0; i < 2000; ++i) { + const QVariant command(QRect(readCounter, i, 10, 10)); + const qint64 blockSize = writeCommand(command, &localSocketWrite, i); + while (localSocketWrite.bytesToWrite()) + QVERIFY(localSocketWrite.waitForBytesWritten()); + while (localSocketRead->bytesAvailable() < blockSize) { + QVERIFY(localSocketRead->waitForReadyRead(1000)); + } + const QVariant variant = readCommand(localSocketRead, &readCounter); + QCOMPARE(readCounter, i); + QCOMPARE(variant, command); + } +} + +void tst_QLocalSocket::simpleCommandProtocol2() +{ + QLocalServer server; + server.listen(QStringLiteral("simpleProtocol")); + + QLocalSocket localSocketWrite; + localSocketWrite.connectToServer(server.serverName()); + QVERIFY(server.waitForNewConnection()); + QLocalSocket* localSocketRead = server.nextPendingConnection(); + QVERIFY(localSocketRead); + + int readCounter = 0; + qint64 writtenBlockSize = 0; + qint64 blockSize = 0; + + QObject::connect(localSocketRead, &QLocalSocket::readyRead, [&] { + forever { + if (localSocketRead->bytesAvailable() < sizeof(qint64)) + return; + + if (blockSize == 0) { + QDataStream in(localSocketRead); + in >> blockSize; + } + + if (localSocketRead->bytesAvailable() < blockSize) + return; + + int commandNumber = 0; + const QVariant variant = readCommand(localSocketRead, &commandNumber, false); + QCOMPARE(writtenBlockSize, blockSize); + QCOMPARE(readCounter, commandNumber); + QCOMPARE(variant.userType(), (int)QMetaType::QRect); + + readCounter++; + blockSize = 0; + } + }); + + for (int i = 0; i < 500; ++i) { + const QVariant command(QRect(readCounter, i, 10, 10)); + writtenBlockSize = writeCommand(command, &localSocketWrite, i) - sizeof(qint64); + if (i % 10 == 0) + QTest::qWait(1); + } + + localSocketWrite.abort(); + QVERIFY(localSocketRead->waitForDisconnected(1000)); +} + // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { -- cgit v1.2.3 From be6a92ec0920491a68e747b48154ad8712d97f4b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 22 Apr 2016 20:20:47 +0200 Subject: remove redundant OTHER_FILES assignments newer versions of qt creator understand QMAKE_EXTRA_COMPILERS and INSTALLS, so there is no need to list the files twice. Change-Id: Iccf3cc3248daf3422b8c366c2eb2d2f46c5f08d1 Reviewed-by: Joerg Bornemann --- tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro index a311173c0e..f03ac49c5d 100644 --- a/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro +++ b/tests/auto/corelib/io/qloggingregistry/qloggingregistry.pro @@ -5,7 +5,6 @@ CONFIG += testcase QT = core core-private testlib SOURCES += tst_qloggingregistry.cpp -OTHER_FILES += qtlogging.ini TESTDATA += qtlogging.ini android:!android-no-sdk: { -- cgit v1.2.3 From 22a7edd816b417daf43e3b4c4f0257fbc3ad7921 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 7 Apr 2016 14:18:21 +0200 Subject: tst_QTcpSocket, tst_QUdpSocket: Improve diagnostics. Add more error messages on failures. Task-number: QTBUG-25367 Task-number: QTBUG-25368 Change-Id: I064143a058b7b98d9d5eecab8b5da49f5307e1eb Reviewed-by: Edward Welbourne Reviewed-by: Richard J. Moore --- tests/auto/network-settings.h | 20 ++++++++++- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 6 ++-- .../network/socket/qudpsocket/tst_qudpsocket.cpp | 40 +++++++++++----------- .../network/socket/qudpsocket/udpServer/main.cpp | 30 +++++++++++----- 4 files changed, 65 insertions(+), 31 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index a90ea62277..f4ec460709 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -34,6 +34,8 @@ #include #ifdef QT_NETWORK_LIB #include +#include +#include #endif #ifdef Q_OS_UNIX @@ -139,5 +141,21 @@ public: } return true; } -#endif + + // Helper function for usage with QVERIFY2 on sockets. + static QByteArray msgSocketError(const QAbstractSocket &s) + { + QString result; + QDebug debug(&result); + debug.nospace(); + debug.noquote(); + if (!s.localAddress().isNull()) + debug << "local=" << s.localAddress().toString() << ':' << s.localPort(); + if (!s.peerAddress().isNull()) + debug << ", peer=" << s.peerAddress().toString() << ':' << s.peerPort(); + debug << ", type=" << s.socketType() << ", state=" << s.state() + << ", error=" << s.error() << ": " << s.errorString(); + return result.toLocal8Bit(); + } +#endif // QT_NETWORK_LIB }; diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index cde453c191..bdfb7d2fb8 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -675,8 +675,10 @@ void tst_QTcpSocket::bindThenResolveHost() dummySocket.close(); - socket->connectToHost(hostName, 80); - QVERIFY2(socket->waitForConnected(), "Network timeout"); + const quint16 port = 80; + socket->connectToHost(hostName, port); + QVERIFY2(socket->waitForConnected(), (hostName.toLocal8Bit() + ": " + QByteArray::number(port) + ' ' + + QtNetworkSettings::msgSocketError(*socket)).constData()); QCOMPARE(socket->localPort(), boundPort); QCOMPARE(socket->socketDescriptor(), fd); diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0ee3255502..7ab8f6d3cc 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -265,7 +266,7 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() char buf[1024]; QHostAddress host; quint16 port; - QVERIFY(serverSocket.waitForReadyRead(5000)); + QVERIFY2(serverSocket.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(serverSocket).constData()); QCOMPARE(int(serverSocket.readDatagram(buf, sizeof(buf), &host, &port)), int(strlen(message[i]))); buf[strlen(message[i])] = '\0'; @@ -397,8 +398,8 @@ void tst_QUdpSocket::loop() QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), peterAddress, peter.localPort()), qint64(paulMessage.length())); - QVERIFY(peter.waitForReadyRead(9000)); - QVERIFY(paul.waitForReadyRead(9000)); + QVERIFY2(peter.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(peter).constData()); + QVERIFY2(paul.waitForReadyRead(9000), QtNetworkSettings::msgSocketError(paul).constData()); char peterBuffer[16*1024]; char paulBuffer[16*1024]; if (success) { @@ -454,8 +455,8 @@ void tst_QUdpSocket::ipv6Loop() char peterBuffer[16*1024]; char paulBuffer[16*1024]; #if !defined(Q_OS_WINCE) - QVERIFY(peter.waitForReadyRead(5000)); - QVERIFY(paul.waitForReadyRead(5000)); + QVERIFY2(peter.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(peter).constData()); + QVERIFY2(paul.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(paul).constData()); #else QVERIFY(peter.waitForReadyRead(15000)); QVERIFY(paul.waitForReadyRead(15000)); @@ -490,7 +491,7 @@ void tst_QUdpSocket::dualStack() QByteArray buffer; //test v4 -> dual QCOMPARE((int)v4Sock.writeDatagram(v4Data.constData(), v4Data.length(), QHostAddress(QHostAddress::LocalHost), dualSock.localPort()), v4Data.length()); - QVERIFY(dualSock.waitForReadyRead(5000)); + QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); buffer.reserve(100); qint64 size = dualSock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, v4Data.length()); @@ -504,7 +505,7 @@ void tst_QUdpSocket::dualStack() //test v6 -> dual QCOMPARE((int)v6Sock.writeDatagram(v6Data.constData(), v6Data.length(), QHostAddress(QHostAddress::LocalHostIPv6), dualSock.localPort()), v6Data.length()); - QVERIFY(dualSock.waitForReadyRead(5000)); + QVERIFY2(dualSock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(dualSock).constData()); buffer.reserve(100); size = dualSock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, v6Data.length()); @@ -513,7 +514,7 @@ void tst_QUdpSocket::dualStack() //test dual -> v6 QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); - QVERIFY(v6Sock.waitForReadyRead(5000)); + QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); buffer.reserve(100); size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -523,7 +524,7 @@ void tst_QUdpSocket::dualStack() //test dual -> v4 QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); - QVERIFY(v4Sock.waitForReadyRead(5000)); + QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); buffer.reserve(100); size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -555,7 +556,7 @@ void tst_QUdpSocket::dualStackAutoBinding() QUdpSocket dualSock; QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); - QVERIFY(v4Sock.waitForReadyRead(5000)); + QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); buffer.reserve(100); size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -563,7 +564,7 @@ void tst_QUdpSocket::dualStackAutoBinding() QCOMPARE(buffer, dualData); QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); - QVERIFY(v6Sock.waitForReadyRead(5000)); + QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); buffer.reserve(100); size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -576,7 +577,7 @@ void tst_QUdpSocket::dualStackAutoBinding() QUdpSocket dualSock; QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHostIPv6), v6Sock.localPort()), dualData.length()); - QVERIFY(v6Sock.waitForReadyRead(5000)); + QVERIFY2(v6Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v6Sock).constData()); buffer.reserve(100); size = v6Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -584,7 +585,7 @@ void tst_QUdpSocket::dualStackAutoBinding() QCOMPARE(buffer, dualData); QCOMPARE((int)dualSock.writeDatagram(dualData.constData(), dualData.length(), QHostAddress(QHostAddress::LocalHost), v4Sock.localPort()), dualData.length()); - QVERIFY(v4Sock.waitForReadyRead(5000)); + QVERIFY2(v4Sock.waitForReadyRead(5000), QtNetworkSettings::msgSocketError(v4Sock).constData()); buffer.reserve(100); size = v4Sock.readDatagram(buffer.data(), 100, &from, &port); QCOMPARE((int)size, dualData.length()); @@ -689,7 +690,7 @@ void tst_QUdpSocket::pendingDatagramSize() QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10); char c = 0; - QVERIFY(server.waitForReadyRead()); + QVERIFY2(server.waitForReadyRead(), QtNetworkSettings::msgSocketError(server).constData()); if (server.hasPendingDatagrams()) { #if defined Q_OS_HPUX && defined __ia64 QEXPECT_FAIL("", "HP-UX 11i v2 can't determine the datagram size correctly.", Abort); @@ -1101,7 +1102,7 @@ void tst_QUdpSocket::zeroLengthDatagram() #endif QCOMPARE(sender.writeDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort()), qint64(0)); - QVERIFY(receiver.waitForReadyRead(1000)); + QVERIFY2(receiver.waitForReadyRead(1000), QtNetworkSettings::msgSocketError(receiver).constData()); QVERIFY(receiver.hasPendingDatagrams()); char buf; @@ -1379,8 +1380,7 @@ void tst_QUdpSocket::multicast() int(datagram.size())); } - QVERIFY2(receiver.waitForReadyRead(), - qPrintable(receiver.errorString())); + QVERIFY2(receiver.waitForReadyRead(), QtNetworkSettings::msgSocketError(receiver).constData()); QVERIFY(receiver.hasPendingDatagrams()); QList receivedDatagrams; while (receiver.hasPendingDatagrams()) { @@ -1446,7 +1446,7 @@ void tst_QUdpSocket::echo() qDebug() << "packets in" << successes << "out" << i; QTest::qWait(50); //choke to avoid triggering flood/DDoS protections on echo service } - QVERIFY(successes >= 9); + QVERIFY2(successes >= 9, QByteArray::number(successes).constData()); } void tst_QUdpSocket::linkLocalIPv6() @@ -1567,7 +1567,7 @@ void tst_QUdpSocket::linkLocalIPv4() QByteArray receiveBuffer("xxxxx"); foreach (QUdpSocket *s, sockets) { QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); - QVERIFY(neutral.waitForReadyRead(10000)); + QVERIFY2(neutral.waitForReadyRead(10000), QtNetworkSettings::msgSocketError(neutral).constData()); QHostAddress from; quint16 fromPort; QCOMPARE((int)neutral.readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); @@ -1576,7 +1576,7 @@ void tst_QUdpSocket::linkLocalIPv4() QCOMPARE(receiveBuffer, testData); QVERIFY(neutral.writeDatagram(testData, s->localAddress(), s->localPort())); - QVERIFY(s->waitForReadyRead(10000)); + QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData()); QCOMPARE((int)s->readDatagram(receiveBuffer.data(), receiveBuffer.length(), &from, &fromPort), testData.length()); QCOMPARE(receiveBuffer, testData); diff --git a/tests/auto/network/socket/qudpsocket/udpServer/main.cpp b/tests/auto/network/socket/qudpsocket/udpServer/main.cpp index 2562e58862..f393c26329 100644 --- a/tests/auto/network/socket/qudpsocket/udpServer/main.cpp +++ b/tests/auto/network/socket/qudpsocket/udpServer/main.cpp @@ -36,18 +36,21 @@ class Server : public QObject { Q_OBJECT public: - Server(int port) + + Server() { connect(&serverSocket, &QIODevice::readyRead, this, &Server::sendEcho); } + + bool bind(quint16 port) { - connect(&serverSocket, SIGNAL(readyRead()), - this, SLOT(sendEcho())); - if (serverSocket.bind(QHostAddress::Any, port, - QUdpSocket::ReuseAddressHint - | QUdpSocket::ShareAddress)) { + const bool result = serverSocket.bind(QHostAddress::Any, port, + QUdpSocket::ReuseAddressHint + | QUdpSocket::ShareAddress); + if (result) { printf("OK\n"); } else { - printf("FAILED\n"); + printf("FAILED: %s\n", qPrintable(serverSocket.errorString())); } fflush(stdout); + return result; } private slots: @@ -73,8 +76,19 @@ private: int main(int argc, char **argv) { QCoreApplication app(argc, argv); + QStringList arguments = QCoreApplication::arguments(); + arguments.pop_front(); + quint16 port = 0; + if (!arguments.isEmpty()) + port = arguments.constFirst().toUShort(); + if (!port) { + printf("Specify port number\n"); + return -1; + } - Server server(app.arguments().at(1).toInt()); + Server server; + if (!server.bind(port)) + return -2; return app.exec(); } -- cgit v1.2.3 From 67509693bdac23af4e062140a1b1058dee3f060b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 14 Dec 2015 10:42:51 +0100 Subject: Improve tst_qtimeline::setPaused resilience MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test should not depend on qWait explicitly Change-Id: I13c01c47c9f7bae8b0c30afa2ac8550dc0fbf028 Reviewed-by: Friedemann Kleint Reviewed-by: Jan Arve Sæther --- tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index b588e1fe82..dd41b5632d 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -649,22 +649,21 @@ void tst_QTimeLine::restart() void tst_QTimeLine::setPaused() { - QTimeLine timeLine(1000); + const int EndTime = 10000; + QTimeLine timeLine(EndTime); { QCOMPARE(timeLine.currentTime(), 0); timeLine.start(); - QTest::qWait(250); + QTRY_VERIFY(timeLine.currentTime() != 0); // wait for start timeLine.setPaused(true); int oldCurrentTime = timeLine.currentTime(); QVERIFY(oldCurrentTime > 0); - QVERIFY(oldCurrentTime < 1000); + QVERIFY(oldCurrentTime < EndTime); QTest::qWait(1000); timeLine.setPaused(false); - QTest::qWait(250); - int currentTime = timeLine.currentTime(); - QVERIFY(currentTime > 0); - QVERIFY(currentTime > oldCurrentTime); - QVERIFY(currentTime < 1000); + QTRY_VERIFY(timeLine.currentTime() > oldCurrentTime); + QVERIFY(timeLine.currentTime() > 0); + QVERIFY(timeLine.currentTime() < EndTime); timeLine.stop(); } } -- cgit v1.2.3 From 2c60125ef967d157b8c1de8eec7e40dcef424c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 4 May 2016 12:07:20 +0200 Subject: Add missing Q_DECL_OVERRIDEs Change-Id: I54552d9fdd0bc8871247246aea1da14848c4f7a0 Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 55b6aff237..92e504e1fb 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5862,7 +5862,7 @@ public: startTimer(1000); } - void timerEvent(QTimerEvent *) + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE { switch (state++) { case 0: @@ -5885,7 +5885,7 @@ public: return false; } - bool nativeEvent(const QByteArray &eventType, void *message, long *) + bool nativeEvent(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE { if (isMapNotify(eventType, message)) gotExpectedMapNotify = true; @@ -5893,7 +5893,7 @@ public: } // QAbstractNativeEventFilter interface - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE + bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE { if (isMapNotify(eventType, message)) gotExpectedGlobalEvent = true; -- cgit v1.2.3 From dec0b15685985d5b7c56748c0e52cfbdb4d1d6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 4 May 2016 13:01:00 +0200 Subject: Change Q_OS_MAC -> Q_OS_OSX Q_OS_DARWIN is the general replacement for Q_OS_MAC, but most/all of the MAC sections in this test are OS X specific. Change-Id: Ic54af9d3dce1e1952a57e15b74acdedf2af60c79 Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 92e504e1fb..c2b01ea087 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -74,7 +74,7 @@ #include "../../../qtest-config.h" -#if defined(Q_OS_MAC) +#if defined(Q_OS_OSX) #include "tst_qwidget_mac_helpers.h" // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile. #endif @@ -141,7 +141,7 @@ bool qt_wince_is_smartphone() { } #endif -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX #include bool macHasAccessToWindowsServer() { @@ -268,7 +268,7 @@ private slots: void restoreVersion1Geometry(); void widgetAt(); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX void sheetOpacity(); void setMask(); #endif @@ -301,7 +301,7 @@ private slots: void update(); void isOpaque(); -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX void scroll(); void scrollNativeChildren(); #endif @@ -434,7 +434,7 @@ private slots: void taskQTBUG_7532_tabOrderWithFocusProxy(); void movedAndResizedAttributes(); void childAt(); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX void childAt_unifiedToolBar(); void taskQTBUG_11373(); #endif @@ -2380,12 +2380,12 @@ void tst_QWidget::showMinimizedKeepsFocus() window.showNormal(); qApp->setActiveWindow(&window); QVERIFY(QTest::qWaitForWindowActive(&window)); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #endif QTRY_COMPARE(window.focusWidget(), firstchild); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); #endif @@ -2725,7 +2725,7 @@ public: void tst_QWidget::lostUpdatesOnHide() { -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX UpdateWidget widget; widget.setAttribute(Qt::WA_DontShowOnScreen); widget.show(); @@ -2767,7 +2767,7 @@ void tst_QWidget::raise() QVERIFY(QTest::qWaitForWindowExposed(parentPtr.data())); QTest::qWait(10); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX if (child1->internalWinId()) { QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events."); } @@ -2947,7 +2947,7 @@ void tst_QWidget::stackUnder() foreach (UpdateWidget *child, allChildren) { int expectedPaintEvents = child == child4 ? 1 : 0; -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_OSX) if (expectedPaintEvents == 1 && child->numPaintEvents == 2) QEXPECT_FAIL(0, "Mac and Windows issues double repaints for Z-Order change", Continue); #endif @@ -2986,7 +2986,7 @@ void tst_QWidget::stackUnder() #ifdef Q_OS_WINCE qApp->processEvents(); #endif -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX QEXPECT_FAIL(0, "See QTBUG-493", Continue); #endif QCOMPARE(child->numPaintEvents, 0); @@ -3523,7 +3523,7 @@ void tst_QWidget::testDeletionInEventHandlers() delete w; } -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX void tst_QWidget::sheetOpacity() { QWidget tmpWindow; @@ -4314,7 +4314,7 @@ void tst_QWidget::update() QCOMPARE(sibling.numPaintEvents, 1); QCOMPARE(sibling.paintedRegion, sibling.visibleRegion()); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX if (child.internalWinId()) // child is native QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue); #endif @@ -4340,7 +4340,7 @@ static inline bool isOpaque(QWidget *widget) void tst_QWidget::isOpaque() { -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX QWidget w; QVERIFY(::isOpaque(&w)); @@ -4412,7 +4412,7 @@ void tst_QWidget::isOpaque() #endif } -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX /* Test that scrolling of a widget invalidates the correct regions */ @@ -4859,7 +4859,7 @@ void tst_QWidget::windowMoveResize() widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); -#if defined(Q_OS_MAC) +#if defined(Q_OS_OSX) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); @@ -4930,7 +4930,7 @@ void tst_QWidget::windowMoveResize() widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); -#if defined(Q_OS_MAC) +#if defined(Q_OS_OSX) if (r.width() == 0 && r.height() > 0) { widget.move(r.topLeft()); widget.resize(r.size()); @@ -5120,7 +5120,7 @@ void tst_QWidget::moveChild() QTRY_COMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); -#if !defined(Q_OS_MAC) +#if !defined(Q_OS_OSX) // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif @@ -6912,7 +6912,7 @@ void tst_QWidget::render_systemClip() // rrrrrrrrrr // ... -#ifndef Q_OS_MAC +#ifndef Q_OS_OSX for (int i = 0; i < image.height(); ++i) { for (int j = 0; j < image.width(); ++j) { if (i < 50 && j < i) @@ -7916,7 +7916,7 @@ void tst_QWidget::sendUpdateRequestImmediately() void tst_QWidget::doubleRepaint() { -#if defined(Q_OS_MAC) +#if defined(Q_OS_OSX) if (!macHasAccessToWindowsServer()) QSKIP("Not having window server access causes the wrong number of repaints to be issues"); #endif @@ -8626,7 +8626,7 @@ void tst_QWidget::setClearAndResizeMask() QTRY_COMPARE(child.mask(), childMask); QTest::qWait(50); // and ensure that the child widget doesn't get any update. -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QCOMPARE(child.numPaintEvents, 1); @@ -8649,7 +8649,7 @@ void tst_QWidget::setClearAndResizeMask() // and ensure that that the child widget gets an update for the area outside the old mask. QTRY_COMPARE(child.numPaintEvents, 1); outsideOldMask = child.rect(); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (!child.internalWinId()) #endif @@ -8664,7 +8664,7 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is bigger than the rect child.setMask(QRegion(0, 0, 1000, 1000)); QTest::qWait(100); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(child.numPaintEvents, 1); @@ -8677,7 +8677,7 @@ void tst_QWidget::setClearAndResizeMask() // ...and the same applies when clearing the mask. child.clearMask(); QTest::qWait(100); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_VERIFY(child.numPaintEvents > 0); @@ -8707,7 +8707,7 @@ void tst_QWidget::setClearAndResizeMask() QTimer::singleShot(100, &resizeChild, SLOT(shrinkMask())); QTest::qWait(200); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); @@ -8719,7 +8719,7 @@ void tst_QWidget::setClearAndResizeMask() const QRegion oldMask = resizeChild.mask(); QTimer::singleShot(0, &resizeChild, SLOT(enlargeMask())); QTest::qWait(100); -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX // Mac always issues a full update when calling setMask, and we cannot force it to not do so. if (child.internalWinId()) QTRY_COMPARE(resizeChild.paintedRegion, resizeChild.mask()); @@ -9432,7 +9432,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { -#if defined (Q_OS_MAC) +#if defined (Q_OS_OSX) QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); QVERIFY(false); #else @@ -9539,7 +9539,7 @@ void tst_QWidget::childAt() QCOMPARE(parent.childAt(120, 120), grandChild); } -#ifdef Q_OS_MAC +#ifdef Q_OS_OSX void tst_QWidget::childAt_unifiedToolBar() { QLabel *label = new QLabel(QLatin1String("foo")); -- cgit v1.2.3 From 728a1b4f29f0042fc13299bf6cc78e83cdc9d7f9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 4 May 2016 13:00:42 +0200 Subject: tst_QKeyEvent::modifiers(): Ensure test data row names are pure ASCII. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test used to output random character sequences which contained terminal control characters. Change it to output plain ASCII and Unicode syntax for non-ASCII characters. Change-Id: Ifaa72f50242bd27416a8698a1f5152bc8b902898 Reviewed-by: Jędrzej Nowacki --- tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index db0bfaf622..811a6d111f 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -116,6 +116,23 @@ static bool orderByModifier(const QVector &v1, const QVector &v2) return true; } +static QByteArray modifiersTestRowName(const QString &keySequence) +{ + QByteArray result; + QTextStream str(&result); + for (int i = 0, size = keySequence.size(); i < size; ++i) { + const QChar &c = keySequence.at(i); + const ushort uc = c.unicode(); + if (uc > 32 && uc < 128) + str << '"' << c << '"'; + else + str << "U+" << hex << uc << dec; + if (i < size - 1) + str << ','; + } + return result; +} + void tst_QKeyEvent::modifiers_data() { struct Modifier @@ -155,7 +172,8 @@ void tst_QKeyEvent::modifiers_data() mods |= modifier.modifier; } QKeySequence keySequence(keys[0], keys[1], keys[2], keys[3]); - QTest::newRow(keySequence.toString(QKeySequence::NativeText).toUtf8().constData()) << mods; + QTest::newRow(modifiersTestRowName(keySequence.toString(QKeySequence::NativeText)).constData()) + << mods; } } -- cgit v1.2.3 From a5159cc50aa0f8a57b6f736621b359a3bcecbf7e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Apr 2016 09:40:49 +0200 Subject: QJsonObject: add some overloads taking QLatin1String QXmlStreamReader also has QLatin1String overloads, which greatly benefits parsers, since the vast majority of keys in both JSON and XML are US-ASCII. This patch adds such an overload to the JSON parser. The value() function is all typical parsers need, so even though many more QJsonObject functions taking QString could benefit from the same treatment, value() is the single most important one for read-only JSON access. Add some more overloads, too, for functions that don't need more internal scaffolding than value(). Requires adding a dummy op[](QL1S) (forwarding to the QString overload) so as not to make QJsonObject json; json[QLatin1String("key")]; // mutable ambiguous between const op[](QL1S) and mutable op[](QString). [ChangeLog][QtCore][QJsonObject] Added value(), op[] const, find(), constFind(), contains() overloads taking QLatin1String. Change-Id: I00883028956ad949ba5ba2b18dd8a6a25ad5085b Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index b4f0bd2b3a..5878d56a47 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -374,12 +374,13 @@ void tst_QtJson::testObjectSimple() QJsonObject object; object.insert("number", 999.); QCOMPARE(object.value("number").type(), QJsonValue::Double); - QCOMPARE(object.value("number").toDouble(), 999.); + QCOMPARE(object.value(QLatin1String("number")).toDouble(), 999.); object.insert("string", QString::fromLatin1("test")); QCOMPARE(object.value("string").type(), QJsonValue::String); - QCOMPARE(object.value("string").toString(), QString("test")); + QCOMPARE(object.value(QLatin1String("string")).toString(), QString("test")); object.insert("boolean", true); QCOMPARE(object.value("boolean").toBool(), true); + QCOMPARE(object.value(QLatin1String("boolean")).toBool(), true); QStringList keys = object.keys(); QVERIFY2(keys.contains("number"), "key number not found"); @@ -403,7 +404,7 @@ void tst_QtJson::testObjectSimple() QString before = object.value("string").toString(); object.insert("string", QString::fromLatin1("foo")); - QVERIFY2(object.value("string").toString() != before, "value should have been updated"); + QVERIFY2(object.value(QLatin1String("string")).toString() != before, "value should have been updated"); size = object.size(); QJsonObject subobject; @@ -678,7 +679,7 @@ void tst_QtJson::testValueRef() QCOMPARE(object.value(QLatin1String("null")), QJsonValue()); object[QLatin1String("null")] = 100.; QCOMPARE(object.value(QLatin1String("null")).type(), QJsonValue::Double); - QJsonValue val = object[QLatin1String("null")]; + QJsonValue val = qAsConst(object)[QLatin1String("null")]; QCOMPARE(val.toDouble(), 100.); QCOMPARE(object.size(), 2); @@ -843,13 +844,13 @@ void tst_QtJson::testObjectFind() QJsonObject::iterator it = object.find(QLatin1String("1")); QCOMPARE((*it).toDouble(), 1.); - it = object.find(QLatin1String("11")); + it = object.find(QString("11")); QCOMPARE((*it).type(), QJsonValue::Undefined); QCOMPARE(it, object.end()); QJsonObject::const_iterator cit = object.constFind(QLatin1String("1")); QCOMPARE((*cit).toDouble(), 1.); - cit = object.constFind(QLatin1String("11")); + cit = object.constFind(QString("11")); QCOMPARE((*it).type(), QJsonValue::Undefined); QCOMPARE(it, object.end()); } @@ -911,7 +912,7 @@ void tst_QtJson::testDocument() doc3.setObject(outer.value(QLatin1String("innter")).toObject()); QCOMPARE(doc3.isArray(), false); QCOMPARE(doc3.isObject(), true); - QVERIFY(doc3.object().contains(QLatin1String("innerKey"))); + QVERIFY(doc3.object().contains(QString("innerKey"))); QCOMPARE(doc3.object().value(QLatin1String("innerKey")), QJsonValue(42)); QJsonDocument doc4(outer.value(QLatin1String("innterArray")).toArray()); @@ -938,9 +939,9 @@ void tst_QtJson::nullValues() QJsonObject object; object.insert(QString("key"), QJsonValue()); - QCOMPARE(object.contains("key"), true); + QCOMPARE(object.contains(QLatin1String("key")), true); QCOMPARE(object.size(), 1); - QCOMPARE(object.value("key"), QJsonValue()); + QCOMPARE(object.value(QString("key")), QJsonValue()); } void tst_QtJson::nullArrays() -- cgit v1.2.3 From e64b2234e829cc47872225debcf80d6c06db18f0 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 10 May 2016 14:47:31 +0200 Subject: QImage::setPixelColor: warn about invalid colors Task-number: QTBUG-52142 Change-Id: I9f390bd332f8edabaece75a6b36830c691ff4b9e Reviewed-by: Gunnar Sletta --- tests/auto/gui/image/qimage/tst_qimage.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 91df1ca520..16cbebeed5 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -3084,6 +3084,14 @@ void tst_QImage::pixelColor() QImage t = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); QCOMPARE(t.pixel(0,0), argb32pm.pixel(0,0)); + + // Try specifying an invalid position. + QTest::ignoreMessage(QtWarningMsg, "QImage::setPixelColor: coordinate (-1,-1) out of range"); + argb32.setPixelColor(-1, -1, QColor(Qt::red)); + + // Try setting an invalid color. + QTest::ignoreMessage(QtWarningMsg, "QImage::setPixelColor: color is invalid"); + argb32.setPixelColor(0, 0, QColor()); } void tst_QImage::pixel() -- cgit v1.2.3