diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2011-09-08 22:05:42 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-30 01:19:59 +0200 |
commit | 1c2144c39fa0069bf496e8f77389a9c2f8a31acf (patch) | |
tree | fb3709b67e9d2f5f76cb9a45c6113b67d686d765 /tests/auto/corelib/io/qurl | |
parent | 1aeb18038661d8da6d37fa278e37e315e35c5c42 (diff) |
Forward the methods dealing with the break down of query to QUrlQuery
Now that QUrlQuery exists, these methods are no longer necessary in
QUrl itself. Manipulation of the items should be done using the new
class.
They are now implemented using a temporary QUrlQuery. This is hardly
efficient but it works.
Change-Id: I34820b3101424593d0715841a2057ac3f74d74f0
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/io/qurl')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 7ca7fbb81d..900d0b7644 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -114,11 +114,8 @@ private slots: void isRelative_data(); void isRelative(); void setQueryItems(); - void queryItems(); void hasQuery_data(); void hasQuery(); - void hasQueryItem_data(); - void hasQueryItem(); void nameprep(); void isValid(); void schemeValidator_data(); @@ -157,8 +154,6 @@ private slots: void toEncodedNotUsingUninitializedPath(); void emptyAuthorityRemovesExistingAuthority(); void acceptEmptyAuthoritySegments(); - void removeAllEncodedQueryItems_data(); - void removeAllEncodedQueryItems(); }; // Testing get/set functions @@ -1416,8 +1411,6 @@ void tst_QUrl::symmetry() 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()); - // unencoded - QCOMPARE(url.allQueryItemValues("a").join(""), QString::fromUtf8("bdøf")); QCOMPARE(url.fragment(), QString::fromUtf8("vræl")); QUrl onlyHost("//qt.nokia.com"); @@ -1577,56 +1570,6 @@ void tst_QUrl::setQueryItems() "/ole&du>anne+jørgen=sant/prosent>%25#top")); } -void tst_QUrl::queryItems() -{ - QUrl url; - QVERIFY(!url.hasQuery()); - - QList<QPair<QString, QString> > newItems; - newItems += qMakePair(QString("2"), QString("b")); - newItems += qMakePair(QString("1"), QString("a")); - newItems += qMakePair(QString("3"), QString("c")); - newItems += qMakePair(QString("4"), QString("a b")); - newItems += qMakePair(QString("5"), QString("&")); - newItems += qMakePair(QString("foo bar"), QString("hello world")); - newItems += qMakePair(QString("foo+bar"), QString("hello+world")); - newItems += qMakePair(QString("tex"), QString("a + b = c")); - url.setQueryItems(newItems); - QVERIFY(url.hasQuery()); - - QList<QPair<QString, QString> > setItems = url.queryItems(); - QVERIFY(newItems == setItems); - - url.addQueryItem("1", "z"); - - QVERIFY(url.hasQueryItem("1")); - QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "a"); - - url.addQueryItem("1", "zz"); - - QStringList expected; - expected += "a"; - expected += "z"; - expected += "zz"; - QCOMPARE(expected, url.allQueryItemValues("1")); - - url.removeQueryItem("1"); - QCOMPARE(url.allQueryItemValues("1").size(), 2); - QCOMPARE(url.queryItemValue("1").toLatin1().constData(), "z"); - - url.removeAllQueryItems("1"); - QVERIFY(!url.hasQueryItem("1")); - - QCOMPARE(url.queryItemValue("4").toLatin1().constData(), "a b"); - QCOMPARE(url.queryItemValue("5").toLatin1().constData(), "&"); - QCOMPARE(url.queryItemValue("tex").toLatin1().constData(), "a + b = c"); - QCOMPARE(url.queryItemValue("foo bar").toLatin1().constData(), "hello world"); - url.setUrl("http://www.google.com/search?q=a+b"); - QCOMPARE(url.queryItemValue("q"), QString("a+b")); - url.setUrl("http://www.google.com/search?q=a=b"); // invalid, but should be tolerated - QCOMPARE(url.queryItemValue("q"), QString("a=b")); -} - void tst_QUrl::hasQuery_data() { QTest::addColumn<QString>("url"); @@ -1656,27 +1599,6 @@ void tst_QUrl::hasQuery() QCOMPARE(qurl.encodedQuery().isNull(), !trueFalse); } -void tst_QUrl::hasQueryItem_data() -{ - QTest::addColumn<QString>("url"); - QTest::addColumn<QString>("item"); - QTest::addColumn<bool>("trueFalse"); - - QTest::newRow("no query items") << "http://www.foo.bar" << "baz" << false; - QTest::newRow("query item: hello") << "http://www.foo.bar?hello=world" << "hello" << true; - QTest::newRow("no query item: world") << "http://www.foo.bar?hello=world" << "world" << false; - QTest::newRow("query item: qt") << "http://www.foo.bar?hello=world&qt=rocks" << "qt" << true; -} - -void tst_QUrl::hasQueryItem() -{ - QFETCH(QString, url); - QFETCH(QString, item); - QFETCH(bool, trueFalse); - - QCOMPARE(QUrl(url).hasQueryItem(item), trueFalse); -} - void tst_QUrl::nameprep() { QUrl url(QString::fromUtf8("http://www.fu""\xc3""\x9f""ball.de/")); @@ -2568,28 +2490,5 @@ void tst_QUrl::effectiveTLDs() QCOMPARE(domain.topLevelDomain(), TLD); } -void tst_QUrl::removeAllEncodedQueryItems_data() -{ - QTest::addColumn<QUrl>("url"); - QTest::addColumn<QByteArray>("key"); - QTest::addColumn<QUrl>("result"); - - QTest::newRow("test1") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("bbb") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&ccc=c"); - QTest::newRow("test2") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("aaa") << QUrl::fromEncoded("http://qt.nokia.com/foo?bbb=b&ccc=c"); -// QTest::newRow("test3") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("ccc") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b"); - QTest::newRow("test4") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c") << QByteArray("b%62b") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&bbb=b&ccc=c"); - QTest::newRow("test5") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c") << QByteArray("b%62b") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&ccc=c"); - QTest::newRow("test6") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c") << QByteArray("bbb") << QUrl::fromEncoded("http://qt.nokia.com/foo?aaa=a&b%62b=b&ccc=c"); -} - -void tst_QUrl::removeAllEncodedQueryItems() -{ - QFETCH(QUrl, url); - QFETCH(QByteArray, key); - QFETCH(QUrl, result); - url.removeAllEncodedQueryItems(key); - QCOMPARE(url, result); -} - QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" |