finalised tests for bigger profile images.
authorVille Tiensuu <ville.tiensuu@ixonos.com>
Thu, 3 Jun 2010 07:28:42 +0000 (10:28 +0300)
committerVille Tiensuu <ville.tiensuu@ixonos.com>
Thu, 3 Jun 2010 07:28:42 +0000 (10:28 +0300)
fixed doxygen documentation from avatarimage.h
reviewed by: Pekka Nissinen

doc/test_cases/functionality-tests.doc
src/ui/avatarimage.h
tests/ui/avatarimage/avatarimage.pro [new file with mode: 0644]
tests/ui/avatarimage/testavatarimage.cpp [new file with mode: 0644]

index 3e4d50f..733b2b6 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index b1f004d..7a9d3a6 100644 (file)
@@ -49,7 +49,7 @@ public:
     * @brief Create avatar image from pixmap.
     *
     * @param image image to use in avatar image
-    * @param image height used to scale image
+    * @param height used to scale image
     */
     static QPixmap create(const QPixmap &image, ImageHeight height);
 };
diff --git a/tests/ui/avatarimage/avatarimage.pro b/tests/ui/avatarimage/avatarimage.pro
new file mode 100644 (file)
index 0000000..a23e1fc
--- /dev/null
@@ -0,0 +1,13 @@
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET +=
+DEPENDPATH += .
+INCLUDEPATH += "../../../src"
+SOURCES += \
+    testavatarimage.cpp \
+    ../../../src/ui/avatarimage.cpp
+
+HEADERS += \
+    ../../../src/ui/avatarimage.h
+
+DEFINES += QT_NO_DEBUG_OUTPUT
diff --git a/tests/ui/avatarimage/testavatarimage.cpp b/tests/ui/avatarimage/testavatarimage.cpp
new file mode 100644 (file)
index 0000000..dc7f671
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Ville Tiensuu - ville.tiensuu@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/avatarimage.h"
+
+const int FRIEND_IMAGE_WIDTH = 50;
+const int FRIEND_IMAGE_HEIGHT = 50;
+const int FRAMED_FRIEND_IMAGE_WIDTH = 64;
+const int FRAMED_FRIEND_IMAGE_HEIGHT = 64;
+const int OWN_IMAGE_NARROW_WIDTH = 39;
+const int OWN_IMAGE_NARROW_HEIGHT = 100;
+const int OWN_IMAGE_WIDE_WIDTH = 200;
+const int OWN_IMAGE_WIDE_HEIGHT = 20;
+const int OWN_IMAGE_FRAME_SIZE = 9;
+const int OWN_IMAGE_SUPPORTED_WIDTH = 100;
+const int OWN_IMAGE_SUPPORTED_HEIGHT = 100;
+const int FIXED_OWN_IMAGE_BORDER_HEIGHT = 118;
+
+class TestAvatarImage : public QObject
+{
+   Q_OBJECT
+
+private slots:
+   void testCreate(); // method tests whether the borders are inserted to the image.
+                      // test is based on the image size.
+};
+
+void TestAvatarImage::testCreate()
+{
+    // test friend image (always 50x50)
+    QPixmap friend50x50(FRIEND_IMAGE_WIDTH, FRIEND_IMAGE_HEIGHT);
+    QPixmap framedFriend50x50 = AvatarImage::create(friend50x50, AvatarImage::Small);
+    QCOMPARE(framedFriend50x50.width(), FRAMED_FRIEND_IMAGE_WIDTH);
+    QCOMPARE(framedFriend50x50.height(), FRAMED_FRIEND_IMAGE_HEIGHT);
+
+    // test narrow own image
+    QPixmap ownNarrow(OWN_IMAGE_NARROW_WIDTH, OWN_IMAGE_NARROW_HEIGHT);
+    QPixmap unFramedOwnNarrow = AvatarImage::create(ownNarrow, AvatarImage::Large);
+    QCOMPARE(unFramedOwnNarrow.width(), OWN_IMAGE_NARROW_WIDTH);
+    QCOMPARE(unFramedOwnNarrow.height(), OWN_IMAGE_NARROW_HEIGHT);
+
+    // test wide own image
+    QPixmap ownWide(OWN_IMAGE_WIDE_WIDTH, OWN_IMAGE_WIDE_HEIGHT);
+    QPixmap unFramedOwnWide = AvatarImage::create(ownWide, AvatarImage::Large);
+    QCOMPARE(unFramedOwnWide.width(), OWN_IMAGE_WIDE_WIDTH);
+    QCOMPARE(unFramedOwnWide.height(), OWN_IMAGE_WIDE_HEIGHT);
+
+    // test supported size own image
+    QPixmap ownSupported(OWN_IMAGE_SUPPORTED_WIDTH, OWN_IMAGE_SUPPORTED_HEIGHT);
+    QPixmap framedOwn = AvatarImage::create(ownSupported, AvatarImage::Large);
+    QCOMPARE(framedOwn.width(), OWN_IMAGE_SUPPORTED_WIDTH + 2*OWN_IMAGE_FRAME_SIZE);
+    QCOMPARE(framedOwn.height(), FIXED_OWN_IMAGE_BORDER_HEIGHT);
+}
+
+QTEST_MAIN(TestAvatarImage)
+#include "testavatarimage.moc"