diff options
Diffstat (limited to 'src/tests/tabbar_test.cpp')
-rw-r--r-- | src/tests/tabbar_test.cpp | 141 |
1 files changed, 75 insertions, 66 deletions
diff --git a/src/tests/tabbar_test.cpp b/src/tests/tabbar_test.cpp index 08f295d1..6df38657 100644 --- a/src/tests/tabbar_test.cpp +++ b/src/tests/tabbar_test.cpp @@ -24,116 +24,125 @@ #include <QtCore> #include <QtGui> -#include "../tabbar.h" +#include "mainwindow.h" +#include "mainview.h" +#include "tabbar.h" -class TabBarTest : public QObject +/** + * Subclass that exposes the protected functions. + */ +class SubTabBar : public TabBar { - Q_OBJECT +public: -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); + SubTabBar(QWidget *parent) : TabBar(parent) {}; -private slots: - void tabbar_data(); - void tabbar(); + QSize call_tabSizeHint(int index) const + { + return SubTabBar::tabSizeHint(index); + } - void tabSizeHint_data(); - void tabSizeHint(); -}; + void call_mouseMoveEvent(QMouseEvent* event) + { + return SubTabBar::mouseMoveEvent(event); + } + void call_leaveEvent(QEvent* event) + { + return SubTabBar::leaveEvent(event); + } -// Subclass that exposes the protected functions. -class SubTabBar : public TabBar -{ -public: - void call_cloneTab(int index) - { return SubTabBar::cloneTab(index); } + void call_mousePressEvent(QMouseEvent* event) + { + return SubTabBar::mousePressEvent(event); + } + + void call_mouseReleaseEvent(QMouseEvent* event) + { + return SubTabBar::mouseReleaseEvent(event); + } +}; - void call_closeOtherTabs(int index) - { return SubTabBar::closeOtherTabs(index); } - void call_closeTab(int index) - { return SubTabBar::closeTab(index); } +// ------------------------------------------------------------------ - void call_mouseMoveEvent(QMouseEvent* event) - { return SubTabBar::mouseMoveEvent(event); } - void call_mousePressEvent(QMouseEvent* event) - { return SubTabBar::mousePressEvent(event); } +class TabBarTest : public QObject +{ + Q_OBJECT - void call_reloadAllTabs() - { return SubTabBar::reloadAllTabs(); } +public slots: + void initTestCase(); + void cleanupTestCase(); - void call_reloadTab(int index) - { return SubTabBar::reloadTab(index); } +private slots: + void tabSizeHint_data(); + void tabSizeHint(); - QSize call_tabSizeHint(int index) const - { return SubTabBar::tabSizeHint(index); } + void mousePress_data(); + void mousePress(); - void call_showTabPreview(int tab) - { return SubTabBar::showTabPreview(tab); } +private: + SubTabBar *_bar; }; -// This will be called before the first test function is executed. -// It is only called once. +// ------------------------------------------- + void TabBarTest::initTestCase() { + MainWindow *w = new MainWindow; + MainView *mv = new MainView(w); + _bar = new SubTabBar(mv); } - -// This will be called after the last test function is executed. -// It is only called once. void TabBarTest::cleanupTestCase() { + delete _bar; } +// ------------------------------------------- -// This will be called before each test function is executed. -void TabBarTest::init() +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; } -// This will be called after every test function. -void TabBarTest::cleanup() +void TabBarTest::tabSizeHint() { -} - -// ------------------------------------------- + QFETCH(int, index); -void TabBarTest::tabbar_data() -{ + QVERIFY(_bar->call_tabSizeHint(index).width() > 0); } -void TabBarTest::tabbar() +void TabBarTest::mousePress_data() { - SubTabBar widget; } -// ------------------------------------------- -void TabBarTest::tabSizeHint_data() +void TabBarTest::mousePress() { -// QTest::addColumn<int>("index"); -// QTest::newRow("0") << 0; +// QTest::mousePress(_bar, Qt::MidButton); +// // QCOMPARE(); ? +// +// QTest::mousePress(_bar, Qt::LeftButton); +// // QCOMPARE(); ? } - -// protected QSize tabSizeHint(int index) const -void TabBarTest::tabSizeHint() -{ - // Need fixes as our function uses MainView methods to determine size -// QFETCH(int, index); -// SubTabBar bar; -// QVERIFY(bar.call_tabSizeHint(index).width() <= 250); -} - // ------------------------------------------- QTEST_KDEMAIN(TabBarTest, GUI) |