From a708a0e447af81412599ec16e8d47e06dc584eb0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Apr 2010 16:43:10 +0200 Subject: New (empty) urlbar test and improved protocolhandler test --- src/tests/protocolhandler_test.cpp | 56 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'src/tests/protocolhandler_test.cpp') diff --git a/src/tests/protocolhandler_test.cpp b/src/tests/protocolhandler_test.cpp index 71d8d9ec..a3c78c2f 100644 --- a/src/tests/protocolhandler_test.cpp +++ b/src/tests/protocolhandler_test.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "protocolhandler.h" @@ -69,45 +70,58 @@ void ProtocolhandlerTest::cleanupTestCase() void ProtocolhandlerTest::preHandling_data() { QTest::addColumn("urlString"); + QTest::addColumn("result"); - QTest::newRow("mailto") << "mailto:me@here.com"; - QTest::newRow("relative") << "google.it"; - QTest::newRow("javascript") << "javascript:alertbox('hello')"; - QTest::newRow("aboutblank") << "about:blank"; - QTest::newRow("abouthome") << "about:home"; - QTest::newRow("ftp") << "ftp://ftp.kde.org"; - QTest::newRow("file") << "file:///home"; + QTest::newRow("mailto") << "mailto:me@here.com" << true ; + QTest::newRow("relative") << "google.it" << false ; + QTest::newRow("javascript") << "javascript:alertbox('hello')" << true ; + QTest::newRow("aboutblank") << "about:blank" << false ; + QTest::newRow("abouthome") << "about:home" << true ; + QTest::newRow("ftp") << "ftp://ftp.kde.org" << false ; + QTest::newRow("file") << "file:///home" << false ; } void ProtocolhandlerTest::preHandling() { -// QFETCH( QString, urlString ); -// -// QWebView *view = new QWebView; -// QWebFrame *frame = view->page()->mainFrame(); -// -// QNetworkRequest *request = new QNetworkRequest( QUrl(urlString) ); -// handler->preHandling( request, frame ); + QFETCH( QString, urlString ); + QFETCH( bool , result ); + + QWebView *view = new QWebView; + QWebFrame *frame = view->page()->mainFrame(); + + QNetworkRequest request = QNetworkRequest( QUrl(urlString) ); + + QCOMPARE( handler->preHandling( request, frame ) , result ); } void ProtocolhandlerTest::postHandling_data() { QTest::addColumn("urlString"); + QTest::addColumn("result"); - QTest::newRow("mailto") << "mailto:me@here.com"; - QTest::newRow("relative") << "google.it"; - QTest::newRow("javascript") << "javascript:alertbox('hello')"; - QTest::newRow("aboutblank") << "about:blank"; - QTest::newRow("abouthome") << "about:home"; - QTest::newRow("ftp") << "ftp://ftp.kde.org"; - QTest::newRow("file") << "file:///home"; + QTest::newRow("mailto") << "mailto:me@here.com" << true ; + QTest::newRow("relative") << "google.it" << false ; + QTest::newRow("javascript") << "javascript:alertbox('hello')" << false ; + QTest::newRow("aboutblank") << "about:blank" << false ; + QTest::newRow("abouthome") << "about:home" << false ; + QTest::newRow("ftp") << "ftp://ftp.kde.org" << true ; + QTest::newRow("file") << "file:///home" << true ; } void ProtocolhandlerTest::postHandling() { + QFETCH( QString, urlString ); + QFETCH( bool , result ); + + QWebView *view = new QWebView; + QWebFrame *frame = view->page()->mainFrame(); + + QNetworkRequest request = QNetworkRequest( QUrl(urlString) ); + + QCOMPARE( handler->postHandling( request, frame ) , result ); } // ------------------------------------------- -- cgit v1.2.1