tests/auto/qurl/tst_qurl.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
    88     void init();
    88     void init();
    89     void cleanup();
    89     void cleanup();
    90 private slots:
    90 private slots:
    91     void getSetCheck();
    91     void getSetCheck();
    92     void constructing();
    92     void constructing();
       
    93     void isDetached();
    93     void assignment();
    94     void assignment();
    94     void comparison();
    95     void comparison();
    95     void copying();
    96     void copying();
    96     void setUrl();
    97     void setUrl();
    97     void i18n_data();
    98     void i18n_data();
   316     QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
   317     QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
   317     buildUNC.toEncoded();
   318     buildUNC.toEncoded();
   318     QVERIFY(!buildUNC.isEmpty());
   319     QVERIFY(!buildUNC.isEmpty());
   319 }
   320 }
   320 
   321 
       
   322 void tst_QUrl::isDetached()
       
   323 {
       
   324     QUrl url;
       
   325     QVERIFY(!url.isDetached());
       
   326 
       
   327     url = "http://qt.nokia.com/";
       
   328     QVERIFY(url.isDetached());
       
   329 
       
   330     url.clear();
       
   331     QVERIFY(!url.isDetached());
       
   332 
       
   333     url.setHost("qt.nokia.com");
       
   334     QVERIFY(url.isDetached());
       
   335 
       
   336     QUrl url2 = url;
       
   337     QVERIFY(!url.isDetached());
       
   338     QVERIFY(!url2.isDetached());
       
   339 }
       
   340 
   321 void tst_QUrl::assignment()
   341 void tst_QUrl::assignment()
   322 {
   342 {
   323     QUrl url("http://qt.nokia.com/");
   343     QUrl url("http://qt.nokia.com/");
   324     QVERIFY(url.isValid());
   344     QVERIFY(url.isValid());
   325 
   345 
  1680     QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt.nokia.com") << -1 << QString::fromLatin1("index.html")
  1700     QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt.nokia.com") << -1 << QString::fromLatin1("index.html")
  1681 	                << QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html")
  1701 	                << QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html")
  1682 			<< QByteArray("//qt.nokia.com/index.html");
  1702 			<< QByteArray("//qt.nokia.com/index.html");
  1683     QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray()
  1703     QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray()
  1684                         << n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
  1704                         << n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
       
  1705     QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde")
       
  1706                                  << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
       
  1707                                  << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/");
       
  1708     QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde")
       
  1709                                      << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
       
  1710                                      << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
  1685 }
  1711 }
  1686 
  1712 
  1687 void tst_QUrl::toString_constructed()
  1713 void tst_QUrl::toString_constructed()
  1688 {
  1714 {
  1689     QFETCH(QString, scheme);
  1715     QFETCH(QString, scheme);
  1715     if (!fragment.isEmpty())
  1741     if (!fragment.isEmpty())
  1716 	url.setFragment(fragment);
  1742 	url.setFragment(fragment);
  1717 
  1743 
  1718     QVERIFY(url.isValid());
  1744     QVERIFY(url.isValid());
  1719     QCOMPARE(url.toString(), asString);
  1745     QCOMPARE(url.toString(), asString);
       
  1746     QCOMPARE(QString::fromLatin1(url.toEncoded()), QString::fromLatin1(asEncoded)); // readable in case of differences
  1720     QCOMPARE(url.toEncoded(), asEncoded);
  1747     QCOMPARE(url.toEncoded(), asEncoded);
  1721 }
  1748 }
  1722 
  1749 
  1723 
  1750 
  1724 void tst_QUrl::isParentOf()
  1751 void tst_QUrl::isParentOf()