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/tabbar_test.cpp | 107 ++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'src/tests/tabbar_test.cpp') 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 #include -#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("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("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) -- cgit v1.2.1