diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-22 09:31:58 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-25 14:03:45 +0200 |
commit | bb4b86618dc930e0035c5829e336f2606d140ada (patch) | |
tree | 6e36808ca46244373bc70aabbb926cc114538beb /tests/auto | |
parent | 276adc5a09914fd89d976bb90cc0cd67de9d3d6e (diff) | |
parent | bbd1228b17ee3f3a5483f88b0a581d6a60c41cad (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
config.tests/unix/compile.test
configure
src/android/jar/src/org/qtproject/qt5/android/QtMessageDialogHelper.java
src/corelib/global/qglobal.cpp
src/widgets/kernel/qapplication.cpp
src/widgets/styles/qwindowsvistastyle.cpp
tests/auto/corelib/kernel/qobject/tst_qobject.cpp
Change-Id: I067083f34e5290aa5f7565e40c30a069cc37b83a
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 32 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 19 |
2 files changed, 49 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 470d5b6434..73672f3572 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -143,6 +143,8 @@ private slots: void hostFlags_data(); void hostFlags(); void setPort(); + void port_data(); + void port(); void toEncoded_data(); void toEncoded(); void setAuthority_data(); @@ -1742,6 +1744,9 @@ void tst_QUrl::symmetry() QUrl url(QString::fromUtf8("http://www.räksmörgås.se/pub?a=b&a=dø&a=f#vræl")); QCOMPARE(url.scheme(), QString::fromLatin1("http")); QCOMPARE(url.host(), QString::fromUtf8("www.räksmörgås.se")); + QCOMPARE(url.host(QUrl::EncodeSpaces), QString::fromUtf8("www.räksmörgås.se")); + QCOMPARE(url.host(QUrl::EncodeUnicode), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); + QCOMPARE(url.host(QUrl::EncodeUnicode | QUrl::EncodeSpaces), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se")); QCOMPARE(url.path(), QString::fromLatin1("/pub")); // this will be encoded ... QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData()); @@ -2200,8 +2205,6 @@ void tst_QUrl::strictParser_data() // 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"; QTest::newRow("invalid-port-1") << "http://example.com:-1" << "Invalid port"; QTest::newRow("invalid-port-2") << "http://example.com:abc" << "Invalid port"; QTest::newRow("invalid-port-3") << "http://example.com:9a" << "Invalid port"; @@ -2778,6 +2781,31 @@ void tst_QUrl::setPort() } } +void tst_QUrl::port_data() +{ + QTest::addColumn<QString>("input"); + QTest::addColumn<int>("port"); + + QTest::newRow("no-port-1") << "http://example.com" << -1; + QTest::newRow("no-port-2") << "http://example.com/" << -1; + QTest::newRow("empty-port-1") << "http://example.com:" << -1; + QTest::newRow("empty-port-2") << "http://example.com:/" << -1; + QTest::newRow("zero-port-1") << "http://example.com:0" << 0; + QTest::newRow("zero-port-2") << "http://example.com:0/" << 0; + QTest::newRow("set-port-1") << "http://example.com:80" << 80; + QTest::newRow("set-port-2") << "http://example.com:80/" << 80; +} + +void tst_QUrl::port() +{ + QFETCH(QString, input); + QFETCH(int, port); + + QUrl url(input); + QVERIFY(url.isValid()); + QCOMPARE(url.port(), port); +} + void tst_QUrl::toEncoded_data() { QTest::addColumn<QByteArray>("url"); diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 23f8ff5857..1902687eef 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -143,6 +143,7 @@ private slots: void exceptions(); void noDeclarativeParentChangedOnDestruction(); void deleteLaterInAboutToBlockHandler(); + void mutableFunctor(); }; struct QObjectCreatedOnShutdown @@ -6512,6 +6513,24 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction() #endif } +struct MutableFunctor { + int count; + MutableFunctor() : count(0) {} + int operator()() { return ++count; } +}; + +void tst_QObject::mutableFunctor() +{ + ReturnValue o; + MutableFunctor functor; + QCOMPARE(functor.count, 0); + connect(&o, &ReturnValue::returnInt, functor); + QCOMPARE(emit o.returnInt(0), 1); + QCOMPARE(emit o.returnInt(0), 2); // each emit should increase the internal count + + QCOMPARE(functor.count, 0); // but the original object should have been copied at connect time +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); |