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,
25 #include "../../../src/ui/friendlistitem.h"
26 #include "../../../src/ui/friendlistview.h"
27 #include "../../../src/user/user.h"
28 #include "../../../src/ui/avatarimage.h"
31 class TestFriendList: public QObject
36 * @brief Add widgets to the view.
38 void friendListViewAddWidget();
42 * @brief Clear unused widgets from the view.
44 void friendListViewClearUnused();
47 void TestFriendList::friendListViewAddWidget()
49 FriendListView *view = new FriendListView();
51 User *user1 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
52 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
53 QString("UserID1"), QString("Units"), 44.12);
54 user1->setProfileImage(QPixmap("situare_user.gif"));
55 User *user2 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
56 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
57 QString("UserID2"), QString("Units"), 44.12);
58 user2->setProfileImage(QPixmap("situare_user.gif"));
60 FriendListItem *item1 = new FriendListItem(view);
61 item1->setData(user1);
62 FriendListItem *item2 = new FriendListItem(view);
63 item2->setData(user2);
65 view->addWidget(user1->userId(), item1);
66 view->addWidget(user2->userId(), item2);
68 QCOMPARE(view->layout()->count(), 2);
70 User *user3 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
71 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
72 QString("UserID3"), QString("Units"), 44.12);
73 user3->setProfileImage(QPixmap("situare_user.gif"));
75 FriendListItem *item3 = new FriendListItem(view);
76 item3->setData(user3);
77 view->addWidget(user3->userId(), item3);
79 QCOMPARE(view->layout()->count(), 3);
81 view->addWidget(user3->userId(), item3);
83 QCOMPARE(view->layout()->count(), 3);
86 void TestFriendList::friendListViewClearUnused()
88 FriendListView *view = new FriendListView();
90 User *user1 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
91 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
92 QString("UserID1"), QString("Units"), 44.12);
93 user1->setProfileImage(QPixmap("situare_user.gif"));
94 User *user2 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
95 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
96 QString("UserID2"), QString("Units"), 44.12);
97 user2->setProfileImage(QPixmap("situare_user.gif"));
99 FriendListItem *item1 = new FriendListItem(view);
100 item1->setData(user1);
101 FriendListItem *item2 = new FriendListItem(view);
102 item2->setData(user2);
104 view->addWidget(user1->userId(), item1);
105 view->addWidget(user2->userId(), item2);
107 QCOMPARE(view->layout()->count(), 2);
109 QStringList newUserIDs;
110 newUserIDs.append(user2->userId());
111 view->clearUnused(newUserIDs);
113 QCOMPARE(view->layout()->count(), 1);
117 QTEST_MAIN(TestFriendList)
118 #include "testfriendlist.moc"