diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/tests/networkaccessmanager_test.cpp | 2 | ||||
-rw-r--r-- | src/tests/protocolhandler_test.cpp | 56 | ||||
-rw-r--r-- | src/tests/urlbar_test.cpp | 74 |
4 files changed, 123 insertions, 23 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index e05a056b..3bc9a27f 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -7,7 +7,6 @@ INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../adblock ${CMAKE_CURRENT_SOURCE_DIR}/../bookmarks ${CMAKE_CURRENT_SOURCE_DIR}/../history - ${CMAKE_CURRENT_SOURCE_DIR}/../rekonqpage ${CMAKE_CURRENT_SOURCE_DIR}/../settings ${CMAKE_CURRENT_SOURCE_DIR}/../urlbar ${KDE4_INCLUDES} @@ -68,6 +67,7 @@ target_link_libraries( protocolhandler_test ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTNETWORK_LIBRARY} ${QT_QTTEST_LIBRARY} ) @@ -153,4 +153,16 @@ target_link_libraries( webview_test ${QT_QTTEST_LIBRARY} ) +##### ------------- urlbar test + +kde4_add_unit_test( urlbar_test urlbar_test.cpp ) + +target_link_libraries( urlbar_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + ############################################################ diff --git a/src/tests/networkaccessmanager_test.cpp b/src/tests/networkaccessmanager_test.cpp index 68ffc108..ac6cf89e 100644 --- a/src/tests/networkaccessmanager_test.cpp +++ b/src/tests/networkaccessmanager_test.cpp @@ -47,7 +47,7 @@ private: void NetworkAccessManagerTest::initTestCase() { - manager = new NetworkAccessManager; + manager = new NetworkAccessManager(this); } 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 <QtCore> #include <QtGui> #include <QtTest> +#include <QtNetwork> #include <QtWebKit> #include "protocolhandler.h" @@ -69,45 +70,58 @@ void ProtocolhandlerTest::cleanupTestCase() void ProtocolhandlerTest::preHandling_data() { QTest::addColumn<QString>("urlString"); + QTest::addColumn<bool>("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<QString>("urlString"); + QTest::addColumn<bool>("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 ); } // ------------------------------------------- diff --git a/src/tests/urlbar_test.cpp b/src/tests/urlbar_test.cpp new file mode 100644 index 00000000..7a1fb40b --- /dev/null +++ b/src/tests/urlbar_test.cpp @@ -0,0 +1,74 @@ +/* + * Copyright 2010 Andrea Diamantini <adjam7@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + + + +#include <qtest_kde.h> + +#include <QtCore> +#include <QtGui> +#include <QtTest> + +#include "webpage.h" +#include "webview.h" +#include "webtab.h" + +#include "urlbar.h" + + +class UrlBarTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + UrlBar *bar; + WebTab *tab; +}; + + +// ------------------------------------------- + +void UrlBarTest::initTestCase() +{ + tab = new WebTab; + bar = new UrlBar(tab); +} + + +void UrlBarTest::cleanupTestCase() +{ + delete bar; + delete tab; +} + + +// ------------------------------------------- + + + +// ------------------------------------------- + +QTEST_KDEMAIN(UrlBarTest,GUI) +#include "urlbar_test.moc" |