Added missing files from the previous commit *sigh*
[situare] / tests / ui / tabbedpanel / testtabbedpanel.cpp
diff --git a/tests/ui/tabbedpanel/testtabbedpanel.cpp b/tests/ui/tabbedpanel/testtabbedpanel.cpp
new file mode 100644 (file)
index 0000000..6dc7345
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Kaj Wallin - kaj.wallin@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+#include <QtTest/QtTest>
+#include <QtCore>
+
+#include "ui/tabbedpanel.h"
+
+class TestTabbedPanel : public QObject
+{
+    Q_OBJECT
+
+private slots:
+//    void testPanelTypes();
+    void testPanelToggling();
+};
+
+//void TestTabbedPanel::testPanelTypes()
+//{
+//    SidePanel *testPanel = new SidePanel();
+//    testPanel->setType(SidePanel::UserPanel);
+//    QCOMPARE(testPanel->objectName(), QString("UserPanel"));
+//    delete testPanel;
+
+//    testPanel = new SidePanel();
+//    testPanel->setType(SidePanel::FriendPanel);
+//    QCOMPARE(testPanel->objectName(), QString("FriendPanel"));
+//    delete testPanel;
+//}
+
+void TestTabbedPanel::testPanelToggling()
+{
+    TabbedPanel *testPanel = new TabbedPanel();
+
+    QSignalSpy toggleSpy(testPanel, SIGNAL(toggleState()));
+
+    QVERIFY(toggleSpy.isValid());
+    QCOMPARE(toggleSpy.count(),0);
+
+    //Try to close the panel. As the panel is closed, no toggle signal should be sent
+    testPanel->closePanel();
+    QTest::qWait(1);
+    QCOMPARE(toggleSpy.count(),0);
+
+    //Now try to open the panel. Signal should be sent
+    testPanel->openPanel();
+    QTest::qWait(1);
+    QCOMPARE(toggleSpy.count(), 1);
+
+    //Now try to open the panel again. Signal should not be sent as the panel is already open
+    testPanel->openPanel();
+    QTest::qWait(1);
+    QCOMPARE(toggleSpy.count(), 1);
+
+    //Now try to close the panel, signal should be sent
+    testPanel->closePanel();
+    QTest::qWait(1);
+    QCOMPARE(toggleSpy.count(), 2);
+    delete testPanel;
+}
+QTEST_MAIN(TestTabbedPanel)
+#include "testtabbedpanel.moc"