From d897ce42be8375ffab89615ab3953b8bd3ab3bbc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 28 Feb 2010 12:22:25 +0100 Subject: All the other (blank) tests.. --- src/tests/protocolhandler_test.cpp | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/tests/protocolhandler_test.cpp (limited to 'src/tests/protocolhandler_test.cpp') diff --git a/src/tests/protocolhandler_test.cpp b/src/tests/protocolhandler_test.cpp new file mode 100644 index 00000000..13e4212c --- /dev/null +++ b/src/tests/protocolhandler_test.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2010 Andrea Diamantini + * + * 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 + +#include +#include +#include + +#include "protocolhandler.h" + + +class ProtocolhandlerTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + + +private: + ProtocolHandler *handler; +}; + + +// ------------------------------------------- + +void ProtocolhandlerTest::initTestCase() +{ +} + + +void ProtocolhandlerTest::cleanupTestCase() +{ +} + + +// ------------------------------------------- + + +// ------------------------------------------- + +QTEST_MAIN(ProtocolhandlerTest) +#include "protocolhandler_test.moc" -- cgit v1.2.1 From e5e4ffa0e844c4f1cbe40eeaa309c4711c1073e6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 28 Feb 2010 17:05:37 +0100 Subject: 10 (of 12) tests working and ready to be "expanded".. --- src/tests/protocolhandler_test.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tests/protocolhandler_test.cpp') diff --git a/src/tests/protocolhandler_test.cpp b/src/tests/protocolhandler_test.cpp index 13e4212c..d738baea 100644 --- a/src/tests/protocolhandler_test.cpp +++ b/src/tests/protocolhandler_test.cpp @@ -21,9 +21,10 @@ #include -#include #include -#include +#include +#include + #include "protocolhandler.h" @@ -48,11 +49,13 @@ private: void ProtocolhandlerTest::initTestCase() { + handler = new ProtocolHandler; } void ProtocolhandlerTest::cleanupTestCase() { + delete handler; } @@ -61,5 +64,5 @@ void ProtocolhandlerTest::cleanupTestCase() // ------------------------------------------- -QTEST_MAIN(ProtocolhandlerTest) +QTEST_KDEMAIN(ProtocolhandlerTest,GUI) #include "protocolhandler_test.moc" -- cgit v1.2.1 From edea0f2fc34738de52a58f00c676e814f7a8c2fd Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 28 Feb 2010 23:58:31 +0100 Subject: First works on new Unit Tests.. --- src/tests/protocolhandler_test.cpp | 52 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src/tests/protocolhandler_test.cpp') diff --git a/src/tests/protocolhandler_test.cpp b/src/tests/protocolhandler_test.cpp index d738baea..71d8d9ec 100644 --- a/src/tests/protocolhandler_test.cpp +++ b/src/tests/protocolhandler_test.cpp @@ -24,7 +24,7 @@ #include #include #include - +#include #include "protocolhandler.h" @@ -38,8 +38,12 @@ public slots: void cleanupTestCase(); private slots: + void preHandling_data(); + void preHandling(); - + void postHandling_data(); + void postHandling(); + private: ProtocolHandler *handler; }; @@ -62,6 +66,50 @@ void ProtocolhandlerTest::cleanupTestCase() // ------------------------------------------- +void ProtocolhandlerTest::preHandling_data() +{ + QTest::addColumn("urlString"); + + 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"; +} + + +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 ); +} + + +void ProtocolhandlerTest::postHandling_data() +{ + QTest::addColumn("urlString"); + + 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"; +} + + +void ProtocolhandlerTest::postHandling() +{ +} + // ------------------------------------------- QTEST_KDEMAIN(ProtocolhandlerTest,GUI) -- cgit v1.2.1 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