diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-06 06:23:07 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-06 06:23:07 (GMT) |
commit | 57ceb11ecf95032418712a686418116cf2398e7a (patch) | |
tree | 378533fcc07983d3a1b461aaaad07d842e50b81c /tests/auto/qdesktopservices/tst_qdesktopservices.cpp | |
parent | 90d4366f1e9657b3240a872698614c7d9747f9e0 (diff) | |
parent | a4fc85c75f068b73f9c2334c77b0ae2275510e17 (diff) | |
download | Qt-57ceb11ecf95032418712a686418116cf2398e7a.zip Qt-57ceb11ecf95032418712a686418116cf2398e7a.tar.gz Qt-57ceb11ecf95032418712a686418116cf2398e7a.tar.bz2 |
Merge commit 'origin/master'
Conflicts:
tests/auto/qfilesystemmodel/qfilesystemmodel.pro
tests/auto/qfontdialog/tst_qfontdialog.cpp
tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp
tests/auto/qsqldriver/qsqldriver.pro
tests/auto/qsqlquery/qsqlquery.pro
tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro
tests/auto/qsqltablemodel/qsqltablemodel.pro
tests/auto/qsqlthread/qsqlthread.pro
tests/auto/qstatemachine/tst_qstatemachine.cpp
tests/auto/qtcpsocket/tst_qtcpsocket.cpp
Diffstat (limited to 'tests/auto/qdesktopservices/tst_qdesktopservices.cpp')
-rw-r--r-- | tests/auto/qdesktopservices/tst_qdesktopservices.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp index c69b112..dd85774 100644 --- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp @@ -61,16 +61,16 @@ private slots: void cleanup(); void openUrl(); #ifdef Q_OS_SYMBIAN - // These test are manual ones, you need to check from device that + // These test are manual ones, you need to check from device that // correct system application is started with correct content - // When you want to run these test, uncomment //#define RUN_MANUAL_TESTS + // When you want to run these test, uncomment //#define RUN_MANUAL_TESTS void openHttpUrl_data(); void openHttpUrl(); void openMailtoUrl_data(); - void openMailtoUrl(); + void openMailtoUrl(); void openFileUrl_data(); void openFileUrl(); -#endif +#endif void handlers(); void storageLocation_data(); void storageLocation(); @@ -104,7 +104,7 @@ void tst_qdesktopservices::openUrl() // At the bare minimum check that they return false for invalid url's QCOMPARE(QDesktopServices::openUrl(QUrl()), false); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - // this test is only valid on windows on other systems it might mean open a new document in the application handling .file + // this test is only valid on windows on other systems it might mean open a new document in the application handling .file QCOMPARE(QDesktopServices::openUrl(QUrl("file://invalid.file")), false); #endif } @@ -112,32 +112,32 @@ void tst_qdesktopservices::openUrl() #ifdef Q_OS_SYMBIAN void tst_qdesktopservices::openHttpUrl_data() { - QTest::addColumn<QUrl>("url"); - QTest::addColumn<bool>("result"); - QTest::newRow("BasicWithHttp") << QUrl("http://www.google.fi") << true; - QTest::newRow("BasicWithoutHttp") << QUrl("www.nokia.fi") << true; + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("result"); + QTest::newRow("BasicWithHttp") << QUrl("http://www.google.fi") << true; + QTest::newRow("BasicWithoutHttp") << QUrl("www.nokia.fi") << true; QTest::newRow("BasicWithUserAndPw") << QUrl("http://s60prereleases:oslofjord@pepper.troll.no/s60prereleases/patches/") << true; QTest::newRow("URL with space") << QUrl("http://www.manataka.org/Contents Page.html") << true; - + } void tst_qdesktopservices::openHttpUrl() { -#ifndef RUN_MANUAL_TESTS - QSKIP("Test disabled -- only for manual purposes", SkipAll); -#endif - - QFETCH(QUrl, url); - QFETCH(bool, result); - QCOMPARE(QDesktopServices::openUrl(url), result); +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); + QCOMPARE(QDesktopServices::openUrl(url), result); QTest::qWait(30000); } void tst_qdesktopservices::openMailtoUrl_data() { QTest::addColumn<QUrl>("url"); - QTest::addColumn<bool>("result"); - + QTest::addColumn<bool>("result"); + // http://en.wikipedia.org/wiki/E-mail_address // RFC Valid e-mail addresses QTest::newRow("Wiki valid email 1") << QUrl("mailto:abc@example.com") << true; @@ -149,97 +149,97 @@ void tst_qdesktopservices::openMailtoUrl_data() QTest::newRow("Wiki valid email 7") << QUrl("mailto:abc+mailbox/department=shipping@example.com") << true; // S60 email client considers the next URL invalid, even ity should be valid QTest::newRow("Wiki valid email 8") << QUrl("mailto:!#$%&'*+-/=?^_`.{|}~@example.com") << true; // all of these characters are allowed - QTest::newRow("Wiki valid email 9") << QUrl("mailto:\"abc@def\"@example.com") << true; // anything goes inside quotation marks + QTest::newRow("Wiki valid email 9") << QUrl("mailto:\"abc@def\"@example.com") << true; // anything goes inside quotation marks QTest::newRow("Wiki valid email 10") << QUrl("mailto:\"Fred \\\"quota\\\" Bloggs\"@example.com") << true; // however, quotes need escaping - - // RFC invalid e-mail addresses - // These return true even though they are invalid, but check that user is notified about invalid URL in mail application - QTest::newRow("Wiki invalid email 1") << QUrl("mailto:Abc.example.com") << true; // character @ is missing - QTest::newRow("Wiki invalid email 2") << QUrl("mailto:Abc.@example.com") << true; // character dot(.) is last in local part - QTest::newRow("Wiki invalid email 3") << QUrl("mailto:Abc..123@example.com") << true; // character dot(.) is double - QTest::newRow("Wiki invalid email 4") << QUrl("mailto:A@b@c@example.com") << true; // only one @ is allowed outside quotations marks - QTest::newRow("Wiki invalid email 5") << QUrl("mailto:()[]\\;:,<>@example.com") << true; // none of the characters before the @ is allowed outside quotation marks - - QTest::newRow("Basic") << QUrl("mailto:test@nokia.com") << true; + + // RFC invalid e-mail addresses + // These return true even though they are invalid, but check that user is notified about invalid URL in mail application + QTest::newRow("Wiki invalid email 1") << QUrl("mailto:Abc.example.com") << true; // character @ is missing + QTest::newRow("Wiki invalid email 2") << QUrl("mailto:Abc.@example.com") << true; // character dot(.) is last in local part + QTest::newRow("Wiki invalid email 3") << QUrl("mailto:Abc..123@example.com") << true; // character dot(.) is double + QTest::newRow("Wiki invalid email 4") << QUrl("mailto:A@b@c@example.com") << true; // only one @ is allowed outside quotations marks + QTest::newRow("Wiki invalid email 5") << QUrl("mailto:()[]\\;:,<>@example.com") << true; // none of the characters before the @ is allowed outside quotation marks + + QTest::newRow("Basic") << QUrl("mailto:test@nokia.com") << true; QTest::newRow("BasicSeveralAddr") << QUrl("mailto:test@nokia.com,test2@nokia.com,test3@nokia.com") << true; - QTest::newRow("BasicAndSubject") << QUrl("mailto:test@nokia.com?subject=hello nokia") << true; - QTest::newRow("BasicAndTo") << QUrl("mailto:test@nokia.com?to=test2@nokia.com") << true; - + QTest::newRow("BasicAndSubject") << QUrl("mailto:test@nokia.com?subject=hello nokia") << true; + QTest::newRow("BasicAndTo") << QUrl("mailto:test@nokia.com?to=test2@nokia.com") << true; + QTest::newRow("BasicAndCc") << QUrl("mailto:test@nokia.com?cc=mycc@address.com") << true; - QTest::newRow("BasicAndBcc") << QUrl("mailto:test@nokia.com?bcc=mybcc@address.com") << true; - QTest::newRow("BasicAndBody") << QUrl("mailto:test@nokia.com?body=Test email message body") << true; - + QTest::newRow("BasicAndBcc") << QUrl("mailto:test@nokia.com?bcc=mybcc@address.com") << true; + QTest::newRow("BasicAndBody") << QUrl("mailto:test@nokia.com?body=Test email message body") << true; + // RFC examples, these are actually invalid because there is not host defined // Check that user is notified about invalid URL in mail application QTest::newRow("RFC2368 Example 1") << QUrl::fromEncoded("mailto:addr1%2C%20addr2") << true; QTest::newRow("RFC2368 Example 2") << QUrl::fromEncoded("mailto:?to=addr1%2C%20addr2") << true; QTest::newRow("RFC2368 Example 3") << QUrl("mailto:addr1?to=addr2") << true; - - QTest::newRow("RFC2368 Example 4") << QUrl("mailto:joe@example.com?cc=bob@example.com&body=hello") << true; + + QTest::newRow("RFC2368 Example 4") << QUrl("mailto:joe@example.com?cc=bob@example.com&body=hello") << true; QTest::newRow("RFC2368 Example 5") << QUrl("mailto:?to=joe@example.com&cc=bob@example.com&body=hello") << true; QTest::newRow("RFC2368 Example 6") << QUrl("mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com") << true; // OpaqueData QTest::newRow("RFC2368 Example 7") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index") << true; QTest::newRow("RFC2368 Example 8") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue") << true; QTest::newRow("RFC2368 Example 9") << QUrl("mailto:infobot@example.com?subject=current-issue") << true; QTest::newRow("RFC2368 Example 10") << QUrl("mailto:chris@example.com") << true; - + //QTest::newRow("RFC2368 Example 11 - illegal chars") << QUrl("mailto:joe@example.com?cc=bob@example.com?body=hello") << false; QTest::newRow("RFC2368 Example 12") << QUrl::fromEncoded("mailto:gorby%25kremvax@example.com") << true; // encoded reserved chars '%' - QTest::newRow("RFC2368 Example 13") << QUrl::fromEncoded("mailto:unlikely%3Faddress@example.com?blat=foop") << true; // encoded reserved chars `?' + QTest::newRow("RFC2368 Example 13") << QUrl::fromEncoded("mailto:unlikely%3Faddress@example.com?blat=foop") << true; // encoded reserved chars `?' } void tst_qdesktopservices::openMailtoUrl() { -#ifndef RUN_MANUAL_TESTS - QSKIP("Test disabled -- only for manual purposes", SkipAll); -#endif - - QFETCH(QUrl, url); - QFETCH(bool, result); - QCOMPARE(QDesktopServices::openUrl(url), result); +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); + QCOMPARE(QDesktopServices::openUrl(url), result); } void tst_qdesktopservices::openFileUrl_data() { QTest::addColumn<QUrl>("url"); - QTest::addColumn<bool>("result"); - + QTest::addColumn<bool>("result"); + // Text files - QTest::newRow("DOS text file") << QUrl("file:///c:/data/others/dosfile.txt") << true; - QTest::newRow("No EOF text file") << QUrl("file:///c:/data/others/noendofline.txt") << true; + QTest::newRow("DOS text file") << QUrl("file:///c:/data/others/dosfile.txt") << true; + QTest::newRow("No EOF text file") << QUrl("file:///c:/data/others/noendofline.txt") << true; QTest::newRow("text file") << QUrl("file:///c:/data/others/testfile.txt") << true; - QTest::newRow("text file with space") << QUrl("file:///c:/data/others/test file.txt") << true; - + QTest::newRow("text file with space") << QUrl("file:///c:/data/others/test file.txt") << true; + // Images - QTest::newRow("BMP image") << QUrl("file:///c:/data/images/image.bmp") << true; - QTest::newRow("GIF image") << QUrl("file:///c:/data/images/image.gif") << true; - QTest::newRow("JPG image") << QUrl("file:///c:/data/images/image.jpg") << true; - QTest::newRow("PNG image") << QUrl("file:///c:/data/images/image.png") << true; - - // Audio - QTest::newRow("MP4 audio") << QUrl("file:///c:/data/sounds/aac-only.mp4") << true; - QTest::newRow("3GP audio") << QUrl("file:///c:/data/sounds/audio_3gpp.3gp") << true; - - // Video - QTest::newRow("MP4 video") << QUrl("file:///c:/data/videos/vid-mpeg4-22k.mp4") << true; - - // Installs - QTest::newRow("SISX") << QUrl("file:///c:/data/installs/ErrRd.sisx") << true; - - // Errors - QTest::newRow("File does not exist") << QUrl("file:///c:/thisfileneverexists.txt") << false; + QTest::newRow("BMP image") << QUrl("file:///c:/data/images/image.bmp") << true; + QTest::newRow("GIF image") << QUrl("file:///c:/data/images/image.gif") << true; + QTest::newRow("JPG image") << QUrl("file:///c:/data/images/image.jpg") << true; + QTest::newRow("PNG image") << QUrl("file:///c:/data/images/image.png") << true; + + // Audio + QTest::newRow("MP4 audio") << QUrl("file:///c:/data/sounds/aac-only.mp4") << true; + QTest::newRow("3GP audio") << QUrl("file:///c:/data/sounds/audio_3gpp.3gp") << true; + + // Video + QTest::newRow("MP4 video") << QUrl("file:///c:/data/videos/vid-mpeg4-22k.mp4") << true; + + // Installs + QTest::newRow("SISX") << QUrl("file:///c:/data/installs/ErrRd.sisx") << true; + + // Errors + QTest::newRow("File does not exist") << QUrl("file:///c:/thisfileneverexists.txt") << false; } void tst_qdesktopservices::openFileUrl() { -#ifndef RUN_MANUAL_TESTS - QSKIP("Test disabled -- only for manual purposes", SkipAll); -#endif - - QFETCH(QUrl, url); - QFETCH(bool, result); +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); QCOMPARE(QDesktopServices::openUrl(url), result); - QTest::qWait(15000); + QTest::qWait(15000); } #endif @@ -297,17 +297,17 @@ void tst_qdesktopservices::storageLocation() QString storageLocation = QDesktopServices::storageLocation(location); QString displayName = QDesktopServices::displayName(location); //qDebug( "displayName: %s", displayName ); - + storageLocation = storageLocation.toLower(); displayName = displayName.toLower(); - - QString drive = QDir::currentPath().left(2).toLower(); + + QString drive = QDir::currentPath().left(2).toLower(); if( drive == "z:" ) drive = "c:"; switch(location) { case QDesktopServices::DesktopLocation: - QCOMPARE( storageLocation, QString() ); + QCOMPARE( storageLocation, drive + QString("/data") ); break; case QDesktopServices::DocumentsLocation: QCOMPARE( storageLocation, drive + QString("/data") ); @@ -319,9 +319,9 @@ void tst_qdesktopservices::storageLocation() case QDesktopServices::ApplicationsLocation: #ifdef Q_CC_NOKIAX86 QCOMPARE( storageLocation, QString("z:/sys/bin") ); -#else - QCOMPARE( storageLocation, drive + QString("/sys/bin") ); -#endif +#else + QCOMPARE( storageLocation, drive + QString("/sys/bin") ); +#endif break; case QDesktopServices::MusicLocation: QCOMPARE( storageLocation, drive + QString("/data/sounds") ); @@ -331,7 +331,7 @@ void tst_qdesktopservices::storageLocation() break; case QDesktopServices::PicturesLocation: QCOMPARE( storageLocation, drive + QString("/data/images") ); - break; + break; case QDesktopServices::TempLocation: QCOMPARE( storageLocation, QDir::tempPath().toLower()); break; @@ -339,18 +339,18 @@ void tst_qdesktopservices::storageLocation() QCOMPARE( storageLocation, QDir::homePath().toLower()); break; case QDesktopServices::DataLocation: - // Just check the folder not the drive + // Just check the folder not the drive QCOMPARE( storageLocation.mid(2), QDir::currentPath().mid(2).toLower()); - break; + break; default: QCOMPARE( storageLocation, QString() ); - break; + break; } #else QDesktopServices::storageLocation(location); QDesktopServices::displayName(location); -#endif +#endif } |