summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-02-28 23:58:31 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-02-28 23:58:31 +0100
commitedea0f2fc34738de52a58f00c676e814f7a8c2fd (patch)
treed95082318d2e71d0a35847e92150b0d3762d094b
parentOk, we have 12 empty tests working... :) (diff)
downloadrekonq-edea0f2fc34738de52a58f00c676e814f7a8c2fd.tar.xz
First works on new Unit Tests..
-rw-r--r--src/tests/CMakeLists.txt1
-rw-r--r--src/tests/findbar_test.cpp1
-rw-r--r--src/tests/mainview_test.cpp183
-rw-r--r--src/tests/protocolhandler_test.cpp52
-rw-r--r--src/tests/webpage_test.cpp12
-rw-r--r--src/tests/websnap_test.cpp1
-rw-r--r--src/tests/webview_test.cpp2
7 files changed, 141 insertions, 111 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 0230a5ce..e05a056b 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -67,6 +67,7 @@ target_link_libraries( protocolhandler_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
index 6b81255f..a79f44a2 100644
--- a/src/tests/findbar_test.cpp
+++ b/src/tests/findbar_test.cpp
@@ -63,6 +63,7 @@ void FindBarTest::cleanupTestCase()
void FindBarTest::matchCase()
{
+
}
void FindBarTest::notifyMatch()
diff --git a/src/tests/mainview_test.cpp b/src/tests/mainview_test.cpp
index 94e7fc30..596ac4e1 100644
--- a/src/tests/mainview_test.cpp
+++ b/src/tests/mainview_test.cpp
@@ -96,7 +96,7 @@ void MainViewTest::initTestCase()
// It is only called once.
void MainViewTest::cleanupTestCase()
{
-// delete window;
+// delete window; // FIXME: this let the test fail. Why??
}
// -------------------------------------------
@@ -107,13 +107,16 @@ void MainViewTest::tabwidget_data()
void MainViewTest::tabwidget()
{
-// 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);
}
// -------------------------------------------
@@ -124,32 +127,30 @@ void MainViewTest::closeTab_data()
QTest::newRow("null") << 0;
}
-// public void closeTab(int index = -1)
+
void MainViewTest::closeTab()
{
- QFETCH(int, index);
-
-/*
- 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()
{
/*
@@ -158,7 +159,6 @@ void MainViewTest::currentWebView_data()
*/
}
-// public WebView *currentWebView() const
void MainViewTest::currentWebView()
{
/*
@@ -166,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);
@@ -193,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);
}
// -------------------------------------------
@@ -236,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();
@@ -272,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();
@@ -302,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);
@@ -335,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);
@@ -370,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);
@@ -391,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()
{
/*
@@ -406,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/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 <QtCore>
#include <QtGui>
#include <QtTest>
-
+#include <QtWebKit>
#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<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)
diff --git a/src/tests/webpage_test.cpp b/src/tests/webpage_test.cpp
index 3527f1ed..3051b8bf 100644
--- a/src/tests/webpage_test.cpp
+++ b/src/tests/webpage_test.cpp
@@ -34,10 +34,6 @@
class WebPageTest : public QObject
{
Q_OBJECT
-
-public:
- WebPageTest();
- virtual ~WebPageTest();
public slots:
void initTestCase();
@@ -65,14 +61,6 @@ private:
// -------------------------------------------
-WebPageTest::WebPageTest()
-{}
-
-
-WebPageTest::~WebPageTest()
-{}
-
-
void WebPageTest::initTestCase()
{
tab = new WebTab;
diff --git a/src/tests/websnap_test.cpp b/src/tests/websnap_test.cpp
index e77e365b..53fc1d4f 100644
--- a/src/tests/websnap_test.cpp
+++ b/src/tests/websnap_test.cpp
@@ -50,7 +50,6 @@ private:
void WebSnapTest::initTestCase()
{
-// snap = new WebSnap;
}
diff --git a/src/tests/webview_test.cpp b/src/tests/webview_test.cpp
index 92431d96..11d1a46c 100644
--- a/src/tests/webview_test.cpp
+++ b/src/tests/webview_test.cpp
@@ -29,6 +29,7 @@
#include "webview.h"
#include "webtab.h"
+
class WebViewTest : public QObject
{
Q_OBJECT
@@ -57,6 +58,7 @@ void WebViewTest::initTestCase()
void WebViewTest::cleanupTestCase()
{
+ delete tab;
}