From: Jukka Saastamoinen Date: Tue, 13 Apr 2010 09:16:16 +0000 (+0300) Subject: Added first version of unit tests for PixMap X-Git-Tag: v0.2~11^2~3^2~10 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=870e16d8dd481acc364fe03182554b149a75045b;p=situare Added first version of unit tests for PixMap --- diff --git a/scripts/master_test_script.sh b/scripts/master_test_script.sh old mode 100644 new mode 100755 diff --git a/src/src.pro b/src/src.pro index 4a487da..56c8a7b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -3,6 +3,9 @@ # ------------------------------------------------- TARGET = ../situare TEMPLATE = app + +RESOURCES += images.qrc + SOURCES += main.cpp \ ui/mainwindow.cpp \ ui/mapviewscreen.cpp \ @@ -47,4 +50,3 @@ unix { target.path = $$BINDIR INSTALLS += target } -RESOURCES += images.qrc diff --git a/tests/testui/testpixmap/dummy_personal_infotab_background.png b/tests/testui/testpixmap/dummy_personal_infotab_background.png new file mode 100644 index 0000000..08dca9d Binary files /dev/null and b/tests/testui/testpixmap/dummy_personal_infotab_background.png differ diff --git a/tests/testui/testpixmap/testpixmap.cpp b/tests/testui/testpixmap/testpixmap.cpp new file mode 100644 index 0000000..1b85356 --- /dev/null +++ b/tests/testui/testpixmap/testpixmap.cpp @@ -0,0 +1,82 @@ +/* + Situare - A location system for Facebook + Copyright (C) 2010 Ixonos Plc. Authors: + + Jukka Saastamoinen - jukka.saastamoinen@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 +#include +#include "ui/pixmap.h" + + +class TestPixmap: public QObject +{ + Q_OBJECT +private slots: + void constructorTest(); + void boundingRegionTest(); +private: + bool pixelCompareImages( const QImage &a, const QImage &b ); +}; + +/** +* @brief Tests that the class accepts the png file used to draw the image +*/ +void TestPixmap::constructorTest() +{ + Pixmap *infoTab = new Pixmap(QPixmap("dummy_personal_infotab_background.png")); + delete infoTab; + infoTab=NULL; + QVERIFY(!infoTab); +} + +/** +* @brief Tests that the bounding area reserved for the picture is the same as +* the picture size. +*/ + +void TestPixmap::boundingRegionTest() +{ + Pixmap testPic(QPixmap("dummy_personal_infotab_background.png")); //350x300 pix + QPixmap refPic("dummy_personal_infotab_background.png"); + QRectF boundArea = testPic.boundingRect(); + QRectF refArea; + refArea.setSize(refPic.size()); + QVERIFY(boundArea.size()==refArea.size()); +} + +bool TestPixmap::pixelCompareImages( const QImage &a, const QImage &b ) +{ + if( a.size() != b.size() ) + return false; + + if( a.format() != b.format() ) + return false; + + for( int x=0; x