diff options
Diffstat (limited to 'tests')
18 files changed, 461 insertions, 201 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 3fa765e2fa..a7dc869805 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1243,6 +1243,7 @@ void tst_QFileInfo::isSymLink_data() QFile::remove("link.lnk"); QFile::remove("brokenlink.lnk"); QFile::remove("dummyfile"); + QFile::remove("relative/link.lnk"); QFile file1(m_sourceFile); QVERIFY(file1.link("link.lnk")); @@ -1259,6 +1260,12 @@ void tst_QFileInfo::isSymLink_data() QTest::newRow("existent file") << m_sourceFile << false << ""; QTest::newRow("link") << "link.lnk" << true << QFileInfo(m_sourceFile).absoluteFilePath(); QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); + +#ifndef Q_OS_WIN + QDir::current().mkdir("relative"); + QFile::link("../dummyfile", "relative/link.lnk"); + QTest::newRow("relative link") << "relative/link.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); +#endif #endif } diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index ff8ee3d168..fc9f50b15c 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -105,6 +105,7 @@ private slots: void stateChange(); void flags(); void cleanup(); + void testBlockingWindowShownAfterModalDialog(); private: QPoint m_availableTopLeft; @@ -2270,6 +2271,47 @@ void tst_QWindow::flags() QCOMPARE(window.flags(), baseFlags | Qt::WindowStaysOnTopHint); } +class EventWindow : public QWindow +{ +public: + EventWindow() : QWindow(), gotBlocked(false) {} + bool gotBlocked; +protected: + bool event(QEvent *e) + { + if (e->type() == QEvent::WindowBlocked) + gotBlocked = true; + return QWindow::event(e); + } +}; + +void tst_QWindow::testBlockingWindowShownAfterModalDialog() +{ + EventWindow normalWindow; + normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80)); + normalWindow.resize(m_testWindowSize); + normalWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normalWindow)); + QVERIFY(!normalWindow.gotBlocked); + + QWindow dialog; + dialog.setFramePosition(m_availableTopLeft + QPoint(200, 200)); + dialog.resize(m_testWindowSize); + dialog.setModality(Qt::ApplicationModal); + dialog.setFlags(Qt::Dialog); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QVERIFY(normalWindow.gotBlocked); + + EventWindow normalWindowAfter; + normalWindowAfter.setFramePosition(m_availableTopLeft + QPoint(80, 80)); + normalWindowAfter.resize(m_testWindowSize); + QVERIFY(!normalWindowAfter.gotBlocked); + normalWindowAfter.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normalWindowAfter)); + QVERIFY(normalWindowAfter.gotBlocked); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/gui/text/qfont/BLACKLIST b/tests/auto/gui/text/qfont/BLACKLIST index 8890ec1ef3..295c61ff12 100644 --- a/tests/auto/gui/text/qfont/BLACKLIST +++ b/tests/auto/gui/text/qfont/BLACKLIST @@ -2,3 +2,5 @@ # QTBUG-46054 opensuse-13.1 opensuse-42.1 +[defaultFamily] +b2qt diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/README b/tests/auto/network/ssl/qsslcertificate/pkcs12/README index 1828d089c1..231567f586 100644 --- a/tests/auto/network/ssl/qsslcertificate/pkcs12/README +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/README @@ -1,8 +1,19 @@ -The PKCS#12 bundle was created by running the following on -in the qsslsocket/certs directory: +The PKCS#12 bundle was created by running the following in an +interactive shell in ../../qsslsocket/certs/: -openssl pkcs12 -export -in leaf.crt -inkey leaf.key \ - -out leaf.p12 \ +openssl pkcs12 -export -in leaf.crt \ + -inkey leaf.key -out leaf.p12 \ -certfile inter.crt -CAfile ca.crt -No password was provided. +An empty password was provided (twice). The pkcs.crt and pkcs.key +files were then copied here and leaf.p12 was moved here. + + +The test-case with no private key (in a valid PKCS12 file) was created +similarly but with the command adjusted to: + +openssl pkcs12 -export -in leaf.crt \ + -nokeys -out leaf-nokey.p12 \ + -certfile inter.crt -CAfile ca.crt + +The file leaf-nokey.p12 was then moved here. diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf-nokey.p12 b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf-nokey.p12 Binary files differnew file mode 100644 index 0000000000..032bf97b1b --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf-nokey.p12 diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index fced638ecb..064efc120b 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -1308,6 +1308,7 @@ void tst_QSslCertificate::version() void tst_QSslCertificate::pkcs12() { + // See pkcs12/README for how to generate the PKCS12 files used here. if (!QSslSocket::supportsSsl()) { qWarning("SSL not supported, skipping test"); return; @@ -1349,6 +1350,15 @@ void tst_QSslCertificate::pkcs12() QVERIFY(!caCerts.isEmpty()); QCOMPARE(caCerts.first(), caCert.first()); QCOMPARE(caCerts, caCert); + + // QTBUG-62335 - Fail (found no private key) but don't crash: + QFile nocert(testDataDir + QLatin1String("/pkcs12/leaf-nokey.p12")); + ok = nocert.open(QIODevice::ReadOnly); + QVERIFY(ok); + QTest::ignoreMessage(QtWarningMsg, "Unable to convert private key"); + ok = QSslCertificate::importPkcs12(&nocert, &key, &cert, &caCerts); + QVERIFY(!ok); + nocert.close(); } #endif // QT_NO_SSL diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index 16bb0b7c3e..cc32e73b9c 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -39,6 +39,7 @@ #include <qpainter.h> #include <qprintengine.h> #include <qpagelayout.h> +#include <qsharedpointer.h> #include <qtemporarydir.h> #include <math.h> @@ -47,25 +48,15 @@ #include <windows.h> #endif +#if QT_CONFIG(printer) +typedef QSharedPointer<QPrinter> PrinterPtr; -QT_FORWARD_DECLARE_CLASS(QPrinter) +Q_DECLARE_METATYPE(PrinterPtr) +Q_DECLARE_METATYPE(QPrinter::Orientation) +Q_DECLARE_METATYPE(QPrinter::PageSize) +#endif // printer -// Helper class to make sure temp files are cleaned up after test complete -class TempFileCleanup -{ -public: - TempFileCleanup(const QString &file) - : m_file(file) - { - } - - ~TempFileCleanup() - { - QFile::remove(m_file); - } -private: - QString m_file; -}; +static int fileNumber = 0; class tst_QPrinter : public QObject { @@ -133,6 +124,9 @@ private slots: void testPageMetrics(); #endif private: + QString testFileName(const QString &prefix, const QString &suffix); + QString testPdfFileName(const QString &prefix) { return testFileName(prefix, QStringLiteral("pdf")); } + QTemporaryDir m_tempDir; }; @@ -202,72 +196,72 @@ void tst_QPrinter::testPrintPreviewDialog() void tst_QPrinter::testPageRectAndPaperRect_data() { - QTest::addColumn<int>("orientation"); + QTest::addColumn<PrinterPtr>("printer"); + QTest::addColumn<QPrinter::Orientation>("orientation"); QTest::addColumn<bool>("withPainter"); QTest::addColumn<int>("resolution"); QTest::addColumn<bool>("doPaperRect"); + const PrinterPtr printer(new QPrinter(QPrinter::HighResolution)); // paperrect - QTest::newRow("paperRect0") << int(QPrinter::Portrait) << true << 300 << true; - QTest::newRow("paperRect1") << int(QPrinter::Portrait) << false << 300 << true; - QTest::newRow("paperRect2") << int(QPrinter::Landscape) << true << 300 << true; - QTest::newRow("paperRect3") << int(QPrinter::Landscape) << false << 300 << true; - QTest::newRow("paperRect4") << int(QPrinter::Portrait) << true << 600 << true; - QTest::newRow("paperRect5") << int(QPrinter::Portrait) << false << 600 << true; - QTest::newRow("paperRect6") << int(QPrinter::Landscape) << true << 600 << true; - QTest::newRow("paperRect7") << int(QPrinter::Landscape) << false << 600 << true; - QTest::newRow("paperRect8") << int(QPrinter::Portrait) << true << 1200 << true; - QTest::newRow("paperRect9") << int(QPrinter::Portrait) << false << 1200 << true; - QTest::newRow("paperRect10") << int(QPrinter::Landscape) << true << 1200 << true; - QTest::newRow("paperRect11") << int(QPrinter::Landscape) << false << 1200 << true; + QTest::newRow("paperRect0") << printer << QPrinter::Portrait << true << 300 << true; + QTest::newRow("paperRect1") << printer << QPrinter::Portrait << false << 300 << true; + QTest::newRow("paperRect2") << printer << QPrinter::Landscape << true << 300 << true; + QTest::newRow("paperRect3") << printer << QPrinter::Landscape << false << 300 << true; + QTest::newRow("paperRect4") << printer << QPrinter::Portrait << true << 600 << true; + QTest::newRow("paperRect5") << printer << QPrinter::Portrait << false << 600 << true; + QTest::newRow("paperRect6") << printer << QPrinter::Landscape << true << 600 << true; + QTest::newRow("paperRect7") << printer << QPrinter::Landscape << false << 600 << true; + QTest::newRow("paperRect8") << printer << QPrinter::Portrait << true << 1200 << true; + QTest::newRow("paperRect9") << printer << QPrinter::Portrait << false << 1200 << true; + QTest::newRow("paperRect10") << printer << QPrinter::Landscape << true << 1200 << true; + QTest::newRow("paperRect11") << printer << QPrinter::Landscape << false << 1200 << true; // page rect - QTest::newRow("pageRect0") << int(QPrinter::Portrait) << true << 300 << false; - QTest::newRow("pageRect1") << int(QPrinter::Portrait) << false << 300 << false; - QTest::newRow("pageRect2") << int(QPrinter::Landscape) << true << 300 << false; - QTest::newRow("pageRect3") << int(QPrinter::Landscape) << false << 300 << false; - QTest::newRow("pageRect4") << int(QPrinter::Portrait) << true << 600 << false; - QTest::newRow("pageRect5") << int(QPrinter::Portrait) << false << 600 << false; - QTest::newRow("pageRect6") << int(QPrinter::Landscape) << true << 600 << false; - QTest::newRow("pageRect7") << int(QPrinter::Landscape) << false << 600 << false; - QTest::newRow("pageRect8") << int(QPrinter::Portrait) << true << 1200 << false; - QTest::newRow("pageRect9") << int(QPrinter::Portrait) << false << 1200 << false; - QTest::newRow("pageRect10") << int(QPrinter::Landscape) << true << 1200 << false; - QTest::newRow("pageRect11") << int(QPrinter::Landscape) << false << 1200 << false; + QTest::newRow("pageRect0") << printer << QPrinter::Portrait << true << 300 << false; + QTest::newRow("pageRect1") << printer << QPrinter::Portrait << false << 300 << false; + QTest::newRow("pageRect2") << printer << QPrinter::Landscape << true << 300 << false; + QTest::newRow("pageRect3") << printer << QPrinter::Landscape << false << 300 << false; + QTest::newRow("pageRect4") << printer << QPrinter::Portrait << true << 600 << false; + QTest::newRow("pageRect5") << printer << QPrinter::Portrait << false << 600 << false; + QTest::newRow("pageRect6") << printer << QPrinter::Landscape << true << 600 << false; + QTest::newRow("pageRect7") << printer << QPrinter::Landscape << false << 600 << false; + QTest::newRow("pageRect8") << printer << QPrinter::Portrait << true << 1200 << false; + QTest::newRow("pageRect9") << printer << QPrinter::Portrait << false << 1200 << false; + QTest::newRow("pageRect10") << printer << QPrinter::Landscape << true << 1200 << false; + QTest::newRow("pageRect11") << printer << QPrinter::Landscape << false << 1200 << false; } void tst_QPrinter::testPageRectAndPaperRect() { + QFETCH(PrinterPtr, printer); QFETCH(bool, withPainter); - QFETCH(int, orientation); + QFETCH(QPrinter::Orientation, orientation); QFETCH(int, resolution); QFETCH(bool, doPaperRect); QPainter *painter = 0; - QPrinter printer(QPrinter::HighResolution); - printer.setOrientation(QPrinter::Orientation(orientation)); - const QString fileName = m_tempDir.path() + QLatin1String("/silly"); - printer.setOutputFileName(fileName); - TempFileCleanup tmpFile(fileName); - - QRect pageRect = doPaperRect ? printer.paperRect() : printer.pageRect(); - float inchesX = float(pageRect.width()) / float(printer.resolution()); - float inchesY = float(pageRect.height()) / float(printer.resolution()); - printer.setResolution(resolution); + printer->setOrientation(orientation); + printer->setOutputFileName(testFileName(QLatin1String("silly"), QString())); + + QRect pageRect = doPaperRect ? printer->paperRect() : printer->pageRect(); + float inchesX = float(pageRect.width()) / float(printer->resolution()); + float inchesY = float(pageRect.height()) / float(printer->resolution()); + printer->setResolution(resolution); if (withPainter) - painter = new QPainter(&printer); + painter = new QPainter(printer.data()); - QRect otherRect = doPaperRect ? printer.paperRect() : printer.pageRect(); - float otherInchesX = float(otherRect.width()) / float(printer.resolution()); - float otherInchesY = float(otherRect.height()) / float(printer.resolution()); + QRect otherRect = doPaperRect ? printer->paperRect() : printer->pageRect(); + float otherInchesX = float(otherRect.width()) / float(printer->resolution()); + float otherInchesY = float(otherRect.height()) / float(printer->resolution()); if (painter != 0) delete painter; QVERIFY(qAbs(otherInchesX - inchesX) < 0.01); QVERIFY(qAbs(otherInchesY - inchesY) < 0.01); - QVERIFY(printer.orientation() == QPrinter::Portrait || pageRect.width() > pageRect.height()); - QVERIFY(printer.orientation() != QPrinter::Portrait || pageRect.width() < pageRect.height()); + QVERIFY(printer->orientation() == QPrinter::Portrait || pageRect.width() > pageRect.height()); + QVERIFY(printer->orientation() != QPrinter::Portrait || pageRect.width() < pageRect.height()); } void tst_QPrinter::testSetOptions() @@ -299,45 +293,40 @@ void tst_QPrinter::testSetOptions() void tst_QPrinter::testMargins_data() { - QTest::addColumn<int>("orientation"); + QTest::addColumn<PrinterPtr>("printer"); + QTest::addColumn<QPrinter::Orientation>("orientation"); QTest::addColumn<bool>("fullpage"); - QTest::addColumn<int>("pagesize"); - QTest::addColumn<int>("width"); - QTest::addColumn<int>("height"); + QTest::addColumn<QPrinter::PageSize>("pagesize"); QTest::addColumn<bool>("withPainter"); - QTest::newRow("data0") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << false; - QTest::newRow("data1") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << false; - QTest::newRow("data2") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << false; - QTest::newRow("data3") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << false; - QTest::newRow("data4") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << true; - QTest::newRow("data5") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << true; - QTest::newRow("data6") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << true; - QTest::newRow("data7") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << true; + const PrinterPtr printer(new QPrinter); + QTest::newRow("data0") << printer << QPrinter::Portrait << true << QPrinter::A4 << false; + QTest::newRow("data1") << printer << QPrinter::Landscape << true << QPrinter::A4 << false; + QTest::newRow("data2") << printer << QPrinter::Landscape << false << QPrinter::A4 << false; + QTest::newRow("data3") << printer << QPrinter::Portrait << false << QPrinter::A4 << false; + QTest::newRow("data4") << printer << QPrinter::Portrait << true << QPrinter::A4 << true; + QTest::newRow("data5") << printer << QPrinter::Landscape << true << QPrinter::A4 << true; + QTest::newRow("data6") << printer << QPrinter::Landscape << false << QPrinter::A4 << true; + QTest::newRow("data7") << printer << QPrinter::Portrait << false << QPrinter::A4 << true; } void tst_QPrinter::testMargins() { + QFETCH(PrinterPtr, printer); QFETCH(bool, withPainter); - QFETCH(int, orientation); - QFETCH(int, pagesize); - QFETCH(int, width); - QFETCH(int, height); + QFETCH(QPrinter::Orientation, orientation); + QFETCH(QPrinter::PageSize, pagesize); QFETCH(bool, fullpage); - Q_UNUSED(width); - Q_UNUSED(height); - QPrinter printer; QPainter *painter = 0; - printer.setOutputFileName("silly"); - printer.setOrientation((QPrinter::Orientation)orientation); - printer.setFullPage(fullpage); - printer.setPageSize((QPrinter::PageSize)pagesize); + printer->setOutputFileName(testFileName(QLatin1String("silly"), QString())); + printer->setOrientation(orientation); + printer->setFullPage(fullpage); + printer->setPageSize(pagesize); if (withPainter) - painter = new QPainter(&printer); + painter = new QPainter(printer.data()); if (painter) delete painter; - QFile::remove("silly"); } void tst_QPrinter::testMulitpleSets_data() @@ -420,9 +409,7 @@ void tst_QPrinter::outputFormatFromSuffix() QSKIP("No printers available."); QPrinter p; QCOMPARE(p.outputFormat(), QPrinter::NativeFormat); - const QString fileName = m_tempDir.path() + QLatin1String("/test.pdf"); - p.setOutputFileName(fileName); - TempFileCleanup tmpFile(fileName); + p.setOutputFileName(testPdfFileName(QLatin1String("test"))); QCOMPARE(p.outputFormat(), QPrinter::PdfFormat); p.setOutputFileName(QString()); QCOMPARE(p.outputFormat(), QPrinter::NativeFormat); @@ -510,9 +497,7 @@ void tst_QPrinter::errorReporting() p.setOutputFileName("/foobar/nonwritable.pdf"); QCOMPARE(painter.begin(&p), false); // it should check the output file is writable #endif - const QString fileName = m_tempDir.path() + QLatin1String("/test.pdf"); - p.setOutputFileName(fileName); - TempFileCleanup tmpFile(fileName); + p.setOutputFileName(testPdfFileName(QLatin1String("test"))); QCOMPARE(painter.begin(&p), true); // it should check the output QCOMPARE(p.isValid(), true); painter.end(); @@ -606,8 +591,7 @@ void tst_QPrinter::customPaperSizeAndMargins() void tst_QPrinter::printDialogCompleter() { QPrintDialog dialog; - dialog.printer()->setOutputFileName("file.pdf"); - TempFileCleanup tmpFile("file.pdf"); + dialog.printer()->setOutputFileName(testPdfFileName(QLatin1String("file"))); dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile); dialog.show(); @@ -627,10 +611,8 @@ static void printPage(QPainter *painter) void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles() { - const QString fileName1 = m_tempDir.path() + QLatin1String("/out1.pdf"); - const QString fileName2 = m_tempDir.path() + QLatin1String("/out2.pdf"); - TempFileCleanup tmpFile1(fileName1); - TempFileCleanup tmpFile2(fileName2); + const QString fileName1 = testPdfFileName(QLatin1String("out1_")); + const QString fileName2 = testPdfFileName(QLatin1String("out2_")); QPrinter printer; { @@ -689,7 +671,7 @@ void tst_QPrinter::testCurrentPage() void tst_QPrinter::testPdfTitle() { - const QString fileName = m_tempDir.path() + QLatin1String("/file.pdf"); + const QString fileName = testPdfFileName(QLatin1String("file")); // Check the document name is represented correctly in produced pdf { @@ -703,7 +685,6 @@ void tst_QPrinter::testPdfTitle() painter.begin(&printer); painter.end(); } - TempFileCleanup tmpFile(fileName); QFile file(fileName); QVERIFY(file.open(QIODevice::ReadOnly)); // The we expect the title to appear in the PDF as: @@ -1244,8 +1225,9 @@ void tst_QPrinter::outputFileName() QPrinter pdf; pdf.setOutputFormat(QPrinter::PdfFormat); QCOMPARE(pdf.outputFileName(), QString()); - pdf.setOutputFileName(QStringLiteral("Test File")); - QCOMPARE(pdf.outputFileName(), QString("Test File")); + const QString fileName = testFileName(QStringLiteral("Test File"), QString()); + pdf.setOutputFileName(fileName); + QCOMPARE(pdf.outputFileName(), fileName); QPrinter native; if (native.outputFormat() == QPrinter::NativeFormat) { @@ -1253,7 +1235,7 @@ void tst_QPrinter::outputFileName() QCOMPARE(native.outputFileName(), QString()); // Test set/get - QString expected = QStringLiteral("Test File"); + QString expected = fileName; native.setOutputFileName(expected); QCOMPARE(native.outputFileName(), expected); @@ -1960,6 +1942,15 @@ void tst_QPrinter::testPageMetrics() QCOMPARE(printer.pageRect(QPrinter::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf)); } +QString tst_QPrinter::testFileName(const QString &prefix, const QString &suffix) +{ + QString result = m_tempDir.path() + QLatin1Char('/') + prefix + + QString::number(fileNumber++); + if (!suffix.isEmpty()) + result += QLatin1Char('.') + suffix; + return result; +} + #endif // QT_CONFIG(printer) QTEST_MAIN(tst_QPrinter) diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index c20fafe158..92a06cda00 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -136,7 +136,7 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem() #ifdef Q_OS_UNIX // This function does roughly the same as the `command substitution` in // the shell. -QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) +QString getOutputFromCommandInternal(const QStringList &command) { // The command execution does nothing on non-unix systems. int pid; @@ -194,6 +194,16 @@ QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) return QString(array); } } + +QString tst_QPrinterInfo::getOutputFromCommand(const QStringList &command) +{ + // Forces the ouptut from the command to be in English + const QByteArray origSoftwareEnv = qgetenv("SOFTWARE"); + qputenv("SOFTWARE", QByteArray()); + QString output = getOutputFromCommandInternal(command); + qputenv("SOFTWARE", origSoftwareEnv); + return output; +} #endif // Windows test support not yet implemented diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index c21223886a..5482dc393b 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -177,7 +177,7 @@ public: for (int i = 0; i < ProdConIterations; ++i) { QVERIFY_SQL(q1, exec("select max(id) from " + qtest)); q1.first(); - q2.bindValue("id", q1.value(0)); + q2.bindValue(":id", q1.value(0)); q1.clear(); QVERIFY_SQL(q2, exec()); QThread::yieldCurrentThread(); diff --git a/tests/auto/tools/qmake/testdata/rawString/main.cpp b/tests/auto/tools/qmake/testdata/rawString/main.cpp index 53a28f7bc0..bc557f39f8 100644 --- a/tests/auto/tools/qmake/testdata/rawString/main.cpp +++ b/tests/auto/tools/qmake/testdata/rawString/main.cpp @@ -26,8 +26,107 @@ ** ****************************************************************************/ +// macro names that *aren't* string-literal-prefixes: +#define Ru8 "rue-it" +#define RL "real life" +#define Ru "are you ?" +#define RU "Are You ?" +#define LLR "double-hockey-sticks" +#define LUR "Tricky" +#define LuR "tricky" +#define Lu8R "l'uber" +#define UUR "Double-Yew" +#define ULR "Eweler" +#define UuR "You ... you-are" +#define Uu8R "You ... you *ate* our ..." +#define uuR "water" +#define uLR "eweler" +#define uUR "double-Your" +#define uu8R "totally uber" +#define u8u8R "rubber-you" +#define u8LR "Uber left-to-right" +#define u8UR "Uber Upper-Right" +#define u8uR "Uber upper-right" +#define Ru8R "bouncy" +#define RLR "Marching" +#define RuR "Rossum's general-purpose workers" +#define RUR "Rossum's Universal Robots" + +static const char monstrosity[] = + Ru8"Ru8(" + RL"RL(" + Ru"Ru(" + RU"RU(" + LLR"LLR(" + LUR"LUR(" + LuR"LuR(" + Lu8R"Lu8R(" + UUR"UUR(" + ULR"ULR(" + UuR"UuR(" + Uu8R"Uu8R(" + uuR"uuR(" + uLR"uLR(" + uUR"uUR(" + uu8R"uu8R(" + u8u8R"u8u8R(" + u8LR"u8LR(" + u8UR"u8UR(" + u8uR"u8uR(" + Ru8R"Ru8R(" + RLR"RLR(" + RuR"RuR(" + RUR"RUR(" + "Finally, some content"; + +#include <moc_object2.cpp> + +static const char closure[] = + ")RUR" + ")RuR" + ")RLR" + ")Ru8R" + ")u8uR" + ")u8UR" + ")u8LR" + ")u8u8R" + ")uu8R" + ")uUR" + ")uLR" + ")uuR" + ")Uu8R" + ")UuR" + ")ULR" + ")UUR" + ")Lu8R" + ")LuR" + ")LUR" + ")LLR" + ")RU" + ")Ru" + ")RL" + ")Ru8"; +// If moc got confused, the confusion should now be over + +// Real raw strings, not actually leaving us inside any comments: static const char raw[] = R"blah(lorem " ipsum /*)blah"\ ; +static const wchar_t wider[] = LR"blah(lorem " ipsum /*)blah"\ +; +static const char32_t UCS4[] = UR"blah(lorem " ipsum /*)blah"\ +; +static const char16_t UCS2[] = uR"blah(lorem " ipsum /*)blah"\ +; +static const char utf8[] = u8R"blah(lorem " ipsum /*)blah"\ +; #include <moc_object1.cpp> -int main () { return 0; } +/* Avoid unused variable warnings by silly uses of arrays: */ +#define final(x) x[sizeof(x) - 1] // 0, of course +int main () { + return final(raw) + * (final(wider) - final(UCS4)) + * (final(UCS2) - final(utf8)) + * (final(monstrosity) - final(closure)); +} +#undef final diff --git a/tests/auto/tools/qmake/testdata/rawString/object2.h b/tests/auto/tools/qmake/testdata/rawString/object2.h new file mode 100644 index 0000000000..2ab77cd3bd --- /dev/null +++ b/tests/auto/tools/qmake/testdata/rawString/object2.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TEST_QMAKE_RAWSTRING_OBJECT2_H +#define TEST_QMAKE_RAWSTRING_OBJECT2_H + +#define Lu8UR "land" +inline char opener(int i) { + const char text[] = Lu8UR"blah( not a raw string; just juxtaposed"; + return text[i]; +} + +#include <QObject> + +class Object2 : public QObject +{ + Q_OBJECT +}; + +inline char closer(int i) { + const char text[] = "pretend to close it, all the same )blah"; + return text[i]; +} + +#endif // TEST_QMAKE_RAWSTRING_OBJECT2_H diff --git a/tests/auto/tools/qmake/testdata/rawString/rawString.pro b/tests/auto/tools/qmake/testdata/rawString/rawString.pro index d2d8132ceb..19c81dfe97 100644 --- a/tests/auto/tools/qmake/testdata/rawString/rawString.pro +++ b/tests/auto/tools/qmake/testdata/rawString/rawString.pro @@ -1,4 +1,4 @@ DESTDIR = ./ -HEADERS += object1.h +HEADERS += object1.h object2.h SOURCES += main.cpp diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 5e3cb66aae..1be17b552e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -41,7 +41,6 @@ #include <qcommonstyle.h> #include <qstylefactory.h> #include <qscreen.h> -#include <QSysInfo> typedef QList<QGraphicsItem *> QGraphicsItemList; @@ -1777,16 +1776,10 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() #ifdef Q_OS_MAC QEXPECT_FAIL("", "QTBUG-23699", Continue); #endif -#ifdef Q_OS_WIN - if (QSysInfo::kernelVersion() == "10.0.15063") { - QEXPECT_FAIL("", "This fails on Windows 10 Creators Update (10.0.15063)", Continue); - } -#endif QTRY_COMPARE(qApp->activeWindow(), static_cast<QWidget *>(&view)); QTRY_COMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(w)); } - void tst_QGraphicsWidget::sizeHint_data() { QTest::addColumn<bool>("layout"); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index d328163a05..096beedf63 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1774,12 +1774,6 @@ void tst_QWidget::activation() QCOMPARE(QApplication::activeWindow(), &widget2); widget2.hide(); QTest::qWait(waitTime); -#ifdef Q_OS_WIN - if (QSysInfo::kernelVersion() == "10.0.15063") { - QEXPECT_FAIL("", "This fails on Windows 10 Creators Update (10.0.15063)", Continue); - // This happens in automated Windows 10 Creators Update (10.0.15063) CI builds! - } -#endif QCOMPARE(QApplication::activeWindow(), &widget1); } #endif // Q_OS_WIN diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index a6855a417e..9dc513c115 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -104,6 +104,8 @@ private slots: void setWindowState(); void nativeShow(); + + void QTBUG_56277_resize_on_showEvent(); }; void tst_QWidget_window::initTestCase() @@ -931,5 +933,34 @@ void tst_QWidget_window::nativeShow() QTRY_VERIFY(!w.isVisible()); } +class ResizedOnShowEventWidget : public QWidget +{ +public: + void showEvent(QShowEvent *) override + { + const auto *primaryScreen = QApplication::primaryScreen(); + auto newSize = primaryScreen->availableGeometry().size() / 4; + if (newSize == geometry().size()) + newSize -= QSize(10, 10); + resize(newSize); + } +}; + +void tst_QWidget_window::QTBUG_56277_resize_on_showEvent() +{ + const auto platformName = QGuiApplication::platformName().toLower(); + if (platformName != "cocoa" && platformName != "windows") + QSKIP("This can only be consistently tested on desktop platforms with well-known behavior."); + + ResizedOnShowEventWidget w; + w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); + const auto *screen = w.windowHandle()->screen(); + const auto geometry = w.geometry(); + const int frameHeight = geometry.top() - w.frameGeometry().top(); + const int topmostY = screen->availableGeometry().top() + frameHeight; + QVERIFY(geometry.top() > topmostY || geometry.left() > screen->availableGeometry().left()); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" diff --git a/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro b/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro index 18425f4a25..0b710ab89c 100644 --- a/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro +++ b/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro @@ -3,4 +3,3 @@ TARGET = tst_bench_qsqlquery SOURCES += main.cpp QT = core sql testlib core-private sql-private -LIBS += $$QMAKE_LIBS_NETWORK diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp index 466a7e20fc..82bcd838e6 100644 --- a/tests/manual/qtabbar/main.cpp +++ b/tests/manual/qtabbar/main.cpp @@ -103,6 +103,9 @@ int main(int argc, char *argv[]) // right // tabBar.setShape(QTabBar::RoundedEast); + const auto shortLabel = QStringLiteral("Tab %1"); + const auto longLabel = QStringLiteral("An Extremely Long Tab Label %1"); + QMap<int, QWidget*> tabs; for (int i = 0; i < TabCount; i++) { QString tabNumberString = QString::number(i); @@ -110,7 +113,7 @@ int main(int argc, char *argv[]) tabs[i] = label; label->setAlignment(Qt::AlignCenter); stackedWidget.addWidget(label); - tabBar.addTab(QStringLiteral("Tab %1").arg(tabNumberString)); + tabBar.addTab(shortLabel.arg(tabNumberString)); } QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) { @@ -205,6 +208,13 @@ int main(int argc, char *argv[]) tabBar.setTabIcon(i, icon); }); + form.ui->longLabelButton->setChecked(false); + QObject::connect(form.ui->longLabelButton, &QCheckBox::toggled, [&] { + const auto &label = form.ui->longLabelButton->isChecked() ? longLabel : shortLabel; + for (int i = 0; i < tabBar.count(); i++) + tabBar.setTabText(i, label.arg(i)); + }); + QObject::connect(form.ui->shapeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [&](int index) { Q_UNUSED(index); // TODO diff --git a/tests/manual/qtabbar/tabbarform.ui b/tests/manual/qtabbar/tabbarform.ui index 17100b3b62..f8766f22f2 100644 --- a/tests/manual/qtabbar/tabbarform.ui +++ b/tests/manual/qtabbar/tabbarform.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>308</width> - <height>260</height> + <height>308</height> </rect> </property> <property name="sizePolicy"> @@ -22,24 +22,61 @@ <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> - <item row="10" column="1"> - <widget class="QRadioButton" name="rightAlignedButton"> + <item row="7" column="1"> + <widget class="QComboBox" name="shapeComboBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>North</string> + </property> + </item> + <item> + <property name="text"> + <string>South</string> + </property> + </item> + <item> + <property name="text"> + <string>West</string> + </property> + </item> + <item> + <property name="text"> + <string>East</string> + </property> + </item> + </widget> + </item> + <item row="8" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>12</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> <property name="text"> - <string>Right aligned</string> + <string>Tab bar options:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - <attribute name="buttonGroup"> - <string notr="true">textAlignmentGroup</string> - </attribute> </widget> </item> - <item row="8" column="1"> - <widget class="QRadioButton" name="leftAlignedButton"> + <item row="0" column="1"> + <widget class="QCheckBox" name="documentModeButton"> <property name="text"> - <string>Left aligned</string> + <string>Document mode</string> </property> - <attribute name="buttonGroup"> - <string notr="true">textAlignmentGroup</string> - </attribute> </widget> </item> <item row="2" column="1"> @@ -49,14 +86,14 @@ </property> </widget> </item> - <item row="8" column="0"> - <widget class="QLabel" name="label"> + <item row="9" column="1"> + <widget class="QRadioButton" name="leftAlignedButton"> <property name="text"> - <string>Tabs alignment:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <string>Left aligned</string> </property> + <attribute name="buttonGroup"> + <string notr="true">textAlignmentGroup</string> + </attribute> </widget> </item> <item row="1" column="1"> @@ -66,10 +103,13 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QCheckBox" name="documentModeButton"> + <item row="7" column="0"> + <widget class="QLabel" name="label_3"> <property name="text"> - <string>Document mode</string> + <string>Tab shape (TODO):</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> @@ -80,47 +120,17 @@ </property> </widget> </item> - <item row="6" column="1"> - <widget class="QComboBox" name="shapeComboBox"> - <property name="enabled"> - <bool>false</bool> - </property> - <item> - <property name="text"> - <string>North</string> - </property> - </item> - <item> - <property name="text"> - <string>South</string> - </property> - </item> - <item> - <property name="text"> - <string>West</string> - </property> - </item> - <item> - <property name="text"> - <string>East</string> - </property> - </item> - </widget> - </item> - <item row="7" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="9" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Tabs alignment:</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>12</height> - </size> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - </spacer> + </widget> </item> - <item row="5" column="1"> + <item row="6" column="1"> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -133,17 +143,14 @@ </property> </spacer> </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> + <item row="4" column="1"> + <widget class="QCheckBox" name="displayIconButton"> <property name="text"> - <string>Tab bar options:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <string>Display icon</string> </property> </widget> </item> - <item row="9" column="1"> + <item row="10" column="1"> <widget class="QRadioButton" name="centeredButton"> <property name="text"> <string>Centered</string> @@ -153,20 +160,20 @@ </attribute> </widget> </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_3"> + <item row="11" column="1"> + <widget class="QRadioButton" name="rightAlignedButton"> <property name="text"> - <string>Tab shape (TODO):</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <string>Right aligned</string> </property> + <attribute name="buttonGroup"> + <string notr="true">textAlignmentGroup</string> + </attribute> </widget> </item> - <item row="4" column="1"> - <widget class="QCheckBox" name="displayIconButton"> + <item row="5" column="1"> + <widget class="QCheckBox" name="longLabelButton"> <property name="text"> - <string>Display icon</string> + <string>Long tab label</string> </property> </widget> </item> |