Added & reviewed remaining unit tests.
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 18 May 2010 08:46:14 +0000 (11:46 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 18 May 2010 08:46:14 +0000 (11:46 +0300)
Reviewed by: Jussi Laitinen

tests/ui/zoombuttonpanel/testzoombuttonpanel [new file with mode: 0755]
tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp [new file with mode: 0644]
tests/ui/zoombuttonpanel/testzoombuttonpanel.pro [new file with mode: 0644]

diff --git a/tests/ui/zoombuttonpanel/testzoombuttonpanel b/tests/ui/zoombuttonpanel/testzoombuttonpanel
new file mode 100755 (executable)
index 0000000..171774a
Binary files /dev/null and b/tests/ui/zoombuttonpanel/testzoombuttonpanel differ
diff --git a/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp b/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp
new file mode 100644 (file)
index 0000000..c72ac66
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Pekka Nissinen - pekka.nissinen@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>
+
+#include "../../../src/ui/zoombuttonpanel.h"
+
+class TestZoomButtonPanel : public QObject
+{
+    Q_OBJECT
+
+private slots:
+    /**
+      * @brief Test case for initialization
+      */
+    void init();
+
+    /**
+      * @brief Test case for disabling Zoom In button
+      */
+    void disableZoomIn();
+
+    /**
+      * @brief Test case for disabling Zoom Out button
+      */
+    void disableZoomOut();
+
+    /**
+      * @brief Test case for resetting buttons
+      */
+    void reset();
+};
+
+void TestZoomButtonPanel::init()
+{
+    // Create a new instance of ZoomButtonPanel
+    ZoomButtonPanel zoomButtonPanel(NULL, 10, 10);
+
+    // Check that panel is positioned to the right place
+    QCOMPARE(zoomButtonPanel.pos(), QPoint(10, 10));
+
+    // Check that both of the buttons images are loaded successfully
+    QVERIFY(zoomButtonPanel.m_zoomInButton != NULL);
+    QVERIFY(zoomButtonPanel.m_zoomOutButton != NULL);
+
+    // Check that both of the button icons are at normal mode
+    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Normal);
+    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Normal);
+}
+
+void TestZoomButtonPanel::disableZoomIn()
+{
+    // Create a new instance of ZoomButtonPanel
+    ZoomButtonPanel zoomButtonPanel(NULL, NULL, NULL);
+
+    // Disable the button
+    zoomButtonPanel.disableZoomInButton();
+
+    // Check that Zoom In button is disabled
+    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Disabled);
+}
+
+void TestZoomButtonPanel::disableZoomOut()
+{
+    // Create a new instance of ZoomButtonPanel
+    ZoomButtonPanel zoomButtonPanel(NULL, NULL, NULL);
+
+    // Disable the button
+    zoomButtonPanel.disableZoomOutButton();
+
+    // Check that Zoom In button is disabled
+    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Disabled);
+}
+
+void TestZoomButtonPanel::reset()
+{
+    // Create a new instance of ZoomButtonPanel
+    ZoomButtonPanel zoomButtonPanel(NULL, NULL, NULL);
+
+    // Set both buttons to disabled mode
+    zoomButtonPanel.m_zoomInButton->setMode(QIcon::Disabled);
+    zoomButtonPanel.m_zoomOutButton->setMode(QIcon::Disabled);
+
+    // Reset the buttons
+    zoomButtonPanel.resetButtons();
+
+    // Check that both buttons are properly resetted to normal mode
+    QVERIFY(zoomButtonPanel.m_zoomInButton->mode() == QIcon::Normal);
+    QVERIFY(zoomButtonPanel.m_zoomOutButton->mode() == QIcon::Normal);
+}
+
+QTEST_MAIN(TestZoomButtonPanel)
+#include "testzoombuttonpanel.moc"
diff --git a/tests/ui/zoombuttonpanel/testzoombuttonpanel.pro b/tests/ui/zoombuttonpanel/testzoombuttonpanel.pro
new file mode 100644 (file)
index 0000000..9b46a68
--- /dev/null
@@ -0,0 +1,19 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Mon May 18 15:38:16 2010
+# #####################################################################
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+
+# Input
+SOURCES += testzoombuttonpanel.cpp \
+    ../../../src/ui/zoombuttonpanel.cpp \
+    ../../../src/ui/imagebutton.cpp
+HEADERS += ../../../src/ui/zoombuttonpanel.h \
+    ../../../src/ui/imagebutton.h
+
+DEFINES += QT_NO_DEBUG_OUTPUT
+RESOURCES += ../../../images.qrc