|
|
|
@ -23,16 +23,6 @@ static const QUrl makeUrlFromCwd( const QString& u, const QString& ref = QString |
|
|
|
return url; |
|
|
|
return url; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool fileExist_always_Func( const QString& ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool fileExist_never_Func( const QString& ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ShellTest |
|
|
|
class ShellTest |
|
|
|
: public QObject |
|
|
|
: public QObject |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -52,35 +42,28 @@ void ShellTest::initTestCase() |
|
|
|
void ShellTest::testUrlArgs_data() |
|
|
|
void ShellTest::testUrlArgs_data() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QTest::addColumn<QString>( "arg" ); |
|
|
|
QTest::addColumn<QString>( "arg" ); |
|
|
|
QTest::addColumn<bool>( "exists" ); |
|
|
|
|
|
|
|
QTest::addColumn<QUrl>( "resUrl" ); |
|
|
|
QTest::addColumn<QUrl>( "resUrl" ); |
|
|
|
|
|
|
|
|
|
|
|
// local files
|
|
|
|
// local files
|
|
|
|
QTest::newRow( "foo.pdf, exist" ) |
|
|
|
QTest::newRow( "foo.pdf, exist" ) |
|
|
|
<< "foo.pdf" |
|
|
|
<< "foo.pdf" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf") ); |
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf") ); |
|
|
|
QTest::newRow( "foo.pdf, !exist" ) |
|
|
|
QTest::newRow( "foo.pdf, !exist" ) |
|
|
|
<< "foo.pdf" |
|
|
|
<< "foo.pdf" |
|
|
|
<< false |
|
|
|
|
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf") ); |
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf") ); |
|
|
|
QTest::newRow( "foo#bar.pdf, !exist" ) |
|
|
|
QTest::newRow( "foo#bar.pdf, !exist" ) |
|
|
|
<< "foo#bar.pdf" |
|
|
|
<< "foo#bar.pdf" |
|
|
|
<< false |
|
|
|
|
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo#bar.pdf") ); |
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo#bar.pdf") ); |
|
|
|
QTest::newRow( "foo.pdf#anchor, !exist" ) |
|
|
|
QTest::newRow( "foo.pdf#anchor, !exist" ) |
|
|
|
<< "foo.pdf#anchor" |
|
|
|
<< "foo.pdf#anchor" |
|
|
|
<< false |
|
|
|
|
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf"), QStringLiteral("anchor") ); |
|
|
|
<< makeUrlFromCwd( QStringLiteral("foo.pdf"), QStringLiteral("anchor") ); |
|
|
|
QTest::newRow( "#207461" ) |
|
|
|
QTest::newRow( "#207461" ) |
|
|
|
<< "file:///tmp/file%20with%20spaces.pdf" |
|
|
|
<< "file:///tmp/file%20with%20spaces.pdf" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< QUrl( QStringLiteral("file:///tmp/file%20with%20spaces.pdf") ); |
|
|
|
<< QUrl( QStringLiteral("file:///tmp/file%20with%20spaces.pdf") ); |
|
|
|
|
|
|
|
|
|
|
|
// non-local files
|
|
|
|
// non-local files
|
|
|
|
QTest::newRow( "http://kde.org/foo.pdf" ) |
|
|
|
QTest::newRow( "http://kde.org/foo.pdf" ) |
|
|
|
<< "http://kde.org/foo.pdf" |
|
|
|
<< "http://kde.org/foo.pdf" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< QUrl( QStringLiteral("http://kde.org/foo.pdf") ); |
|
|
|
<< QUrl( QStringLiteral("http://kde.org/foo.pdf") ); |
|
|
|
// make sure we don't have a fragment
|
|
|
|
// make sure we don't have a fragment
|
|
|
|
QUrl hashInName( QStringLiteral("http://kde.org") ); |
|
|
|
QUrl hashInName( QStringLiteral("http://kde.org") ); |
|
|
|
@ -89,33 +72,28 @@ void ShellTest::testUrlArgs_data() |
|
|
|
QVERIFY( hashInName.fragment().isEmpty() ); |
|
|
|
QVERIFY( hashInName.fragment().isEmpty() ); |
|
|
|
QTest::newRow( "http://kde.org/foo#bar.pdf" ) |
|
|
|
QTest::newRow( "http://kde.org/foo#bar.pdf" ) |
|
|
|
<< "http://kde.org/foo#bar.pdf" |
|
|
|
<< "http://kde.org/foo#bar.pdf" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< hashInName; |
|
|
|
<< hashInName; |
|
|
|
QUrl withAnchor( QStringLiteral("http://kde.org/foo.pdf") ); |
|
|
|
QUrl withAnchor( QStringLiteral("http://kde.org/foo.pdf") ); |
|
|
|
withAnchor.setFragment( QStringLiteral("anchor") ); |
|
|
|
withAnchor.setFragment( QStringLiteral("anchor") ); |
|
|
|
QTest::newRow( "http://kde.org/foo.pdf#anchor" ) |
|
|
|
QTest::newRow( "http://kde.org/foo.pdf#anchor" ) |
|
|
|
<< "http://kde.org/foo.pdf#anchor" |
|
|
|
<< "http://kde.org/foo.pdf#anchor" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< withAnchor; |
|
|
|
<< withAnchor; |
|
|
|
QTest::newRow( "#207461" ) |
|
|
|
QTest::newRow( "#207461" ) |
|
|
|
<< "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" |
|
|
|
<< "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< QUrl( QStringLiteral("http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf") ); |
|
|
|
<< QUrl( QStringLiteral("http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf") ); |
|
|
|
QUrl openOnPage3 = QUrl( QStringLiteral("http://itzsimpl.info/lectures/CG/L2-transformations.pdf") ); |
|
|
|
QUrl openOnPage3 = QUrl( QStringLiteral("http://itzsimpl.info/lectures/CG/L2-transformations.pdf") ); |
|
|
|
openOnPage3.setFragment( QStringLiteral("3") ); |
|
|
|
openOnPage3.setFragment( QStringLiteral("3") ); |
|
|
|
QTest::newRow( "RR124738" ) |
|
|
|
QTest::newRow( "RR124738" ) |
|
|
|
<< "http://itzsimpl.info/lectures/CG/L2-transformations.pdf#3" |
|
|
|
<< "http://itzsimpl.info/lectures/CG/L2-transformations.pdf#3" |
|
|
|
<< true |
|
|
|
|
|
|
|
<< openOnPage3; |
|
|
|
<< openOnPage3; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ShellTest::testUrlArgs() |
|
|
|
void ShellTest::testUrlArgs() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFETCH( QString, arg ); |
|
|
|
QFETCH( QString, arg ); |
|
|
|
QFETCH( bool, exists ); |
|
|
|
|
|
|
|
QFETCH( QUrl, resUrl ); |
|
|
|
QFETCH( QUrl, resUrl ); |
|
|
|
qDebug() << "Expected url:" << resUrl << "path =" << resUrl.path() << "fragment =" << resUrl.fragment(); |
|
|
|
qDebug() << "Expected url:" << resUrl << "path =" << resUrl.path() << "fragment =" << resUrl.fragment(); |
|
|
|
QUrl url = ShellUtils::urlFromArg( arg, exists ? fileExist_always_Func : fileExist_never_Func ); |
|
|
|
QUrl url = ShellUtils::urlFromArg( arg ); |
|
|
|
QCOMPARE( url, resUrl ); |
|
|
|
QCOMPARE( url, resUrl ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|