diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/findbar.cpp | 19 | ||||
-rw-r--r-- | src/findbar.h | 3 | ||||
-rw-r--r-- | src/tabbar.cpp | 4 | ||||
-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 |
16 files changed, 1086 insertions, 190 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp index 43b23035..bb693ab0 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -29,12 +29,14 @@ #include "findbar.h" #include "findbar.moc" +// Local Includes +#include "mainwindow.h" + // KDE Includes #include <KLineEdit> #include <KIcon> #include <KPushButton> #include <klocalizedstring.h> -#include <KMainWindow> #include <KApplication> // Qt Includes @@ -47,8 +49,8 @@ #include <QtCore/QTimer> -FindBar::FindBar(KMainWindow *mainwindow) - : QWidget(mainwindow) +FindBar::FindBar(QWidget *parent) + : QWidget(parent) , m_lineEdit(new KLineEdit(this)) , m_matchCase(new QCheckBox(i18n("&Match case"), this)) , m_hideTimer(new QTimer(this)) @@ -73,24 +75,27 @@ FindBar::FindBar(KMainWindow *mainwindow) QLabel *label = new QLabel(i18n("Find:")); layout->addWidget(label); + // mainwindow pointer + MainWindow *window = qobject_cast<MainWindow *>(parent); + // lineEdit, focusProxy setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); - connect(m_lineEdit, SIGNAL(textChanged(const QString &)), mainwindow, SLOT(find(const QString &))); + connect(m_lineEdit, SIGNAL(textChanged(const QString &)), window, SLOT(find(const QString &))); layout->addWidget(m_lineEdit); // buttons KPushButton *findNext = new KPushButton(KIcon("go-down"), i18n("&Next"), this); KPushButton *findPrev = new KPushButton(KIcon("go-up"), i18n("&Previous"), this); - connect(findNext, SIGNAL(clicked()), mainwindow, SLOT(findNext())); - connect(findPrev, SIGNAL(clicked()), mainwindow, SLOT(findPrevious())); + connect(findNext, SIGNAL(clicked()), window, SLOT(findNext())); + connect(findPrev, SIGNAL(clicked()), window, SLOT(findPrevious())); layout->addWidget(findNext); layout->addWidget(findPrev); // Case sensitivity. Deliberately set so this is off by default. m_matchCase->setCheckState(Qt::Unchecked); m_matchCase->setTristate(false); - connect(m_matchCase, SIGNAL(toggled(bool)), mainwindow, SLOT(matchCaseUpdate())); + connect(m_matchCase, SIGNAL(toggled(bool)), window, SLOT(matchCaseUpdate())); layout->addWidget(m_matchCase); // stretching widget on the left diff --git a/src/findbar.h b/src/findbar.h index c192b498..7a4efc59 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -40,7 +40,6 @@ #include <QtGui/QCheckBox> // Forward Declarations -class KMainWindow; class QString; @@ -49,7 +48,7 @@ class REKONQ_TESTS_EXPORT FindBar : public QWidget Q_OBJECT public: - FindBar(KMainWindow *mainwindow); + FindBar(QWidget *parent); ~FindBar(); KLineEdit *lineEdit() const; bool matchCase() const; diff --git a/src/tabbar.cpp b/src/tabbar.cpp index ff996cb5..49ed230b 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -93,13 +93,13 @@ QSize TabBar::tabSizeHint(int index) const int minWidth = view->sizeHint().width()/MIN_WIDTH_DIVISOR; int w; - if (baseWidth*count()<tabBarWidth) + if (baseWidth*count() < tabBarWidth) { w = baseWidth; } else { - if (count() > 0 && tabBarWidth/count()>minWidth) + if (count() > 0 && tabBarWidth/count() > minWidth) { w = tabBarWidth/count(); } 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" |