From 0f1dfeac60cdf35e44838b1323d98db8383738c7 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 27 Feb 2010 15:29:58 +0100 Subject: New (embrional) unit tests: mainview, tabbar, webtab, webpage --- src/tests/mainview_test.cpp | 47 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/tests/mainview_test.cpp') diff --git a/src/tests/mainview_test.cpp b/src/tests/mainview_test.cpp index f56d73ab..1dfffcbe 100644 --- a/src/tests/mainview_test.cpp +++ b/src/tests/mainview_test.cpp @@ -31,8 +31,21 @@ #include #include -#include "../mainview.h" -#include "../webview.h" +#include "mainview.h" +#include "webview.h" + + +// Subclass that exposes the protected functions. +class SubMainView : public MainView +{ +public: + SubMainView(MainWindow *parent) : MainView(parent) {}; + + void call_resizeEvent(QResizeEvent *event) + { return SubMainView::resizeEvent(event); } +}; + +// ----------------------------------------------------------- class MainViewTest : public QObject @@ -42,8 +55,6 @@ class MainViewTest : public QObject public slots: void initTestCase(); void cleanupTestCase(); - void init(); - void cleanup(); private slots: void tabwidget_data(); @@ -75,38 +86,30 @@ private slots: void currentChanged_data(); void currentChanged(); + +private: + MainWindow *mainWindow; + SubMainView *mainView; }; -// 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() { + mainWindow = new MainWindow; + mainView = new SubMainView(mainWindow); } // 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 mainView; + delete mainWindow; } // ------------------------------------------- @@ -117,7 +120,6 @@ void MainViewTest::tabwidget_data() void MainViewTest::tabwidget() { - SubMainView widget; // widget.currentWebView(); // QCOMPARE(widget.currentIndex(), 0); // widget.newTab(); @@ -140,7 +142,6 @@ void MainViewTest::closeTab() { QFETCH(int, index); - SubMainView widget; /* QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); -- cgit v1.2.1