summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-27 13:22:37 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-10-28 10:32:06 +0100
commitaf3bd5037aeb9b842193f0e21cd5c03572b6dac6 (patch)
tree7ce55202a0d40b75b18da24722d373376142d206 /tests/auto
parent5adbb9cc576546c42249099e549f1947cca54610 (diff)
parent2eb26c170920d28213b71e549d5dac4663febb14 (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp10
-rw-r--r--tests/auto/corelib/io/largefile/tst_largefile.cpp2
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp45
-rw-r--r--tests/auto/gui/text/qglyphrun/qglyphrun.pro9
-rw-r--r--tests/auto/gui/text/qglyphrun/testdata.qrc2
-rw-r--r--tests/auto/gui/text/qrawfont/qrawfont.pro8
-rw-r--r--tests/auto/gui/text/qrawfont/testdata.qrc2
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp39
-rw-r--r--tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp12
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp18
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp46
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp8
-rw-r--r--tests/auto/shared/platforminputcontext.h2
-rw-r--r--tests/auto/shared/resources/test.ttf (renamed from tests/auto/gui/text/qglyphrun/test.ttf)bin2008 -> 2008 bytes
-rw-r--r--tests/auto/shared/resources/testfont.ttf (renamed from tests/auto/gui/text/qrawfont/testfont.ttf)bin63212 -> 63212 bytes
-rw-r--r--tests/auto/tools/rcc/data/images/images.expected2
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc6
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp30
-rw-r--r--tests/auto/widgets/gestures/gestures.pro6
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro4
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp336
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp89
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp25
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp36
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp28
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp37
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp43
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp17
-rw-r--r--tests/auto/widgets/widgets.pro1
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp10
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp54
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp45
33 files changed, 915 insertions, 59 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
index 7c154575d0..4e3d5c64bc 100644
--- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
@@ -196,10 +196,9 @@ void tst_QTextCodec::fromUnicode_data()
QTest::newRow("windows-1257") << "windows-1257" << true;
QTest::newRow("windows-1258") << "windows-1258" << true;
- QTest::newRow("macintosh") << "macintosh" << true;
+ QTest::newRow("Apple Roman") << "Apple Roman" << true;
//QTest::newRow("WINSAMI2") << "WINSAMI2" << true;
QTest::newRow("TIS-620") << "TIS-620" << true;
-// QTest::newRow("hp-roman8") << "hp-roman8" << true;
QTest::newRow("SJIS") << "SJIS" << false;
// all codecs from documentation
@@ -209,20 +208,17 @@ void tst_QTextCodec::fromUnicode_data()
QTest::newRow("windows-949") << "windows-949" << false;
QTest::newRow("EUC-JP") << "EUC-JP" << false;
QTest::newRow("EUC-KR") << "EUC-KR" << false;
- //QTest::newRow("GB18030-0") << "GB18030-0" << false; // only GB18030 works
QTest::newRow("GB18030") << "GB18030" << false;
+ QTest::newRow("HP-ROMAN8") << "HP-ROMAN8" << false;
QTest::newRow("IBM 850") << "IBM 850" << false;
QTest::newRow("IBM 866") << "IBM 866" << false;
QTest::newRow("IBM 874") << "IBM 874" << false;
QTest::newRow("ISO 2022-JP") << "ISO 2022-JP" << false;
//ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously
// Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test
- //QTest::newRow("JIS X 0201") << "JIS X 0201" << false; // actually not there
- //QTest::newRow("JIS X 0208") << "JIS X 0208" << false; // actually not there
QTest::newRow("KOI8-R") << "KOI8-R" << false;
QTest::newRow("KOI8-U") << "KOI8-U" << false;
- //QTest::newRow("MuleLao-1") << "MuleLao-1" << false; //only on x11
- QTest::newRow("ROMAN8") << "ROMAN8" << false;
+ QTest::newRow("Macintosh") << "Macintosh" << true;
QTest::newRow("Shift-JIS") << "Shift-JIS" << false;
QTest::newRow("TIS-620") << "TIS-620" << false;
QTest::newRow("TSCII") << "TSCII" << false;
diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp
index bedbeb6181..62410f7c80 100644
--- a/tests/auto/corelib/io/largefile/tst_largefile.cpp
+++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp
@@ -75,7 +75,7 @@ public:
#elif defined(Q_OS_MAC)
// HFS+ does not support sparse files, so we limit file size for the test
// on Mac OS.
- maxSizeBits = 32; // 4 GiB
+ maxSizeBits = 24; // 16 MiB
#else
maxSizeBits = 24; // 16 MiB
#endif
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index b3e683a29b..4264c96745 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -35,6 +35,7 @@
#include <qvariant.h>
#include <qbitarray.h>
+#include <qbytearraylist.h>
#include <qdatetime.h>
#include <qmap.h>
#include <qiodevice.h>
@@ -208,6 +209,7 @@ private slots:
void convertBoolToByteArray_data() const;
void convertByteArrayToBool() const;
void convertByteArrayToBool_data() const;
+ void convertIterables() const;
void toIntFromQString() const;
void toIntFromDouble() const;
void setValue();
@@ -2838,6 +2840,49 @@ void tst_QVariant::convertByteArrayToBool_data() const
<< QByteArray("true");
}
+void tst_QVariant::convertIterables() const
+{
+ {
+ QStringList list;
+ list.append("Hello");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QByteArrayList list;
+ list.append("Hello");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QVariantList list;
+ list.append("World");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QMap<QString, int> map;
+ map.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ }
+ {
+ QVariantMap map;
+ map.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ }
+ {
+ QHash<QString, int> hash;
+ hash.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ }
+ {
+ QVariantHash hash;
+ hash.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ }
+}
+
/*!
We verify that:
1. Converting the string "9.9" to int fails. This is the behavior of
diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro
index 0993a5c49c..b7d9f164c9 100644
--- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro
+++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro
@@ -8,14 +8,13 @@ linux: CONFIG += insignificant_test
SOURCES += \
tst_qglyphrun.cpp
-android {
- RESOURCES += \
- testdata.qrc
-}
wince* {
additionalFiles.files = test.ttf
- additionalFiles.path = .
+ additionalFiles.path = ../../../shared/resources/
DEPLOYMENT += additionalFiles
+} else {
+ RESOURCES += \
+ testdata.qrc
}
diff --git a/tests/auto/gui/text/qglyphrun/testdata.qrc b/tests/auto/gui/text/qglyphrun/testdata.qrc
index c4e237ad2f..25cadc477e 100644
--- a/tests/auto/gui/text/qglyphrun/testdata.qrc
+++ b/tests/auto/gui/text/qglyphrun/testdata.qrc
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>test.ttf</file>
+ <file alias="test.ttf">../../../shared/resources/test.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro
index 1891e7a9bf..20da2e9a22 100644
--- a/tests/auto/gui/text/qrawfont/qrawfont.pro
+++ b/tests/auto/gui/text/qrawfont/qrawfont.pro
@@ -7,9 +7,5 @@ QT = core core-private gui gui-private testlib
SOURCES += \
tst_qrawfont.cpp
-TESTDATA += testfont_bold_italic.ttf testfont.ttf
-
-android {
- RESOURCES += \
- testdata.qrc
-}
+RESOURCES += \
+ testdata.qrc
diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc
index 7bea0d5a39..8f8e32ed24 100644
--- a/tests/auto/gui/text/qrawfont/testdata.qrc
+++ b/tests/auto/gui/text/qrawfont/testdata.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>testfont_bold_italic.ttf</file>
- <file>testfont.ttf</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index a6d75390c3..a2f1668ef5 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -55,6 +55,7 @@ public slots:
void init();
void cleanup();
void accessAfterRemoveReadyReadSlot();
+ void setCookieHeaderMetaDataChangedSlot();
private slots:
void qnetworkdiskcache_data();
@@ -68,6 +69,7 @@ private slots:
void metaData();
void remove();
void accessAfterRemove(); // QTBUG-17400
+ void setCookieHeader(); // QTBUG-41514
void setCacheDirectory_data();
void setCacheDirectory();
void updateMetaData();
@@ -86,8 +88,9 @@ private slots:
private:
QTemporaryDir tempDir;
- QUrl url; // used by accessAfterRemove()
+ QUrl url; // used by accessAfterRemove(), setCookieHeader()
QNetworkDiskCache *diskCache; // used by accessAfterRemove()
+ QNetworkAccessManager *manager; // used by setCookieHeader()
};
// FIXME same as in tst_qnetworkreply.cpp .. could be unified
@@ -403,6 +406,40 @@ void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot()
diskCache->remove(url); // this used to cause a crash later on
}
+void tst_QNetworkDiskCache::setCookieHeader() // QTBUG-41514
+{
+ SubQNetworkDiskCache *cache = new SubQNetworkDiskCache();
+ url = QUrl("http://www.foo.com/cookieTest.html");
+ QNetworkCacheMetaData metaData;
+ metaData.setUrl(url);
+
+ QNetworkCacheMetaData::RawHeaderList headers;
+ headers.append(QNetworkCacheMetaData::RawHeader("Set-Cookie", "aaa=bbb"));
+ metaData.setRawHeaders(headers);
+ metaData.setSaveToDisk(true);
+ cache->setupWithOne(tempDir.path(), url, metaData);
+
+ manager = new QNetworkAccessManager();
+ manager->setCache(cache);
+
+ QNetworkRequest request(url);
+ QNetworkReply *reply = manager->get(request);
+ connect(reply, SIGNAL(metaDataChanged()), this, SLOT(setCookieHeaderMetaDataChangedSlot()));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ reply->deleteLater();
+ manager->deleteLater();
+}
+
+void tst_QNetworkDiskCache::setCookieHeaderMetaDataChangedSlot()
+{
+ QList<QNetworkCookie> actualCookieJar = manager->cookieJar()->cookiesForUrl(url);
+ QVERIFY(!actualCookieJar.empty());
+}
+
void tst_QNetworkDiskCache::setCacheDirectory_data()
{
QTest::addColumn<QString>("cacheDir");
diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
index d3ff95a26d..1e0d9555dd 100644
--- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
@@ -271,7 +271,11 @@ void tst_QNetworkSession::sessionProperties()
<< QLatin1String("WCDMA")
<< QLatin1String("HSPA")
<< QLatin1String("Bluetooth")
- << QLatin1String("WiMAX");
+ << QLatin1String("WiMAX")
+ << QLatin1String("BearerEVDO")
+ << QLatin1String("BearerLTE")
+ << QLatin1String("Bearer3G")
+ << QLatin1String("Bearer4G");
if (!configuration.isValid()) {
QVERIFY(configuration.bearerTypeName().isEmpty());
@@ -1022,7 +1026,11 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur
if (config.bearerTypeName() != "2G" &&
config.bearerTypeName() != "CDMA2000" &&
config.bearerTypeName() != "WCDMA" &&
- config.bearerTypeName() != "HSPA") {
+ config.bearerTypeName() != "HSPA" &&
+ config.bearerTypeName() != "EVDO" &&
+ config.bearerTypeName() != "LTE" &&
+ config.bearerTypeName() != "3G" &&
+ config.bearerTypeName() != "4G") {
// qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name();
discoveredConfigs.removeOne(config);
}
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 6e915f89fb..aa954429de 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1088,7 +1088,7 @@ void tst_QSslSocket::protocolServerSide_data()
#endif
QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false;
QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true;
- QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << true;
+ QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false;
#ifndef OPENSSL_NO_SSL2
QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a
// numerical IP, so OpenSSL will send a SSL 2 handshake
@@ -1120,7 +1120,7 @@ void tst_QSslSocket::protocolServerSide_data()
#ifndef OPENSSL_NO_SSL2
QTest::newRow("secure-ssl2") << QSsl::SecureProtocols << QSsl::SslV2 << false;
#endif
- QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << true;
+ QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << false;
QTest::newRow("secure-tls1.0") << QSsl::SecureProtocols << QSsl::TlsV1_0 << true;
QTest::newRow("secure-tls1ssl3") << QSsl::SecureProtocols << QSsl::TlsV1SslV3 << true;
QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true;
@@ -2300,28 +2300,28 @@ void tst_QSslSocket::sslOptions()
#ifdef SSL_OP_NO_COMPRESSION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION));
#else
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
#endif
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)));
#endif
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableLegacyRenegotiation),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2329,7 +2329,7 @@ void tst_QSslSocket::sslOptions()
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET)));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2339,7 +2339,7 @@ void tst_QSslSocket::sslOptions()
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets
|QSsl::SslOptionDisableCompression),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION)));
#endif
#endif
}
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index c42450607d..1be570e4b8 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -1022,9 +1022,9 @@ void tst_QPrinter::duplex()
{
// duplex()) / setDuplex() / PPK_Duplex
// PdfFormat: Supported, default QPrinter::DuplexNone
- // NativeFormat, Cups: Supported, default QPrinter::DuplexNone
- // NativeFormat, Win: Unsupported, always QPrinter::DuplexNone
- // NativeFormat, Mac: Unsupported, always QPrinter::DuplexNone
+ // NativeFormat, Cups: Supported, default to printer default
+ // NativeFormat, Win: Supported, default to printer default
+ // NativeFormat, Mac: Supported, default to printer default
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
@@ -1035,15 +1035,17 @@ void tst_QPrinter::duplex()
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
- // TODO Printer specific, need QPrinterInfo::duplex()
- //QCOMPARE(native.duplex(), QPrinter::DuplexNone);
-
- // Test set/get
- QPrinter::DuplexMode expected = QPrinter::DuplexAuto;
+ QPrinterInfo printerInfo = QPrinterInfo::defaultPrinter();
+ QPrinter::DuplexMode expected = printerInfo.defaultDuplexMode();
+ QCOMPARE(native.duplex(), expected);
+ // Test set/get (skipping Auto as that will return something different)
+ foreach (QPrinter::DuplexMode mode, printerInfo.supportedDuplexModes()) {
+ if (mode != expected && mode != QPrinter::DuplexAuto) {
+ expected = mode;
+ break;
+ }
+ }
native.setDuplex(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = QPrinter::DuplexNone;
-#endif // Q_OS_MAC || Q_OS_WIN
QCOMPARE(native.duplex(), expected);
// Test value preservation
@@ -1051,6 +1053,12 @@ void tst_QPrinter::duplex()
QCOMPARE(native.duplex(), expected);
native.setOutputFormat(QPrinter::NativeFormat);
QCOMPARE(native.duplex(), expected);
+
+ // Test setting invalid option
+ if (!printerInfo.supportedDuplexModes().contains(QPrinter::DuplexLongSide)) {
+ native.setDuplex(QPrinter::DuplexLongSide);
+ QCOMPARE(native.duplex(), expected);
+ }
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
@@ -1059,9 +1067,9 @@ void tst_QPrinter::duplex()
void tst_QPrinter::doubleSidedPrinting()
{
// PdfFormat: Supported, default false
- // NativeFormat, Cups: Supported, default false
- // NativeFormat, Win: Unsupported, always false
- // NativeFormat, Mac: Unsupported, always false
+ // NativeFormat, Cups: Supported, default to printer default
+ // NativeFormat, Win: Supported, default to printer default
+ // NativeFormat, Mac: Supported, default to printer default
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
@@ -1072,15 +1080,13 @@ void tst_QPrinter::doubleSidedPrinting()
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
- // TODO Printer specific, need QPrinterInfo::duplex()
- //QCOMPARE(native.doubleSidedPrinting(), false);
+ QPrinterInfo printerInfo;
+ bool expected = (printerInfo.defaultDuplexMode() != QPrinter::DuplexNone);
+ QCOMPARE(native.doubleSidedPrinting(), false);
// Test set/get
- bool expected = true;
+ expected = (printerInfo.supportedDuplexModes().count() > 1);
native.setDoubleSidedPrinting(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = false;
-#endif // Q_OS_MAC || Q_OS_WIN
QCOMPARE(native.doubleSidedPrinting(), expected);
// Test value preservation
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
index 88a526ba17..f3e8b9209d 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
@@ -298,6 +298,8 @@ void tst_QPrinterInfo::testConstructors()
QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy1.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy1.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
QPrinter printer(printers.at(i));
QPrinterInfo copy2(printer);
@@ -317,6 +319,8 @@ void tst_QPrinterInfo::testConstructors()
QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy2.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy2.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
}
}
@@ -347,6 +351,8 @@ void tst_QPrinterInfo::testAssignment()
QCOMPARE(copy.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
QCOMPARE(copy.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
QCOMPARE(copy.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
}
}
@@ -371,6 +377,8 @@ void tst_QPrinterInfo::namedPrinter()
QCOMPARE(pi2.minimumPhysicalPageSize(), pi.minimumPhysicalPageSize());
QCOMPARE(pi2.maximumPhysicalPageSize(), pi.maximumPhysicalPageSize());
QCOMPARE(pi2.supportedResolutions(), pi.supportedResolutions());
+ QCOMPARE(pi2.defaultDuplexMode(), pi.defaultDuplexMode());
+ QCOMPARE(pi2.supportedDuplexModes(), pi.supportedDuplexModes());
}
}
#endif // QT_NO_PRINTER
diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h
index fc415d833b..22b7ad6610 100644
--- a/tests/auto/shared/platforminputcontext.h
+++ b/tests/auto/shared/platforminputcontext.h
@@ -56,6 +56,8 @@ public:
virtual void reset() { m_resetCallCount++; }
virtual void commit() {
m_commitCallCount++;
+ if (m_commitString.isEmpty())
+ return;
QInputMethodEvent commitEvent;
commitEvent.setCommitString(m_commitString);
if (qGuiApp->focusObject())
diff --git a/tests/auto/gui/text/qglyphrun/test.ttf b/tests/auto/shared/resources/test.ttf
index 382b2547b0..382b2547b0 100644
--- a/tests/auto/gui/text/qglyphrun/test.ttf
+++ b/tests/auto/shared/resources/test.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qrawfont/testfont.ttf b/tests/auto/shared/resources/testfont.ttf
index d6042d2e58..d6042d2e58 100644
--- a/tests/auto/gui/text/qrawfont/testfont.ttf
+++ b/tests/auto/shared/resources/testfont.ttf
Binary files differ
diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected
index ae470db336..1f0157d51c 100644
--- a/tests/auto/tools/rcc/data/images/images.expected
+++ b/tests/auto/tools/rcc/data/images/images.expected
@@ -116,6 +116,7 @@ bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *,
}
#endif
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
@@ -123,6 +124,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
return 1;
}
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
diff --git a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
index 8116fe379a..dc1702971e 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
+++ b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
@@ -7,6 +7,8 @@ QT += core-private gui-private
SOURCES += tst_qfontdialog.cpp
+RESOURCES += testfonts.qrc
+
mac {
# ### fixme
# OBJECTIVE_SOURCES += tst_qfontdialog_mac_helpers.mm
diff --git a/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc
new file mode 100644
index 0000000000..cdfa287b39
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="test.ttf">../../../shared/resources/test.ttf</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 22c84c2244..92ea7e5e57 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -36,6 +36,7 @@
#include <qapplication.h>
+#include <qfontdatabase.h>
#include <qfontinfo.h>
#include <qtimer.h>
#include <qmainwindow.h>
@@ -70,6 +71,10 @@ private slots:
void setFont();
void task256466_wrongStyle();
void setNonStandardFontSize();
+#ifndef QT_NO_STYLE_STYLESHEET
+ void qtbug_41513_stylesheetStyle();
+#endif
+
private:
void runSlotWithFailsafeTimer(const char *member);
@@ -201,6 +206,31 @@ void tst_QFontDialog::setNonStandardFontSize()
{
runSlotWithFailsafeTimer(SLOT(testNonStandardFontSize()));
}
+#ifndef QT_NO_STYLE_STYLESHEET
+static const QString offendingStyleSheet = QStringLiteral("* { font-family: \"QtBidiTestFont\"; }");
+
+void tst_QFontDialog::qtbug_41513_stylesheetStyle()
+{
+ if (QFontDatabase::addApplicationFont(QFINDTESTDATA("test.ttf")) < 0)
+ QSKIP("Test fonts not found.");
+ if (QFontDatabase::addApplicationFont(QFINDTESTDATA("testfont.ttf")) < 0)
+ QSKIP("Test fonts not found.");
+ QFont testFont = QFont(QStringLiteral("QtsSpecialTestFont"));
+ qApp->setStyleSheet(offendingStyleSheet);
+ bool accepted = false;
+ QTimer::singleShot(2000, this, SLOT(postKeyReturn()));
+ QFont resultFont = QFontDialog::getFont(&accepted, testFont,
+ QApplication::activeWindow(),
+ QLatin1String("QFontDialog - Stylesheet Test"),
+ QFontDialog::DontUseNativeDialog);
+ QVERIFY(accepted);
+
+ QCOMPARE(resultFont, testFont);
+
+ // reset stylesheet
+ qApp->setStyleSheet(QString());
+}
+#endif // QT_NO_STYLE_STYLESHEET
void tst_QFontDialog::testNonStandardFontSize()
{
diff --git a/tests/auto/widgets/gestures/gestures.pro b/tests/auto/widgets/gestures/gestures.pro
new file mode 100644
index 0000000000..5a87a01ee2
--- /dev/null
+++ b/tests/auto/widgets/gestures/gestures.pro
@@ -0,0 +1,6 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qgesturerecognizer \
+
+mac: SUBDIRS -= \ # Uses native recognizers
+ qgesturerecognizer \
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro
new file mode 100644
index 0000000000..7c9ddcfb03
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qgesturerecognizer
+QT += widgets testlib gui-private core-private
+SOURCES += tst_qgesturerecognizer.cpp
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
new file mode 100644
index 0000000000..833494f25e
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** 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.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** 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.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QTest>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QGestureEvent>
+#include <QtGui/QScreen>
+#include <QtGui/QTouchDevice>
+#include <QtCore/QVector>
+#include <QtCore/QString>
+#include <QtCore/QHash>
+#include <QtCore/QDebug>
+
+#include <qpa/qwindowsysteminterface.h>
+
+class tst_QGestureRecognizer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QGestureRecognizer();
+
+private Q_SLOTS:
+ void initTestCase();
+#ifndef QT_NO_GESTURES
+ void panGesture_data();
+ void panGesture();
+ void pinchGesture_data();
+ void pinchGesture();
+ void swipeGesture_data();
+ void swipeGesture();
+#endif // !QT_NO_GESTURES
+
+private:
+ const int m_fingerDistance;
+ QTouchDevice *m_touchDevice;
+};
+
+tst_QGestureRecognizer::tst_QGestureRecognizer()
+ : m_fingerDistance(qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch() / 2.0))
+ , m_touchDevice(new QTouchDevice)
+{
+}
+
+void tst_QGestureRecognizer::initTestCase()
+{
+ m_touchDevice->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+}
+
+#ifndef QT_NO_GESTURES
+
+typedef QVector<Qt::GestureType> GestureTypeVector;
+
+class TestWidget : public QWidget
+{
+public:
+ explicit TestWidget(const GestureTypeVector &gestureTypes);
+
+ bool gestureReceived(Qt::GestureType gestureType) const
+ { return m_receivedGestures.value(gestureType); }
+
+protected:
+ bool event(QEvent * event) Q_DECL_OVERRIDE;
+
+private:
+ typedef QHash<Qt::GestureType, bool> GestureTypeHash;
+ GestureTypeHash m_receivedGestures;
+};
+
+TestWidget::TestWidget(const GestureTypeVector &gestureTypes)
+{
+ setAttribute(Qt::WA_AcceptTouchEvents);
+
+ foreach (Qt::GestureType gestureType, gestureTypes) {
+ grabGesture(gestureType);
+ m_receivedGestures.insert(gestureType, false);
+ }
+
+ const QRect geometry = QGuiApplication::primaryScreen()->availableGeometry();
+ const QSize size = geometry.size() / 2;
+ resize(size);
+ move(geometry.center() - QPoint(size.width() / 2, size.height() / 2));
+}
+
+bool TestWidget::event(QEvent * event)
+{
+ switch (event->type()) {
+ case QEvent::Gesture: {
+ const QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event);
+ const GestureTypeHash::iterator hend = m_receivedGestures.end();
+ for (GestureTypeHash::iterator it = m_receivedGestures.begin(); it != hend; ++it) {
+ if (const QGesture *gesture = gestureEvent->gesture(it.key())) {
+ if (gesture->state() == Qt::GestureFinished)
+ it.value() = true;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(event);
+}
+
+static void pressSequence(QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int p = 0; p < pointCount; ++p)
+ sequence.press(p, points.at(p), widget);
+ sequence.commit();
+}
+
+static void linearSequence(int n, const QPoint &delta,
+ QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int s = 0; s < n; ++s) {
+ for (int p = 0; p < pointCount; ++p) {
+ points[p] += delta;
+ sequence.move(p, points[p], widget);
+ }
+ sequence.commit();
+ }
+}
+
+static void releaseSequence(QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int p = 0; p < pointCount; ++p)
+ sequence.release(p, points[p], widget);
+ sequence.commit();
+}
+
+// --- Pan
+
+enum PanSubTest {
+ TwoFingerPanSubTest
+};
+
+void tst_QGestureRecognizer::panGesture_data()
+{
+ QTest::addColumn<int>("panSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Two finger") << int(TwoFingerPanSubTest) << true;
+}
+
+void tst_QGestureRecognizer::panGesture()
+{
+ QFETCH(int, panSubTest);
+ QFETCH(bool, gestureExpected);
+
+ Q_UNUSED(panSubTest) // Single finger pan will be added later.
+
+ const int panPoints = 2;
+ const Qt::GestureType gestureType = Qt::PanGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVector<QPoint> points;
+ for (int i = 0; i < panPoints; ++i)
+ points.append(QPoint(10 + i *20, 10 + i *20));
+
+ QTest::QTouchEventSequence panSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(panSequence, points, &widget);
+ linearSequence(5, QPoint(20, 20), panSequence, points, &widget);
+ releaseSequence(panSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+// --- Pinch
+
+enum PinchSubTest {
+ StandardPinchSubTest
+};
+
+void tst_QGestureRecognizer::pinchGesture_data()
+{
+ QTest::addColumn<int>("pinchSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Standard") << int(StandardPinchSubTest) << true;
+}
+
+void tst_QGestureRecognizer::pinchGesture()
+{
+ QFETCH(int, pinchSubTest);
+ QFETCH(bool, gestureExpected);
+
+ Q_UNUSED(pinchSubTest)
+
+ const Qt::GestureType gestureType = Qt::PinchGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVector<QPoint> points;
+ points.append(widget.rect().center());
+ points.append(points.front() + QPoint(0, 20));
+
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(pinchSequence, points, &widget);
+
+ for (int s = 0; s < 5; ++s) {
+ points[0] += QPoint(5, 30);
+ pinchSequence.move(0, points[0], &widget);
+ points[1] += QPoint(5, -30);
+ pinchSequence.move(1, points[1], &widget);
+ pinchSequence.commit();
+ }
+
+ releaseSequence(pinchSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+// --- Swipe
+
+enum SwipeSubTest {
+ SwipeLineSubTest,
+ SwipeChangeDirectionSubTest,
+};
+
+void tst_QGestureRecognizer::swipeGesture_data()
+{
+ QTest::addColumn<int>("swipeSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Line") << int(SwipeLineSubTest) << true;
+ QTest::newRow("ChangeDirection") << int(SwipeChangeDirectionSubTest) << false;
+}
+
+void tst_QGestureRecognizer::swipeGesture()
+{
+ enum { swipePoints = 3 };
+
+ QFETCH(int, swipeSubTest);
+ QFETCH(bool, gestureExpected);
+
+ const Qt::GestureType gestureType = Qt::SwipeGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ // Start a swipe sequence with 2 points (QTBUG-15768)
+ const QPoint fingerDistance(m_fingerDistance, m_fingerDistance);
+ QVector<QPoint> points;
+ for (int i = 0; i < swipePoints - 1; ++i)
+ points.append(fingerDistance + i * fingerDistance);
+
+ QTest::QTouchEventSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(swipeSequence, points, &widget);
+
+ // Press point #3
+ points.append(points.last() + fingerDistance);
+ swipeSequence.press(points.size() - 1, points.last(), &widget);
+ swipeSequence.commit();
+ Q_ASSERT(points.size() == swipePoints);
+
+ // Move.
+ const QPoint moveDelta(60, 20);
+ switch (swipeSubTest) {
+ case SwipeLineSubTest:
+ linearSequence(5, moveDelta, swipeSequence, points, &widget);
+ break;
+ case SwipeChangeDirectionSubTest:
+ linearSequence(5, moveDelta, swipeSequence, points, &widget);
+ linearSequence(3, QPoint(-moveDelta.x(), moveDelta.y()), swipeSequence, points, &widget);
+ break;
+ }
+
+ releaseSequence(swipeSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+#endif // !QT_NO_GESTURES
+
+QTEST_MAIN(tst_QGestureRecognizer)
+
+#include "tst_qgesturerecognizer.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index c90c431d8b..3b55fcd5fc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -124,6 +124,7 @@ private slots:
void heightForWidthWithSpanning();
void stretchAndHeightForWidth();
void testDefaultAlignment();
+ void hiddenItems();
};
class RectWidget : public QGraphicsWidget
@@ -3485,6 +3486,94 @@ void tst_QGraphicsGridLayout::testDefaultAlignment()
QCOMPARE(w->geometry(), QRectF(0,0,50,50));
QCOMPARE(w2->geometry(), QRectF(0,50,100,100));
}
+
+static RectWidget *addWidget(QGraphicsGridLayout *grid, int row, int column)
+{
+ RectWidget *w = new RectWidget;
+ w->setPreferredSize(20, 20);
+ grid->addItem(w, row, column);
+ return w;
+}
+
+static void setVisible(bool visible, QGraphicsWidget **widgets)
+{
+ for (int i = 0; i < 3; ++i)
+ if (widgets[i]) widgets[i]->setVisible(visible);
+}
+
+static void setRetainSizeWhenHidden(bool retainSize, QGraphicsWidget **widgets)
+{
+ QSizePolicy sp = widgets[0]->sizePolicy();
+ sp.setRetainSizeWhenHidden(retainSize);
+ for (int i = 0; i < 3; ++i)
+ if (widgets[i]) widgets[i]->setSizePolicy(sp);
+}
+
+void tst_QGraphicsGridLayout::hiddenItems()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ // Create a 3x3 layout
+ addWidget(layout, 0, 0);
+ RectWidget *w01 = addWidget(layout, 0, 1);
+ addWidget(layout, 0, 2);
+ RectWidget *w10 = addWidget(layout, 1, 0);
+ RectWidget *w11 = addWidget(layout, 1, 1);
+ RectWidget *w12 = addWidget(layout, 1, 2);
+ addWidget(layout, 2, 0);
+ RectWidget *w21 = addWidget(layout, 2, 1);
+ addWidget(layout, 2, 2);
+
+ QGraphicsWidget *middleColumn[] = {w01, w11, w21 };
+ QGraphicsWidget *topTwoOfMiddleColumn[] = {w01, w11, 0 };
+
+ // hide and show middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setVisible(false, middleColumn); // hide middle column
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ setVisible(true, middleColumn); // show middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setRetainSizeWhenHidden(true, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setVisible(false, middleColumn); // hide middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setRetainSizeWhenHidden(false, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ setVisible(true, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+
+ // Hide only two items, => column should not collapse
+ setVisible(false, topTwoOfMiddleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+
+
+ QGraphicsWidget *middleRow[] = {w10, w11, w12 };
+ QGraphicsWidget *leftMostTwoOfMiddleRow[] = {w10, w11, 0 };
+
+ // hide and show middle row
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setVisible(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(42));
+ setVisible(true, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setRetainSizeWhenHidden(true, middleColumn);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setVisible(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setRetainSizeWhenHidden(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(42));
+ setVisible(true, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+
+ // Hide only two items => row should not collapse
+ setVisible(false, leftMostTwoOfMiddleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+
+}
+
QTEST_MAIN(tst_QGraphicsGridLayout)
#include "tst_qgraphicsgridlayout.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index d35667f215..107e3eb48a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -50,6 +50,7 @@ private slots:
void compressLayoutRequest();
void automaticReparenting();
void verifyActivate();
+ void sizeHintOfHiddenLayout();
void invalidate();
void constructors();
void alternativeLayoutItems();
@@ -279,6 +280,30 @@ void tst_QGraphicsLayout::verifyActivate()
}
+
+void tst_QGraphicsLayout::sizeHintOfHiddenLayout()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window);
+ scene.addItem(window);
+ TestLayout *lout = new TestLayout(window);
+ lout->setContentsMargins(1,2,2,1);
+ QGraphicsWidget *w = new QGraphicsWidget;
+ w->setPreferredSize(20, 20);
+ w->setMaximumSize(50, 50);
+ lout->addItem(w);
+ window->setLayout(lout);
+
+ for (int pass = 0; pass < 3; ++pass) {
+ QCOMPARE(lout->sizeHint(Qt::MinimumSize), QSizeF(3,3));
+ QCOMPARE(lout->sizeHint(Qt::PreferredSize), QSizeF(23,23));
+ QCOMPARE(lout->sizeHint(Qt::MaximumSize), QSizeF(53,53));
+ window->setVisible(pass % 2);
+ }
+}
+
static void clearAllCounters(TestGraphicsWidget *widget)
{
if (!widget)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 7147bb8cce..1513abf0b1 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -103,6 +103,7 @@ private slots:
void testOffByOneInLargerLayout();
void testDefaultAlignment();
void combineSizePolicies();
+ void hiddenItems();
// Task specific tests
void task218400_insertStretchCrash();
@@ -1721,6 +1722,41 @@ void tst_QGraphicsLinearLayout::combineSizePolicies()
QCOMPARE(layout->maximumHeight(), qreal(200));
}
+void tst_QGraphicsLinearLayout::hiddenItems()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ RectWidget *w1 = new RectWidget;
+ w1->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w1);
+
+ RectWidget *w2 = new RectWidget;
+ w2->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w2);
+
+ RectWidget *w3 = new RectWidget;
+ w3->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w3);
+
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ w2->hide();
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ w2->show();
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ QSizePolicy sp = w2->sizePolicy();
+ sp.setRetainSizeWhenHidden(true);
+ w2->setSizePolicy(sp);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ w2->hide();
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ sp.setRetainSizeWhenHidden(false);
+ w2->setSizePolicy(sp);
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+}
+
QTEST_MAIN(tst_QGraphicsLinearLayout)
#include "tst_qgraphicslinearlayout.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index ab84c9e482..66d0f64ceb 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -174,6 +174,7 @@ private slots:
void clickFocus();
void windowFrameMargins();
void QTBUG_6986_sendMouseEventToAlienWidget();
+ void mapToGlobal();
};
// Subclass that exposes the protected functions.
@@ -3659,5 +3660,32 @@ void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget()
QTRY_COMPARE(scene.hoverButton->hoverLeaveReceived, true);
}
+void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
+{
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ const QSize size = availableGeometry.size() / 5;
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowTitle(QTest::currentTestFunction());
+ view.resize(size);
+ view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100));
+ QWidget *embeddedWidget = new QWidget;
+ embeddedWidget->setFixedSize(size / 2);
+ scene.addWidget(embeddedWidget);
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ const QPoint embeddedCenter = embeddedWidget->geometry().center();
+ const QPoint embeddedCenterGlobal = embeddedWidget->mapToGlobal(embeddedCenter);
+ QCOMPARE(embeddedWidget->mapFromGlobal(embeddedCenterGlobal), embeddedCenter);
+ // This should be equivalent to the view center give or take rounding
+ // errors due to odd window margins
+ const QPoint viewCenter = view.geometry().center();
+ QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2,
+ qPrintable(QStringLiteral("%1, %2 != %3, %4")
+ .arg(viewCenter.x()).arg(viewCenter.y())
+ .arg(embeddedCenterGlobal.x()).arg(embeddedCenterGlobal.y())));
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 70448f9813..bd1c6a0dc5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -242,6 +242,7 @@ private slots:
void style();
void sorting_data();
void sorting();
+ void insertionOrder();
void changedSignal_data();
void changedSignal();
void stickyFocus_data();
@@ -3633,6 +3634,42 @@ void tst_QGraphicsScene::sorting()
<< t_1);
}
+void tst_QGraphicsScene::insertionOrder()
+{
+ QGraphicsScene scene;
+ const int numItems = 5;
+ QList<QGraphicsItem*> items;
+
+ for (int i = 0; i < numItems; ++i) {
+ QGraphicsRectItem* item = new QGraphicsRectItem(i * 20, i * 20, 200, 200);
+ item->setData(0, i);
+ items.append(item);
+ scene.addItem(item);
+ }
+
+ {
+ QList<QGraphicsItem*> itemList = scene.items();
+ QCOMPARE(itemList.count(), numItems);
+ for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
+ }
+ }
+
+ for (int i = 0; i < items.size(); ++i)
+ {
+ scene.removeItem(items.at(i));
+ scene.addItem(items.at(i));
+ }
+
+ {
+ QList<QGraphicsItem*> itemList = scene.items();
+ QCOMPARE(itemList.count(), numItems);
+ for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
+ }
+ }
+}
+
class ChangedListener : public QObject
{
Q_OBJECT
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index d38bb86487..afd8be71e8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -160,6 +160,7 @@ private slots:
void dragMode_scrollHand();
void dragMode_rubberBand();
void rubberBandSelectionMode();
+ void rotated_rubberBand();
void backgroundBrush();
void foregroundBrush();
void matrix();
@@ -935,6 +936,48 @@ void tst_QGraphicsView::rubberBandSelectionMode()
QCOMPARE(scene.selectedItems(), QList<QGraphicsItem *>() << rect);
}
+void tst_QGraphicsView::rotated_rubberBand()
+{
+ QWidget toplevel;
+ setFrameless(&toplevel);
+
+ QGraphicsScene scene;
+ const int dim = 3;
+ for (int i = 0; i < dim; i++) {
+ for (int j = 0; j < dim; j ++) {
+ QGraphicsRectItem *rect = new QGraphicsRectItem(i * 20, j * 20, 10, 10);
+ rect->setFlag(QGraphicsItem::ItemIsSelectable);
+ rect->setData(0, (i == j));
+ scene.addItem(rect);
+ }
+ }
+
+ QGraphicsView view(&scene, &toplevel);
+ QCOMPARE(view.rubberBandSelectionMode(), Qt::IntersectsItemShape);
+ view.setDragMode(QGraphicsView::RubberBandDrag);
+ view.resize(120, 120);
+ view.rotate(45);
+ toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
+
+ // Disable mouse tracking to prevent the window system from sending mouse
+ // move events to the viewport while we are synthesizing events. If
+ // QGraphicsView gets a mouse move event with no buttons down, it'll
+ // terminate the rubber band.
+ view.viewport()->setMouseTracking(false);
+
+ QCOMPARE(scene.selectedItems(), QList<QGraphicsItem *>());
+ int midWidth = view.viewport()->width() / 2;
+ sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton);
+ sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()),
+ Qt::LeftButton, Qt::LeftButton);
+ QCOMPARE(scene.selectedItems().count(), dim);
+ foreach (const QGraphicsItem *item, scene.items()) {
+ QCOMPARE(item->isSelected(), item->data(0).toBool());
+ }
+ sendMouseRelease(view.viewport(), QPoint(), Qt::LeftButton);
+}
+
void tst_QGraphicsView::backgroundBrush()
{
QGraphicsScene scene;
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index ec3e8ece6a..44d7671ca3 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -55,6 +55,7 @@
#include <qmainwindow.h>
#include <qdockwidget.h>
#include <qtoolbar.h>
+#include <qtoolbutton.h>
#include <QtGui/qpaintengine.h>
#include <QtGui/qbackingstore.h>
#include <QtGui/qguiapplication.h>
@@ -268,6 +269,7 @@ private slots:
void winIdChangeEvent();
void persistentWinId();
void showNativeChild();
+ void transientParent();
void qobject_castInDestroyedSlot();
void showHideEvent_data();
@@ -3992,6 +3994,21 @@ void tst_QWidget::persistentWinId()
QCOMPARE(w3->winId(), winId3);
}
+void tst_QWidget::transientParent()
+{
+ QWidget topLevel;
+ topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize));
+ topLevel.setWindowTitle(__FUNCTION__);
+ QWidget *child = new QWidget(&topLevel);
+ QMenu *menu = new QMenu(child); // QTBUG-41898: Use top level as transient parent for native widgets as well.
+ QToolButton *toolButton = new QToolButton(child);
+ toolButton->setMenu(menu);
+ toolButton->winId();
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(menu->windowHandle()->transientParent(), topLevel.windowHandle());
+}
+
void tst_QWidget::showNativeChild()
{
QWidget topLevel;
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 8b6c4722be..efcc47171d 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -8,3 +8,4 @@ SUBDIRS=\
styles \
util \
widgets \
+ gestures \
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index e3e7b13cbe..d0a787d32a 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -67,6 +67,8 @@ private slots:
void showPrevNext();
void firstDayOfWeek();
+
+ void contentsMargins();
};
// Testing get/set functions
@@ -391,5 +393,13 @@ void tst_QCalendarWidget::firstDayOfWeek()
QCOMPARE(calendar.firstDayOfWeek(), germanLocale.firstDayOfWeek());
}
+void tst_QCalendarWidget::contentsMargins()
+{
+ QCalendarWidget calendar1;
+ QCalendarWidget calendar2;
+ calendar2.setContentsMargins(10, 5, 20, 30);
+ QCOMPARE(calendar1.minimumSizeHint() + QSize(30, 35), calendar2.minimumSizeHint());
+}
+
QTEST_MAIN(tst_QCalendarWidget)
#include "tst_qcalendarwidget.moc"
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 54cf1af5d3..ac32ee4968 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -152,6 +152,7 @@ private slots:
void resetModel();
void keyBoardNavigationWithMouse();
void task_QTBUG_1071_changingFocusEmitsActivated();
+ void maxVisibleItems_data();
void maxVisibleItems();
void task_QTBUG_10491_currentIndexAndModelColumn();
void highlightedSignal();
@@ -159,6 +160,7 @@ private slots:
void task_QTBUG_31146_popupCompletion();
void keyboardSelection();
void setCustomModelAndView();
+ void updateDelegateOnEditableChange();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -2749,8 +2751,18 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
QTRY_COMPARE(spy.count(), 1);
}
+void tst_QComboBox::maxVisibleItems_data()
+{
+ QTest::addColumn<int>("spacing");
+ QTest::newRow("Default") << -1;
+ QTest::newRow("No spacing") << 0;
+ QTest::newRow("20") << -1;
+}
+
void tst_QComboBox::maxVisibleItems()
{
+ QFETCH(int, spacing);
+
QComboBox comboBox;
QCOMPARE(comboBox.maxVisibleItems(), 10); //default value.
@@ -2771,15 +2783,18 @@ void tst_QComboBox::maxVisibleItems()
QTRY_VERIFY(comboBox.view());
QTRY_VERIFY(comboBox.view()->isVisible());
- QAbstractItemView *v = comboBox.view();
- int itemHeight = v->visualRect(v->model()->index(0,0)).height();
- QListView *lv = qobject_cast<QListView*>(v);
- if (lv)
- itemHeight += lv->spacing();
+ QListView *listView = qobject_cast<QListView*>(comboBox.view());
+ QVERIFY(listView);
+ if (spacing >= 0)
+ listView->setSpacing(spacing);
+
+ const int itemHeight = listView->visualRect(listView->model()->index(0,0)).height()
+ + 2 * listView->spacing();
+
QStyleOptionComboBox opt;
opt.initFrom(&comboBox);
if (!comboBox.style()->styleHint(QStyle::SH_ComboBox_Popup, &opt))
- QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
+ QCOMPARE(listView->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
}
void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn()
@@ -3035,5 +3050,32 @@ void tst_QComboBox::keyboardSelection()
QCOMPARE(comboBox.currentText(), list.at(1));
}
+void tst_QComboBox::updateDelegateOnEditableChange()
+{
+
+ QComboBox box;
+ box.addItem(QStringLiteral("Foo"));
+ box.addItem(QStringLiteral("Bar"));
+ box.setEditable(false);
+
+ QComboBoxPrivate *d = static_cast<QComboBoxPrivate *>(QComboBoxPrivate::get(&box));
+
+ {
+ bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ d->updateDelegate();
+ bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ QCOMPARE(menuDelegateAfter, menuDelegateBefore);
+ }
+
+ box.setEditable(true);
+
+ {
+ bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ d->updateDelegate();
+ bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ QCOMPARE(menuDelegateAfter, menuDelegateBefore);
+ }
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index ebda07ee0c..27c803b43d 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -137,6 +137,7 @@ private slots:
#endif
void addToolbarAfterShow();
void centralWidgetSize();
+ void fixedSizeCentralWidget();
void dockWidgetSize();
void QTBUG2774_stylechange();
void QTBUG15080_restoreState();
@@ -1737,6 +1738,50 @@ void tst_QMainWindow::centralWidgetSize()
QTRY_COMPARE(widget.size(), widget.sizeHint());
}
+void tst_QMainWindow::fixedSizeCentralWidget()
+{
+ // QTBUG-40410: dock widgets does not get all the available space when
+ // central widget is fixed size
+ QMainWindow mainWindow;
+ mainWindow.setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
+
+ MyWidget widget;
+ widget.setFixedSize(100,100);
+ mainWindow.setCentralWidget(&widget);
+
+ QDockWidget dock("D1");
+ QWidget *child = new MyWidget;
+ dock.setWidget(child);
+ mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock);
+
+ QDockWidget dock2("D2");
+ dock2.setWidget(new MyWidget);
+ mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &dock2);
+
+ QSize sizeH = mainWindow.sizeHint();
+ QSize mwSize = QSize(sizeH.width(), sizeH.height() * 2);
+ mainWindow.resize(mwSize);
+ mainWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
+ if (mainWindow.height() < mwSize.height())
+ QSKIP("The screen is too small for this test");
+
+ // first, check that we get more than the size hint when we have more space
+ QTRY_VERIFY(child->height() > child->sizeHint().height());
+ int childHeight = child->height();
+
+ if (qGuiApp->styleHints()->showIsFullScreen())
+ QSKIP("The platform is auto maximizing, so we cannot resize the window");
+
+ // then, check that we get nothing when there is no space
+ mainWindow.resize(100,100);
+ QTRY_COMPARE(child->height(), 0);
+
+ // finally verify that we get the space back when we resize to the old size
+ mainWindow.resize(mwSize);
+ QTRY_COMPARE(child->height(), childHeight);
+}
+
void tst_QMainWindow::dockWidgetSize()
{
QMainWindow mainWindow;