summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qdebug/qdebug.pro2
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp49
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp22
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp3
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro1
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp7
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro2
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp3
-rw-r--r--tests/auto/corelib/tools/qcollator/tst_qcollator.cpp11
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp11
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp72
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp11
-rw-r--r--tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp7
-rw-r--r--tests/auto/corelib/tools/qset/tst_qset.cpp2
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp59
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp125
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp15
-rw-r--r--tests/auto/gui/text/qcssparser/qcssparser.pro5
-rw-r--r--tests/auto/gui/text/qcssparser/testdata.qrc18
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp4
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp10
-rw-r--r--tests/auto/gui/text/qfontdatabase/qfontdatabase.pro5
-rw-r--r--tests/auto/gui/text/qfontdatabase/testdata.qrc5
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp24
-rw-r--r--tests/auto/gui/text/qglyphrun/qglyphrun.pro12
-rw-r--r--tests/auto/gui/text/qglyphrun/testdata.qrc5
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp2
-rw-r--r--tests/auto/gui/text/qrawfont/qrawfont.pro5
-rw-r--r--tests/auto/gui/text/qrawfont/testdata.qrc6
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp24
-rw-r--r--tests/auto/gui/text/qzip/qzip.pro8
-rw-r--r--tests/auto/gui/text/qzip/testdata.qrc6
-rw-r--r--tests/auto/gui/text/qzip/tst_qzip.cpp4
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp109
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp92
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp4
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp4
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp3
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp4
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2007.pem25
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2011.pem26
-rw-r--r--tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2014.pem26
-rw-r--r--tests/auto/other/other.pro3
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro4
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/test.pro5
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp89
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp58
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro4
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp6
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp32
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp197
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp37
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp43
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp29
55 files changed, 1106 insertions, 241 deletions
diff --git a/tests/auto/corelib/io/qdebug/qdebug.pro b/tests/auto/corelib/io/qdebug/qdebug.pro
index 820c17fc69..5e902bb105 100644
--- a/tests/auto/corelib/io/qdebug/qdebug.pro
+++ b/tests/auto/corelib/io/qdebug/qdebug.pro
@@ -1,5 +1,5 @@
CONFIG += testcase parallel_test
TARGET = tst_qdebug
-QT = core testlib
+QT = core testlib concurrent
SOURCES = tst_qdebug.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 80144dba20..99c4ee7edc 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -44,6 +44,9 @@
#include <QtCore/QtDebug>
#include <QtTest/QtTest>
+#include <QtConcurrentRun>
+#include <QFutureSynchronizer>
+
class tst_QDebug: public QObject
{
Q_OBJECT
@@ -59,6 +62,7 @@ private slots:
void qDebugQLatin1String() const;
void textStreamModifiers() const;
void defaultMessagehandler() const;
+ void threadSafety() const;
};
void tst_QDebug::assignment() const
@@ -295,15 +299,52 @@ void tst_QDebug::textStreamModifiers() const
void tst_QDebug::defaultMessagehandler() const
{
- MessageHandlerSetter mhs(0);
- QtMessageHandler defaultMessageHandler1 = qInstallMessageHandler((QtMessageHandler)0);
- QtMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler);
+ MessageHandlerSetter mhs(0); // set 0, should set default handler
+ QtMessageHandler defaultMessageHandler1 = qInstallMessageHandler((QtMessageHandler)0); // set 0, should set and return default handler
+ QVERIFY(defaultMessageHandler1);
+ QtMessageHandler defaultMessageHandler2 = qInstallMessageHandler(myMessageHandler); // set myMessageHandler and return default handler
bool same = (*defaultMessageHandler1 == *defaultMessageHandler2);
QVERIFY(same);
- QtMessageHandler messageHandler = qInstallMessageHandler((QtMessageHandler)0);
+ QtMessageHandler messageHandler = qInstallMessageHandler((QtMessageHandler)0); // set 0, should set default and return myMessageHandler
same = (*messageHandler == *myMessageHandler);
QVERIFY(same);
}
+QMutex s_mutex;
+QStringList s_messages;
+QSemaphore s_sema;
+
+static void threadSafeMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ QMutexLocker lock(&s_mutex);
+ s_messages.append(msg);
+ Q_UNUSED(type);
+ Q_UNUSED(context);
+}
+
+static void doDebug() // called in each thread
+{
+ s_sema.acquire();
+ qDebug() << "doDebug";
+}
+
+void tst_QDebug::threadSafety() const
+{
+ MessageHandlerSetter mhs(threadSafeMessageHandler);
+ const int numThreads = 10;
+ QThreadPool::globalInstance()->setMaxThreadCount(numThreads);
+ QFutureSynchronizer<void> sync;
+ for (int i = 0; i < numThreads; ++i) {
+ sync.addFuture(QtConcurrent::run(&doDebug));
+ }
+ s_sema.release(numThreads);
+ sync.waitForFinished();
+ QMutexLocker lock(&s_mutex);
+ QCOMPARE(s_messages.count(), numThreads);
+ for (int i = 0; i < numThreads; ++i) {
+ QCOMPARE(s_messages.at(i), QStringLiteral("doDebug"));
+ }
+}
+
QTEST_MAIN(tst_QDebug);
#include "tst_qdebug.moc"
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 2bac6f5834..cf7cdc874c 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.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.
@@ -72,8 +72,12 @@ class tst_QDir : public QObject
{
Q_OBJECT
+public:
+ tst_QDir();
+
private slots:
void init();
+ void initTestCase();
void cleanupTestCase();
void getSetCheck();
@@ -198,19 +202,25 @@ private slots:
void cdBelowRoot();
private:
- QString m_dataPath;
+ const QString m_dataPath;
};
-void tst_QDir::init()
+tst_QDir::tst_QDir()
+ : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath())
{
- // Directory under which testdata can be found.
- m_dataPath = QFileInfo(QFINDTESTDATA("testData")).absolutePath();
- QVERIFY2(!m_dataPath.isEmpty(), "test data not found");
+}
+void tst_QDir::init()
+{
// Some tests want to use "." as relative path to data.
QVERIFY2(QDir::setCurrent(m_dataPath), qPrintable("Could not chdir to " + m_dataPath));
}
+void tst_QDir::initTestCase()
+{
+ QVERIFY2(!m_dataPath.isEmpty(), "test data not found");
+}
+
void tst_QDir::cleanupTestCase()
{
QDir(QDir::currentPath() + "/tmpdir").removeRecursively();
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 13f8ced842..19f4549706 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -194,6 +194,9 @@ void tst_QIODevice::unget()
#if defined(Q_OS_WINCE) && defined(WINCE_EMULATOR_TEST)
QSKIP("Networking tests in a WinCE emulator are unstable");
#endif
+#if defined(Q_OS_MAC)
+ QSKIP("The unget network test is unstable on Mac. See QTBUG-39983.");
+#endif
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
buffer.write("ZXCV");
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 79ea53cc6b..90afeddaa0 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -2,7 +2,6 @@ CONFIG += testcase
CONFIG += parallel_test
CONFIG -= app_bundle debug_and_release_target
QT = core testlib network
-embedded: QT += gui
SOURCES = ../tst_qprocess.cpp
TARGET = ../tst_qprocess
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index b67166272b..82a0f3f832 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1953,7 +1953,7 @@ void tst_QProcess::setStandardOutputFile2()
process.start("testProcessEcho2/testProcessEcho2");
process.write(testdata, sizeof testdata);
QPROCESS_VERIFY(process,waitForFinished());
- QVERIFY(!process.bytesAvailable());
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
}
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()
diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
index 8d117793bf..f5d06b3de9 100644
--- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
+++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro
@@ -4,7 +4,7 @@ CONFIG += ordered
SUBDIRS = lib \
theplugin \
tst
-!win32: !mac: SUBDIRS += almostplugin
+!android: !win32: !mac: SUBDIRS += almostplugin
macx-*: SUBDIRS += machtest
TARGET = tst_qpluginloader
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 0c91c419cc..3bf25da5ee 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -371,6 +371,9 @@ void tst_QThreadPool::expiryTimeout()
void tst_QThreadPool::expiryTimeoutRace() // QTBUG-3786
{
+#ifdef Q_OS_WIN
+ QSKIP("This test is unstable on Windows. See QTBUG-3786.");
+#endif
ExpiryTimeoutTask task;
QThreadPool threadPool;
diff --git a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
index 9ed27a8742..3a00ebd505 100644
--- a/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
+++ b/tests/auto/corelib/tools/qcollator/tst_qcollator.cpp
@@ -121,10 +121,12 @@ void tst_QCollator::compare_data()
diaresis (E4), which comes before o diaresis (F6), which
all come after z.
*/
+#if !defined(Q_OS_WIN) || defined(QT_USE_ICU)
QTest::newRow("swedish1") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xe4") << -1 << -1;
+#endif
QTest::newRow("swedish2") << QString("sv_SE") << QString::fromLatin1("\xe4") << QString::fromLatin1("\xf6") << -1 << -1;
QTest::newRow("swedish3") << QString("sv_SE") << QString::fromLatin1("\xe5") << QString::fromLatin1("\xf6") << -1 << -1;
-#ifndef Q_OS_MAC
+#if !defined(Q_OS_OSX) && (!defined(Q_OS_WIN) || defined(QT_USE_ICU))
QTest::newRow("swedish4") << QString("sv_SE") << QString::fromLatin1("z") << QString::fromLatin1("\xe5") << -1 << -1;
#endif
@@ -133,11 +135,12 @@ void tst_QCollator::compare_data()
comes before a with ring above (E5).
*/
QTest::newRow("norwegian1") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xd8") << -1 << -1;
-#ifndef Q_OS_MAC
+#if !defined(Q_OS_WIN) || defined(QT_USE_ICU)
+# ifndef Q_OS_OSX
QTest::newRow("norwegian2") << QString("no_NO") << QString::fromLatin1("\xd8") << QString::fromLatin1("\xe5") << -1 << -1;
-#endif
+# endif
QTest::newRow("norwegian3") << QString("no_NO") << QString::fromLatin1("\xe6") << QString::fromLatin1("\xe5") << -1 << -1;
-
+#endif // !Q_OS_WIN || QT_USE_ICU
/*
In German, z comes *after* a with diaresis (E4),
which comes before o diaresis (F6).
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 9c96aaf78d..77baed87c2 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -1327,10 +1327,15 @@ void tst_QHash::twoArguments_qHash()
void tst_QHash::initializerList()
{
#ifdef Q_COMPILER_INITIALIZER_LISTS
- QHash<int, QString> hash{{1, "hello"}, {2, "initializer_list"}};
+ QHash<int, QString> hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
QCOMPARE(hash.count(), 2);
- QVERIFY(hash[1] == "hello");
- QVERIFY(hash[2] == "initializer_list");
+ QCOMPARE(hash[1], QString("hello"));
+ QCOMPARE(hash[2], QString("initializer_list"));
+
+ // note the difference to std::unordered_map:
+ // std::unordered_map<int, QString> stdh = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
+ // QCOMPARE(stdh.size(), 2UL);
+ // QCOMPARE(stdh[1], QString("bar"));
QMultiHash<QString, int> multiHash{{"il", 1}, {"il", 2}, {"il", 3}};
QCOMPARE(multiHash.count(), 3);
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 211fbca330..da65ea105e 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1389,10 +1389,23 @@ void tst_QLocale::toDateTime()
}
#ifdef Q_OS_MAC
-void tst_QLocale::macDefaultLocale()
+
+// Format number string according to system locale settings.
+// Expected in format is US "1,234.56".
+QString systemLocaleFormatNumber(const QString &numberString)
{
+ QLocale locale = QLocale::system();
+ QString numberStringCopy = numberString;
+ return numberStringCopy.replace(QChar(','), QChar('G'))
+ .replace(QChar('.'), QChar('D'))
+ .replace(QChar('G'), locale.groupSeparator())
+ .replace(QChar('D'), locale.decimalPoint());
+}
+void tst_QLocale::macDefaultLocale()
+{
QLocale locale = QLocale::system();
+
if (locale.name() != QLatin1String("en_US"))
QSKIP("This test only tests for en_US");
@@ -1404,20 +1417,20 @@ void tst_QLocale::macDefaultLocale()
QCOMPARE(locale.toString(invalidDate, QLocale::NarrowFormat), QString());
QCOMPARE(locale.toString(invalidTime, QLocale::LongFormat), QString());
QCOMPARE(locale.toString(invalidDate, QLocale::LongFormat), QString());
- QCOMPARE(locale.decimalPoint(), QChar('.'));
- QCOMPARE(locale.groupSeparator(), QChar(','));
- QCOMPARE(locale.dateFormat(QLocale::ShortFormat), QString("M/d/yy"));
- QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy"));
- QCOMPARE(locale.timeFormat(QLocale::ShortFormat), QString("h:mm AP"));
- QCOMPARE(locale.timeFormat(QLocale::LongFormat), QString("h:mm:ss AP t"));
+
+ // On OS X the decimal point and group separator are configurable
+ // independently of the locale. Verify that they have one of the
+ // allowed values and are not the same.
+ QVERIFY(locale.decimalPoint() == QChar('.') || locale.decimalPoint() == QChar(','));
+ QVERIFY(locale.groupSeparator() == QChar(',')
+ || locale.groupSeparator() == QChar('.')
+ || locale.groupSeparator() == QChar('\xA0') // no-breaking space
+ || locale.groupSeparator() == QChar('\'')
+ || locale.groupSeparator() == QChar());
+ QVERIFY(locale.decimalPoint() != locale.groupSeparator());
// make sure we are using the system to parse them
- QCOMPARE(locale.toString(1234.56), QString("1,234.56"));
- QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::ShortFormat), QString("12/1/74"));
- QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::NarrowFormat), locale.toString(QDate(1974, 12, 1), QLocale::ShortFormat));
- QCOMPARE(locale.toString(QDate(1974, 12, 1), QLocale::LongFormat), QString("December 1, 1974"));
- QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), QString("1:02 AM"));
- QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat), locale.toString(QTime(1,2,3), QLocale::ShortFormat));
+ QCOMPARE(locale.toString(1234.56), systemLocaleFormatNumber(QString("1,234.56")));
QTime currentTime = QTime::currentTime();
QTime utcTime = QDateTime::currentDateTime().toUTC().time();
@@ -1433,35 +1446,38 @@ void tst_QLocale::macDefaultLocale()
const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat);
QVERIFY(timeString.contains(QString("1:02:03")));
- // System Preferences->Language & Text, Region Tab, should choose "United States" for Region field
- QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00"));
- QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), QString("($1,234.00)"));
- QCOMPARE(locale.toCurrencyString(double(1234.56)), QString("$1,234.56"));
- QCOMPARE(locale.toCurrencyString(double(-1234.56)), QString("($1,234.56)"));
+ // To run this test make sure "Curreny" is US Dollar in System Preferences->Language & Region->Advanced.
+ if (locale.currencySymbol() == QString("$")) {
+ QCOMPARE(locale.toCurrencyString(qulonglong(1234)), systemLocaleFormatNumber(QString("$1,234.00")));
+ QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), systemLocaleFormatNumber(QString("($1,234.00)")));
+ QCOMPARE(locale.toCurrencyString(double(1234.56)), systemLocaleFormatNumber(QString("$1,234.56")));
+ QCOMPARE(locale.toCurrencyString(double(-1234.56)), systemLocaleFormatNumber(QString("($1,234.56)")));
+ }
// Depending on the configured time zone, the time string might not
// contain a GMT specifier. (Sometimes it just names the zone, like "CEST")
if (timeString.contains(QString("GMT"))) {
- QString expectedGMTSpecifier("GMT");
+ QString expectedGMTSpecifierBase("GMT");
if (diff >= 0)
- expectedGMTSpecifier.append("+");
+ expectedGMTSpecifierBase.append("+");
else
- expectedGMTSpecifier.append("-");
- if (qAbs(diff) < 10)
- expectedGMTSpecifier.append(QString("0%1").arg(qAbs(diff)));
- else
- expectedGMTSpecifier.append(QString("%1").arg(qAbs(diff)));
- QVERIFY2(timeString.contains(expectedGMTSpecifier), qPrintable(
- QString("timeString `%1', expectedGMTSpecifier `%2'")
+ expectedGMTSpecifierBase.append("-");
+
+ QString expectedGMTSpecifier = expectedGMTSpecifierBase + QString("%1").arg(qAbs(diff));
+ QString expectedGMTSpecifierZeroExtended = expectedGMTSpecifierBase + QString("0%1").arg(qAbs(diff));
+
+ QVERIFY2(timeString.contains(expectedGMTSpecifier)
+ || timeString.contains(expectedGMTSpecifierZeroExtended),
+ qPrintable(QString("timeString `%1', expectedGMTSpecifier `%2' or `%3'")
.arg(timeString)
.arg(expectedGMTSpecifier)
+ .arg(expectedGMTSpecifierZeroExtended)
));
}
QCOMPARE(locale.dayName(1), QString("Monday"));
QCOMPARE(locale.dayName(7), QString("Sunday"));
QCOMPARE(locale.monthName(1), QString("January"));
QCOMPARE(locale.monthName(12), QString("December"));
- QCOMPARE(locale.firstDayOfWeek(), Qt::Sunday);
QCOMPARE(locale.quoteString("string"), QString::fromUtf8("\xe2\x80\x9c" "string" "\xe2\x80\x9d"));
QCOMPARE(locale.quoteString("string", QLocale::AlternateQuotation), QString::fromUtf8("\xe2\x80\x98" "string" "\xe2\x80\x99"));
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 00e669c1d8..3daab73cc2 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -1179,10 +1179,15 @@ void tst_QMap::checkMostLeftNode()
void tst_QMap::initializerList()
{
#ifdef Q_COMPILER_INITIALIZER_LISTS
- QMap<int, QString> map{{1, "hello"}, {2, "initializer_list"}};
+ QMap<int, QString> map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
QCOMPARE(map.count(), 2);
- QVERIFY(map[1] == "hello");
- QVERIFY(map[2] == "initializer_list");
+ QCOMPARE(map[1], QString("hello"));
+ QCOMPARE(map[2], QString("initializer_list"));
+
+ // note the difference to std::map:
+ // std::map<int, QString> stdm = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}};
+ // QCOMPARE(stdm.size(), 2UL);
+ // QCOMPARE(stdm[1], QString("bar"));
QMultiMap<QString, int> multiMap{{"il", 1}, {"il", 2}, {"il", 3}};
QCOMPARE(multiMap.count(), 3);
diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
index 6780493206..285cc3042a 100644
--- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
+++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp
@@ -111,6 +111,13 @@ void tst_QRingBuffer::readPointerAtPositionWithHead()
buf2 = ringBuffer.readPointerAtPosition(0, length);
QCOMPARE(length, qint64(0));
QVERIFY(buf2 == 0);
+
+ // check buffer with 2 blocks
+ memcpy(ringBuffer.reserve(4), "0123", 4);
+ ringBuffer.append(QByteArray("45678", 5));
+ ringBuffer.free(3);
+ buf2 = ringBuffer.readPointerAtPosition(1, length);
+ QCOMPARE(length, qint64(5));
}
void tst_QRingBuffer::readPointerAtPositionEmptyRead()
diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp
index eaa1c018ba..5ef1b44b6f 100644
--- a/tests/auto/corelib/tools/qset/tst_qset.cpp
+++ b/tests/auto/corelib/tools/qset/tst_qset.cpp
@@ -922,7 +922,7 @@ void tst_QSet::makeSureTheComfortFunctionsCompile()
void tst_QSet::initializerList()
{
#ifdef Q_COMPILER_INITIALIZER_LISTS
- QSet<int> set{1, 2, 3, 4, 5};
+ QSet<int> set = {1, 1, 2, 3, 4, 5};
QCOMPARE(set.count(), 5);
QVERIFY(set.contains(1));
QVERIFY(set.contains(2));
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index 0f642bcc10..524f0a30ed 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.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.
@@ -55,6 +55,7 @@ public:
tst_QIcon();
private slots:
+ void initTestCase();
void actualSize_data(); // test with 1 pixmap
void actualSize();
void actualSize2_data(); // test with 2 pixmaps with different aspect ratio
@@ -79,6 +80,10 @@ private slots:
private:
bool haveImageFormat(QByteArray const&);
+ const QString m_pngImageFileName;
+ const QString m_pngRectFileName;
+ const QString m_sourceFileName;
+
const static QIcon staticIcon;
};
@@ -92,9 +97,19 @@ bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat)
}
tst_QIcon::tst_QIcon()
+ : m_pngImageFileName(QFINDTESTDATA("image.png"))
+ , m_pngRectFileName(QFINDTESTDATA("rect.png"))
+ , m_sourceFileName(QFINDTESTDATA(__FILE__))
{
}
+void tst_QIcon::initTestCase()
+{
+ QVERIFY(!m_pngImageFileName.isEmpty());
+ QVERIFY(!m_pngRectFileName.isEmpty());
+ QVERIFY(!m_sourceFileName.isEmpty());
+}
+
void tst_QIcon::actualSize_data()
{
QTest::addColumn<QString>("source");
@@ -115,14 +130,13 @@ void tst_QIcon::actualSize_data()
QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30);
QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40);
- const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
- QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128);
- QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64);
- QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32);
- QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16);
- QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16);
- QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16);
- QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128);
+ QTest::newRow("external0") << m_pngImageFileName << QSize(128, 128) << QSize(128, 128);
+ QTest::newRow("external1") << m_pngImageFileName << QSize( 64, 64) << QSize( 64, 64);
+ QTest::newRow("external2") << m_pngImageFileName << QSize( 32, 64) << QSize( 32, 32);
+ QTest::newRow("external3") << m_pngImageFileName << QSize( 16, 64) << QSize( 16, 16);
+ QTest::newRow("external4") << m_pngImageFileName << QSize( 16, 128) << QSize( 16, 16);
+ QTest::newRow("external5") << m_pngImageFileName << QSize(128, 16) << QSize( 16, 16);
+ QTest::newRow("external6") << m_pngImageFileName << QSize(150, 150) << QSize(128, 128);
// rect image
QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40);
QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20);
@@ -170,10 +184,8 @@ void tst_QIcon::actualSize2_data()
void tst_QIcon::actualSize2()
{
QIcon icon;
- const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
-
- icon.addPixmap(QPixmap(prefix + "image.png"));
- icon.addPixmap(QPixmap(prefix + "rect.png"));
+ icon.addPixmap(m_pngImageFileName);
+ icon.addPixmap(m_pngRectFileName);
QFETCH(QSize, argument);
QFETCH(QSize, result);
@@ -209,14 +221,13 @@ void tst_QIcon::isNull() {
QVERIFY(!iconNoFileSuffix.isNull());
QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid());
- const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/";
// test string constructor with existing file but unsupported format
- QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp");
+ QIcon iconUnsupportedFormat = QIcon(m_sourceFileName);
QVERIFY(!iconUnsupportedFormat.isNull());
QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid());
// test string constructor with existing file and supported format
- QIcon iconSupportedFormat = QIcon(prefix + "image.png");
+ QIcon iconSupportedFormat = QIcon(m_pngImageFileName);
QVERIFY(!iconSupportedFormat.isNull());
QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid());
}
@@ -347,7 +358,7 @@ void tst_QIcon::bestMatch()
void tst_QIcon::cacheKey()
{
- QIcon icon1("image.png");
+ QIcon icon1(m_pngImageFileName);
qint64 icon1_key = icon1.cacheKey();
QIcon icon2 = icon1;
@@ -363,7 +374,7 @@ void tst_QIcon::detach()
img.fill(0xffff0000);
QIcon icon1(QPixmap::fromImage(img));
QIcon icon2 = icon1;
- icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64));
+ icon2.addFile(m_pngImageFileName, QSize(64, 64));
QImage img1 = icon1.pixmap(64, 64).toImage();
QImage img2 = icon2.pixmap(64, 64).toImage();
@@ -415,11 +426,11 @@ void tst_QIcon::availableSizes()
{
{
QIcon icon;
- icon.addFile("image.png", QSize(32,32));
- icon.addFile("image.png", QSize(64,64));
- icon.addFile("image.png", QSize(128,128));
- icon.addFile("image.png", QSize(256,256), QIcon::Disabled);
- icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On);
+ icon.addFile(m_pngImageFileName, QSize(32,32));
+ icon.addFile(m_pngImageFileName, QSize(64,64));
+ icon.addFile(m_pngImageFileName, QSize(128,128));
+ icon.addFile(m_pngImageFileName, QSize(256,256), QIcon::Disabled);
+ icon.addFile(m_pngImageFileName, QSize(16,16), QIcon::Normal, QIcon::On);
QList<QSize> availableSizes = icon.availableSizes();
QCOMPARE(availableSizes.size(), 3);
@@ -542,7 +553,7 @@ static inline bool operator<(const QSize &lhs, const QSize &rhs)
#ifndef QT_NO_WIDGETS
void tst_QIcon::task184901_badCache()
{
- QPixmap pm(QFINDTESTDATA("image.png"));
+ QPixmap pm(m_pngImageFileName);
QIcon icon(pm);
//the disabled icon must have an effect (grayed)
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 95a9b142ec..6c496ba6d4 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -146,6 +146,9 @@ private slots:
void fillRGB888();
+ void fillPixel_data();
+ void fillPixel();
+
void rgbSwapped_data();
void rgbSwapped();
@@ -2054,6 +2057,42 @@ void tst_QImage::fillRGB888()
}
}
+void tst_QImage::fillPixel_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<uint>("color");
+ QTest::addColumn<uint>("pixelValue");
+
+ QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << 0x0u << 0xff000000u;
+ QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << 0x0u << 0xff000000u;
+ QTest::newRow("RGBx8888, transparent") << QImage::Format_RGBX8888 << 0x0u << 0xff000000u;
+ QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
+ QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
+ QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
+
+ QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
+ QTest::newRow("RGB32, red") << QImage::Format_RGB32 << 0xffff0000u << 0xffff0000u;
+ QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
+ QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
+
+ QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
+ QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
+ QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
+ QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
+}
+
+void tst_QImage::fillPixel()
+{
+ QFETCH(QImage::Format, format);
+ QFETCH(uint, color);
+ QFETCH(uint, pixelValue);
+
+ QImage image(1, 1, format);
+
+ image.fill(color);
+ QCOMPARE(image.pixel(0, 0), pixelValue);
+}
+
void tst_QImage::rgbSwapped_data()
{
QTest::addColumn<QImage::Format>("format");
@@ -2124,35 +2163,56 @@ void tst_QImage::mirrored_data()
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<bool>("swap_vertical");
QTest::addColumn<bool>("swap_horizontal");
-
- QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false;
- QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
- QTest::newRow("Format_ARGB32_Premultiplied, vertical") << QImage::Format_ARGB32_Premultiplied << true << false;
- QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
- QTest::newRow("Format_ARGB8565_Premultiplied, vertical") << QImage::Format_ARGB8565_Premultiplied << true << false;
- QTest::newRow("Format_ARGB6666_Premultiplied, vertical") << QImage::Format_ARGB6666_Premultiplied << true << false;
- QTest::newRow("Format_ARGB4444_Premultiplied, vertical") << QImage::Format_ARGB4444_Premultiplied << true << false;
- QTest::newRow("Format_RGB666, vertical") << QImage::Format_RGB666 << true << false;
- QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false;
- QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false;
- QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
- QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false;
- QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false;
- QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false;
- QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false;
- QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false;
-
- QTest::newRow("Format_ARGB32_Premultiplied, horizontal") << QImage::Format_ARGB32_Premultiplied << false << true;
- QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
- QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
- QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true;
- QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true;
-
- QTest::newRow("Format_ARGB32_Premultiplied, horizontal+vertical") << QImage::Format_ARGB32_Premultiplied << true << true;
- QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
- QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
- QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true;
- QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true;
+ QTest::addColumn<int>("width");
+ QTest::addColumn<int>("height");
+
+ QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB32_Premultiplied, vertical") << QImage::Format_ARGB32_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB8565_Premultiplied, vertical") << QImage::Format_ARGB8565_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB6666_Premultiplied, vertical") << QImage::Format_ARGB6666_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB4444_Premultiplied, vertical") << QImage::Format_ARGB4444_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_RGB666, vertical") << QImage::Format_RGB666 << true << false << 16 << 16;
+ QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false << 16 << 16;
+ QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false << 16 << 16;
+ QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false << 16 << 16;
+ QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false << 16 << 16;
+ QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false << 16 << 16;
+ QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false << 16 << 16;
+ QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false << 16 << 16;
+ QTest::newRow("Format_MonoLSB, vertical") << QImage::Format_MonoLSB << true << false << 16 << 16;
+
+ QTest::newRow("Format_ARGB32_Premultiplied, horizontal") << QImage::Format_ARGB32_Premultiplied << false << true << 16 << 16;
+ QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true << 16 << 16;
+ QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true << 16 << 16;
+ QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true << 16 << 16;
+ QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true << 16 << 16;
+ QTest::newRow("Format_MonoLSB, horizontal") << QImage::Format_MonoLSB << false << true << 16 << 16;
+
+ QTest::newRow("Format_ARGB32_Premultiplied, horizontal+vertical") << QImage::Format_ARGB32_Premultiplied << true << true << 16 << 16;
+ QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true << 16 << 16;
+ QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true << 16 << 16;
+ QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true << 16 << 16;
+ QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true << 16 << 16;
+ QTest::newRow("Format_MonoLSB, horizontal+vertical") << QImage::Format_MonoLSB << true << true << 16 << 16;
+
+ QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false << 8 << 16;
+ QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false << 16 << 8;
+ QTest::newRow("Format_Mono, vertical, non-aligned") << QImage::Format_Mono << true << false << 19 << 25;
+ QTest::newRow("Format_MonoLSB, vertical, non-aligned") << QImage::Format_MonoLSB << true << false << 19 << 25;
+
+ // Non-aligned horizontal 1-bit needs special handling so test this.
+ QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 13 << 17;
+ QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 19 << 25;
+ QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 25 << 47;
+ QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 21 << 16;
+
+ QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 13 << 17;
+ QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 19 << 25;
+ QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 25 << 47;
+ QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 21 << 16;
}
void tst_QImage::mirrored()
@@ -2160,11 +2220,14 @@ void tst_QImage::mirrored()
QFETCH(QImage::Format, format);
QFETCH(bool, swap_vertical);
QFETCH(bool, swap_horizontal);
+ QFETCH(int, width);
+ QFETCH(int, height);
- QImage image(16, 16, format);
+ QImage image(width, height, format);
switch (format) {
case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
for (int i = 0; i < image.height(); ++i) {
ushort* scanLine = (ushort*)image.scanLine(i);
*scanLine = (i % 2) ? 0x5555U : 0xCCCCU;
@@ -2201,7 +2264,7 @@ void tst_QImage::mirrored()
QCOMPARE(image, imageMirroredTwice);
- if (format != QImage::Format_Mono)
+ if (format != QImage::Format_Mono && format != QImage::Format_MonoLSB)
QCOMPARE(memcmp(image.constBits(), imageMirroredTwice.constBits(), image.byteCount()), 0);
else {
for (int i = 0; i < image.height(); ++i)
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 79dc3f311a..b9d0adcd21 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -91,6 +91,7 @@ private slots:
void convertFromImage_data();
void convertFromImage();
+ void convertFromImageShouldDetach();
void testMetrics();
@@ -343,6 +344,20 @@ void tst_QPixmap::convertFromImage()
QCOMPARE(pix, res);
}
+void tst_QPixmap::convertFromImageShouldDetach()
+{
+ const QString prefix = QFINDTESTDATA("convertFromImage");
+ QImage img1;
+ QImage img2;
+ QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
+ QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
+ QPixmap pix = QPixmap::fromImage(img1);
+ QPixmap pix1 = pix;
+ pix.convertFromImage(img2);
+ QCOMPARE(pix, QPixmap::fromImage(img2));
+ QCOMPARE(pix1, QPixmap::fromImage(img1)); // unchanged
+}
+
void tst_QPixmap::scroll_data()
{
QTest::addColumn<QImage>("input");
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 @@
+<RCC>
+ <qresource prefix="/">
+ <file>testdata/scanner/comments/input</file>
+ <file>testdata/scanner/comments/output</file>
+ <file>testdata/scanner/comments2/input</file>
+ <file>testdata/scanner/comments2/output</file>
+ <file>testdata/scanner/comments3/input</file>
+ <file>testdata/scanner/comments3/output</file>
+ <file>testdata/scanner/comments4/input</file>
+ <file>testdata/scanner/comments4/output</file>
+ <file>testdata/scanner/quotedstring/input</file>
+ <file>testdata/scanner/quotedstring/output</file>
+ <file>testdata/scanner/simple/input</file>
+ <file>testdata/scanner/simple/output</file>
+ <file>testdata/scanner/unicode/input</file>
+ <file>testdata/scanner/unicode/output</file>
+ </qresource>
+</RCC>
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<QString>("input");
QTest::addColumn<QString>("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/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 4c88212c72..995f7a0378 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -624,11 +624,11 @@ void tst_QFont::defaultFamily_data()
QTest::addColumn<QFont::StyleHint>("styleHint");
QTest::addColumn<QStringList>("acceptableFamilies");
- QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << getPlatformGenericFont("serif"));
- QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << getPlatformGenericFont("monospace"));
- QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << getPlatformGenericFont("cursive"));
- QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << getPlatformGenericFont("fantasy"));
- QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << getPlatformGenericFont("sans-serif"));
+ QTest::newRow("serif") << QFont::Serif << (QStringList() << "Times New Roman" << "Times" << "Droid Serif" << getPlatformGenericFont("serif"));
+ QTest::newRow("monospace") << QFont::Monospace << (QStringList() << "Courier New" << "Monaco" << "Droid Sans Mono" << getPlatformGenericFont("monospace"));
+ QTest::newRow("cursive") << QFont::Cursive << (QStringList() << "Comic Sans MS" << "Apple Chancery" << "Roboto" << "Droid Sans" << getPlatformGenericFont("cursive"));
+ QTest::newRow("fantasy") << QFont::Fantasy << (QStringList() << "Impact" << "Zapfino" << "Roboto" << "Droid Sans" << getPlatformGenericFont("fantasy"));
+ QTest::newRow("sans-serif") << QFont::SansSerif << (QStringList() << "Arial" << "Lucida Grande" << "Roboto" << "Droid Sans" << getPlatformGenericFont("sans-serif"));
}
void tst_QFont::defaultFamily()
diff --git a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
index 6975c4088b..831ed1f572 100644
--- a/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
+++ b/tests/auto/gui/text/qfontdatabase/qfontdatabase.pro
@@ -9,3 +9,8 @@ wince* {
additionalFiles.path = .
DEPLOYMENT += additionalFiles
}
+
+android {
+ RESOURCES += testdata.qrc
+}
+
diff --git a/tests/auto/gui/text/qfontdatabase/testdata.qrc b/tests/auto/gui/text/qfontdatabase/testdata.qrc
new file mode 100644
index 0000000000..8a8670bf17
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/testdata.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>LED_REAL.TTF</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 28db0ba291..2ae12ec246 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -44,6 +44,8 @@
#include <qfontdatabase.h>
#include <qfontinfo.h>
#include <qfontmetrics.h>
+#include <qtextlayout.h>
+#include <private/qrawfont_p.h>
#include <qpa/qplatformfontdatabase.h>
class tst_QFontDatabase : public QObject
@@ -77,6 +79,7 @@ private slots:
void addAppFont();
void aliases();
+ void fallbackFonts();
private:
const QString m_testFont;
@@ -285,5 +288,26 @@ void tst_QFontDatabase::aliases()
QVERIFY(db.hasFamily(alias));
}
+void tst_QFontDatabase::fallbackFonts()
+{
+ QTextLayout layout;
+ QString s;
+ s.append(QChar(0x31));
+ s.append(QChar(0x05D0));
+ layout.setText(s);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> runs = layout.glyphRuns(0, 1);
+ foreach (QGlyphRun run, runs) {
+ QRawFont rawFont = run.rawFont();
+ QVERIFY(rawFont.isValid());
+
+ QCOMPARE(run.glyphIndexes().size(), 1);
+ QVERIFY(run.glyphIndexes().at(0) != 0);
+ }
+}
+
QTEST_MAIN(tst_QFontDatabase)
#include "tst_qfontdatabase.moc"
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 @@
+<RCC>
+ <qresource prefix="/">
+ <file>test.ttf</file>
+ </qresource>
+</RCC>
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 @@
+<RCC>
+ <qresource prefix="/">
+ <file>testfont_bold_italic.ttf</file>
+ <file>testfont.ttf</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 26eaec0470..ec698e5db4 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -139,6 +139,7 @@ private slots:
void cursorInLigatureWithMultipleLines();
void xToCursorForLigatures();
void cursorInNonStopChars();
+ void nbsp();
private:
QFont testFont;
@@ -2011,5 +2012,28 @@ void tst_QTextLayout::justifyTrailingSpaces()
QVERIFY(qFuzzyIsNull(layout.lineAt(0).cursorToX(0)));
}
+void tst_QTextLayout::nbsp()
+{
+ QString s = QString() + QChar(' ') + QChar('a') + QString(10, QChar::Nbsp) + QChar('a') + QChar(' ') + QChar('A');
+ QString text = s + s + s + s + s + s + s + s + s + s + s + s + s + s;
+ QTextLayout layout(text);
+ layout.setCacheEnabled(true);
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ int naturalWidth = qCeil(layout.lineAt(0).naturalTextWidth());
+ int lineWidth = naturalWidth;
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ while (lineWidth-- > naturalWidth / 2) {
+ line.setLineWidth(lineWidth);
+ QVERIFY(text.at(line.textLength()-1).unicode() != QChar::Nbsp);
+ }
+
+ layout.endLayout();
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"
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 @@
+<RCC>
+ <qresource prefix="/">
+ <file>testdata/symlink.zip</file>
+ <file>testdata/test.zip</file>
+ </qresource>
+</RCC>
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<QZipReader::FileInfo> 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<QZipReader::FileInfo> files = zip.fileInfoList();
QCOMPARE(files.count(), 2);
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index 44edcc66c0..d28f11ff9d 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -62,6 +62,7 @@ public slots:
void cleanupTestCase();
void init();
void cleanup();
+ void accessAfterRemoveReadyReadSlot();
private slots:
void qnetworkdiskcache_data();
@@ -74,6 +75,7 @@ private slots:
void data();
void metaData();
void remove();
+ void accessAfterRemove(); // QTBUG-17400
void setCacheDirectory_data();
void setCacheDirectory();
void updateMetaData();
@@ -83,12 +85,17 @@ private slots:
void oldCacheVersionFile_data();
void oldCacheVersionFile();
+ void streamVersion_data();
+ void streamVersion();
+
void sync();
void crashWhenParentingCache();
private:
QTemporaryDir tempDir;
+ QUrl url; // used by accessAfterRemove()
+ QNetworkDiskCache *diskCache; // used by accessAfterRemove()
};
// FIXME same as in tst_qnetworkreply.cpp .. could be unified
@@ -370,6 +377,40 @@ void tst_QNetworkDiskCache::remove()
QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
}
+void tst_QNetworkDiskCache::accessAfterRemove() // QTBUG-17400
+{
+ QByteArray data("HTTP/1.1 200 OK\r\n"
+ "Content-Length: 1\r\n"
+ "\r\n"
+ "a");
+
+ MiniHttpServer server(data);
+
+ QNetworkAccessManager *manager = new QNetworkAccessManager();
+ SubQNetworkDiskCache subCache;
+ subCache.setCacheDirectory(QLatin1String("cacheDir"));
+ diskCache = &subCache;
+ manager->setCache(&subCache);
+
+ url = QUrl("http://127.0.0.1:" + QString::number(server.serverPort()));
+ QNetworkRequest request(url);
+
+ QNetworkReply *reply = manager->get(request);
+ connect(reply, SIGNAL(readyRead()), this, SLOT(accessAfterRemoveReadyReadSlot()));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ reply->deleteLater();
+ manager->deleteLater();
+}
+
+void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot()
+{
+ diskCache->remove(url); // this used to cause a crash later on
+}
+
void tst_QNetworkDiskCache::setCacheDirectory_data()
{
QTest::addColumn<QString>("cacheDir");
@@ -530,6 +571,74 @@ void tst_QNetworkDiskCache::oldCacheVersionFile()
}
}
+void tst_QNetworkDiskCache::streamVersion_data()
+{
+ QTest::addColumn<int>("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
{
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 0509eb9a77..480eeecb63 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -461,6 +461,8 @@ private Q_SLOTS:
void backgroundRequestConnectInBackground();
#endif
+ void putWithRateLimiting();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
private:
@@ -7776,6 +7778,96 @@ void tst_QNetworkReply::backgroundRequestConnectInBackground()
}
#endif
+class RateLimitedUploadDevice : public QIODevice
+{
+ Q_OBJECT
+public:
+ QByteArray data;
+ QBuffer buffer;
+ qint64 read;
+ qint64 bandwidthQuota;
+ QTimer timer;
+
+ RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) {
+ buffer.setData(data);
+ buffer.open(QIODevice::ReadOnly);
+ timer.setInterval(200);
+ QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(timeoutSlot()));
+ timer.start();
+ }
+
+ virtual qint64 writeData(const char* , qint64 ) {
+ Q_ASSERT(false);
+ return 0;
+ }
+
+ virtual qint64 readData(char* data, qint64 maxlen) {
+ //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota;
+ maxlen = qMin(maxlen, buffer.bytesAvailable());
+ maxlen = qMin(maxlen, bandwidthQuota);
+ if (maxlen <= 0) { // no quota or at end
+ return 0;
+ }
+ bandwidthQuota -= maxlen; // reduce quota
+
+ qint64 ret = buffer.read(data, maxlen);
+ if (ret == -1) {
+ return -1;
+ }
+ read += ret;
+ //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota << read << ret << buffer.bytesAvailable();
+ return ret;
+ }
+ virtual bool atEnd() const {
+ return buffer.atEnd();
+ }
+ virtual qint64 size() const{
+ return data.length();
+ }
+ qint64 bytesAvailable() const
+ {
+ return buffer.bytesAvailable() + QIODevice::bytesAvailable();
+ }
+ virtual bool isSequential() const{ // random access, we can seek
+ return false;
+ }
+ virtual bool seek ( qint64 pos ) {
+ return buffer.seek(pos);
+ }
+protected slots:
+ void timeoutSlot() {
+ //qDebug() << Q_FUNC_INFO;
+ bandwidthQuota = 8*1024; // fill quota
+ emit readyRead();
+ }
+};
+
+void tst_QNetworkReply::putWithRateLimiting()
+{
+ QFile reference(testDataDir + "/rfc3252.txt");
+ reference.open(QIODevice::ReadOnly);
+ QByteArray data = reference.readAll();
+ QVERIFY(data.length() > 0);
+
+ QUrl url = QUrl::fromUserInput("http://" + QtNetworkSettings::serverName()+ "/qtest/cgi-bin/echo.cgi?");
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply;
+
+ RateLimitedUploadDevice rateLimitedUploadDevice(data);
+ rateLimitedUploadDevice.open(QIODevice::ReadOnly);
+
+ RUN_REQUEST(runCustomRequest(request, reply,QByteArray("POST"), &rateLimitedUploadDevice));
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+
+ QByteArray uploadedData = reply->readAll();
+ QCOMPARE(uploadedData.length(), data.length());
+ QCOMPARE(uploadedData, data);
+}
+
+
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index c4d42206fe..99f677643c 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -55,6 +55,10 @@
# endif
#endif
+#ifdef Q_OS_ANDROID
+# include <netinet/in.h>
+#endif
+
class tst_QHostAddress : public QObject
{
Q_OBJECT
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 6053021cf4..b70fa5c881 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -829,6 +829,10 @@ private:
*/
void tst_QLocalSocket::processConnection()
{
+#ifdef Q_OS_MAC
+ QSKIP("The processConnection test is unstable on Mac. See QTBUG-39986.");
+#endif
+
#ifdef Q_OS_WIN
const QString exeSuffix = QStringLiteral(".exe");
#else
diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
index f01d79d9bc..23a1455571 100644
--- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -576,6 +576,9 @@ protected:
#ifndef QT_NO_PROCESS
void tst_QTcpServer::addressReusable()
{
+#ifdef Q_OS_LINUX
+ QSKIP("The addressReusable test is unstable on Linux. See QTBUG-39985.");
+#endif
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
#ifndef QT_NO_NETWORKPROXY
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index fcf6315c1f..8e69d827a6 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -1976,9 +1976,9 @@ public slots:
attemptedToConnect = true;
sock->connectToHost(QtNetworkSettings::serverName(), 80);
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC)
pthread_yield_np();
-#elif defined Q_OS_LINUX
+#elif defined Q_OS_LINUX && !defined Q_OS_ANDROID
pthread_yield();
#endif
if (!sock->waitForConnected()) {
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2007.pem b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2007.pem
new file mode 100644
index 0000000000..2106f66332
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2007.pem
@@ -0,0 +1,25 @@
+-----BEGIN CERTIFICATE-----
+MIIENjCCAx6gAwIBAgICJ4MwDQYJKoZIhvcNAQEFBQAwOjELMAkGA1UEBhMCSU4x
+EjAQBgNVBAoTCUluZGlhIFBLSTEXMBUGA1UEAxMOQ0NBIEluZGlhIDIwMDcwHhcN
+MDcwNzAyMDY0MTU5WhcNMTUwNzA0MDYzMDAwWjCBsDELMAkGA1UEBhMCSU4xJDAi
+BgNVBAoTG05hdGlvbmFsIEluZm9ybWF0aWNzIENlbnRyZTEOMAwGA1UECxMFTklD
+Q0ExITAfBgNVBAMTGE5JQyBDZXJ0aWZ5aW5nIEF1dGhvcml0eTESMBAGA1UEBxMJ
+TmV3IERlbGhpMSQwIgYJKoZIhvcNAQkBFhVzdXBwb3J0QGNhbWFpbC5uaWMuaW4x
+DjAMBgNVBAgTBURlbGhpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
+wLRKDEWWC1iWcxpVgA7GJEjQVjGIMx9XPLoaMKXiEQdajHgmjKdOhlFkSWiHgiCS
+Uo39U0/UoC4rAYzBCcfHWdAGjXNs7dt/cz+muK2aMoPoAgXWLF2A48CJMrTcyNFE
+HryIYJeCiK8DTlEhBxL8II9VBx8qKSquizh4MQTmpqvfjHNqd6qCHF6q8W439io5
+kVIFnGNd/p0V5HFv0OpWeF/IpKJA1m1lb729FwfsVpqipf7DLVQUKtSjK/32RDtB
+hnAmkDlW6IZRPs2F896A5COPSDjJlAeUX8JqDnBOr64bPRgUy0VDnW/soRB3knkn
+5w5ueXj3DrgONtjGcBSwVwIDAQABo4HOMIHLMA8GA1UdEwEB/wQFMAMBAf8wEQYD
+VR0OBAoECEwne24Nsv9UMBMGA1UdIwQMMAqACE8ewFgn2LjkMAsGA1UdDwQEAwIB
+BjCBggYDVR0fBHsweTB3oHWgc4ZxbGRhcDovL25yZGMuY2NhLmdvdi5pbjozODkv
+Y249Q0NBIEluZGlhIDIwMDcsb3U9Q0NBIEluZGlhIDIwMDcsbz1JbmRpYSBQS0ks
+Yz1JTj9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0O2JpbmFyeT8wDQYJKoZIhvcN
+AQEFBQADggEBAKx6RkVgMGQADgl4jTy3qBDq8nvkegDaDnviTUsGzsR6RpooT0xd
+wuKiRU0I7p2gAo6uBTMEZtS+XWJz+7xlfo4fao5XIU4e1fxkQuxddM23/J7M4+Uz
+3pL7ziK5RcVizhQqz3IjSH440/OoFhUBT5d5WWN0hliEcr7+6nLPAOcAX/qR509a
+Djd/aonfyQFCMyfiPpYLx5ElTuqUZeHApJ58+Iprwbu3EIux+C+mfS8QCMY+WYje
+aocCIwIutrmoxIXxGy9yV5OKIe2+4wsCT8aNin+6AV7qNTmFVhp+MF50v69ONTO7
+w2Sa+ire2N5FgklMW2WTCi8d8rwLzaWuse4=
+-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2011.pem b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2011.pem
new file mode 100644
index 0000000000..d3a8c10502
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2011.pem
@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIEWzCCA0OgAwIBAgICJ5IwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCSU4x
+EjAQBgNVBAoTCUluZGlhIFBLSTEXMBUGA1UEAxMOQ0NBIEluZGlhIDIwMTEwHhcN
+MTEwMzExMDgxNTExWhcNMTYwMzExMDYzMDAwWjCByDELMAkGA1UEBhMCSU4xJDAi
+BgNVBAoTG05hdGlvbmFsIEluZm9ybWF0aWNzIENlbnRyZTEdMBsGA1UECxMUQ2Vy
+dGlmeWluZyBBdXRob3JpdHkxDzANBgNVBBETBjExMDAwMzEOMAwGA1UECBMFRGVs
+aGkxHjAcBgNVBAkTFUxvZGhpIFJvYWQsIE5ldyBEZWxoaTEdMBsGA1UEMwwUQS1C
+bG9jaywgQ0dPIENvbXBsZXgxFDASBgNVBAMTC05JQyBDQSAyMDExMIIBIjANBgkq
+hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7J/N88MoXcCHTz4A5DKF59+8kvSnriGr
+TEowLSa5NCvH+o89+Mf7V260kKZJ/hQox5RG/F8/gY7u9ziLeypbedeG8EIl88HC
+4x9hT0SNLsrj9qo90waDuGYB4/KQ8q5E6ivVxxV0epzQfFA5A5biKltPBbku/M4D
+iZ+TqBbHxo6nRUEZoukJi0+JLykGI4VpJlQBzow04omxQUZHzvCffo6QvN6FdzZ0
+MopwqaggyfHDFu9o4elCR9Kd/obYlgXAHLYwJlN0pybbe2WpKj81/pxDhKgxrVN+
+OZaI5OMBBkjDRQG+ZyEnQb8XYMNPJbOgQGYgsRdPPjIn7poTzxe7SQIDAQABo4Hb
+MIHYMBIGA1UdEwEB/wQIMAYBAf8CAQEwEQYDVR0OBAoECE5VT66z36FmMBIGA1Ud
+IAQLMAkwBwYFYIJkZAIwEwYDVR0jBAwwCoAITQeoY/LbHN8wLgYIKwYBBQUHAQEE
+IjAgMB4GCCsGAQUFBzABhhJodHRwOi8vb2N2cy5nb3YuaW4wDgYDVR0PAQH/BAQD
+AgEGMEYGA1UdHwQ/MD0wO6A5oDeGNWh0dHA6Ly9jY2EuZ292LmluL3J3L3Jlc291
+cmNlcy9DQ0FJbmRpYTIwMTFMYXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQB5
+LCqtHbxfO72KRWJbW9dAHNh2xh8n7wstNgSPHLbjL5B0l7RZlCFauy4fjc2faMiB
+xnOq5oEXeIZBrT2NkuEymQ8f0Pzm3pcXrMkFrj78SiA07/cPQShBKKpw39t6puJV
+8ykiVZMZvSCjCzzZZlVO12b2ChADkf6wtseftx5O/zBsqP3Y2+3+KvEeDVtuseKu
+FV2OxSsqSfffJq7IYTwpRPOVzHGJnjV3Igtj3zAzZm8CWxRM/yhnkGyVc+xz/T7o
+WY0870eciR+bmLjZ9j0opudZR6e+lCsMHH2Lxc8C/0XRcCzcganxfWCb/fb0gx44
+iY0a+wWCVebjuyKU/BXk
+-----END CERTIFICATE-----
diff --git a/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2014.pem b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2014.pem
new file mode 100644
index 0000000000..54670866d5
--- /dev/null
+++ b/tests/auto/network/ssl/qsslcertificate/more-certificates/blacklisted-nic-india-2014.pem
@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIEWzCCA0OgAwIBAgICJ7EwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCSU4x
+EjAQBgNVBAoTCUluZGlhIFBLSTEXMBUGA1UEAxMOQ0NBIEluZGlhIDIwMTQwHhcN
+MTQwMzA1MTExNTI0WhcNMjQwMzA1MDYzMDAwWjCByDELMAkGA1UEBhMCSU4xJDAi
+BgNVBAoTG05hdGlvbmFsIEluZm9ybWF0aWNzIENlbnRyZTEdMBsGA1UECxMUQ2Vy
+dGlmeWluZyBBdXRob3JpdHkxDzANBgNVBBETBjExMDAwMzEOMAwGA1UECBMFRGVs
+aGkxHjAcBgNVBAkTFUxvZGhpIFJvYWQsIE5ldyBEZWxoaTEdMBsGA1UEMxMUQS1C
+bG9jaywgQ0dPIENvbXBsZXgxFDASBgNVBAMTC05JQyBDQSAyMDE0MIIBIjANBgkq
+hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/OQ56Ge9MhJiBwtOlCJP4p5gjcCuqkQ2
+6BCSQgfAsxyNxAwtL1f0h3d5KNFIInIG2Y9PwBgUrgavOWy2cZICxgXIGaOzK5bI
+TyGhxYMPUzkazGppfj0ScW7Ed/kjeDnic3WlYkPwtNaV1qwTElr8zqPUtT27ZDqd
+6upor9MICngXAC1tHjhPuGrGtu4i6FMPrmkofwdh8dkuRzU/OPjf9lA+E9Qu0Nvq
+soI9grJA0etgRfn9juR4X3KTG21qHnza50PpMYC4+vh8jAnIT7Kcz8Ggr4eghkvP
++iz2yEtIcV9M1xeo98XU/jxuYS7LeWtO79jkiqCIqgI8T3x7LHuCaQIDAQABo4Hb
+MIHYMBIGA1UdEwEB/wQIMAYBAf8CAQEwEQYDVR0OBAoECEZwyi8lTsNHMBIGA1Ud
+IAQLMAkwBwYFYIJkZAIwEwYDVR0jBAwwCoAIQrjFz22zV+EwLgYIKwYBBQUHAQEE
+IjAgMB4GCCsGAQUFBzABhhJodHRwOi8vb2N2cy5nb3YuaW4wDgYDVR0PAQH/BAQD
+AgEGMEYGA1UdHwQ/MD0wO6A5oDeGNWh0dHA6Ly9jY2EuZ292LmluL3J3L3Jlc291
+cmNlcy9DQ0FJbmRpYTIwMTRMYXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQCB
+i3iJeUlkfjY96HgfBIUEsLi+knO3VUrxDmwps1YyhgRSt22NQLZ4jksSWLI2EQbn
+9k5tH8rwSbsOWf+TZH7jpaKAVSYi1GhEbGR/C2ZeFiWATwtPWKoVGwx/ksUO9YPM
+zf0wh6fDIuyBJIs/nuN93+L2ib+TS5viNky+HrR3XyqE0z43W5bbzMbido3lbwgr
+drMWD6hCNSZs888L0Se4rn2ei0aPmHmxjDjbExF3NF6m2uYC/wAR4cVIzMvvptFY
+n+SAdG/pwkKHaMVncB/cxxEWiKzOxVpjBsM4N19lpxp2RU/n+x7xRK3WTQvNAZdU
+7pcAYmZIXPu/ES9qpK4f
+-----END CERTIFICATE-----
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index e6017168d0..407237e519 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -23,6 +23,7 @@ SUBDIRS=\
qobjectperformance \
qobjectrace \
qsharedpointer_and_qwidget \
+ qprocess_and_guieventloop \
qtokenautomaton \
windowsmobile \
@@ -71,3 +72,5 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility
!embedded|wince*: SUBDIRS -= \
qdirectpainter
+winrt: SUBDIRS -= \
+ qprocess_and_guieventloop
diff --git a/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro b/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro
new file mode 100644
index 0000000000..e349fe5b11
--- /dev/null
+++ b/tests/auto/other/qprocess_and_guieventloop/qprocess_and_guieventloop.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = \
+ write-read-write
+SUBDIRS += test.pro
diff --git a/tests/auto/other/qprocess_and_guieventloop/test.pro b/tests/auto/other/qprocess_and_guieventloop/test.pro
new file mode 100644
index 0000000000..54d6f194b0
--- /dev/null
+++ b/tests/auto/other/qprocess_and_guieventloop/test.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+CONFIG += parallel_test
+QT = core gui testlib
+SOURCES = tst_qprocess_and_guieventloop.cpp
+TARGET = tst_qprocess_and_guieventloop
diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
new file mode 100644
index 0000000000..42153c6c80
--- /dev/null
+++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Intel Corporation
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtTest/QtTest>
+#include <QtCore/QProcess>
+
+class tst_QProcess_and_GuiEventLoop : public QObject
+{
+ Q_OBJECT
+private slots:
+ void waitForAndEventLoop();
+};
+
+
+void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop()
+{
+ // based on testcase provided in QTBUG-39488
+ QByteArray msg = "Hello World";
+
+ QProcess process;
+ process.start("write-read-write/write-read-write", QStringList() << msg);
+ QVERIFY(process.waitForStarted(5000));
+ QVERIFY(process.waitForReadyRead(5000));
+ QCOMPARE(process.readAll().trimmed(), msg);
+
+ // run the GUI event dispatcher once
+ QSignalSpy spy(&process, SIGNAL(readyRead()));
+ qApp->processEvents(QEventLoop::AllEvents, 100);
+
+ // we mustn't have read anything in the event loop
+ QCOMPARE(spy.count(), 0);
+
+ // ensure the process hasn't died
+ QVERIFY(!process.waitForFinished(250));
+
+ // we mustn't have read anything during waitForFinished either
+ QCOMPARE(spy.count(), 0);
+
+ // release the child for the second write
+ process.write("\n");
+ QVERIFY(process.waitForFinished(5000));
+ QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit));
+ QCOMPARE(process.exitCode(), 0);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(process.readAll().trimmed(), msg);
+}
+
+QTEST_MAIN(tst_QProcess_and_GuiEventLoop)
+
+#include "tst_qprocess_and_guieventloop.moc"
diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
new file mode 100644
index 0000000000..e8fc3b5cff
--- /dev/null
+++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Intel Corporation
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ const char *msg = argv[1];
+ char buf[2];
+
+ puts(msg);
+ fflush(stdout);
+
+ // wait for a newline
+ fgets(buf, sizeof buf, stdin);
+
+ puts(msg);
+ fflush(stdout);
+ return 0;
+}
diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro b/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro
new file mode 100644
index 0000000000..e236e05c7d
--- /dev/null
+++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/write-read-write.pro
@@ -0,0 +1,4 @@
+SOURCES = main.cpp
+CONFIG -= qt app_bundle
+CONFIG += console
+DESTDIR = ./
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 04140fa4a1..2e1504383f 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1828,6 +1828,12 @@ void tst_Moc::warnings_data()
<< QString("IGNORE_ALL_STDOUT")
<< QString(":3: Warning: Macro argument mismatch.\n:4: Warning: Macro argument mismatch.");
+ QTest::newRow("Class declaration lacks Q_OBJECT macro.")
+ << QByteArray("class X : public QObject \n { \n public slots: \n void foo() {} \n };")
+ << QStringList()
+ << 1
+ << QString()
+ << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro.");
}
void tst_Moc::warnings()
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 <QVBoxLayout>
#include <QSizeGrip>
#include <QDesktopWidget>
+#include <QWindow>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformtheme_p.h>
@@ -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<bool>("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"
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 73bec9a6b9..4252fb673b 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -262,7 +262,6 @@ private slots:
void optimizedResizeMove();
void optimizedResize_topLevel();
void resizeEvent();
- void moveEvent();
void task110173();
void testDeletionInEventHandlers();
@@ -1211,6 +1210,12 @@ void tst_QWidget::isEnabledTo()
QVERIFY( !childWidget->isEnabledTo( testWidget ) );
QVERIFY( grandChildWidget->isEnabledTo( childWidget ) );
QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) );
+
+ QMainWindow* childDialog = new QMainWindow(testWidget);
+ testWidget->setEnabled(false);
+ QVERIFY(!childDialog->isEnabled());
+ QVERIFY(childDialog->isEnabledTo(0));
+ testWidget->setEnabled(true);
}
void tst_QWidget::visible()
@@ -1465,7 +1470,8 @@ void tst_QWidget::mapFromAndTo()
subWindow2->setGeometry(75, 75, 100, 100);
subSubWindow->setGeometry(10, 10, 10, 10);
-#if !defined (Q_OS_WINCE) //still no proper minimizing
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_QNX) \
+ || (defined(Q_OS_BLACKBERRY) && !defined(Q_OS_BLACKBERRY_TABLET))
//update visibility
if (windowMinimized) {
if (!windowHidden) {
@@ -1828,17 +1834,19 @@ void tst_QWidget::windowState()
{
if (m_platform == QStringLiteral("xcb"))
QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail.");
-#ifdef Q_OS_WINCE_WM
- QPoint pos(500, 500);
+
+ QPoint pos;
QSize size(200, 200);
- if (qt_wince_is_smartphone()) { //small screen
- pos = QPoint(10,10);
- size = QSize(100,100);
- }
-#else
- const QPoint pos(500, 500);
- const QSize size(200, 200);
+ if (QGuiApplicationPrivate::platformIntegration()->defaultWindowState(Qt::Widget)
+ == Qt::WindowFullScreen) {
+ size = QGuiApplication::primaryScreen()->size();
+ } else {
+ pos = QPoint(10, 10);
+#ifdef Q_OS_WINCE_WM
+ if (qt_wince_is_smartphone()) { //small screen
+ size = QSize(100,100);
#endif
+ }
QWidget widget1;
widget1.move(pos);
@@ -1860,7 +1868,7 @@ void tst_QWidget::windowState()
VERIFY_STATE(Qt::WindowMaximized);
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowMaximized);
- widget1.show();
+ widget1.setVisible(true);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowMaximized);
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowMaximized);
@@ -2109,53 +2117,41 @@ void tst_QWidget::showFullScreen()
class ResizeWidget : public QWidget {
public:
- ResizeWidget(QWidget *p = 0)
- : QWidget(p)
- , m_spontaneousResizeEventCount(0)
- , m_synthesizedResizeEventCount(0)
- , m_spontaneousMoveEventCount(0)
- , m_synthesizedMoveEventCount(0)
+ ResizeWidget(QWidget *p = 0) : QWidget(p)
{
setObjectName(QLatin1String("ResizeWidget"));
setWindowTitle(objectName());
+ m_resizeEventCount = 0;
}
protected:
void resizeEvent(QResizeEvent *e){
QCOMPARE(size(), e->size());
- (e->spontaneous() ? m_spontaneousResizeEventCount : m_synthesizedResizeEventCount)++;
- }
- void moveEvent(QMoveEvent *e)
- {
- (e->spontaneous() ? m_spontaneousMoveEventCount : m_synthesizedMoveEventCount)++;
+ ++m_resizeEventCount;
}
public:
- int m_spontaneousResizeEventCount;
- int m_synthesizedResizeEventCount;
- int m_spontaneousMoveEventCount;
- int m_synthesizedMoveEventCount;
+ int m_resizeEventCount;
};
void tst_QWidget::resizeEvent()
{
+ QSKIP("QTBUG-30744");
+
{
QWidget wParent;
wParent.resize(200, 200);
ResizeWidget wChild(&wParent);
wParent.show();
QTest::qWaitForWindowExposed(&wParent);
- QCOMPARE (wChild.m_synthesizedResizeEventCount, 1); // initial resize event before paint
- QCOMPARE (wChild.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint
wParent.hide();
QSize safeSize(640,480);
if (wChild.size() == safeSize)
safeSize.setWidth(639);
wChild.resize(safeSize);
- QCOMPARE (wChild.m_synthesizedResizeEventCount, 1);
- QCOMPARE (wChild.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wChild.m_resizeEventCount, 1);
wParent.show();
- QCOMPARE (wChild.m_synthesizedResizeEventCount, 2);
- QCOMPARE (wChild.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wChild.m_resizeEventCount, 2);
}
{
@@ -2163,39 +2159,19 @@ void tst_QWidget::resizeEvent()
wTopLevel.resize(200, 200);
wTopLevel.show();
QTest::qWaitForWindowExposed(&wTopLevel);
- const int synthesizedResizeEventCountAfterShow = wTopLevel.m_synthesizedResizeEventCount;
- QCOMPARE (synthesizedResizeEventCountAfterShow, 1); // initial resize event before paint for toplevels
- QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels
wTopLevel.hide();
QSize safeSize(640,480);
if (wTopLevel.size() == safeSize)
safeSize.setWidth(639);
wTopLevel.resize(safeSize);
- QCOMPARE (wTopLevel.m_synthesizedResizeEventCount, synthesizedResizeEventCountAfterShow);
- QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wTopLevel.m_resizeEventCount, 1);
wTopLevel.show();
QTest::qWaitForWindowExposed(&wTopLevel);
-#ifdef Q_OS_OSX
- QEXPECT_FAIL("", "QTBUG-30744", Abort);
-#endif
- QCOMPARE (wTopLevel.m_synthesizedResizeEventCount, synthesizedResizeEventCountAfterShow + 1);
- QCOMPARE (wTopLevel.m_spontaneousResizeEventCount, 0);
+ QCOMPARE (wTopLevel.m_resizeEventCount, 2);
}
}
-void tst_QWidget::moveEvent()
-{
- ResizeWidget wTopLevel;
- wTopLevel.resize(200, 200);
- centerOnScreen(&wTopLevel);
- wTopLevel.show();
- QTest::qWaitForWindowExposed(&wTopLevel);
- const int synthesizedMoveEventCountAfterShow = wTopLevel.m_synthesizedMoveEventCount;
- wTopLevel.move(wTopLevel.pos() + QPoint(20, 20));
- QTRY_COMPARE (wTopLevel.m_synthesizedMoveEventCount, synthesizedMoveEventCountAfterShow + 1);
- QCOMPARE (wTopLevel.m_spontaneousMoveEventCount, 0);
-}
-
void tst_QWidget::showMinimized()
{
QWidget plain;
@@ -2471,7 +2447,7 @@ void tst_QWidget::normalGeometry()
QCOMPARE(child->normalGeometry(), QRect());
parent.setGeometry(100, 100, 200, 200);
- parent.show();
+ parent.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&parent));
QApplication::processEvents();
@@ -2574,7 +2550,7 @@ void tst_QWidget::setGeometry()
QRect cr(50,50,50,50);
tlw.setGeometry(tr);
child.setGeometry(cr);
- tlw.show();
+ tlw.showNormal();
QTest::qWait(50);
QCOMPARE(tlw.geometry().size(), tr.size());
QCOMPARE(child.geometry(), cr);
@@ -2584,7 +2560,7 @@ void tst_QWidget::setGeometry()
tr.moveTopLeft(QApplication::desktop()->availableGeometry().topLeft());
tlw.setGeometry(tr);
QCOMPARE(tlw.geometry(), tr);
- tlw.show();
+ tlw.showNormal();
QTest::qWait(50);
if (tlw.frameGeometry() != tlw.geometry())
QSKIP("Your window manager is too broken for this test");
@@ -3042,7 +3018,7 @@ void tst_QWidget::saveRestoreGeometry()
QWidget widget;
widget.move(position);
widget.resize(size);
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
@@ -3069,7 +3045,7 @@ void tst_QWidget::saveRestoreGeometry()
QVERIFY(widget.restoreGeometry(garbage) == false);
QVERIFY(widget.restoreGeometry(savedGeometry));
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
@@ -3084,7 +3060,7 @@ void tst_QWidget::saveRestoreGeometry()
QWidget widget;
widget.move(position);
widget.resize(size);
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTRY_COMPARE(widget.geometry().size(), size);
@@ -3206,7 +3182,7 @@ void tst_QWidget::restoreVersion1Geometry()
QCOMPARE(widget.pos(), expectedPosition);
QCOMPARE(widget.size(), expectedSize);
}
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTest::qWait(100);
@@ -3264,14 +3240,14 @@ void tst_QWidget::widgetAt()
w2->setGeometry(50,50, 160, 100);
w2->setObjectName(QLatin1String("w2"));
w2->setWindowTitle(w2->objectName());
- w1->show();
+ w1->showNormal();
QVERIFY(QTest::qWaitForWindowExposed(w1.data()));
qApp->processEvents();
QWidget *wr;
QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)));
QCOMPARE(wr->objectName(), QString("w1"));
- w2->show();
+ w2->showNormal();
QVERIFY(QTest::qWaitForWindowExposed(w2.data()));
qApp->processEvents();
qApp->processEvents();
@@ -3290,7 +3266,7 @@ void tst_QWidget::widgetAt()
QWidget *w3 = new QWidget(w2.data());
w3->setGeometry(10,10,50,50);
w3->setObjectName("w3");
- w3->show();
+ w3->showNormal();
qApp->processEvents();
QTRY_VERIFY((wr = QApplication::widgetAt(100,100)) && wr->objectName() == QString("w3"));
@@ -3298,6 +3274,11 @@ void tst_QWidget::widgetAt()
qApp->processEvents();
QTRY_VERIFY((wr = QApplication::widgetAt(100, 100)) && wr->objectName() == QString("w2"));
+ if (!QGuiApplicationPrivate::platformIntegration()
+ ->hasCapability(QPlatformIntegration::WindowMasks)) {
+ QSKIP("Platform does not support WindowMasks");
+ }
+
QRegion rgn = QRect(QPoint(0,0), w2->size());
QPoint point = w2->mapFromGlobal(QPoint(100,100));
rgn -= QRect(point, QSize(1,1));
@@ -3735,7 +3716,7 @@ void tst_QWidget::setMinimumSize()
#ifndef Q_OS_WINCE
QSize nonDefaultSize = defaultSize + QSize(5,5);
w.setMinimumSize(nonDefaultSize);
- w.show();
+ w.showNormal();
QTest::qWait(50);
QVERIFY(w.height() >= nonDefaultSize.height());
QVERIFY(w.width() >= nonDefaultSize.width());
@@ -3786,7 +3767,7 @@ void tst_QWidget::setFixedSize()
QVERIFY(!w.testAttribute(Qt::WA_Resized));
w.setFixedSize(defaultSize + QSize(150, 150));
- w.show();
+ w.showNormal();
QTest::qWait(50);
if (m_platform == QStringLiteral("xcb"))
QSKIP("QTBUG-26424");
@@ -4319,7 +4300,7 @@ void tst_QWidget::scroll()
updateWidget.resize(w, h);
updateWidget.reset();
updateWidget.move(QGuiApplication::primaryScreen()->geometry().center() - QPoint(250, 250));
- updateWidget.show();
+ updateWidget.showNormal();
qApp->setActiveWindow(&updateWidget);
QVERIFY(QTest::qWaitForWindowActive(&updateWidget));
QVERIFY(updateWidget.numPaintEvents > 0);
@@ -4522,7 +4503,7 @@ void tst_QWidget::setWindowGeometry()
widget.setWindowFlags(Qt::WindowFlags(windowFlags));
widget.setGeometry(rect);
- widget.show();
+ widget.showNormal();
if (rect.isValid())
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTRY_COMPARE(widget.geometry(), rect);
@@ -4570,7 +4551,7 @@ void tst_QWidget::setWindowGeometry()
if (windowFlags != 0)
widget.setWindowFlags(Qt::WindowFlags(windowFlags));
- widget.show();
+ widget.showNormal();
if (rect.isValid())
QVERIFY(QTest::qWaitForWindowExposed(&widget));
widget.setGeometry(rect);
@@ -4684,7 +4665,7 @@ void tst_QWidget::windowMoveResize()
widget.move(rect.topLeft());
widget.resize(rect.size());
- widget.show();
+ widget.showNormal();
QTest::qWait(10);
QTRY_COMPARE(widget.pos(), rect.topLeft());
@@ -4764,7 +4745,7 @@ void tst_QWidget::windowMoveResize()
if (windowFlags != 0)
widget.setWindowFlags(Qt::WindowFlags(windowFlags));
- widget.show();
+ widget.showNormal();
if (rect.isValid())
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QApplication::processEvents();
@@ -5008,7 +4989,7 @@ void tst_QWidget::moveChild()
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
QCursor::setPos(parent.geometry().topRight() + QPoint(50 , 50));
#endif
- parent.show();
+ parent.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&parent));
QTest::qWait(30);
@@ -5163,6 +5144,7 @@ void tst_QWidget::multipleToplevelFocusCheck()
w2.resize(200,200);
w2.show();
QVERIFY(QTest::qWaitForWindowExposed(&w2));
+ QTest::qWait(50);
QApplication::setActiveWindow(&w1);
w1.activateWindow();
@@ -5949,16 +5931,15 @@ void tst_QWidget::childEvents()
QCoreApplication::postEvent(&widget, new QEvent(QEvent::Type(QEvent::User + 1)));
- widget.show();
+ widget.showNormal();
expected =
EventRecorder::EventList()
- << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
- << qMakePair(&widget, QEvent::Show);
-
- expected << qMakePair(&widget, QEvent::ShowToParent);
+ << qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
@@ -5968,12 +5949,11 @@ void tst_QWidget::childEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
- << qMakePair(&widget, QEvent::Type(QEvent::User + 1));
-
-#ifdef Q_OS_MAC
- expected << qMakePair(&widget, QEvent::UpdateLater);
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 1))
+#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
+ << qMakePair(&widget, QEvent::UpdateLater)
#endif
- expected << qMakePair(&widget, QEvent::UpdateRequest);
+ << qMakePair(&widget, QEvent::UpdateRequest);
if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
@@ -6039,18 +6019,17 @@ void tst_QWidget::childEvents()
QCOMPARE(spy.eventList(), expected);
spy.clear();
- widget.show();
+ widget.showNormal();
expected =
EventRecorder::EventList()
- << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
- << qMakePair(&widget, QEvent::Show);
-
- expected << qMakePair(&widget, QEvent::ShowToParent);
+ << qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
@@ -6061,12 +6040,11 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
-
-#ifdef Q_OS_MAC
- expected << qMakePair(&widget, QEvent::UpdateLater);
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
+#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
+ << qMakePair(&widget, QEvent::UpdateLater)
#endif
- expected << qMakePair(&widget, QEvent::UpdateRequest);
+ << qMakePair(&widget, QEvent::UpdateRequest);
if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
@@ -6135,17 +6113,17 @@ void tst_QWidget::childEvents()
QCOMPARE(spy.eventList(), expected);
spy.clear();
- widget.show();
+ widget.showNormal();
expected =
EventRecorder::EventList()
- << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::WinIdChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
- << qMakePair(&widget, QEvent::Show);
+ << qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::ShowToParent);
- expected << qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
spy.clear();
@@ -6155,12 +6133,11 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
-
-#ifdef Q_OS_MAC
- expected << qMakePair(&widget, QEvent::UpdateLater);
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
+#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
+ << qMakePair(&widget, QEvent::UpdateLater)
#endif
- expected << qMakePair(&widget, QEvent::UpdateRequest);
+ << qMakePair(&widget, QEvent::UpdateRequest);
if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
@@ -6323,7 +6300,7 @@ void tst_QWidget::renderInvisible()
QFont f;
f.setStyleStrategy(QFont::NoAntialias);
calendar->setFont(f);
- calendar->show();
+ calendar->showNormal();
QVERIFY(QTest::qWaitForWindowExposed(calendar.data()));
// Create a dummy focus widget to get rid of focus rect in reference image.
@@ -7188,7 +7165,7 @@ void tst_QWidget::moveWindowInShowEvent()
QCOMPARE(widget.pos(), initial);
// show it
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QTest::qWait(100);
// it should have moved
@@ -7273,6 +7250,9 @@ void tst_QWidget::hideOpaqueChildWhileHidden()
#if !defined(Q_OS_WINCE)
void tst_QWidget::updateWhileMinimized()
{
+#if defined(Q_OS_QNX) && (!defined(Q_OS_BLACKBERRY) || defined(Q_OS_BLACKBERRY_TABLET))
+ QSKIP("Platform does not support showMinimized()");
+#endif
UpdateWidget widget;
// Filter out activation change and focus events to avoid update() calls in QWidget.
widget.updateOnActivationChangeAndFocusIn = false;
@@ -7823,6 +7803,9 @@ void tst_QWidget::doubleRepaint()
// Minmize: Should not trigger a repaint.
widget.showMinimized();
QTest::qWait(10);
+#if defined(Q_OS_QNX) && (!defined(Q_OS_BLACKBERRY) || defined(Q_OS_BLACKBERRY_TABLET))
+ QEXPECT_FAIL("", "Platform does not support showMinimized()", Continue);
+#endif
QCOMPARE(widget.numPaintEvents, 0);
widget.numPaintEvents = 0;
@@ -9089,7 +9072,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
bigWidget->setPalette(palette);
bigWidget->setAutoFillBackground(true);
- main.show();
+ main.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&main));
QPixmap correct(main.size());
@@ -10285,7 +10268,7 @@ void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282()
childWidget.setAttribute(Qt::WA_OpaquePaintEvent);
childWidget.setGeometry(250, 250, 500, 500);
- widget.show();
+ widget.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QVERIFY(childWidget.numPaintEvents == 0);
childWidget.reset();
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 14d59d3630..b1e43b69ad 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -106,7 +106,7 @@ private slots:
void changeStyleInChangeEvent();
void QTBUG15910_crashNullWidget();
void QTBUG36933_brokenPseudoClassLookup();
-
+ void styleSheetChangeBeforePolish();
//at the end because it mess with the style.
void widgetStyle();
void appStyle();
@@ -147,7 +147,7 @@ tst_QStyleSheetStyle::~tst_QStyleSheetStyle()
void tst_QStyleSheetStyle::numinstances()
{
- QWidget w;
+ /*QWidget w;
w.resize(200, 200);
centerOnScreen(&w);
QCommonStyle *style = new QCommonStyle;
@@ -180,7 +180,7 @@ void tst_QStyleSheetStyle::numinstances()
c.setStyle(style);
QCOMPARE(QStyleSheetStyle::numinstances, 2);
w.setStyleSheet("");
- QCOMPARE(QStyleSheetStyle::numinstances, 0);
+ QCOMPARE(QStyleSheetStyle::numinstances, 0);*/
}
void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet()
@@ -351,7 +351,7 @@ void tst_QStyleSheetStyle::repolish()
void tst_QStyleSheetStyle::widgetStyle()
{
- qApp->setStyleSheet("");
+ /*qApp->setStyleSheet("");
QWidget *window1 = new QWidget;
window1->setObjectName("window1");
@@ -488,12 +488,12 @@ void tst_QStyleSheetStyle::widgetStyle()
delete widget2;
delete window2;
delete style1;
- delete style2;
+ delete style2;*/
}
void tst_QStyleSheetStyle::appStyle()
{
- qApp->setStyleSheet("");
+ /* qApp->setStyleSheet("");
// qApp style can never be 0
QVERIFY(QApplication::style() != 0);
QPointer<QStyle> style1 = QStyleFactory::create("Windows");
@@ -531,7 +531,7 @@ void tst_QStyleSheetStyle::appStyle()
QVERIFY(qApp->style() == style1);
qApp->setStyleSheet("");
- QVERIFY(qApp->style() == style1);
+ QVERIFY(qApp->style() == style1);*/
}
void tst_QStyleSheetStyle::dynamicProperty()
@@ -1754,6 +1754,29 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00)));
}
+void tst_QStyleSheetStyle::styleSheetChangeBeforePolish()
+{
+ QWidget widget;
+ QVBoxLayout *vbox = new QVBoxLayout(&widget);
+ QFrame *frame = new QFrame(&widget);
+ frame->setFixedSize(200, 200);
+ frame->setStyleSheet("background-color: #FF0000;");
+ frame->setStyleSheet("background-color: #00FF00;");
+ vbox->addWidget(frame);
+ QFrame *frame2 = new QFrame(&widget);
+ frame2->setFixedSize(200, 200);
+ frame2->setStyleSheet("background-color: #FF0000;");
+ frame2->setStyleSheet("background-color: #00FF00;");
+ vbox->addWidget(frame);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QImage image(frame->size(), QImage::Format_ARGB32);
+ frame->render(&image);
+ QVERIFY(testForColors(image, QColor(0x00, 0xFF, 0x00)));
+ QImage image2(frame2->size(), QImage::Format_ARGB32);
+ frame2->render(&image2);
+ QVERIFY(testForColors(image2, QColor(0x00, 0xFF, 0x00)));
+}
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index abc0129f8b..c38c254b9a 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.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.
@@ -72,6 +72,7 @@
#include <qstylefactory.h>
#include <qabstractitemview.h>
#include <qstyleditemdelegate.h>
+#include <qstandarditemmodel.h>
#include <qproxystyle.h>
static inline void setFrameless(QWidget *w)
@@ -163,6 +164,7 @@ private slots:
void itemData();
void task_QTBUG_31146_popupCompletion();
void keyboardSelection();
+ void setCustomModelAndView();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1580,6 +1582,45 @@ void tst_QComboBox::setModel()
QVERIFY(box.model() != oldModel);
}
+void tst_QComboBox::setCustomModelAndView()
+{
+ // QTBUG-27597, ensure the correct text is returned when using custom view and a tree model.
+ QComboBox combo;
+ combo.setWindowTitle("QTBUG-27597, setCustomModelAndView");
+ combo.setEditable(true);
+ combo.setMinimumWidth(400);
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ combo.move(availableGeometry.center() - QPoint(200, 20));
+
+ QStandardItemModel *model = new QStandardItemModel(0, 1, &combo);
+
+ QStandardItem *item = new QStandardItem(QStringLiteral("Item1"));
+ item->appendRow(new QStandardItem(QStringLiteral("Item11")));
+ model->appendRow(item);
+
+ item = new QStandardItem(QStringLiteral("Item2"));
+ model->appendRow(item);
+ const QString subItem21Text = QStringLiteral("Item21");
+ QStandardItem *subItem = new QStandardItem(subItem21Text);
+ item->appendRow(subItem);
+
+ QTreeView* view = new QTreeView(&combo);
+ view->setHeaderHidden(true);
+ view->setSelectionMode(QAbstractItemView::SingleSelection);
+ view->setModel(model);
+ view->expandAll();
+ combo.setModel(model);
+ combo.setView(view);
+ combo.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&combo));
+ combo.showPopup();
+ QTRY_VERIFY(combo.view()->isVisible());
+ const QRect subItemRect = view->visualRect(model->indexFromItem(subItem));
+ QWidget *window = view->window();
+ QTest::mouseClick(window->windowHandle(), Qt::LeftButton, 0, view->mapTo(window, subItemRect.center()));
+ QTRY_COMPARE(combo.currentText(), subItem21Text);
+}
+
void tst_QComboBox::modelDeleted()
{
QComboBox box;
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 <qtextedit.h>
#include <qtreeview.h>
#include <qlabel.h>
+#include <qdialog.h>
+#include <qscreen.h>
#include <qdebug.h> // 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"