diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-11-08 09:11:01 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-11-08 09:11:02 +0100 |
commit | 78c687f98eabb3da00026ac2375cdb4bb5770a0a (patch) | |
tree | 0bd20a65aa9051229e813bc6b09cb59f8b5778f1 /tests/auto | |
parent | 3e529369eb16704aa0d601a7f4b8e490dc8b772c (diff) | |
parent | a866055d18b2c2efc0f3cf5307d8eac78cce26eb (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I963b5f48b5d6f3500ca379fbd7f1a4290b570175
Diffstat (limited to 'tests/auto')
8 files changed, 159 insertions, 6 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2a9b92ed35..e9aa9aad30 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -924,6 +924,9 @@ void tst_QImage::convertToFormat_data() QTest::newRow("blue rgb30 -> argb32") << int(QImage::Format_RGB30) << 0xff0000ff << int(QImage::Format_ARGB32) << 0xff0000ff; + QTest::newRow("semigray argb32 -> a2rgb30 pm") << int(QImage::Format_ARGB32) << 0x4c646565u + << int(QImage::Format_A2RGB30_Premultiplied) << 0x55212222u; + QTest::newRow("white gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xfffffeffu << int(QImage::Format_ARGB32_Premultiplied) << 0xfffefefeu; QTest::newRow("gray gray8 -> argb pm") << int(QImage::Format_Grayscale8) << 0xff565557u diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index d722856366..9487436336 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -301,6 +301,13 @@ void tst_QFont::resolve() font5.setFamilies(fontFamilies); font6 = font6.resolve(font5); QCOMPARE(font6.families(), fontFamilies); + + QFont font7, font8; + font7.setFamily(QLatin1String("Helvetica")); + font8.setFamilies(fontFamilies); + font7 = font7.resolve(font8); + QCOMPARE(font7.families(), QStringList({"Helvetica", "Arial"})); + QCOMPARE(font7.family(), "Helvetica"); } #ifndef QT_NO_WIDGETS diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp index 8f51a7a474..2f0b877799 100644 --- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp +++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp @@ -53,6 +53,8 @@ class tst_QTextMarkdownImporter : public QObject private slots: void headingBulletsContinuations(); void thematicBreaks(); + void lists_data(); + void lists(); }; void tst_QTextMarkdownImporter::headingBulletsContinuations() @@ -159,5 +161,66 @@ void tst_QTextMarkdownImporter::thematicBreaks() #endif } +void tst_QTextMarkdownImporter::lists_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<int>("expectedItemCount"); + QTest::addColumn<bool>("expectedEmptyItems"); + QTest::addColumn<QString>("rewrite"); + + // Some of these cases show odd behavior, which is subject to change + // as the importer and the writer are tweaked to fix bugs over time. + QTest::newRow("dot newline") << ".\n" << 0 << true << ".\n\n"; + QTest::newRow("number dot newline") << "1.\n" << 1 << true << "1. \n"; + QTest::newRow("star newline") << "*\n" << 1 << true << "* \n"; + QTest::newRow("hyphen newline") << "-\n" << 1 << true << "- \n"; + QTest::newRow("hyphen space newline") << "- \n" << 1 << true << "- \n"; + QTest::newRow("hyphen space letter newline") << "- a\n" << 1 << false << "- a\n"; + QTest::newRow("hyphen nbsp newline") << + QString::fromUtf8("-\u00A0\n") << 0 << true << "-\u00A0\n\n"; + QTest::newRow("nested empty lists") << "*\n *\n *\n" << 1 << true << " * \n"; + QTest::newRow("list nested in empty list") << "-\n * a\n" << 2 << false << "- \n * a\n"; + QTest::newRow("lists nested in empty lists") + << "-\n * a\n * b\n- c\n *\n + d\n" << 5 << false + << "- \n * a\n * b\n- c *\n + d\n"; + QTest::newRow("numeric lists nested in empty lists") + << "- \n 1. a\n 2. b\n- c\n 1.\n + d\n" << 4 << false + << "- \n 1. a\n 2. b\n- c 1. + d\n"; +} + +void tst_QTextMarkdownImporter::lists() +{ + QFETCH(QString, input); + QFETCH(int, expectedItemCount); + QFETCH(bool, expectedEmptyItems); + QFETCH(QString, rewrite); + + QTextDocument doc; + doc.setMarkdown(input); // QTBUG-78870 : don't crash + QTextFrame::iterator iterator = doc.rootFrame()->begin(); + QTextFrame *currentFrame = iterator.currentFrame(); + int i = 0; + int itemCount = 0; + bool emptyItems = true; + while (!iterator.atEnd()) { + // There are no child frames + QCOMPARE(iterator.currentFrame(), currentFrame); + // Check whether the block is text or a horizontal rule + QTextBlock block = iterator.currentBlock(); + if (block.textList()) { + ++itemCount; + if (!block.text().isEmpty()) + emptyItems = false; + } + qCDebug(lcTests, "%d %s%s", i, + (block.textList() ? "<li>" : "<p>"), qPrintable(block.text())); + ++iterator; + ++i; + } + QCOMPARE(itemCount, expectedItemCount); + QCOMPARE(emptyItems, expectedEmptyItems); + QCOMPARE(doc.toMarkdown(), rewrite); +} + QTEST_MAIN(tst_QTextMarkdownImporter) #include "tst_qtextmarkdownimporter.moc" diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp index 1e6c354f17..d15e856a20 100644 --- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp +++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp @@ -50,6 +50,7 @@ private slots: void testWriteParagraph_data(); void testWriteParagraph(); void testWriteList(); + void testWriteEmptyList(); void testWriteNestedBulletLists_data(); void testWriteNestedBulletLists(); void testWriteNestedNumericLists(); @@ -124,6 +125,14 @@ void tst_QTextMarkdownWriter::testWriteList() "- ListItem 1\n- ListItem 2\n")); } +void tst_QTextMarkdownWriter::testWriteEmptyList() +{ + QTextCursor cursor(document); + cursor.createList(QTextListFormat::ListDisc); + + QCOMPARE(documentToUnixMarkdown(), QString::fromLatin1("- \n")); +} + void tst_QTextMarkdownWriter::testWriteNestedBulletLists_data() { QTest::addColumn<bool>("checkbox"); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 98cb343ff8..5a643c11a2 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -262,6 +262,8 @@ private slots: void disabledProtocols_data(); void disabledProtocols(); + void oldErrorsOnSocketReuse(); + void setEmptyDefaultConfiguration(); // this test should be last protected slots: @@ -4391,6 +4393,53 @@ void tst_QSslSocket::disabledProtocols() } } +void tst_QSslSocket::oldErrorsOnSocketReuse() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; // not relevant + SslServer server; + server.protocol = QSsl::TlsV1_1; + server.m_certFile = testDataDir + "certs/fluke.cert"; + server.m_keyFile = testDataDir + "certs/fluke.key"; + QVERIFY(server.listen(QHostAddress::SpecialAddress::LocalHost)); + + QSslSocket socket; + socket.setProtocol(QSsl::TlsV1_1); + QList<QSslError> errorList; + auto connection = connect(&socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors), + [&socket, &errorList](const QList<QSslError> &errors) { + errorList += errors; + socket.ignoreSslErrors(errors); + socket.resume(); + }); + + socket.connectToHostEncrypted(QString::fromLatin1("localhost"), server.serverPort()); + QVERIFY(QTest::qWaitFor([&socket](){ return socket.isEncrypted(); })); + socket.disconnectFromHost(); + if (socket.state() != QAbstractSocket::UnconnectedState) { + QVERIFY(QTest::qWaitFor( + [&socket](){ + return socket.state() == QAbstractSocket::UnconnectedState; + })); + } + + auto oldList = errorList; + errorList.clear(); + server.close(); + server.m_certFile = testDataDir + "certs/bogus-client.crt"; + server.m_keyFile = testDataDir + "certs/bogus-client.key"; + QVERIFY(server.listen(QHostAddress::SpecialAddress::LocalHost)); + + socket.connectToHostEncrypted(QString::fromLatin1("localhost"), server.serverPort()); + QVERIFY(QTest::qWaitFor([&socket](){ return socket.isEncrypted(); })); + + for (const auto &error : oldList) { + QVERIFY2(!errorList.contains(error), + "The new errors should not contain any of the old ones"); + } +} + #endif // QT_NO_SSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 3f67b0e1b4..7398cc103e 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1030,15 +1030,13 @@ void tst_QFileSystemModel::dirsBeforeFiles() // Wait for model to be notified by the file system watcher QTRY_COMPARE(model->rowCount(root), 2 * itemCount); - // ensure that no file occurs before a directory - for (int i = 0; i < model->rowCount(root); ++i) { + // Ensure that no file occurs before any directory: + for (int i = 1; i < model->rowCount(root); ++i) { #ifndef Q_OS_MAC - QVERIFY(i == 0 || - !(model->fileInfo(model->index(i - 1, 0, root)).isFile() + QVERIFY(!(model->fileInfo(model->index(i - 1, 0, root)).isFile() && model->fileInfo(model->index(i, 0, root)).isDir())); #else - QVERIFY(i == 0 || - model->fileInfo(model->index(i - 1, 0, root)).fileName() < + QVERIFY(model->fileInfo(model->index(i - 1, 0, root)).fileName() < model->fileInfo(model->index(i, 0, root)).fileName()); #endif } diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 83bb4dc08f..f5358ceb93 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -228,6 +228,7 @@ void tst_QFontDialog::qtbug_41513_stylesheetStyle() // The fontdialog sets the styleName, when the fontdatabase knows the style name. resultFont.setStyleName(testFont.styleName()); + testFont.setFamilies(QStringList(testFont.family())); QCOMPARE(resultFont, testFont); // reset stylesheet diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index c29d1bbe04..3f2b8bca13 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -401,6 +401,7 @@ private slots: void tabletTracking(); void closeEvent(); + void closeWithChildWindow(); private: bool ensureScreenSize(int width, int height); @@ -11173,5 +11174,27 @@ void tst_QWidget::closeEvent() QCOMPARE(widget.closeCount, 1); } +void tst_QWidget::closeWithChildWindow() +{ + QWidget widget; + auto childWidget = new QWidget(&widget); + childWidget->setAttribute(Qt::WA_NativeWindow); + childWidget->windowHandle()->create(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + widget.windowHandle()->close(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + // Check that the child window inside the window is now visible + QVERIFY(childWidget->isVisible()); + + // Now explicitly hide the childWidget + childWidget->hide(); + widget.windowHandle()->close(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QVERIFY(!childWidget->isVisible()); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" |