diff options
Diffstat (limited to 'tests')
22 files changed, 614 insertions, 131 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index cca4655f58..42dca7fc66 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1193,6 +1193,13 @@ void tst_QFile::permissions() if (qt_ntfs_permission_lookup) QEXPECT_FAIL("readonly", "QTBUG-25630", Abort); #endif +#ifdef Q_OS_UNIX + if (strcmp(QTest::currentDataTag(), "readonly") == 0) { + // in case accidentally run as root + if (::getuid() == 0) + QSKIP("Running this test as root doesn't make sense"); + } +#endif QCOMPARE((memberResult == QFile::Permissions(perms)), expected); QCOMPARE((staticResult == QFile::Permissions(perms)), expected); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 898aefffd3..2a79a6963e 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1937,6 +1937,21 @@ void tst_QUrl::strictParser_data() QTest::newRow("invalid-ipvfuture-3") << "http://[v789]" << "Invalid IPvFuture address"; QTest::newRow("unbalanced-brackets") << "http://[ff02::1" << "Expected ']' to match '[' in hostname"; + // invalid IDN hostnames happen in TolerantMode too + QTest::newRow("idn-prohibited-char-space") << "http:// " << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-nbsp") << "http://\xc2\xa0" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-1f") << "http://\x1f" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-7f") << "http://\x7f" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-80") << "http://\xc2\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-bmp") << "http://\xee\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-plane15") << "http://\xf3\xb0\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-plane16") << "http://\xf4\x80\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-ffff") << "http://\xef\xbf\xbf" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-1") << "http://" + QString(QChar(0xD800)) << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-2") << "http://" + QString(QChar(0xDC00)) << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-3") << "http://" + QString(QChar(0xD800)) + "a" << "Invalid hostname (contains invalid characters)"; + // FIXME: add some tests for prohibited BiDi (RFC 3454 section 6) + // port errors happen in TolerantMode too QTest::newRow("empty-port-1") << "http://example.com:" << "Port field was empty"; QTest::newRow("empty-port-2") << "http://example.com:/" << "Port field was empty"; diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index fa3dec620a..2014045171 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -351,7 +351,7 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Non-ASCII multibyte space character U+1680") - << QString::fromUtf8("\xE1\x9A\x80") + << QString::fromUtf8("x\xE1\x9A\x80x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -375,13 +375,18 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString::fromUtf8("\x10\x7F") << QString() << 0 << 0; + QTest::newRow("Non-ASCII 8bit control character U+0080") + << QString::fromUtf8("x\xC2\x80x") + << QString() + << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; + QTest::newRow("Non-ASCII 8bit control character U+0085") - << QString::fromUtf8("\xC2\x85") + << QString::fromUtf8("x\xC2\x85x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-ASCII multibyte control character U+180E") - << QString::fromUtf8("\xE1\xA0\x8E") + << QString::fromUtf8("x\xE1\xA0\x8Ex") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -391,47 +396,47 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Non-ASCII control character U+1D175") - << QString::fromUtf8("\xF0\x9D\x85\xB5") + << QString::fromUtf8("x\xF0\x9D\x85\xB5x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 0 private use character U+F123") - << QString::fromUtf8("\xEF\x84\xA3") + << QString::fromUtf8("x\xEF\x84\xA3x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 15 private use character U+F1234") - << QString::fromUtf8("\xF3\xB1\x88\xB4") + << QString::fromUtf8("x\xF3\xB1\x88\xB4x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 16 private use character U+10F234") - << QString::fromUtf8("\xF4\x8F\x88\xB4") + << QString::fromUtf8("x\xF4\x8F\x88\xB4x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-character code point U+8FFFE") - << QString::fromUtf8("\xF2\x8F\xBF\xBE") + << QString::fromUtf8("x\xF2\x8F\xBF\xBEx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-character code point U+10FFFF") - << QString::fromUtf8("\xF4\x8F\xBF\xBF") + << QString::fromUtf8("x\xF4\x8F\xBF\xBFx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Surrogate code U+DF42") - << QString::fromUtf8("\xED\xBD\x82") + << QString::fromUtf8("x\xED\xBD\x82x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-plain text character U+FFFD") - << QString::fromUtf8("\xEF\xBF\xBD") + << QString::fromUtf8("x\xEF\xBF\xBDx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Ideographic description character U+2FF5") - << QString::fromUtf8("\xE2\xBF\xB5") + << QString::fromUtf8("x\xE2\xBF\xB5x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -441,22 +446,22 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Left-to-right mark U+200E") - << QString::fromUtf8("\xE2\x80\x8E") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xE2\x80\x8Ex") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Deprecated U+202A") - << QString::fromUtf8("\xE2\x80\xAA") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xE2\x80\xAA") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Language tagging character U+E0001") - << QString::fromUtf8("\xF3\xA0\x80\x81") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xF3\xA0\x80\x81x") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Language tagging character U+E0042") - << QString::fromUtf8("\xF3\xA0\x81\x82") + << QString::fromUtf8("x\xF3\xA0\x81\x82x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -512,12 +517,6 @@ void tst_QUrlInternal::nameprep_testsuite() QFETCH(QString, out); QFETCH(QString, profile); - QEXPECT_FAIL("Left-to-right mark U+200E", - "Investigate further", Continue); - QEXPECT_FAIL("Deprecated U+202A", - "Investigate further", Continue); - QEXPECT_FAIL("Language tagging character U+E0001", - "Investigate further", Continue); qt_nameprep(&in, 0); QCOMPARE(in, out); } @@ -549,9 +548,9 @@ void tst_QUrlInternal::nameprep_highcodes_data() << QString() << 0 << 0; } { - QChar st[] = { 'D', 0xdb40, 0xdc20, 'o', 0xd834, 0xdd7a, '\'', 0x2060, 'h' }; + QChar st[] = { 'D', 'o', '\'', 0x2060, 'h' }; QChar se[] = { 'd', 'o', '\'', 'h' }; - QTest::newRow("highcodes (D, U+E0020, o, U+1D17A, ', U+2060, h)") + QTest::newRow("highcodes (D, o, ', U+2060, h)") << QString(st, sizeof(st)/sizeof(st[0])) << QString(se, sizeof(se)/sizeof(se[0])) << QString() << 0 << 0; diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index c19a42e4a6..6f5cda5307 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -252,18 +252,18 @@ void tst_QtJson::testNumbers() 0, -1, 1, - (1UL<<54), - (1UL<<55), - (1UL<<56), - -(1UL<<54), - -(1UL<<55), - -(1UL<<56), - (1UL<<54) - 1, - (1UL<<55) - 1, - (1UL<<56) - 1, - -((1UL<<54) - 1), - -((1UL<<55) - 1), - -((1UL<<56) - 1) + (1ll<<54), + (1ll<<55), + (1ll<<56), + -(1ll<<54), + -(1ll<<55), + -(1ll<<56), + (1ll<<54) - 1, + (1ll<<55) - 1, + (1ll<<56) - 1, + -((1ll<<54) - 1), + -((1ll<<55) - 1), + -((1ll<<56) - 1) }; int n = sizeof(numbers)/sizeof(qint64); @@ -289,18 +289,18 @@ void tst_QtJson::testNumbers() 0, -1, 1, - (1UL<<54), - (1UL<<55), - (1UL<<56), - -(1UL<<54), - -(1UL<<55), - -(1UL<<56), - (1UL<<54) - 1, - (1UL<<55) - 1, - (1UL<<56) - 1, - -((1UL<<54) - 1), - -((1UL<<55) - 1), - -((1UL<<56) - 1), + double(1ll<<54), + double(1ll<<55), + double(1ll<<56), + double(-(1ll<<54)), + double(-(1ll<<55)), + double(-(1ll<<56)), + double((1ll<<54) - 1), + double((1ll<<55) - 1), + double((1ll<<56) - 1), + double(-((1ll<<54) - 1)), + double(-((1ll<<55) - 1)), + double(-((1ll<<56) - 1)), 1.1, 0.1, -0.1, diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp index 0e243988e2..1ac3645349 100644 --- a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp +++ b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp @@ -101,7 +101,7 @@ void tst_QMessageAuthenticationCode::result_data() << QByteArray::fromHex("750c783e6ab0b503eaa86e310a5db738"); QTest::newRow("rfc-md5-3") << QCryptographicHash::Md5 << QByteArray::fromHex("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") - << QByteArray(50, 0xdd) + << QByteArray(50, char(0xdd)) << QByteArray::fromHex("56be34521d144c88dbb8c733f0e8b3f6"); } diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 4856f52c55..75aed3bf8b 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -451,8 +451,8 @@ void tst_QGuiVariant::vector2D() QVariant variant; QVector2D vector = qvariant_cast<QVector2D>(variant); QVERIFY(vector.isNull()); - variant.setValue(QVector2D(0.1, 0.2)); - QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast<QVector2D>(variant)); + variant.setValue(QVector2D(0.1f, 0.2f)); + QCOMPARE(QVector2D(0.1f, 0.2f), qvariant_cast<QVector2D>(variant)); void *pvector = QMetaType::create(QVariant::Vector2D, 0); QVERIFY(pvector); diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 9135c57420..17be5e4c43 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -61,6 +61,7 @@ class tst_QDnsLookup: public QObject QString domainName(const QString &input); QString domainNameList(const QString &input); + QStringList domainNameListAlternatives(const QString &input); public slots: void initTestCase(); @@ -74,8 +75,8 @@ private slots: void tst_QDnsLookup::initTestCase() { QTest::addColumn<QString>("tld"); - QTest::newRow("normal") << ".test.macieira.org"; - QTest::newRow("idn") << ".alqualond\xc3\xab.test.macieira.org"; + QTest::newRow("normal") << ".test.qt-project.org"; + QTest::newRow("idn") << ".alqualond\xc3\xab.test.qt-project.org"; } QString tst_QDnsLookup::domainName(const QString &input) @@ -105,6 +106,14 @@ QString tst_QDnsLookup::domainNameList(const QString &input) return result; } +QStringList tst_QDnsLookup::domainNameListAlternatives(const QString &input) +{ + QStringList alternatives = input.split('|'); + for (int i = 0; i < alternatives.length(); ++i) + alternatives[i] = domainNameList(alternatives[i]); + return alternatives; +} + void tst_QDnsLookup::lookup_data() { QTest::addColumn<int>("type"); @@ -116,46 +125,57 @@ void tst_QDnsLookup::lookup_data() QTest::addColumn<QString>("ns"); QTest::addColumn<QString>("ptr"); QTest::addColumn<QString>("srv"); - QTest::addColumn<QByteArray>("txt"); - - QTest::newRow("a-empty") << int(QDnsLookup::A) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << ""<< "" << QByteArray(); - QTest::newRow("a-notfound") << int(QDnsLookup::A) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("a-single") << int(QDnsLookup::A) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("a-multi") << int(QDnsLookup::A) << "a-multi" << int(QDnsLookup::NoError) << "" << "192.0.2.1;192.0.2.2;192.0.2.3" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-empty") << int(QDnsLookup::AAAA) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-notfound") << int(QDnsLookup::AAAA) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-single") << int(QDnsLookup::AAAA) << "aaaa-single" << int(QDnsLookup::NoError) << "" << "2001:db8::1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-multi") << int(QDnsLookup::AAAA) << "aaaa-multi" << int(QDnsLookup::NoError) << "" << "2001:db8::1;2001:db8::2;2001:db8::3" << "" << "" << "" << "" << QByteArray(); - - QTest::newRow("any-empty") << int(QDnsLookup::ANY) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-notfound") << int(QDnsLookup::ANY) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-a-single") << int(QDnsLookup::ANY) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-a-plus-aaaa") << int(QDnsLookup::ANY) << "a-plus-aaaa" << int(QDnsLookup::NoError) << "" << "198.51.100.1;2001:db8::1:1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-multi") << int(QDnsLookup::ANY) << "multi" << int(QDnsLookup::NoError) << "" << "198.51.100.1;198.51.100.2;198.51.100.3;2001:db8::1:1;2001:db8::1:2" << "" << "" << "" << "" << QByteArray(); - - QTest::newRow("mx-empty") << int(QDnsLookup::MX) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-notfound") << int(QDnsLookup::MX) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-single") << int(QDnsLookup::MX) << "mx-single" << int(QDnsLookup::NoError) << "" << "" << "10 multi" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-single-cname") << int(QDnsLookup::MX) << "mx-single-cname" << int(QDnsLookup::NoError) << "" << "" << "10 cname" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-multi") << int(QDnsLookup::MX) << "mx-multi" << int(QDnsLookup::NoError) << "" << "" << "10 multi;20 a-single" << "" << "" << "" << QByteArray(); - - QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns3.macieira.info." << "" << "" << QByteArray(); - QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "gondolin.macieira.info.;ns3.macieira.info." << "" << "" << QByteArray(); - - QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << QByteArray(); - - QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("srv-single") << int(QDnsLookup::SRV) << "_echo._tcp.srv-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "5 0 7 multi" << QByteArray(); - QTest::newRow("srv-prio") << int(QDnsLookup::SRV) << "_echo._tcp.srv-prio" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "1 0 7 multi;2 0 7 a-plus-aaaa" << QByteArray(); - - QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("txt-single") << int(QDnsLookup::TXT) << "txt-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << QByteArray("Hello"); + QTest::addColumn<QString>("txt"); + + QTest::newRow("a-empty") << int(QDnsLookup::A) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << ""<< "" << ""; + QTest::newRow("a-notfound") << int(QDnsLookup::A) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("a-single") << int(QDnsLookup::A) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << ""; + QTest::newRow("a-multi") << int(QDnsLookup::A) << "a-multi" << int(QDnsLookup::NoError) << "" << "192.0.2.1;192.0.2.2;192.0.2.3" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-empty") << int(QDnsLookup::AAAA) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-notfound") << int(QDnsLookup::AAAA) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-single") << int(QDnsLookup::AAAA) << "aaaa-single" << int(QDnsLookup::NoError) << "" << "2001:db8::1" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-multi") << int(QDnsLookup::AAAA) << "aaaa-multi" << int(QDnsLookup::NoError) << "" << "2001:db8::1;2001:db8::2;2001:db8::3" << "" << "" << "" << "" << ""; + + QTest::newRow("any-empty") << int(QDnsLookup::ANY) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("any-notfound") << int(QDnsLookup::ANY) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("any-a-single") << int(QDnsLookup::ANY) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << ""; + QTest::newRow("any-a-plus-aaaa") << int(QDnsLookup::ANY) << "a-plus-aaaa" << int(QDnsLookup::NoError) << "" << "198.51.100.1;2001:db8::1:1" << "" << "" << "" << "" << ""; + QTest::newRow("any-multi") << int(QDnsLookup::ANY) << "multi" << int(QDnsLookup::NoError) << "" << "198.51.100.1;198.51.100.2;198.51.100.3;2001:db8::1:1;2001:db8::1:2" << "" << "" << "" << "" << ""; + + QTest::newRow("mx-empty") << int(QDnsLookup::MX) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("mx-notfound") << int(QDnsLookup::MX) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("mx-single") << int(QDnsLookup::MX) << "mx-single" << int(QDnsLookup::NoError) << "" << "" << "10 multi" << "" << "" << "" << ""; + QTest::newRow("mx-single-cname") << int(QDnsLookup::MX) << "mx-single-cname" << int(QDnsLookup::NoError) << "" << "" << "10 cname" << "" << "" << "" << ""; + QTest::newRow("mx-multi") << int(QDnsLookup::MX) << "mx-multi" << int(QDnsLookup::NoError) << "" << "" << "10 multi;20 a-single" << "" << "" << "" << ""; + QTest::newRow("mx-multi-sameprio") << int(QDnsLookup::MX) << "mx-multi-sameprio" << int(QDnsLookup::NoError) << "" << "" + << "10 multi;10 a-single|" + "10 a-single;10 multi" << "" << "" << "" << ""; + + QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns-foo.linpro.net." << "" << "" << ""; + QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "ns-bar.linpro.net.;ns-foo.linpro.net." << "" << "" << ""; + + QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << ""; + + QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("srv-single") << int(QDnsLookup::SRV) << "_echo._tcp.srv-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "5 0 7 multi" << ""; + QTest::newRow("srv-prio") << int(QDnsLookup::SRV) << "_echo._tcp.srv-prio" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "1 0 7 multi;2 0 7 a-plus-aaaa" << ""; + QTest::newRow("srv-weighted") << int(QDnsLookup::SRV) << "_echo._tcp.srv-weighted" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" + << "5 75 7 multi;5 25 7 a-plus-aaaa|" + "5 25 7 a-plus-aaaa;5 75 7 multi" << ""; + QTest::newRow("srv-multi") << int(QDnsLookup::SRV) << "_echo._tcp.srv-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" + << "1 50 7 multi;2 50 7 a-single;2 50 7 aaaa-single;3 50 7 a-multi|" + "1 50 7 multi;2 50 7 aaaa-single;2 50 7 a-single;3 50 7 a-multi" << ""; + + QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("txt-single") << int(QDnsLookup::TXT) << "txt-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello"; + QTest::newRow("txt-multi-onerr") << int(QDnsLookup::TXT) << "txt-multi-onerr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello World"; + QTest::newRow("txt-multi-multirr") << int(QDnsLookup::TXT) << "txt-multi-multirr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello;World"; } void tst_QDnsLookup::lookup() @@ -169,15 +189,18 @@ void tst_QDnsLookup::lookup() QFETCH(QString, ns); QFETCH(QString, ptr); QFETCH(QString, srv); - QFETCH(QByteArray, txt); + QFETCH(QString, txt); // transform the inputs domain = domainName(domain); cname = domainName(cname); - mx = domainNameList(mx); ns = domainNameList(ns); ptr = domainNameList(ptr); - srv = domainNameList(srv); + + // SRV and MX have reply entries that can change order + // and we can't sort + QStringList mx_alternatives = domainNameListAlternatives(mx); + QStringList srv_alternatives = domainNameListAlternatives(srv); QDnsLookup lookup; lookup.setType(static_cast<QDnsLookup::Type>(type)); @@ -218,7 +241,8 @@ void tst_QDnsLookup::lookup() QCOMPARE(record.name(), domain); mailExchanges << QString("%1 %2").arg(QString::number(record.preference()), record.exchange()); } - QCOMPARE(mailExchanges.join(';'), mx); + QVERIFY2(mx_alternatives.contains(mailExchanges.join(';')), + qPrintable("Actual: " + mailExchanges.join(';') + "\nExpected one of:\n" + mx_alternatives.join('\n'))); // name servers QStringList nameServers; @@ -250,18 +274,23 @@ void tst_QDnsLookup::lookup() QString::number(record.port()), record.target()); } - QCOMPARE(services.join(';'), srv); + QVERIFY2(srv_alternatives.contains(services.join(';')), + qPrintable("Actual: " + services.join(';') + "\nExpected one of:\n" + srv_alternatives.join('\n'))); // text - if (!txt.isEmpty()) { - QVERIFY(!lookup.textRecords().isEmpty()); - const QDnsTextRecord firstRecord = lookup.textRecords().first(); - QCOMPARE(firstRecord.name(), domain); - QCOMPARE(firstRecord.values().size(), 1); - QCOMPARE(firstRecord.values().first(), txt); - } else { - QVERIFY(lookup.textRecords().isEmpty()); + QStringList texts; + foreach (const QDnsTextRecord &record, lookup.textRecords()) { + QCOMPARE(record.name(), domain); + QString text; + foreach (const QByteArray &ba, record.values()) { + if (!text.isEmpty()) + text += ' '; + text += QString::fromLatin1(ba); + } + texts << text; } + texts.sort(); + QCOMPARE(texts.join(';'), txt); } void tst_QDnsLookup::lookupReuse() diff --git a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp index 84b63c7148..91b5d9292d 100644 --- a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp +++ b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp @@ -56,7 +56,7 @@ private slots: void tst_QDnsLookup_Appless::noApplication() { QTest::ignoreMessage(QtWarningMsg, "QDnsLookup requires a QCoreApplication"); - QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); + QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org"); dns.lookup(); } @@ -66,7 +66,7 @@ void tst_QDnsLookup_Appless::recreateApplication() char **argv = 0; for (int i = 0; i < 10; ++i) { QCoreApplication app(argc, argv); - QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); + QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org"); dns.lookup(); if (!dns.isFinished()) { QObject::connect(&dns, SIGNAL(finished()), diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index ee6ea546f3..e81c7f71db 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -93,7 +93,7 @@ #include "../../../network-settings.h" -#define TEST_DOMAIN ".test.macieira.org" +#define TEST_DOMAIN ".test.qt-project.org" class tst_QHostInfo : public QObject diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index e06285dc67..dd24f6757e 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -389,6 +389,11 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QCOMPARE(systemProxy.first().port(), static_cast<quint16>(port)); qunsetenv(envVar); #else + Q_UNUSED(envVar) + Q_UNUSED(url) + Q_UNUSED(proxyType) + Q_UNUSED(hostName) + Q_UNUSED(port) QSKIP("Generic system proxy not available on this platform."); #endif } diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index b6b534b1da..c74edab9a2 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -334,12 +334,13 @@ static inline float qrandom() { return (rand() % 100) / 100.f; } void renderAScene(int w, int h) { #ifdef QT_OPENGL_ES_2 + Q_UNUSED(w) + Q_UNUSED(h) QGLShaderProgram program; program.addShaderFromSourceCode(QGLShader::Vertex, "attribute highp vec2 pos; void main() { gl_Position = vec4(pos.xy, 1.0, 1.0); }"); program.addShaderFromSourceCode(QGLShader::Fragment, "uniform lowp vec4 color; void main() { gl_FragColor = color; }"); program.bindAttributeLocation("pos", 0); program.bind(); - int colorId = program.uniformLocation("color"); glEnableVertexAttribArray(0); diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 1f7582243e..1d57206a73 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -41,6 +41,7 @@ SUBDIRS=\ windowsmobile \ qaccessibility \ qaccessibilitylinux \ + qaccessibilitymac \ !qtHaveModule(network): SUBDIRS -= \ baselineexample \ @@ -63,7 +64,8 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility !mac: SUBDIRS -= \ macgui \ macnativeevents \ - macplist + macplist \ + qaccessibilitymac !embedded|wince*: SUBDIRS -= \ qdirectpainter diff --git a/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro b/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro new file mode 100644 index 0000000000..5d81567f45 --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qaccessibilitymac +# LIBS += -framework Carbon +QT += widgets testlib + +HEADERS += tst_qaccessibilitymac_helpers.h +SOURCES += tst_qaccessibilitymac.cpp + +mac { + LIBS += -framework Security -framework AppKit -framework ApplicationServices + OBJECTIVE_SOURCES += tst_qaccessibilitymac_helpers.mm +} + + +requires(mac) +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp new file mode 100644 index 0000000000..25dd0d39dd --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +#include <QApplication> +#include <QtWidgets> +#include <QtTest/QtTest> +#include <QtCore/qcoreapplication.h> + +#include "tst_qaccessibilitymac_helpers.h" + +QT_USE_NAMESPACE + + +class AccessibleTestWindow : public QWidget +{ + Q_OBJECT +public: + AccessibleTestWindow() + { + new QHBoxLayout(this); + } + + void addWidget(QWidget* widget) + { + layout()->addWidget(widget); + widget->show(); + QTest::qWaitForWindowExposed(widget); + } + + void clearChildren() + { + qDeleteAll(children()); + new QHBoxLayout(this); + } +}; + +class tst_QAccessibilityMac : public QObject +{ +Q_OBJECT +private slots: + void init(); + void cleanup(); + + void lineEditTest(); + void hierarchyTest(); +private: + AccessibleTestWindow *m_window; +}; + + +void tst_QAccessibilityMac::init() +{ + m_window = new AccessibleTestWindow(); + m_window->setWindowTitle("Test window"); + m_window->show(); + m_window->resize(400, 400); + + QTest::qWaitForWindowExposed(m_window); +} + +void tst_QAccessibilityMac::cleanup() +{ + delete m_window; +} + + +void tst_QAccessibilityMac::lineEditTest() +{ + if (!macNativeAccessibilityEnabled()) + return; + + QLineEdit *lineEdit = new QLineEdit(m_window); + lineEdit->setText("a11y test QLineEdit"); + m_window->addWidget(lineEdit); + QVERIFY(QTest::qWaitForWindowExposed(m_window)); + QCoreApplication::processEvents(); + QVERIFY(testLineEdit()); +} + +void tst_QAccessibilityMac::hierarchyTest() +{ + if (!macNativeAccessibilityEnabled()) + return; + + QWidget *w = new QWidget(m_window); + m_window->addWidget(w); + QPushButton *b = new QPushButton(w); + w->setLayout(new QVBoxLayout()); + w->layout()->addWidget(b); + b->setText("I am a button"); + + QVERIFY(QTest::qWaitForWindowExposed(m_window)); + QCoreApplication::processEvents(); + QVERIFY(testHierarchy()); +} + +QTEST_MAIN(tst_QAccessibilityMac) +#include "tst_qaccessibilitymac.moc" diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h new file mode 100644 index 0000000000..ec5beab125 --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ +#include <QtCore/QString> +#include <QtCore/QPair> +#include <QtWidgets/QWidget> + + +#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X. + +bool macNativeAccessibilityEnabled(); +bool trusted(); +bool testLineEdit(); +bool testHierarchy(); diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm new file mode 100644 index 0000000000..8620b7dd2f --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +// some versions of CALayer.h use 'slots' as an identifier +#define QT_NO_KEYWORDS + +#include "tst_qaccessibilitymac_helpers.h" +#include <QApplication> +#include <QDebug> +#include <unistd.h> + +#import <Cocoa/Cocoa.h> +#import <ApplicationServices/ApplicationServices.h> + +bool macNativeAccessibilityEnabled() +{ + bool enabled = AXAPIEnabled(); + if (!enabled) + qWarning() << "Accessibility is disabled (check System Preferences) skipping test."; + return enabled; +} + +bool trusted() +{ + return AXIsProcessTrusted(); +} + + +#define EXPECT(cond) \ + if (!(cond)) { \ + qWarning("Failure in %s, line: %d", __FILE__ , __LINE__); \ + return false; \ + } \ + + +@interface TestAXObject : NSObject +{ + AXUIElementRef reference; +} + @property (readonly) NSString *role; + @property (readonly) NSString *description; + @property (readonly) NSString *value; + @property (readonly) CGRect rect; +@end + +@implementation TestAXObject +- (id) initWithAXUIElementRef: (AXUIElementRef) ref { + if ( self = [super init] ) { + reference = ref; + AXUIElementCopyAttributeValue(ref, kAXRoleAttribute, (CFTypeRef*)&_role); + AXUIElementCopyAttributeValue(ref, kAXDescriptionAttribute, (CFTypeRef*)&_description); + AXUIElementCopyAttributeValue(ref, kAXValueAttribute, (CFTypeRef*)&_value); + AXValueRef sizeValue; + AXUIElementCopyAttributeValue(ref, kAXSizeAttribute, (CFTypeRef*)&sizeValue); + AXValueGetValue(sizeValue, kAXValueCGSizeType, &_rect.size); + AXValueRef positionValue; + AXUIElementCopyAttributeValue(ref, kAXPositionAttribute, (CFTypeRef*)&positionValue); + AXValueGetValue(positionValue, kAXValueCGPointType, &_rect.origin); + } + return self; +} + +- (AXUIElementRef) ref { return reference; } +- (void) print { + NSLog(@"Accessible Object role: '%@', description: '%@', value: '%@', rect: '%@'", self.role, self.description, self.value, NSStringFromRect(self.rect)); + NSLog(@" Children: %ld", [self.childList count]); +} + +- (NSArray*) windowList +{ + NSArray *list; + AXUIElementCopyAttributeValues( + reference, + kAXWindowsAttribute, + 0, 100, /*min, max*/ + (CFArrayRef *) &list); + return list; +} + +- (NSArray*) childList +{ + NSArray *list; + AXUIElementCopyAttributeValues( + reference, + kAXChildrenAttribute, + 0, 100, /*min, max*/ + (CFArrayRef *) &list); + return list; +} + +- (AXUIElementRef) findDirectChildByRole: (CFStringRef) role +{ + AXUIElementRef result = nil; + NSArray *childList = [self childList]; + for (id child in childList) { + CFStringRef typeString; + AXUIElementCopyAttributeValue((AXUIElementRef)child, kAXRoleAttribute, (CFTypeRef*)&typeString); + if (CFStringCompare(typeString, role, 0) == 0) { + result = (AXUIElementRef) child; + break; + } + } + return result; +} + +- (AXUIElementRef) parent +{ + AXUIElementRef p = nil; + AXUIElementCopyAttributeValue(reference, kAXParentAttribute, (CFTypeRef*)&p); + return p; +} + +@end + + +bool testLineEdit() +{ +// not sure if this is needed. on my machine the calls succeed. +// NSString *path = @"/Users/frederik/qt5/qtbase/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.app/Contents/MacOS/tst_qaccessibilitymac"; +// NSString *path = @"/Users/frederik/qt5/qtbase/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.app"; +// AXError e = AXMakeProcessTrusted((CFStringRef) path); +// NSLog(@"error: %i", e); + + pid_t pid = getpid(); + AXUIElementRef app = AXUIElementCreateApplication(pid); + EXPECT(app != nil); + TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + + NSArray *windowList = [appObject windowList]; + // one window + EXPECT([windowList count] == 1); + AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0]; + EXPECT(windowRef != nil); + TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef]; + + EXPECT([window rect].size.width == 400); + // height of window includes title bar + EXPECT([window rect].size.height >= 400); + + // children of window: + AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole]; + EXPECT(lineEdit != nil); + + TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEdit]; + EXPECT([[le value] isEqualToString:@"a11y test QLineEdit"]); + return true; +} + +bool testHierarchy() +{ + pid_t pid = getpid(); + AXUIElementRef app = AXUIElementCreateApplication(pid); + EXPECT(app != nil); + TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + + NSArray *windowList = [appObject windowList]; + // one window + EXPECT([windowList count] == 1); + AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0]; + EXPECT(windowRef != nil); + TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef]; + + // Because the plain widget is filtered out of the hierarchy, we expect the button + // to be a direct child of the window + AXUIElementRef buttonRef = [window findDirectChildByRole: kAXButtonRole]; + EXPECT(buttonRef != nil); + + TestAXObject *buttonObject = [[TestAXObject alloc] initWithAXUIElementRef: buttonRef]; + TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]]; + + // check that the parent is a window + EXPECT([[parentObject role] isEqualToString: (NSString *)kAXWindowRole]); + + return true; +} diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index e36eaa5af2..0fe7c8ab75 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1033,6 +1033,14 @@ void tst_QFileSystemModel::roleNames() QVERIFY(values.contains(roleName)); } +static inline QByteArray permissionRowName(bool readOnly, int permission) +{ + QByteArray result = readOnly ? QByteArrayLiteral("ro") : QByteArrayLiteral("rw"); + result += QByteArrayLiteral("-0"); + result += QByteArray::number(permission, 16); + return result; +} + void tst_QFileSystemModel::permissions_data() { QTest::addColumn<int>("permissions"); @@ -1043,11 +1051,10 @@ void tst_QFileSystemModel::permissions_data() QFile::ReadOwner, QFile::WriteOwner|QFile::ReadOwner, }; -#define ROW_NAME(i) qPrintable(QString().sprintf("%s-0%04x", readOnly ? "ro" : "rw", permissions[i])) - for (int readOnly = false ; readOnly <= true; ++readOnly) - for (size_t i = 0; i < sizeof permissions / sizeof *permissions; ++i) - QTest::newRow(ROW_NAME(i)) << permissions[i] << bool(readOnly); -#undef ROW_NAME + for (size_t i = 0; i < sizeof permissions / sizeof *permissions; ++i) { + QTest::newRow(permissionRowName(false, permissions[i]).constData()) << permissions[i] << false; + QTest::newRow(permissionRowName(true, permissions[i]).constData()) << permissions[i] << true; + } } void tst_QFileSystemModel::permissions() // checks QTBUG-20503 diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h index fe9e71e650..920fa5e023 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h @@ -42,7 +42,7 @@ #include <QtCore/QPair> #include <QtWidgets/QWidget> -#pragma once // Yeah, it's deprecated in general, but it's standard practive for Mac OS X. +#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X. QString nativeWindowTitle(QWidget *widget, Qt::WindowState state); bool nativeWindowModified(QWidget *widget); diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 2b9268f35d..4d18971cc6 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -6,10 +6,7 @@ QT += widgets testlib SOURCES += tst_qstyle.cpp wince* { - DEFINES += SRCDIR=\\\".\\\" addPixmap.files = task_25863.png addPixmap.path = . DEPLOYMENT += addPixmap -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index fc94f95f8e..94d2d22d96 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -250,9 +250,12 @@ void tst_QStyle::testProxyStyle() void tst_QStyle::drawItemPixmap() { testWidget->resize(300, 300); - testWidget->show(); + testWidget->showNormal(); - QPixmap p(QString(SRCDIR) + "/task_25863.png", "PNG"); + const QString imageFileName = QFINDTESTDATA("task_25863.png"); + QVERIFY(!imageFileName.isEmpty()); + + QPixmap p(imageFileName, "PNG"); const QPixmap actualPix = testWidget->grab(); QCOMPARE(actualPix, p); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 36b83eefda..0bfd4baa0c 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2044,10 +2044,11 @@ void tst_QComboBox::itemListPosition() //we test QFontComboBox because it has the specific behaviour to set a fixed size //to the list view QWidget topLevel; - topLevel.resize(200, 200); - topLevel.move(100, 100); + QHBoxLayout *layout = new QHBoxLayout(&topLevel); + QFontComboBox combo(&topLevel); + layout->addWidget(&combo); //the code to get the available screen space is copied from QComboBox code const int scrNumber = QApplication::desktop()->screenNumber(&combo); @@ -2058,11 +2059,12 @@ void tst_QComboBox::itemListPosition() QApplication::desktop()->screenGeometry(scrNumber) : QApplication::desktop()->availableGeometry(scrNumber); - combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner + topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner topLevel.show(); + //wait because the window manager can move the window if there is a right panel - QTRY_VERIFY(combo.isVisible()); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); combo.showPopup(); QTRY_VERIFY(combo.view()); QTRY_VERIFY(combo.view()->isVisible()); diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index 6b4bc3cd35..26f49a3fed 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1705,8 +1705,8 @@ void tst_QDom::germanUmlautToByteArray() const QByteArray baseline("<a"); /* http://www.fileformat.info/info/unicode/char/00FC/index.htm */ - baseline += 0xC3; - baseline += 0xBC; + baseline += char(0xC3); + baseline += char(0xBC); baseline += "b/>\n"; QCOMPARE(data, baseline); |