2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include "ui/extendedlistitemstore.h"
25 #include "ui/listcommon.h"
26 #include "user/user.h"
28 #include "ui/friendlistitem.h"
30 class TestFriendListItem: public QObject
35 void cleanupTestCase();
38 void toggleSelection();
41 FriendListItem *friendListItem;
46 void TestFriendListItem::cleanupTestCase()
48 delete friendListItem;
53 void TestFriendListItem::initTestCase()
55 friendListItem = new FriendListItem();
57 user1 = new User(QString("Address address address address address"),
58 GeoCoordinate(12.22, 23.33), QString("Name na msfdsa dsfadsaf sdaf"),
59 QString("Note note note note note note note note note note note note " \
60 "note note note note note"),
61 QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
62 true, QString("id1"), QString("km"), 44.12);
63 user1->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
65 user2 = new User(QString("Address address"),
66 GeoCoordinate(12.1, 44.33), QString("Name na msfdsa dsfadsaf sdaf"),
67 QString("Note note note note note note note note note note note note" \
68 "note note note note note"),
69 QUrl("http://image.url"), QString("Timestamp timestamp timestamp tim"),
70 true, QString("id2"), QString("km"), 144.12);
71 user2->setProfileImage(QPixmap(":/res/images/profile_pic_border.png"));
73 QVERIFY(friendListItem != 0);
78 void TestFriendListItem::setUserData()
80 friendListItem->setUserData(user1);
81 QCOMPARE(friendListItem->coordinates().latitude(), GeoCoordinate(12.22, 23.33).latitude());
82 QCOMPARE(friendListItem->coordinates().longitude(), GeoCoordinate(12.22, 23.33).longitude());
84 QPixmap profileImage = QPixmap(qvariant_cast<QPixmap>(friendListItem->data(
85 AVATAR_IMAGE_INDEX)));
86 QCOMPARE(profileImage, QPixmap(":/res/images/profile_pic_border.png"));
88 friendListItem->setUserData(user2);
89 QCOMPARE(friendListItem->coordinates().latitude(), GeoCoordinate(12.1, 44.33).latitude());
90 QCOMPARE(friendListItem->coordinates().longitude(), GeoCoordinate(12.1, 44.33).longitude());
93 void TestFriendListItem::toggleSelection()
95 QCOMPARE(friendListItem->data(ITEM_SIZE_HINT_INDEX).toSize(), QSize(368, 139));
97 QList<ExtendedListItemStore *> *subItems = (QList<ExtendedListItemStore *> *)
98 (friendListItem->data(SUBITEM_STORE_INDEX)
101 QVERIFY(friendListItem->data(ITEM_HAS_IMAGE_INDEX).toBool());
104 QCOMPARE(subItems->count(), 3);
106 friendListItem->toggleSelection();
107 QCOMPARE(friendListItem->data(ITEM_EXPANDED_INDEX).toBool(), true);
109 friendListItem->toggleSelection();
110 QCOMPARE(friendListItem->data(ITEM_SIZE_HINT_INDEX).toSize(), QSize(368, 139));
111 QCOMPARE(friendListItem->data(ITEM_EXPANDED_INDEX).toBool(), false);
114 QTEST_MAIN(TestFriendListItem)
115 #include "testfriendlistitem.moc"