File indexing completed on 2024-05-12 04:19:59
0001 /* 0002 Gwenview: an image viewer 0003 Copyright 2009 Aurélien Gâteau <agateau@kde.org> 0004 0005 This program is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU General Public License 0007 as published by the Free Software Foundation; either version 2 0008 of the License, or (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 0019 */ 0020 #include "urlutilstest.h" 0021 0022 // Qt 0023 #include <QDir> 0024 #include <QTest> 0025 0026 // KF 0027 0028 // Local 0029 #include "../lib/urlutils.h" 0030 0031 QTEST_MAIN(UrlUtilsTest) 0032 0033 using namespace Gwenview; 0034 0035 void UrlUtilsTest::testFixUserEnteredUrl() 0036 { 0037 QFETCH(QUrl, in); 0038 QFETCH(QUrl, expected); 0039 QUrl out = UrlUtils::fixUserEnteredUrl(in); 0040 QCOMPARE(out.url(), expected.url()); 0041 } 0042 0043 #define NEW_ROW(in, expected) QTest::newRow(QString(in).toLocal8Bit().data()) << QUrl(in) << QUrl(expected) 0044 void UrlUtilsTest::testFixUserEnteredUrl_data() 0045 { 0046 QTest::addColumn<QUrl>("in"); 0047 QTest::addColumn<QUrl>("expected"); 0048 0049 QString pwd = QDir::currentPath(); 0050 0051 NEW_ROW("http://example.com", "http://example.com"); 0052 NEW_ROW("file://" + pwd + "/example.zip", "zip:" + pwd + "/example.zip"); 0053 NEW_ROW("file://" + pwd + "/example.cbz", "zip:" + pwd + "/example.cbz"); 0054 NEW_ROW("file://" + pwd + "/example.jpg", "file://" + pwd + "/example.jpg"); 0055 // Check it does not get turned into gzip://... 0056 NEW_ROW("file://" + pwd + "/example.svgz", "file://" + pwd + "/example.svgz"); 0057 } 0058 0059 #include "moc_urlutilstest.cpp"