diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/CMakeLists.txt | 144 | ||||
-rw-r--r-- | src/tests/findbar_test.cpp | 76 | ||||
-rw-r--r-- | src/tests/mainview_test.cpp | 217 | ||||
-rw-r--r-- | src/tests/mainwindow_test.cpp | 65 | ||||
-rw-r--r-- | src/tests/networkaccessmanager_test.cpp | 67 | ||||
-rw-r--r-- | src/tests/protocolhandler_test.cpp | 116 | ||||
-rw-r--r-- | src/tests/sessionmanager_test.cpp | 69 | ||||
-rw-r--r-- | src/tests/tabbar_test.cpp | 107 | ||||
-rw-r--r-- | src/tests/walletbar_test.cpp | 69 | ||||
-rw-r--r-- | src/tests/webpage_test.cpp | 112 | ||||
-rw-r--r-- | src/tests/websnap_test.cpp | 69 | ||||
-rw-r--r-- | src/tests/webtab_test.cpp | 68 | ||||
-rw-r--r-- | src/tests/webview_test.cpp | 71 |
13 files changed, 1071 insertions, 179 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 18de9299..e05a056b 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -2,11 +2,86 @@ SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) -INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR}/.. +INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_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} ${QT4_INCLUDES} ) +##### ------------- findbar test + +kde4_add_unit_test( findbar_test findbar_test.cpp ) + +target_link_libraries( findbar_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTGUI_LIBRARY} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- mainwindow test + +kde4_add_unit_test( mainwindow_test mainwindow_test.cpp ) + +target_link_libraries( mainwindow_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- mainview test + +kde4_add_unit_test( mainview_test mainview_test.cpp ) + +target_link_libraries( mainview_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- networkaccessmanager test + +kde4_add_unit_test( networkaccessmanager_test networkaccessmanager_test.cpp ) + +target_link_libraries( networkaccessmanager_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- protocolhandler test + +kde4_add_unit_test( protocolhandler_test protocolhandler_test.cpp ) + +target_link_libraries( protocolhandler_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- sessionmanager test + +kde4_add_unit_test( sessionmanager_test sessionmanager_test.cpp ) + +target_link_libraries( sessionmanager_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${QT_QTTEST_LIBRARY} +) + ##### ------------- tabbar test kde4_add_unit_test( tabbar_test tabbar_test.cpp ) @@ -18,15 +93,64 @@ target_link_libraries( tabbar_test ${QT_QTTEST_LIBRARY} ) -##### ------------- mainview test +##### ------------- walletbar test + +kde4_add_unit_test( walletbar_test walletbar_test.cpp ) + +target_link_libraries( walletbar_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- webpage test -# kde4_add_unit_test( mainview_test mainview_test.cpp ) -# -# target_link_libraries( mainview_test -# kdeinit_rekonq -# ${KDE4_KDECORE_LIBS} -# ${KDE4_KDEUI_LIBS} -# ${QT_QTTEST_LIBRARY} -# ) +kde4_add_unit_test( webpage_test webpage_test.cpp ) + +target_link_libraries( webpage_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- websnap test + +kde4_add_unit_test( websnap_test websnap_test.cpp ) + +target_link_libraries( websnap_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- webtab test + +kde4_add_unit_test( webtab_test webtab_test.cpp ) + +target_link_libraries( webtab_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) + +##### ------------- webview test + +kde4_add_unit_test( webview_test webview_test.cpp ) + +target_link_libraries( webview_test + kdeinit_rekonq + ${KDE4_KDECORE_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KDEWEBKIT_LIBS} + ${QT_QTTEST_LIBRARY} +) ############################################################ diff --git a/src/tests/findbar_test.cpp b/src/tests/findbar_test.cpp new file mode 100644 index 00000000..a79f44a2 --- /dev/null +++ b/src/tests/findbar_test.cpp @@ -0,0 +1,76 @@ +/* + * 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 <QtGui> +#include <QtTest/QtTest> + +#include "findbar.h" +#include "mainwindow.h" + + +class FindBarTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void matchCase(); + void notifyMatch(); + +private: + FindBar *bar; + MainWindow *w; +}; + + +// ------------------------------------------- + + +void FindBarTest::initTestCase() +{ + w = new MainWindow; + bar = new FindBar(w); +} + + +void FindBarTest::cleanupTestCase() +{ + delete bar; +} + +void FindBarTest::matchCase() +{ + +} + +void FindBarTest::notifyMatch() +{ +} + +// ------------------------------------------- + +QTEST_KDEMAIN(FindBarTest, GUI) +#include "findbar_test.moc" diff --git a/src/tests/mainview_test.cpp b/src/tests/mainview_test.cpp index f56d73ab..596ac4e1 100644 --- a/src/tests/mainview_test.cpp +++ b/src/tests/mainview_test.cpp @@ -27,12 +27,13 @@ #include <qtest_kde.h> -#include <QtTest> #include <QtCore> #include <QtGui> +#include <QtTest> -#include "../mainview.h" -#include "../webview.h" +#include "mainwindow.h" +#include "mainview.h" +#include "webview.h" class MainViewTest : public QObject @@ -42,8 +43,6 @@ class MainViewTest : public QObject public slots: void initTestCase(); void cleanupTestCase(); - void init(); - void cleanup(); private slots: void tabwidget_data(); @@ -75,38 +74,29 @@ private slots: void currentChanged_data(); void currentChanged(); + +private: + MainWindow *window; + MainView *view; }; -// Subclass that exposes the protected functions. -class SubMainView : public MainView -{ -public: - void call_resizeEvent(QResizeEvent *event) - { return SubMainView::resizeEvent(event); } -}; +// ------------------------------------------------------------------------------- // This will be called before the first test function is executed. // It is only called once. void MainViewTest::initTestCase() { + window = new MainWindow; + view = window->mainView(); } // This will be called after the last test function is executed. // It is only called once. void MainViewTest::cleanupTestCase() { -} - -// This will be called before each test function is executed. -void MainViewTest::init() -{ -} - -// This will be called after every test function. -void MainViewTest::cleanup() -{ +// delete window; // FIXME: this let the test fail. Why?? } // ------------------------------------------- @@ -117,14 +107,16 @@ void MainViewTest::tabwidget_data() void MainViewTest::tabwidget() { - SubMainView widget; -// widget.currentWebView(); -// QCOMPARE(widget.currentIndex(), 0); -// widget.newTab(); -// widget.nextTab(); -// QCOMPARE(widget.currentIndex(), 1); -// widget.previousTab(); -// QCOMPARE(widget.currentIndex(), 0); + QCOMPARE(view->currentIndex(), -1); + +// view->newTab(); +// QCOMPARE(view->currentIndex(), 1); +// view->newTab(); +// view->nextTab(); +// QCOMPARE(view->currentIndex(), 0); +// +// view->previousTab(); +// QCOMPARE(view->currentIndex(), 0); } // ------------------------------------------- @@ -135,33 +127,30 @@ void MainViewTest::closeTab_data() QTest::newRow("null") << 0; } -// public void closeTab(int index = -1) + void MainViewTest::closeTab() { - QFETCH(int, index); - - SubMainView widget; -/* - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); -QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); - - widget.newTab(); - widget.slotCloseTab(index); - widget.newTab(); - widget.slotCloseTab(index); - widget.newTab(); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy3.count(), 2); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0);*/ +// QFETCH(int, index); +// +// QSignalSpy spy1(view, SIGNAL(linkHovered(const QString &))); +// QSignalSpy spy2(view, SIGNAL(setCurrentTitle(const QString &))); +// QSignalSpy spy3(view, SIGNAL(tabsChanged())); +// QSignalSpy spy4(view, SIGNAL(lastTabClosed())); +// +// view->newTab(); +// view->closeTab(index); +// view->newTab(); +// view->closeTab(index); +// view->newTab(); +// +// QCOMPARE(spy1.count(), 0); +// QCOMPARE(spy2.count(), 2); +// QCOMPARE(spy3.count(), 0); +// QCOMPARE(spy4.count(), 0); } // ------------------------------------------- -Q_DECLARE_METATYPE(WebView*) void MainViewTest::currentWebView_data() { /* @@ -170,7 +159,6 @@ void MainViewTest::currentWebView_data() */ } -// public WebView *currentWebView() const void MainViewTest::currentWebView() { /* @@ -178,12 +166,12 @@ void MainViewTest::currentWebView() SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); QCOMPARE(widget.currentWebView(), currentWebView); @@ -205,31 +193,24 @@ void MainViewTest::newTab_data() QTest::newRow("null") << 0; } -// public void newTab() + void MainViewTest::newTab() { - /* - QFETCH(int, foo); - - SubMainView widget; - - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); - - widget.newTab(); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - */ - QSKIP("Test is not implemented.", SkipAll); +// QFETCH(int, foo); +// +// QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); +// QSignalSpy spy1(view, SIGNAL(setCurrentTitle(const QString &))); +// QSignalSpy spy2(view, SIGNAL(showStatusBarMessage(const QString &))); +// QSignalSpy spy3(view, SIGNAL(tabsChanged())); +// QSignalSpy spy4(view, SIGNAL(lastTabClosed())); +// +// view->newTab(); +// +// QCOMPARE(spy0.count(), 0); +// QCOMPARE(spy1.count(), 0); +// QCOMPARE(spy2.count(), 0); +// QCOMPARE(spy3.count(), 0); +// QCOMPARE(spy4.count(), 0); } // ------------------------------------------- @@ -248,12 +229,12 @@ void MainViewTest::nextTab() SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); widget.nextTab(); @@ -284,12 +265,12 @@ void MainViewTest::previousTab() SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); widget.previousTab(); @@ -314,12 +295,12 @@ void MainViewTest::recentlyClosedTabs() /* SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); QCOMPARE(spy0.count(), 0); QCOMPARE(spy2.count(), 0); @@ -347,12 +328,12 @@ void MainViewTest::setCurrentTitle(const QString &) SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); widget.call_setCurrentTitle(url); @@ -382,12 +363,12 @@ void MainViewTest::showStatusBarMessage(const QString &) SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); widget.call_showStatusBarMessage(message); @@ -403,14 +384,12 @@ void MainViewTest::showStatusBarMessage(const QString &) // ------------------------------------------- -// void slotCurrentChanged(int index); void MainViewTest::currentChanged_data() { QTest::addColumn<int>("foo"); QTest::newRow("null") << 0; } -// private slotCurrentChanged void MainViewTest::currentChanged() { /* @@ -418,12 +397,12 @@ void MainViewTest::currentChanged() SubMainView widget; - QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); - QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); - QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); - QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); - QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); - QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); + QSignalSpy spy0(view, SIGNAL(linkHovered(const QString &))); + QSignalSpy spy2(view, SIGNAL(loadProgress(int))); + QSignalSpy spy3(view, SIGNAL(setCurrentTitle(const QString &))); + QSignalSpy spy4(view, SIGNAL(showStatusBarMessage(const QString &))); + QSignalSpy spy5(view, SIGNAL(tabsChanged())); + QSignalSpy spy6(view, SIGNAL(lastTabClosed())); widget.call_tabsChanged(); diff --git a/src/tests/mainwindow_test.cpp b/src/tests/mainwindow_test.cpp new file mode 100644 index 00000000..d3ab6bef --- /dev/null +++ b/src/tests/mainwindow_test.cpp @@ -0,0 +1,65 @@ +/* + * 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 "mainwindow.h" +#include "application.h" + + +class MainWindowTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + + +private: + MainWindow *window; +}; + + +// ------------------------------------------- + + +void MainWindowTest::initTestCase() +{ + window = new MainWindow; +} + + +void MainWindowTest::cleanupTestCase() +{ +// delete window; +} + +// ------------------------------------------- + +QTEST_KDEMAIN(MainWindowTest,GUI) +#include "mainwindow_test.moc" diff --git a/src/tests/networkaccessmanager_test.cpp b/src/tests/networkaccessmanager_test.cpp new file mode 100644 index 00000000..68ffc108 --- /dev/null +++ b/src/tests/networkaccessmanager_test.cpp @@ -0,0 +1,67 @@ +/* + * 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 "networkaccessmanager.h" + + +class NetworkAccessManagerTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + NetworkAccessManager *manager; +}; + + +// ------------------------------------------- + +void NetworkAccessManagerTest::initTestCase() +{ + manager = new NetworkAccessManager; +} + + +void NetworkAccessManagerTest::cleanupTestCase() +{ + delete manager; +} + + +// ------------------------------------------- + + + +// ------------------------------------------- + +QTEST_KDEMAIN(NetworkAccessManagerTest,GUI) +#include "networkaccessmanager_test.moc" diff --git a/src/tests/protocolhandler_test.cpp b/src/tests/protocolhandler_test.cpp new file mode 100644 index 00000000..71d8d9ec --- /dev/null +++ b/src/tests/protocolhandler_test.cpp @@ -0,0 +1,116 @@ +/* + * 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 <QtWebKit> + +#include "protocolhandler.h" + + +class ProtocolhandlerTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void preHandling_data(); + void preHandling(); + + void postHandling_data(); + void postHandling(); + +private: + ProtocolHandler *handler; +}; + + +// ------------------------------------------- + +void ProtocolhandlerTest::initTestCase() +{ + handler = new ProtocolHandler; +} + + +void ProtocolhandlerTest::cleanupTestCase() +{ + delete handler; +} + + +// ------------------------------------------- + + +void ProtocolhandlerTest::preHandling_data() +{ + QTest::addColumn<QString>("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<QString>("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) +#include "protocolhandler_test.moc" diff --git a/src/tests/sessionmanager_test.cpp b/src/tests/sessionmanager_test.cpp new file mode 100644 index 00000000..e3e1b329 --- /dev/null +++ b/src/tests/sessionmanager_test.cpp @@ -0,0 +1,69 @@ +/* + * 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 "sessionmanager.h" + + +class SessionManagerTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + SessionManager *sessman; +}; + + +// ------------------------------------------- + + +void SessionManagerTest::initTestCase() +{ + sessman = new SessionManager; +} + + +void SessionManagerTest::cleanupTestCase() +{ + delete sessman; +} + + +// ------------------------------------------- + + + +// ------------------------------------------- + +QTEST_KDEMAIN(SessionManagerTest,GUI) +#include "sessionmanager_test.moc" diff --git a/src/tests/tabbar_test.cpp b/src/tests/tabbar_test.cpp index 7162e6a4..560f2c9b 100644 --- a/src/tests/tabbar_test.cpp +++ b/src/tests/tabbar_test.cpp @@ -24,29 +24,14 @@ #include <QtCore> #include <QtGui> -#include "../tabbar.h" +#include "mainwindow.h" +#include "mainview.h" +#include "tabbar.h" -class TabBarTest : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void tabbar_data(); - void tabbar(); - - void tabSizeHint_data(); - void tabSizeHint(); -}; - - -// Subclass that exposes the protected functions. +/** + * Subclass that exposes the protected functions. + */ class SubTabBar : public TabBar { public: @@ -70,62 +55,84 @@ public: }; -// This will be called before the first test function is executed. -// It is only called once. -void TabBarTest::initTestCase() -{ -} +// ------------------------------------------------------------------ -// This will be called after the last test function is executed. -// It is only called once. -void TabBarTest::cleanupTestCase() +class TabBarTest : public QObject { -} + Q_OBJECT +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void tabSizeHint_data(); + void tabSizeHint(); + + void mousePress_data(); + void mousePress(); + +private: + SubTabBar *_bar; +}; + + +// ------------------------------------------- -// This will be called before each test function is executed. -void TabBarTest::init() +void TabBarTest::initTestCase() { + MainWindow *w = new MainWindow; + MainView *mv = new MainView(w); + _bar = new SubTabBar(mv); } - -// This will be called after every test function. -void TabBarTest::cleanup() +void TabBarTest::cleanupTestCase() { + delete _bar; } // ------------------------------------------- -void TabBarTest::tabbar_data() +void TabBarTest::tabSizeHint_data() { + QTest::addColumn<int>("index"); + + QTest::newRow("1th") << 0; + QTest::newRow("2nd") << 1; + QTest::newRow("3rd") << 2; + QTest::newRow("4th") << 3; + QTest::newRow("5th") << 4; + QTest::newRow("6th") << 5; + QTest::newRow("7th") << 6; + QTest::newRow("8th") << 7; + QTest::newRow("9th") << 8; + QTest::newRow("10th") << 9; } -void TabBarTest::tabbar() +void TabBarTest::tabSizeHint() { - QWidget *w = new QWidget; - SubTabBar widget(w); + QFETCH(int, index); + + QVERIFY(_bar->call_tabSizeHint(index).width() > 0); } -// ------------------------------------------- -void TabBarTest::tabSizeHint_data() +void TabBarTest::mousePress_data() { -// QTest::addColumn<int>("index"); -// QTest::newRow("0") << 0; } -// protected QSize tabSizeHint(int index) const -void TabBarTest::tabSizeHint() +void TabBarTest::mousePress() { - // Need fixes as our function uses MainView methods to determine size -// QFETCH(int, index); -// SubTabBar bar; -// QVERIFY(bar.call_tabSizeHint(index).width() <= 250); +// QTest::mousePress(_bar, Qt::MidButton); +// // QCOMPARE(); ? +// +// QTest::mousePress(_bar, Qt::LeftButton); +// // QCOMPARE(); ? } - + // ------------------------------------------- QTEST_KDEMAIN(TabBarTest, GUI) diff --git a/src/tests/walletbar_test.cpp b/src/tests/walletbar_test.cpp new file mode 100644 index 00000000..ec9c3559 --- /dev/null +++ b/src/tests/walletbar_test.cpp @@ -0,0 +1,69 @@ +/* + * 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 "walletbar.h" + + +class WalletBarTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + WalletBar *bar; +}; + + +// ------------------------------------------- + + +void WalletBarTest::initTestCase() +{ + QWidget *w = new QWidget; + bar = new WalletBar(w); +} + + +void WalletBarTest::cleanupTestCase() +{ + delete bar; +} + + +// ------------------------------------------- + + + +// ------------------------------------------- + +QTEST_KDEMAIN(WalletBarTest,GUI) +#include "walletbar_test.moc" diff --git a/src/tests/webpage_test.cpp b/src/tests/webpage_test.cpp new file mode 100644 index 00000000..3051b8bf --- /dev/null +++ b/src/tests/webpage_test.cpp @@ -0,0 +1,112 @@ +/* + * 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 <QtWebKit> + +#include "webpage.h" +#include "webview.h" +#include "webtab.h" + + +class WebPageTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void manageNetworkErrors(); + void downloadRequest(); + void downloadAllContentsWithKGet(); + + void createWindow(); + void acceptNavigationRequest(); + + void handleUnsupportedContent(); + + void loadFinished(); + +private: + WebTab *tab; + WebPage *page; + WebView *view; +}; + + +// ------------------------------------------- + + +void WebPageTest::initTestCase() +{ + tab = new WebTab; + view = tab->view(); + page = tab->page(); +} + + +void WebPageTest::cleanupTestCase() +{ + delete tab; +} + + +// ------------------------------------------- + + +void WebPageTest::manageNetworkErrors() +{ +} + +void WebPageTest::downloadRequest() +{ +} + +void WebPageTest::downloadAllContentsWithKGet() +{ +} + +void WebPageTest::createWindow() +{ +} + +void WebPageTest::acceptNavigationRequest() +{ +} + +void WebPageTest::handleUnsupportedContent() +{ +} + +void WebPageTest::loadFinished() +{ +} + +// ------------------------------------------- + +QTEST_KDEMAIN(WebPageTest,GUI) +#include "webpage_test.moc" diff --git a/src/tests/websnap_test.cpp b/src/tests/websnap_test.cpp new file mode 100644 index 00000000..53fc1d4f --- /dev/null +++ b/src/tests/websnap_test.cpp @@ -0,0 +1,69 @@ +/* + * 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 <QtWebKit> + +#include "websnap.h" + + +class WebSnapTest : public QObject +{ + Q_OBJECT + + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + WebSnap *snap; +}; + + +// ------------------------------------------- + + +void WebSnapTest::initTestCase() +{ +} + + +void WebSnapTest::cleanupTestCase() +{ + delete snap; +} + + +// ------------------------------------------- + + + +// ------------------------------------------- + +QTEST_KDEMAIN(WebSnapTest,GUI) +#include "websnap_test.moc" diff --git a/src/tests/webtab_test.cpp b/src/tests/webtab_test.cpp new file mode 100644 index 00000000..2c6edf35 --- /dev/null +++ b/src/tests/webtab_test.cpp @@ -0,0 +1,68 @@ +/* + * 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 <QtWebKit> + +#include "webpage.h" +#include "webview.h" +#include "webtab.h" + + +class WebTabTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private: + WebTab *tab; +}; + + +// ------------------------------------------- + + +void WebTabTest::initTestCase() +{ + tab = new WebTab; +} + + +void WebTabTest::cleanupTestCase() +{ + delete tab; +} + + +// ------------------------------------------- + + +// ------------------------------------------- + +QTEST_KDEMAIN(WebTabTest,GUI) +#include "webtab_test.moc" diff --git a/src/tests/webview_test.cpp b/src/tests/webview_test.cpp new file mode 100644 index 00000000..11d1a46c --- /dev/null +++ b/src/tests/webview_test.cpp @@ -0,0 +1,71 @@ +/* + * 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 <QtWebKit> + +#include "webview.h" +#include "webtab.h" + + +class WebViewTest : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + +private: + WebView *view; + WebTab *tab; +}; + + +// ------------------------------------------- + + +void WebViewTest::initTestCase() +{ + tab = new WebTab; + view = tab->view(); +} + + +void WebViewTest::cleanupTestCase() +{ + delete tab; +} + + +// ------------------------------------------- + + +// ------------------------------------------- + +QTEST_KDEMAIN(WebViewTest,GUI) +#include "webview_test.moc" |