Merge branch 'new_zoom_buttons_panel' v0.4
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 18 May 2010 08:48:47 +0000 (11:48 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Tue, 18 May 2010 08:48:47 +0000 (11:48 +0300)
src/ui/imagebutton.cpp
src/ui/imagebutton.h
src/ui/zoombuttonpanel.cpp
tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp [new file with mode: 0644]
tests/ui/zoombuttonpanel/testzoombuttonpanel.pro [new file with mode: 0644]

index 0c3bf40..28e8358 100644 (file)
@@ -78,8 +78,15 @@ void ImageButton::paintEvent(QPaintEvent *event)
 
 void ImageButton::setMode(QIcon::Mode mode)
 {
-    qDebug() << __PRETTY_FUNCTION__ << "Button icon mode:" << mode;
+    qDebug() << __PRETTY_FUNCTION__;
 
     m_buttonMode = mode;
     update();
 }
+
+QIcon::Mode ImageButton::mode()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_buttonMode;
+}
index be7852e..df47c61 100644 (file)
@@ -86,6 +86,13 @@ public:
      */
     void setMode(QIcon::Mode mode);
 
+    /**
+     * @brief Returns the current button icon mode
+     *
+     * @return Button icon mode
+     */
+    QIcon::Mode mode();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index c21ceb1..94d04c0 100644 (file)
@@ -27,6 +27,8 @@
 
 ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
     : QWidget(parent),
+      m_zoomInButton(0),
+      m_zoomOutButton(0),
       m_panelLayout(this),
       m_x(x),
       m_y(y)
diff --git a/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp b/tests/ui/zoombuttonpanel/testzoombuttonpanel.cpp
new file mode 100644 (file)
index 0000000..58cbdfd
--- /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(0, 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 != 0);
+    QVERIFY(zoomButtonPanel.m_zoomOutButton != 0);
+
+    // 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(0, 0, 0);
+
+    // 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(0, 0, 0);
+
+    // 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(0, 0, 0);
+
+    // 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