From cdba2439f91c1d3757e5d36f7759ac73a2e8ac2d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Jul 2014 10:32:07 +0200 Subject: QSplitter: Exclude top level widgets from child event handling. Prevent the splitter from adding them to the layout or showing them. Task-number: QTBUG-40132 Change-Id: Ife2be0bbd7e489570ef41f6f72a034b356c65f18 Reviewed-by: J-P Nurmi --- .../widgets/widgets/qsplitter/tst_qsplitter.cpp | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index 8de3291207..d66a10ae56 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -54,6 +54,8 @@ #include #include #include +#include +#include #include // for file error messages QT_FORWARD_DECLARE_CLASS(QSplitter) @@ -94,6 +96,8 @@ private slots: void taskQTBUG_4101_ensureOneNonCollapsedWidget_data(); void taskQTBUG_4101_ensureOneNonCollapsedWidget(); void setLayout(); + void autoAdd(); + private: void removeThirdWidget(); void addThirdWidget(); @@ -781,5 +785,28 @@ void tst_QSplitter::setLayout() QCOMPARE(splitter.layout(), &layout); } +void tst_QSplitter::autoAdd() +{ + QSplitter splitter; + splitter.setWindowTitle("autoAdd"); + splitter.setMinimumSize(QSize(200, 200)); + splitter.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100)); + splitter.show(); + QVERIFY(QTest::qWaitForWindowExposed(&splitter)); + // Constructing a child widget on the splitter should + // automatically add and show it. + QWidget *childWidget = new QWidget(&splitter); + QCOMPARE(splitter.count(), 1); + QTRY_VERIFY(childWidget->isVisible()); + // Deleting should automatically remove it + delete childWidget; + QCOMPARE(splitter.count(), 0); + // QTBUG-40132, top level windows should not be affected by this. + QDialog *dialog = new QDialog(&splitter); + QCOMPARE(splitter.count(), 0); + QCoreApplication::processEvents(); + QVERIFY(!dialog->isVisible()); +} + QTEST_MAIN(tst_QSplitter) #include "tst_qsplitter.moc" -- cgit v1.2.3 From feb1afc78290433b0c22b1b3f6d65542eeb5b957 Mon Sep 17 00:00:00 2001 From: Nikita Krupenko Date: Fri, 13 Jun 2014 20:04:16 +0300 Subject: Added stream version into network cache file format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the moment, there is no stream information in the cache file. This can lead to a problem when current stream version differs from version cache file written with. As an example, if file written with Qt 5.1.1, QTimeDate in the metadata stored as 13-bytes value, but Qt 5.2 and later can read additional 4 bytes which breaks following data, leading to network request just hangs forever. Adding stream version fixes this problem. As cache format changed, cache version bumped. Task-number: QTBUG-36219 Change-Id: I467d8c9fda82bcf9302192f51e7a00d2f6a9ff66 Reviewed-by: Jędrzej Nowacki --- .../qnetworkdiskcache/tst_qnetworkdiskcache.cpp | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 4740b92b84..d28f11ff9d 100644 --- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -85,6 +85,9 @@ private slots: void oldCacheVersionFile_data(); void oldCacheVersionFile(); + void streamVersion_data(); + void streamVersion(); + void sync(); void crashWhenParentingCache(); @@ -568,6 +571,74 @@ void tst_QNetworkDiskCache::oldCacheVersionFile() } } +void tst_QNetworkDiskCache::streamVersion_data() +{ + QTest::addColumn("version"); + QTest::newRow("Qt 5.1") << int(QDataStream::Qt_5_1); + QDataStream ds; + QTest::newRow("current") << ds.version(); + QTest::newRow("higher than current") << ds.version() + 1; +} + +void tst_QNetworkDiskCache::streamVersion() +{ + SubQNetworkDiskCache cache; + QUrl url(EXAMPLE_URL); + cache.setupWithOne(tempDir.path(), url); + + QString cacheFile; + // find the file + QStringList files = countFiles(cache.cacheDirectory()); + foreach (const QString &file, files) { + QFileInfo info(file); + if (info.isFile()) { + cacheFile = file; + break; + } + } + + QFile file(cacheFile); + QVERIFY(file.open(QFile::ReadWrite|QIODevice::Truncate)); + QDataStream out(&file); + QFETCH(int, version); + if (version < out.version()) + out.setVersion(version); + out << qint32(0xe8); // cache magic + // Following code works only for cache file version 8 and should be updated on version change + out << qint32(8); + out << qint32(version); + + QNetworkCacheMetaData md; + md.setUrl(url); + QNetworkCacheMetaData::RawHeader header("content-type", "text/html"); + QNetworkCacheMetaData::RawHeaderList list; + list.append(header); + md.setRawHeaders(list); + md.setLastModified(QDateTime::currentDateTimeUtc().toOffsetFromUtc(3600)); + out << md; + + bool compressed = true; + out << compressed; + + QByteArray data("Hello World!"); + out << qCompress(data); + + file.close(); + + QNetworkCacheMetaData cachedMetaData = cache.call_fileMetaData(cacheFile); + if (version > out.version()) { + QVERIFY(!cachedMetaData.isValid()); + QVERIFY(!QFile::exists(cacheFile)); + } else { + QVERIFY(cachedMetaData.isValid()); + QVERIFY(QFile::exists(cacheFile)); + QIODevice *dataDevice = cache.data(url); + QVERIFY(dataDevice != 0); + QByteArray cachedData = dataDevice->readAll(); + QCOMPARE(cachedData, data); + } +} + class Runner : public QThread { -- cgit v1.2.3 From a71e285133087714034f3c84a758980c85b3801e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 14 Jul 2014 13:53:23 +0200 Subject: Ensure transient parents are top level widgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a dialog was parented on a native child widget, its window handle was used as a transient parent. This confused QPlatformWindow::initialGeometry() among other things. Use top level window as is in Qt 4. Task-number: QTBUG-40195 Change-Id: Ic82adc276175f92adde825fb2551274351e41f30 Reviewed-by: Jørgen Lind --- tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index c3d2c4a9e7..cd9ff28891 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -85,6 +86,8 @@ private slots: void setVisible(); void reject(); void snapToDefaultButton(); + void transientParent_data(); + void transientParent(); private: QDialog *testWidget; @@ -584,5 +587,34 @@ void tst_QDialog::snapToDefaultButton() #endif // !QT_NO_CURSOR } +void tst_QDialog::transientParent_data() +{ + QTest::addColumn("nativewidgets"); + QTest::newRow("Non-native") << false; + QTest::newRow("Native") << true; +} + +void tst_QDialog::transientParent() +{ + QFETCH(bool, nativewidgets); + testWidget->hide(); + QWidget topLevel; + topLevel.resize(200, 200); + topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100)); + QVBoxLayout *layout = new QVBoxLayout(&topLevel); + QWidget *innerWidget = new QWidget(&topLevel); + layout->addWidget(innerWidget); + if (nativewidgets) + innerWidget->winId(); + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + QDialog dialog(innerWidget); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + // Transient parent should always be the top level, also when using + // native child widgets. + QCOMPARE(dialog.windowHandle()->transientParent(), topLevel.windowHandle()); +} + QTEST_MAIN(tst_QDialog) #include "tst_qdialog.moc" -- cgit v1.2.3 From e746e2a11a1fb0b4603df3d8740b09b362116698 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Jul 2014 12:04:49 +0200 Subject: Android: Fix tests in gui/text requiring test data Several tests require test data to be deployed with the application. The easiest way to achieve this on Android is to add them to a qrc file and use the QFINDTESTDATA macro to look up the files. This fixes several test failures in the gui/text subdirectory for Android. Change-Id: If944bb1fc93434a1b2d6487da829d21bd6b84e87 Reviewed-by: BogDan Vatra --- tests/auto/gui/text/qcssparser/qcssparser.pro | 5 +++++ tests/auto/gui/text/qcssparser/testdata.qrc | 18 ++++++++++++++++++ tests/auto/gui/text/qcssparser/tst_qcssparser.cpp | 4 +++- tests/auto/gui/text/qglyphrun/qglyphrun.pro | 12 +++++++++--- tests/auto/gui/text/qglyphrun/testdata.qrc | 5 +++++ tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp | 2 +- tests/auto/gui/text/qrawfont/qrawfont.pro | 5 +++++ tests/auto/gui/text/qrawfont/testdata.qrc | 6 ++++++ tests/auto/gui/text/qzip/qzip.pro | 8 +++++--- tests/auto/gui/text/qzip/testdata.qrc | 6 ++++++ tests/auto/gui/text/qzip/tst_qzip.cpp | 4 ++-- 11 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 tests/auto/gui/text/qcssparser/testdata.qrc create mode 100644 tests/auto/gui/text/qglyphrun/testdata.qrc create mode 100644 tests/auto/gui/text/qrawfont/testdata.qrc create mode 100644 tests/auto/gui/text/qzip/testdata.qrc (limited to 'tests') diff --git a/tests/auto/gui/text/qcssparser/qcssparser.pro b/tests/auto/gui/text/qcssparser/qcssparser.pro index 346a38d5f6..bb0c8c4f40 100644 --- a/tests/auto/gui/text/qcssparser/qcssparser.pro +++ b/tests/auto/gui/text/qcssparser/qcssparser.pro @@ -15,3 +15,8 @@ wince* { DEPLOYMENT += addFiles timesFont } +android { + RESOURCES += \ + testdata.qrc + +} diff --git a/tests/auto/gui/text/qcssparser/testdata.qrc b/tests/auto/gui/text/qcssparser/testdata.qrc new file mode 100644 index 0000000000..56e45cfbb0 --- /dev/null +++ b/tests/auto/gui/text/qcssparser/testdata.qrc @@ -0,0 +1,18 @@ + + + testdata/scanner/comments/input + testdata/scanner/comments/output + testdata/scanner/comments2/input + testdata/scanner/comments2/output + testdata/scanner/comments3/input + testdata/scanner/comments3/output + testdata/scanner/comments4/input + testdata/scanner/comments4/output + testdata/scanner/quotedstring/input + testdata/scanner/quotedstring/output + testdata/scanner/simple/input + testdata/scanner/simple/output + testdata/scanner/unicode/input + testdata/scanner/unicode/output + + diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 86e282fad2..719ca5a0a7 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -130,7 +130,9 @@ void tst_QCssParser::scanner_data() QTest::addColumn("input"); QTest::addColumn("output"); -#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE) +#if defined(Q_OS_ANDROID) + QDir d(":/"); +#elif !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE) QDir d(SRCDIR); #else QDir d(QDir::current()); diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro index db28a690a7..0993a5c49c 100644 --- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro +++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro @@ -8,8 +8,14 @@ linux: CONFIG += insignificant_test SOURCES += \ tst_qglyphrun.cpp +android { + RESOURCES += \ + testdata.qrc +} + wince* { - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" + additionalFiles.files = test.ttf + additionalFiles.path = . + DEPLOYMENT += additionalFiles } + diff --git a/tests/auto/gui/text/qglyphrun/testdata.qrc b/tests/auto/gui/text/qglyphrun/testdata.qrc new file mode 100644 index 0000000000..c4e237ad2f --- /dev/null +++ b/tests/auto/gui/text/qglyphrun/testdata.qrc @@ -0,0 +1,5 @@ + + + test.ttf + + diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 3d2cde5fd3..f576627745 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -94,7 +94,7 @@ void tst_QGlyphRun::initTestCase() { m_testFont_ok = false; - m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf"); + m_testFontId = QFontDatabase::addApplicationFont(QFINDTESTDATA("test.ttf")); QVERIFY(m_testFontId >= 0); m_testFont = QFont("QtsSpecialTestFont"); diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro index 540ffb94d7..1891e7a9bf 100644 --- a/tests/auto/gui/text/qrawfont/qrawfont.pro +++ b/tests/auto/gui/text/qrawfont/qrawfont.pro @@ -8,3 +8,8 @@ SOURCES += \ tst_qrawfont.cpp TESTDATA += testfont_bold_italic.ttf testfont.ttf + +android { + RESOURCES += \ + testdata.qrc +} diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc new file mode 100644 index 0000000000..7bea0d5a39 --- /dev/null +++ b/tests/auto/gui/text/qrawfont/testdata.qrc @@ -0,0 +1,6 @@ + + + testfont_bold_italic.ttf + testfont.ttf + + diff --git a/tests/auto/gui/text/qzip/qzip.pro b/tests/auto/gui/text/qzip/qzip.pro index 309f2167d1..ebcd6ec022 100644 --- a/tests/auto/gui/text/qzip/qzip.pro +++ b/tests/auto/gui/text/qzip/qzip.pro @@ -7,7 +7,9 @@ wince* { addFiles.files = testdata addFiles.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\".\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +android { + RESOURCES += \ + testdata.qrc } diff --git a/tests/auto/gui/text/qzip/testdata.qrc b/tests/auto/gui/text/qzip/testdata.qrc new file mode 100644 index 0000000000..c7e3a6b14e --- /dev/null +++ b/tests/auto/gui/text/qzip/testdata.qrc @@ -0,0 +1,6 @@ + + + testdata/symlink.zip + testdata/test.zip + + diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp index c5ce6c2676..9a5c4aaab9 100644 --- a/tests/auto/gui/text/qzip/tst_qzip.cpp +++ b/tests/auto/gui/text/qzip/tst_qzip.cpp @@ -68,7 +68,7 @@ void tst_QZip::cleanup() void tst_QZip::basicUnpack() { - QZipReader zip(QString(SRCDIR) + "/testdata/test.zip", QIODevice::ReadOnly); + QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly); QList files = zip.fileInfoList(); QCOMPARE(files.count(), 2); @@ -104,7 +104,7 @@ void tst_QZip::basicUnpack() void tst_QZip::symlinks() { - QZipReader zip(QString(SRCDIR) + "/testdata/symlink.zip", QIODevice::ReadOnly); + QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly); QList files = zip.fileInfoList(); QCOMPARE(files.count(), 2); -- cgit v1.2.3 From 6f3bb0aafab877c34dea3d9141a9931b5a7914a5 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 15 Jul 2014 15:25:23 +0200 Subject: tst_qurl: add tests for mailto parsing and toString. No bug. This was prompted by https://git.reviewboard.kde.org/r/119221 Change-Id: Ia148f07f6d711df533693918bbedfa5e7dc02cd5 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 92dbb96817..d5eab54363 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1027,6 +1027,13 @@ void tst_QUrl::toString_data() QTest::newRow("underscore") << QString::fromLatin1("http://foo_bar.host.com/rss.php") << uint(QUrl::None) << QString::fromLatin1("http://foo_bar.host.com/rss.php"); + + QTest::newRow("mailto-brackets") << QString::fromLatin1("mailto:test[at]gmail[dot]com") + << uint(QUrl::PrettyDecoded) + << QString::fromLatin1("mailto:test[at]gmail[dot]com"); + QTest::newRow("mailto-query") << QString::fromLatin1("mailto:?to=test@example.com") + << uint(QUrl::PrettyDecoded) + << QString::fromLatin1("mailto:?to=test@example.com"); } void tst_QUrl::toString() -- cgit v1.2.3