#include <QtTest/QtTest>
#include <QtCore>
-#include <QWidget>
+#include "ui/panelbase.h"
#include "ui/tabbedpanel.h"
class TestTabbedPanel : public QObject
void TestTabbedPanel::testPanelToggling()
{
- TabbedPanel *testPanel = new TabbedPanel();
+ TabbedPanel *testTabbedPanel = new TabbedPanel;
- QWidget *testWidget = new QWidget();
- testPanel->addTab(testWidget, QIcon(":/res/images/user_info.png"));
+ PanelBase *testPanel = new PanelBase;
+ testTabbedPanel->addTab(testPanel, QIcon(":/res/images/user_info.png"));
- QSignalSpy closedSpy(testPanel, SIGNAL(panelClosed()));
- QSignalSpy openedSpy(testPanel, SIGNAL(panelOpened()));
- QSignalSpy toggleSpy(testPanel, SIGNAL(toggleState()));
+ QSignalSpy closedSpy(testTabbedPanel, SIGNAL(panelClosed()));
+ QSignalSpy openedSpy(testTabbedPanel, SIGNAL(panelOpened()));
+ QSignalSpy toggleSpy(testTabbedPanel, SIGNAL(toggleState()));
// Check that everything is initialized properly
QVERIFY(closedSpy.isValid());
QCOMPARE(toggleSpy.count(), 0);
// Try to close the panel. As the panel is closed, no signals should be sent.
- testPanel->closePanel();
+ testTabbedPanel->closePanel();
QTest::qWait(1);
QCOMPARE(closedSpy.count(), 0);
QCOMPARE(openedSpy.count(), 0);
QCOMPARE(toggleSpy.count(), 0);
// Now try to open the panel, only toggleState and panelOpened signals should be sent
- testPanel->showPanel(testWidget);
+ testTabbedPanel->openPanel(testPanel);
QTest::qWait(1);
QCOMPARE(closedSpy.count(), 0);
QCOMPARE(openedSpy.count(), 0);
QCOMPARE(toggleSpy.count(), 1);
// Now try to open the panel again. As the panel is already open, no signals should not be sent.
- testPanel->showPanel(testWidget);
+ testTabbedPanel->openPanel(testPanel);
QTest::qWait(1);
QCOMPARE(closedSpy.count(), 0);
QCOMPARE(openedSpy.count(), 1);
QCOMPARE(toggleSpy.count(), 1);
//Now try to close the panel, only toggleState and panelClosed signals should be sent
- testPanel->closePanel();
+ testTabbedPanel->closePanel();
QTest::qWait(1);
QCOMPARE(closedSpy.count(), 0);
QCOMPARE(openedSpy.count(), 1);
- QCOMPARE(toggleSpy.count(), 2);
+ QCOMPARE(toggleSpy.count(), 1);
QTest::qWait(1000);
QCOMPARE(closedSpy.count(), 1);
QCOMPARE(openedSpy.count(), 1);
QCOMPARE(toggleSpy.count(), 2);
- delete testWidget;
delete testPanel;
+ delete testTabbedPanel;
}
QTEST_MAIN(TestTabbedPanel)