summaryrefslogtreecommitdiff
path: root/src/tests/mainview_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/mainview_test.cpp')
-rw-r--r--src/tests/mainview_test.cpp239
1 files changed, 109 insertions, 130 deletions
diff --git a/src/tests/mainview_test.cpp b/src/tests/mainview_test.cpp
index f56d73ab..d32eb58f 100644
--- a/src/tests/mainview_test.cpp
+++ b/src/tests/mainview_test.cpp
@@ -11,9 +11,9 @@
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
+* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
-*
+*
* 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
@@ -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,71 +43,60 @@ class MainViewTest : public QObject
public slots:
void initTestCase();
void cleanupTestCase();
- void init();
- void cleanup();
private slots:
void tabwidget_data();
void tabwidget();
-
+
void closeTab_data();
void closeTab();
-
+
void currentWebView_data();
void currentWebView();
-
+
void newTab_data();
void newTab();
-
+
void nextTab_data();
void nextTab();
-
+
void previousTab_data();
void previousTab();
-
+
void recentlyClosedTabs_data();
void recentlyClosedTabs();
-
+
void setCurrentTitle_data();
void setCurrentTitle(const QString &);
-
+
void showStatusBarMessage_data();
void showStatusBarMessage(const QString &);
-
+
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();