diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-09-10 11:41:29 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-09-10 11:42:50 +0200 |
commit | d572ab1bb446e880fcb8d27294ba8149550f1659 (patch) | |
tree | d29c449b551e47569c6d9f146ba9e86810c05353 /tests/auto | |
parent | 211cef46f6d9d8738c09f906f9c0c3080b445dc8 (diff) | |
parent | 71df09b6cca7cd7a673bf39f49d0dda28b78a860 (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Change-Id: Id4997327cc01bd4bb397a463bdffbd15e80398ef
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 13 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp | 10 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/qwindow.pro | 2 | ||||
-rw-r--r-- | tests/auto/network/ssl/qasn1element/tst_qasn1element.cpp | 68 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp | 66 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslkey/qsslkey.pro | 3 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslkey/rsa-with-passphrase-rc2.pem | 18 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp | 126 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 25 | ||||
-rw-r--r-- | tests/auto/other/other.pro | 3 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/accessiblewidgets.h | 167 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/qaccessibility.pro | 3 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 141 | ||||
-rw-r--r-- | tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 17 |
14 files changed, 588 insertions, 74 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 0389ae7976..076e3eee1c 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -45,6 +45,8 @@ #include <QPair> #include <QTextCodec> +#include <QSysInfo> +#include <QLatin1String> class tst_QGlobal: public QObject { @@ -65,6 +67,7 @@ private slots: void integerForSize(); void qprintable(); void qprintable_data(); + void buildAbiEndianness(); }; void tst_QGlobal::qIsNull() @@ -652,5 +655,15 @@ void tst_QGlobal::qprintable_data() } +void tst_QGlobal::buildAbiEndianness() +{ +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + QLatin1String endian("little_endian"); +#elif Q_BYTE_ORDER == Q_BIG_ENDIAN + QLatin1String endian("big_endian"); +#endif + QVERIFY(QSysInfo::buildAbi().contains(endian)); +} + QTEST_APPLESS_MAIN(tst_QGlobal) #include "tst_qglobal.moc" diff --git a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp b/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp index f2852f6a50..48e3745be4 100644 --- a/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp +++ b/tests/auto/corelib/tools/qelapsedtimer/tst_qelapsedtimer.cpp @@ -48,12 +48,7 @@ static const int minResolution = 50; // the minimum resolution for the tests QDebug operator<<(QDebug s, const QElapsedTimer &t) { - union { - QElapsedTimer t; - struct { qint64 t1, t2; } i; - } copy; - copy.t = t; - s.nospace() << "(" << copy.i.t1 << ", " << copy.i.t2 << ")"; + s.nospace() << "(" << t.msecsSinceReference() << ")"; return s.space(); } @@ -81,8 +76,7 @@ void tst_QElapsedTimer::validity() { QElapsedTimer t; - t.invalidate(); - QVERIFY(!t.isValid()); + QVERIFY(!t.isValid()); // non-POD now, it should always start invalid t.start(); QVERIFY(t.isValid()); diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro index e419a10440..5210585796 100644 --- a/tests/auto/gui/kernel/qwindow/qwindow.pro +++ b/tests/auto/gui/kernel/qwindow/qwindow.pro @@ -4,3 +4,5 @@ TARGET = tst_qwindow QT += core-private gui-private testlib SOURCES += tst_qwindow.cpp + +contains(QT_CONFIG,dynamicgl):win32:!wince*:!winrt: LIBS += -luser32 diff --git a/tests/auto/network/ssl/qasn1element/tst_qasn1element.cpp b/tests/auto/network/ssl/qasn1element/tst_qasn1element.cpp index 661d13bc69..92b603473b 100644 --- a/tests/auto/network/ssl/qasn1element/tst_qasn1element.cpp +++ b/tests/auto/network/ssl/qasn1element/tst_qasn1element.cpp @@ -49,6 +49,10 @@ class tst_QAsn1Element : public QObject private slots: void emptyConstructor(); + void equals_data(); + void equals(); + void toBool_data(); + void toBool(); void dateTime_data(); void dateTime(); void integer_data(); @@ -68,6 +72,62 @@ void tst_QAsn1Element::emptyConstructor() QCOMPARE(elem.value(), QByteArray()); } +Q_DECLARE_METATYPE(QAsn1Element) + +void tst_QAsn1Element::equals_data() +{ + QTest::addColumn<QAsn1Element>("a"); + QTest::addColumn<QAsn1Element>("b"); + QTest::addColumn<bool>("equals"); + + QTest::newRow("equal") + << QAsn1Element(QAsn1Element::BooleanType, QByteArray("\0", 1)) + << QAsn1Element(QAsn1Element::BooleanType, QByteArray("\0", 1)) + << true; + QTest::newRow("different type") + << QAsn1Element(QAsn1Element::BooleanType, QByteArray("\0", 1)) + << QAsn1Element(QAsn1Element::IntegerType, QByteArray("\0", 1)) + << false; + QTest::newRow("different value") + << QAsn1Element(QAsn1Element::BooleanType, QByteArray("\0", 1)) + << QAsn1Element(QAsn1Element::BooleanType, QByteArray("\xff", 1)) + << false; +} + +void tst_QAsn1Element::equals() +{ + QFETCH(QAsn1Element, a); + QFETCH(QAsn1Element, b); + QFETCH(bool, equals); + QCOMPARE(a == b, equals); + QCOMPARE(a != b, !equals); +} + +void tst_QAsn1Element::toBool_data() +{ + QTest::addColumn<QByteArray>("encoded"); + QTest::addColumn<bool>("value"); + QTest::addColumn<bool>("valid"); + + QTest::newRow("bad type") << QByteArray::fromHex("0201ff") << false << false; + QTest::newRow("bad value") << QByteArray::fromHex("010102") << false << false; + QTest::newRow("false") << QByteArray::fromHex("010100") << false << true; + QTest::newRow("true") << QByteArray::fromHex("0101ff") << true << true; +} + +void tst_QAsn1Element::toBool() +{ + QFETCH(QByteArray, encoded); + QFETCH(bool, value); + QFETCH(bool, valid); + + bool ok; + QAsn1Element elem; + QVERIFY(elem.read(encoded)); + QCOMPARE(elem.toBool(&ok), value); + QCOMPARE(ok, valid); +} + void tst_QAsn1Element::dateTime_data() { QTest::addColumn<QByteArray>("encoded"); @@ -122,6 +182,14 @@ void tst_QAsn1Element::integer() QFETCH(QByteArray, encoded); QFETCH(int, value); + // read + bool ok; + QAsn1Element elem; + QVERIFY(elem.read(encoded)); + QCOMPARE(elem.type(), quint8(QAsn1Element::IntegerType)); + QCOMPARE(elem.toInteger(&ok), value); + QVERIFY(ok); + // write QByteArray buffer; QDataStream stream(&buffer, QIODevice::WriteOnly); diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index cc90be00a2..229ce4abb5 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -111,6 +111,7 @@ private slots: void subjectAndIssuerAttributes(); void verify(); void extensions(); + void extensionsCritical(); void threadSafeConstMethods(); void version_data(); void version(); @@ -927,7 +928,7 @@ void tst_QSslCertificate::toText() QString txtcert = cert.toText(); -#ifdef Q_OS_WINRT +#ifdef QT_NO_OPENSSL QEXPECT_FAIL("", "QTBUG-40884: QSslCertificate::toText is not implemented on WinRT", Continue); #endif QVERIFY(QString::fromLatin1(txt098) == txtcert || @@ -975,7 +976,7 @@ void tst_QSslCertificate::verify() qPrintable(QString("errors: %1").arg(toString(errors))) \ ) -#ifdef Q_OS_WINRT +#ifdef QT_NO_OPENSSL QEXPECT_FAIL("", "QTBUG-40884: WinRT API does not yet support verifying a chain", Abort); #endif // Empty chain is unspecified error @@ -1059,9 +1060,6 @@ void tst_QSslCertificate::extensions() QSslCertificate cert = certList[0]; QList<QSslCertificateExtension> extensions = cert.extensions(); -#ifdef Q_OS_WINRT - QEXPECT_FAIL("", "QTBUG-40884: WinRT API does not support extensions information", Abort); -#endif QVERIFY(extensions.count() == 9); int unknown_idx = -1; @@ -1096,6 +1094,8 @@ void tst_QSslCertificate::extensions() QSslCertificateExtension unknown = extensions[unknown_idx]; QVERIFY(unknown.oid() == QStringLiteral("1.3.6.1.5.5.7.1.12")); QVERIFY(unknown.name() == QStringLiteral("1.3.6.1.5.5.7.1.12")); + QVERIFY(!unknown.isCritical()); + QVERIFY(!unknown.isSupported()); QByteArray unknownValue = QByteArray::fromHex( "3060A15EA05C305A305830561609696D6167652F6769663021301F300706052B0E03021A0414" \ @@ -1107,8 +1107,11 @@ void tst_QSslCertificate::extensions() QSslCertificateExtension aia = extensions[authority_info_idx]; QVERIFY(aia.oid() == QStringLiteral("1.3.6.1.5.5.7.1.1")); QVERIFY(aia.name() == QStringLiteral("authorityInfoAccess")); + QVERIFY(!aia.isCritical()); + QVERIFY(aia.isSupported()); QVariantMap aiaValue = aia.value().toMap(); + QCOMPARE(aiaValue.keys(), QList<QString>() << QStringLiteral("OCSP") << QStringLiteral("caIssuers")); QString ocsp = aiaValue[QStringLiteral("OCSP")].toString(); QString caIssuers = aiaValue[QStringLiteral("caIssuers")].toString(); @@ -1119,25 +1122,76 @@ void tst_QSslCertificate::extensions() QSslCertificateExtension basic = extensions[basic_constraints_idx]; QVERIFY(basic.oid() == QStringLiteral("2.5.29.19")); QVERIFY(basic.name() == QStringLiteral("basicConstraints")); + QVERIFY(!basic.isCritical()); + QVERIFY(basic.isSupported()); QVariantMap basicValue = basic.value().toMap(); + QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca")); QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false); // Subject key identifier QSslCertificateExtension subjectKey = extensions[subject_key_idx]; QVERIFY(subjectKey.oid() == QStringLiteral("2.5.29.14")); QVERIFY(subjectKey.name() == QStringLiteral("subjectKeyIdentifier")); + QVERIFY(!subjectKey.isCritical()); + QVERIFY(subjectKey.isSupported()); QVERIFY(subjectKey.value().toString() == QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0")); // Authority key identifier QSslCertificateExtension authKey = extensions[auth_key_idx]; QVERIFY(authKey.oid() == QStringLiteral("2.5.29.35")); QVERIFY(authKey.name() == QStringLiteral("authorityKeyIdentifier")); + QVERIFY(!authKey.isCritical()); + QVERIFY(authKey.isSupported()); QVariantMap authValue = authKey.value().toMap(); + QCOMPARE(authValue.keys(), QList<QString>() << QStringLiteral("keyid")); QVERIFY(authValue[QStringLiteral("keyid")].toByteArray() == QByteArray("4e43c81d76ef37537a4ff2586f94f338e2d5bddf")); +} + +void tst_QSslCertificate::extensionsCritical() +{ + QList<QSslCertificate> certList = + QSslCertificate::fromPath(testDataDir + "/verify-certs/test-addons-mozilla-org-cert.pem"); + QVERIFY2(certList.count() > 0, "Please run this test from the source directory"); + + QSslCertificate cert = certList[0]; + QList<QSslCertificateExtension> extensions = cert.extensions(); + QVERIFY(extensions.count() == 9); + + int basic_constraints_idx = -1; + int key_usage_idx = -1; + + for (int i=0; i < extensions.length(); ++i) { + QSslCertificateExtension ext = extensions[i]; + + if (ext.name() == QStringLiteral("basicConstraints")) + basic_constraints_idx = i; + if (ext.name() == QStringLiteral("keyUsage")) + key_usage_idx = i; + } + + QVERIFY(basic_constraints_idx != -1); + QVERIFY(key_usage_idx != -1); + + // Basic constraints + QSslCertificateExtension basic = extensions[basic_constraints_idx]; + QVERIFY(basic.oid() == QStringLiteral("2.5.29.19")); + QVERIFY(basic.name() == QStringLiteral("basicConstraints")); + QVERIFY(basic.isCritical()); + QVERIFY(basic.isSupported()); + + QVariantMap basicValue = basic.value().toMap(); + QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca")); + QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false); + // Key Usage + QSslCertificateExtension keyUsage = extensions[key_usage_idx]; + QVERIFY(keyUsage.oid() == QStringLiteral("2.5.29.15")); + QVERIFY(keyUsage.name() == QStringLiteral("keyUsage")); + QVERIFY(keyUsage.isCritical()); + QVERIFY(!keyUsage.isSupported()); } class TestThread : public QThread @@ -1254,7 +1308,7 @@ void tst_QSslCertificate::pkcs12() QSslCertificate cert; QList<QSslCertificate> caCerts; -#ifdef Q_OS_WINRT +#ifdef QT_NO_OPENSSL QEXPECT_FAIL("", "QTBUG-40884: WinRT API does not support pkcs12 imports", Abort); #endif ok = QSslCertificate::importPKCS12(&f, &key, &cert, &caCerts); diff --git a/tests/auto/network/ssl/qsslkey/qsslkey.pro b/tests/auto/network/ssl/qsslkey/qsslkey.pro index 78cfb9ce92..4ec4f27e6f 100644 --- a/tests/auto/network/ssl/qsslkey/qsslkey.pro +++ b/tests/auto/network/ssl/qsslkey/qsslkey.pro @@ -4,6 +4,9 @@ CONFIG += parallel_test SOURCES += tst_qsslkey.cpp !wince*:win32:LIBS += -lws2_32 QT = core network testlib +contains(QT_CONFIG, private_tests) { + QT += core-private network-private +} TARGET = tst_qsslkey diff --git a/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-rc2.pem b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-rc2.pem new file mode 100644 index 0000000000..7a0722fb8d --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/rsa-with-passphrase-rc2.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: RC2-CBC,EAAF396E2CDD3680 + +G+kY27Vq0Bkw6dEGlpe4oyyXlilyKJgkX53NQHv0WtLsu+cfamGst9viSQbAluP0 +Pk2m78Z05IZHBkxcl20tZZR3G3hFTVqf7OemEucT5Kb/Vx6V++ZXY5eI54bh1oEJ +f8klr2DnscyTYdT33cmMuaxUm1sWjHeBBdQuQlMnW11XoCiGQMgMyf2fwbzd/og+ +vDPtORIMw+zedxaTsiOyNASLWB5ILDpUR9PTzz1tRIIOF5DnKttEe3SYPIqkLhxu +N7OtpVhor0QUulph8sS2uiilTVyaYVciOJK7Cqq2K015l9nlqGg/KI0GRIC9ty+k +wd+/Hdazp+YcLn3tL8jhekST/DAxK9VIb0DBvaboKr8UJw35nLOwA7smsij50l2S +kfpu9z/80gFbnSSQo7L8zD/kBzaPlup0H+h96rF3IjdCrnbveHlvJDo3GcPNxauw +rGUQXnnMzDVSTY179HfcgLZdsm3uOIBicEFaxXu2/L4Eof9yp8D/b6SeZeS41O7a +ICvLXxkiIfQHukHvqMLJ2SqKQ0J8zEXN0OBSLjaHUkBIOs3L4IFe2v8DMN798GrG +QzcxC0bmr9s6TvihlYFBbYkMZ3IYPT4SFZg92/pKTPlyD/Blc9oZm8QpQMGIMDKc +nWDLeqeCTXV6TL1mymqzwyzs9+4cXvEiM167FsLqk5tGRIyl4AR/dItELEtCWl3I +koIOUEk5rbJekOhTc85SFSQmCV0IebsUv0CpdWlmNeexNryLZu0r6kTUFWzpHcv/ +0yEaBQFLVx9QAfRSIiNt+yAgGnpMxxMxeHs6shVmuscZ0fV50GpOpA== +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index 642b115bee..1c16f47ad6 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -47,6 +47,11 @@ #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qnetworkproxy.h> +#if !defined(QT_NO_SSL) && defined(QT_NO_OPENSSL) && defined(QT_BUILD_INTERNAL) +#include "private/qsslkey_p.h" +#define TEST_CRYPTO +#endif + class tst_QSslKey : public QObject { Q_OBJECT @@ -90,6 +95,11 @@ private slots: void passphraseChecks_data(); void passphraseChecks(); void noPassphraseChecks(); +#ifdef TEST_CRYPTO + void encrypt_data(); + void encrypt(); +#endif + #endif private: QString testDataDir; @@ -306,9 +316,6 @@ void tst_QSslKey::toEncryptedPemOrDer() QByteArray pwBytes(password.toLatin1()); if (type == QSsl::PrivateKey) { -#ifdef QT_NO_OPENSSL - QSKIP("Encrypted keys require support from the SSL backend"); -#endif QByteArray encryptedPem = key.toPem(pwBytes); QVERIFY(!encryptedPem.isEmpty()); QSslKey keyPem(encryptedPem, algorithm, QSsl::Pem, type, pwBytes); @@ -347,6 +354,7 @@ void tst_QSslKey::passphraseChecks_data() QTest::newRow("DES") << QString(testDataDir + "/rsa-with-passphrase-des.pem"); QTest::newRow("3DES") << QString(testDataDir + "/rsa-with-passphrase-3des.pem"); + QTest::newRow("RC2") << QString(testDataDir + "/rsa-with-passphrase-rc2.pem"); } void tst_QSslKey::passphraseChecks() @@ -379,9 +387,6 @@ void tst_QSslKey::passphraseChecks() QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "WRONG!"); QVERIFY(key.isNull()); // wrong passphrase => should not be able to decode key } -#ifdef QT_NO_OPENSSL - QEXPECT_FAIL("", "Encrypted keys require support from the SSL backend", Abort); -#endif { if (!keyFile.isOpen()) keyFile.open(QIODevice::ReadOnly); @@ -413,9 +418,6 @@ void tst_QSslKey::noPassphraseChecks() QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, ""); QVERIFY(!key.isNull()); // empty passphrase => should be able to decode key } -#ifdef QT_NO_OPENSSL - QEXPECT_FAIL("", "Encrypted keys require support from the SSL backend", Abort); -#endif { if (!keyFile.isOpen()) keyFile.open(QIODevice::ReadOnly); @@ -426,6 +428,112 @@ void tst_QSslKey::noPassphraseChecks() } } +#ifdef TEST_CRYPTO +Q_DECLARE_METATYPE(QSslKeyPrivate::Cipher) + +void tst_QSslKey::encrypt_data() +{ + QTest::addColumn<QSslKeyPrivate::Cipher>("cipher"); + QTest::addColumn<QByteArray>("key"); + QTest::addColumn<QByteArray>("plainText"); + QTest::addColumn<QByteArray>("cipherText"); + + QTest::newRow("DES-CBC, length 0") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray() + << QByteArray::fromHex("956585228BAF9B1F"); + QTest::newRow("DES-CBC, length 1") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(1, 'a') + << QByteArray::fromHex("E6880AF202BA3C12"); + QTest::newRow("DES-CBC, length 2") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(2, 'a') + << QByteArray::fromHex("A82492386EED6026"); + QTest::newRow("DES-CBC, length 3") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(3, 'a') + << QByteArray::fromHex("90B76D5B79519CBA"); + QTest::newRow("DES-CBC, length 4") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(4, 'a') + << QByteArray::fromHex("63E3DD6FED87052A"); + QTest::newRow("DES-CBC, length 5") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(5, 'a') + << QByteArray::fromHex("03ACDB0EACBDFA94"); + QTest::newRow("DES-CBC, length 6") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(6, 'a') + << QByteArray::fromHex("7D95024E42A3A88A"); + QTest::newRow("DES-CBC, length 7") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(7, 'a') + << QByteArray::fromHex("5003436B8A8E42E9"); + QTest::newRow("DES-CBC, length 8") + << QSslKeyPrivate::DesCbc << QByteArray("01234567") + << QByteArray(8, 'a') + << QByteArray::fromHex("E4C1F054BF5521C0A4A0FD4A2BC6C1B1"); + + QTest::newRow("DES-EDE3-CBC, length 0") + << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray() + << QByteArray::fromHex("3B2B4CD0B0FD495F"); + QTest::newRow("DES-EDE3-CBC, length 8") + << QSslKeyPrivate::DesEde3Cbc << QByteArray("0123456789abcdefghijklmn") + << QByteArray(8, 'a') + << QByteArray::fromHex("F2A5A87763C54A72A3224103D90CDB03"); + + QTest::newRow("RC2-40-CBC, length 0") + << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") + << QByteArray() + << QByteArray::fromHex("6D05D52392FF6E7A"); + QTest::newRow("RC2-40-CBC, length 8") + << QSslKeyPrivate::Rc2Cbc << QByteArray("01234") + << QByteArray(8, 'a') + << QByteArray::fromHex("75768E64C5749072A5D168F3AFEB0005"); + + QTest::newRow("RC2-64-CBC, length 0") + << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") + << QByteArray() + << QByteArray::fromHex("ADAE6BF70F420130"); + QTest::newRow("RC2-64-CBC, length 8") + << QSslKeyPrivate::Rc2Cbc << QByteArray("01234567") + << QByteArray(8, 'a') + << QByteArray::fromHex("C7BF5C80AFBE9FBEFBBB9FD935F6D0DF"); + + QTest::newRow("RC2-128-CBC, length 0") + << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") + << QByteArray() + << QByteArray::fromHex("1E965D483A13C8FB"); + QTest::newRow("RC2-128-CBC, length 8") + << QSslKeyPrivate::Rc2Cbc << QByteArray("012345679abcdefg") + << QByteArray(8, 'a') + << QByteArray::fromHex("5AEC1A5B295660B02613454232F7DECE"); +} + +void tst_QSslKey::encrypt() +{ + QFETCH(QSslKeyPrivate::Cipher, cipher); + QFETCH(QByteArray, key); + QFETCH(QByteArray, plainText); + QFETCH(QByteArray, cipherText); + QByteArray iv("abcdefgh"); + +#ifdef Q_OS_WINRT + QEXPECT_FAIL("RC2-40-CBC, length 0", "WinRT treats RC2 as 128-bit", Abort); + QEXPECT_FAIL("RC2-40-CBC, length 8", "WinRT treats RC2 as 128-bit", Abort); + QEXPECT_FAIL("RC2-64-CBC, length 0", "WinRT treats RC2 as 128-bit", Abort); + QEXPECT_FAIL("RC2-64-CBC, length 8", "WinRT treats RC2 as 128-bit", Abort); +#endif + QByteArray encrypted = QSslKeyPrivate::encrypt(cipher, plainText, key, iv); + QCOMPARE(encrypted, cipherText); + + QByteArray decrypted = QSslKeyPrivate::decrypt(cipher, cipherText, key, iv); + QCOMPARE(decrypted, plainText); +} +#endif + #endif QTEST_MAIN(tst_QSslKey) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 33cee37b92..295b60e739 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -138,7 +138,9 @@ private slots: void peerCertificate(); void peerCertificateChain(); void privateKey(); +#ifndef QT_NO_OPENSSL void privateKeyOpaque(); +#endif void protocol(); void protocolServerSide_data(); void protocolServerSide(); @@ -186,7 +188,9 @@ private slots: void writeBigChunk(); void blacklistedCertificates(); void versionAccessors(); +#ifndef QT_NO_OPENSSL void sslOptions(); +#endif void encryptWithoutConnecting(); void resume_data(); void resume(); @@ -810,6 +814,7 @@ void tst_QSslSocket::privateKey() { } +#ifndef QT_NO_OPENSSL void tst_QSslSocket::privateKeyOpaque() { if (!QSslSocket::supportsSsl()) @@ -839,6 +844,7 @@ void tst_QSslSocket::privateKeyOpaque() if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); } +#endif void tst_QSslSocket::protocol() { @@ -1992,10 +1998,23 @@ void tst_QSslSocket::peerVerifyError() socket->connectToHostEncrypted(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 443); if (socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); + + // check HostNameMismatch was emitted by peerVerifyError QVERIFY(!peerVerifyErrorSpy.isEmpty()); + SslErrorList peerErrors; + const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy; + foreach (const QVariantList &args, peerVerifyList) + peerErrors << qvariant_cast<QSslError>(args.first()).error(); + QVERIFY(peerErrors.contains(QSslError::HostNameMismatch)); + + // check HostNameMismatch was emitted by sslErrors QVERIFY(!sslErrorsSpy.isEmpty()); - QCOMPARE(qvariant_cast<QSslError>(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch); - QCOMPARE(qvariant_cast<QList<QSslError> >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size()); + SslErrorList sslErrors; + foreach (const QSslError &err, qvariant_cast<QList<QSslError> >(sslErrorsSpy.first().first())) + sslErrors << err.error(); + QVERIFY(peerErrors.contains(QSslError::HostNameMismatch)); + + QCOMPARE(sslErrors.size(), peerErrors.size()); } void tst_QSslSocket::disconnectFromHostWhenConnecting() @@ -2280,6 +2299,7 @@ void tst_QSslSocket::versionAccessors() qDebug() << QString::number(QSslSocket::sslLibraryVersionNumber(), 16); } +#ifndef QT_NO_OPENSSL void tst_QSslSocket::sslOptions() { if (!QSslSocket::supportsSsl()) @@ -2331,6 +2351,7 @@ void tst_QSslSocket::sslOptions() #endif #endif } +#endif void tst_QSslSocket::encryptWithoutConnecting() { diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 745c8f2499..bd3997f8c9 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -3,7 +3,6 @@ SUBDIRS=\ # atwrapper \ # QTBUG-19452 baselineexample \ compiler \ - d3dcompiler \ gestures \ headersclean \ lancelot \ @@ -58,8 +57,6 @@ cross_compile: SUBDIRS -= \ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility -!angle_d3d11: SUBDIRS -= d3dcompiler - !contains(QT_CONFIG, accessibility-atspi-bridge): SUBDIRS -= qaccessibilitylinux !mac: SUBDIRS -= \ diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h new file mode 100644 index 0000000000..c15cd43f85 --- /dev/null +++ b/tests/auto/other/qaccessibility/accessiblewidgets.h @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ + + +#ifndef ACCESSIBLEWIDGETS_H +#define ACCESSIBLEWIDGETS_H + +#include <QtWidgets/qaccessiblewidget.h> +#include <QtWidgets/qpushbutton.h> + +class QtTestAccessibleWidget: public QWidget +{ + Q_OBJECT +public: + QtTestAccessibleWidget(QWidget *parent, const char *name): QWidget(parent) + { + setObjectName(name); + } +}; + +class QtTestAccessibleWidgetIface: public QAccessibleWidget +{ +public: + QtTestAccessibleWidgetIface(QtTestAccessibleWidget *w): QAccessibleWidget(w) {} + QString text(QAccessible::Text t) const Q_DECL_OVERRIDE + { + if (t == QAccessible::Help) + return QString::fromLatin1("Help yourself"); + return QAccessibleWidget::text(t); + } + static QAccessibleInterface *ifaceFactory(const QString &key, QObject *o) + { + if (key == "QtTestAccessibleWidget") + return new QtTestAccessibleWidgetIface(static_cast<QtTestAccessibleWidget*>(o)); + return 0; + } +}; + +class QtTestAccessibleWidgetSubclass: public QtTestAccessibleWidget +{ + Q_OBJECT +public: + QtTestAccessibleWidgetSubclass(QWidget *parent, const char *name): QtTestAccessibleWidget(parent, name) + {} +}; + + +class KFooButton: public QPushButton +{ + Q_OBJECT +public: + KFooButton(const QString &text, QWidget* parent = 0) + : QPushButton(text, parent) + {} +}; + + +class CustomTextWidget : public QWidget +{ + Q_OBJECT +public: + int cursorPosition; + QString text; +}; + +class CustomTextWidgetIface: public QAccessibleWidget, public QAccessibleTextInterface +{ +public: + static QAccessibleInterface *ifaceFactory(const QString &key, QObject *o) + { + if (key == "CustomTextWidget") + return new CustomTextWidgetIface(static_cast<CustomTextWidget*>(o)); + return 0; + } + CustomTextWidgetIface(CustomTextWidget *w): QAccessibleWidget(w) {} + void *interface_cast(QAccessible::InterfaceType t) { + if (t == QAccessible::TextInterface) + return static_cast<QAccessibleTextInterface*>(this); + return 0; + } + + // this is mostly to test the base implementation for textBefore/At/After + QString text(QAccessible::Text t) const Q_DECL_OVERRIDE + { + if (t == QAccessible::Value) + return textWidget()->text; + return QAccessibleWidget::text(t); + } + + QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const + { + if (offset == -2) + offset = textWidget()->cursorPosition; + return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset); + } + QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const + { + if (offset == -2) + offset = textWidget()->cursorPosition; + return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset); + } + QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, int *startOffset, int *endOffset) const + { + if (offset == -2) + offset = textWidget()->cursorPosition; + return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset); + } + + void selection(int, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE + { *startOffset = *endOffset = -1; } + int selectionCount() const Q_DECL_OVERRIDE { return 0; } + void addSelection(int, int) Q_DECL_OVERRIDE {} + void removeSelection(int) Q_DECL_OVERRIDE {} + void setSelection(int, int, int) Q_DECL_OVERRIDE {} + int cursorPosition() const Q_DECL_OVERRIDE { return textWidget()->cursorPosition; } + void setCursorPosition(int position) Q_DECL_OVERRIDE { textWidget()->cursorPosition = position; } + QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE { return textWidget()->text.mid(startOffset, endOffset); } + int characterCount() const Q_DECL_OVERRIDE { return textWidget()->text.length(); } + QRect characterRect(int) const Q_DECL_OVERRIDE { return QRect(); } + int offsetAtPoint(const QPoint &) const Q_DECL_OVERRIDE { return 0; } + void scrollToSubstring(int, int) Q_DECL_OVERRIDE {} + QString attributes(int, int *, int *) const Q_DECL_OVERRIDE + { return QString(); } + +private: + CustomTextWidget *textWidget() const { return qobject_cast<CustomTextWidget *>(widget()); } +}; + +#endif // ACCESSIBLEWIDGETS_H diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index e6c5bb1149..8d445437df 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -2,7 +2,8 @@ CONFIG += testcase TARGET = tst_qaccessibility requires(contains(QT_CONFIG,accessibility)) QT += testlib core-private gui-private widgets-private -SOURCES += tst_qaccessibility.cpp +SOURCES += tst_qaccessibility.cpp +HEADERS += accessiblewidgets.h unix:!mac:LIBS+=-lm diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index d3c9aa87ef..68723e9c2f 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -69,6 +69,8 @@ #include <algorithm> +#include "accessiblewidgets.h" + // Make a widget frameless to prevent size constraints of title bars // from interfering (Windows). static inline void setFrameless(QWidget *w) @@ -260,6 +262,8 @@ private slots: void lineEditTest(); void lineEditTextFunctions_data(); void lineEditTextFunctions(); + void textInterfaceTest_data(); + void textInterfaceTest(); void groupBoxTest(); void dialogButtonBoxTest(); void dialTest(); @@ -389,43 +393,6 @@ void tst_QAccessibility::eventTest() QTestAccessibility::clearEvents(); } - -class QtTestAccessibleWidget: public QWidget -{ - Q_OBJECT -public: - QtTestAccessibleWidget(QWidget *parent, const char *name): QWidget(parent) - { - setObjectName(name); - } -}; - -class QtTestAccessibleWidgetIface: public QAccessibleWidget -{ -public: - QtTestAccessibleWidgetIface(QtTestAccessibleWidget *w): QAccessibleWidget(w) {} - QString text(QAccessible::Text t) const - { - if (t == QAccessible::Help) - return QString::fromLatin1("Help yourself"); - return QAccessibleWidget::text(t); - } - static QAccessibleInterface *ifaceFactory(const QString &key, QObject *o) - { - if (key == "QtTestAccessibleWidget") - return new QtTestAccessibleWidgetIface(static_cast<QtTestAccessibleWidget*>(o)); - return 0; - } -}; - -class QtTestAccessibleWidgetSubclass: public QtTestAccessibleWidget -{ - Q_OBJECT -public: - QtTestAccessibleWidgetSubclass(QWidget *parent, const char *name): QtTestAccessibleWidget(parent, name) - {} -}; - void tst_QAccessibility::customWidget() { { @@ -485,14 +452,6 @@ void tst_QAccessibility::deletedWidget() // fixme: QVERIFY(!iface->isValid()); } -class KFooButton: public QPushButton -{ - Q_OBJECT -public: - KFooButton(const QString &text, QWidget* parent = 0) : QPushButton(text, parent) - {} -}; - void tst_QAccessibility::subclassedWidget() { KFooButton button("Ploink", 0); @@ -2375,6 +2334,98 @@ void tst_QAccessibility::lineEditTextFunctions() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::textInterfaceTest_data() +{ + lineEditTextFunctions_data(); + QString hello = QStringLiteral("hello\nworld\nend"); + QTest::newRow("multi line at 0") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 0 << 0 << 6 << "hello\n"; + QTest::newRow("multi line at 1") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 1 << 0 << 6 << "hello\n"; + QTest::newRow("multi line at 2") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 2 << 0 << 6 << "hello\n"; + QTest::newRow("multi line at 5") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 5 << 0 << 6 << "hello\n"; + QTest::newRow("multi line at 6") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 6 << 6 << 12 << "world\n"; + QTest::newRow("multi line at 7") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 7 << 6 << 12 << "world\n"; + QTest::newRow("multi line at 8") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 8 << 6 << 12 << "world\n"; + QTest::newRow("multi line at 10") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 10 << 6 << 12 << "world\n"; + QTest::newRow("multi line at 11") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 11 << 6 << 12 << "world\n"; + QTest::newRow("multi line at 12") << hello << 1 << (int) QAccessible::LineBoundary << 0 << 12 << 12 << 15 << "end"; + + QTest::newRow("multi line before 0") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 0 << -1 << -1 << ""; + QTest::newRow("multi line before 1") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 1 << -1 << -1 << ""; + QTest::newRow("multi line before 2") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 2 << -1 << -1 << ""; + QTest::newRow("multi line before 5") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 5 << -1 << -1 << ""; + QTest::newRow("multi line before 6") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 6 << 0 << 6 << "hello\n"; + QTest::newRow("multi line before 7") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 7 << 0 << 6 << "hello\n"; + QTest::newRow("multi line before 8") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 8 << 0 << 6 << "hello\n"; + QTest::newRow("multi line before 10") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 10 << 0 << 6 << "hello\n"; + QTest::newRow("multi line before 11") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 11 << 0 << 6 << "hello\n"; + QTest::newRow("multi line before 12") << hello << 0 << (int) QAccessible::LineBoundary << 0 << 12 << 6 << 12 << "world\n"; + + QTest::newRow("multi line after 0") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 0 << 6 << 12 << "world\n"; + QTest::newRow("multi line after 1") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 1 << 6 << 12 << "world\n"; + QTest::newRow("multi line after 2") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 2 << 6 << 12 << "world\n"; + QTest::newRow("multi line after 5") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 5 << 6 << 12 << "world\n"; + QTest::newRow("multi line after 6") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 6 << 12 << 15 << "end"; + QTest::newRow("multi line after 7") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 7 << 12 << 15 << "end"; + QTest::newRow("multi line after 8") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 8 << 12 << 15 << "end"; + QTest::newRow("multi line after 10") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 10 << 12 << 15 << "end"; + QTest::newRow("multi line after 11") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 11 << 12 << 15 << "end"; + QTest::newRow("multi line after 12") << hello << 2 << (int) QAccessible::LineBoundary << 0 << 12 << -1 << -1 << ""; + + QTest::newRow("before 4 \\nFoo\\n") << QStringLiteral("\nFoo\n") << 0 << (int) QAccessible::LineBoundary << 0 << 4 << 0 << 1 << "\n"; + QTest::newRow("at 4 \\nFoo\\n") << QStringLiteral("\nFoo\n") << 1 << (int) QAccessible::LineBoundary << 0 << 4 << 1 << 5 << "Foo\n"; + QTest::newRow("after 4 \\nFoo\\n") << QStringLiteral("\nFoo\n") << 2 << (int) QAccessible::LineBoundary << 0 << 4 << 5 << 5 << ""; + QTest::newRow("before 4 Foo\\nBar\\n") << QStringLiteral("Foo\nBar\n") << 0 << (int) QAccessible::LineBoundary << 0 << 7 << 0 << 4 << "Foo\n"; + QTest::newRow("at 4 Foo\\nBar\\n") << QStringLiteral("Foo\nBar\n") << 1 << (int) QAccessible::LineBoundary << 0 << 7 << 4 << 8 << "Bar\n"; + QTest::newRow("after 4 Foo\\nBar\\n") << QStringLiteral("Foo\nBar\n") << 2 << (int) QAccessible::LineBoundary << 0 << 7 << 8 << 8 << ""; + QTest::newRow("at 0 Foo\\n") << QStringLiteral("Foo\n") << 1 << (int) QAccessible::LineBoundary << 0 << 0 << 0 << 4 << "Foo\n"; +} + +void tst_QAccessibility::textInterfaceTest() +{ + QFETCH(QString, text); + QFETCH(int, textFunction); + QFETCH(int, boundaryType); + QFETCH(int, cursorPosition); + QFETCH(int, offset); + QFETCH(int, expectedStart); + QFETCH(int, expectedEnd); + QFETCH(QString, expectedText); + + QAccessible::installFactory(CustomTextWidgetIface::ifaceFactory); + CustomTextWidget *w = new CustomTextWidget(); + w->text = text; + w->cursorPosition = cursorPosition; + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(w); + QVERIFY(iface); + QCOMPARE(iface->text(QAccessible::Value), text); + QAccessibleTextInterface *textIface = iface->textInterface(); + QVERIFY(textIface); + + int start = -33; + int end = -33; + QString result; + switch (textFunction) { + case 0: + result = textIface->textBeforeOffset(offset, (QAccessible::TextBoundaryType) boundaryType, &start, &end); + break; + case 1: + result = textIface->textAtOffset(offset, (QAccessible::TextBoundaryType) boundaryType, &start, &end); + break; + case 2: + result = textIface->textAfterOffset(offset, (QAccessible::TextBoundaryType) boundaryType, &start, &end); + break; + } + + QCOMPARE(result, expectedText); + QCOMPARE(start, expectedStart); + QCOMPARE(end, expectedEnd); + + delete w; + QAccessible::removeFactory(CustomTextWidgetIface::ifaceFactory); + QTestAccessibility::clearEvents(); +} + void tst_QAccessibility::groupBoxTest() { { diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index c89b05616d..8847a5748f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -461,6 +461,7 @@ private slots: void touchEventPropagation_data(); void touchEventPropagation(); void deviceCoordinateCache_simpleRotations(); + void resolvePaletteForItemChildren(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -11695,5 +11696,21 @@ void tst_QGraphicsItem::QTBUG_21618_untransformable_sceneTransform() QCOMPARE(item2_bottomright->deviceTransform(tx).map(QPointF()), QPointF(100, 300)); } +void tst_QGraphicsItem::resolvePaletteForItemChildren() +{ + QGraphicsScene scene; + QGraphicsRectItem item(0, 0, 50, -150); + scene.addItem(&item); + QGraphicsWidget widget; + widget.setParentItem(&item); + + QColor green(Qt::green); + QPalette paletteForScene = scene.palette(); + paletteForScene.setColor(QPalette::Active, QPalette::Window, green); + scene.setPalette(paletteForScene); + + QCOMPARE(widget.palette().color(QPalette::Active, QPalette::Window), green); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |