Merge branch 'master' into contact_dialog
[situare] / tests / ui / tabbedpanel / testtabbedpanel.cpp
index 63df118..5a58036 100644 (file)
@@ -22,8 +22,8 @@
 
 #include <QtTest/QtTest>
 #include <QtCore>
-#include <QWidget>
 
+#include "ui/panelbase.h"
 #include "ui/tabbedpanel.h"
 
 class TestTabbedPanel : public QObject
@@ -36,14 +36,14 @@ private slots:
 
 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());
@@ -56,7 +56,7 @@ void TestTabbedPanel::testPanelToggling()
     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);
@@ -67,7 +67,7 @@ void TestTabbedPanel::testPanelToggling()
     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);
@@ -78,7 +78,7 @@ void TestTabbedPanel::testPanelToggling()
     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);
@@ -89,18 +89,18 @@ void TestTabbedPanel::testPanelToggling()
     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)