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/coordinates/geocoordinate.h"
26 #include "src/ui/friendlistitem.h"
27 #include "src/ui/friendlistview.h"
28 #include "src/user/user.h"
29 #include "src/ui/avatarimage.h"
32 class TestFriendList: public QObject
37 * @brief Add widgets to the view.
39 void friendListViewAddWidget();
43 * @brief Clear unused widgets from the view.
45 void friendListViewClearUnused();
48 void TestFriendList::friendListViewAddWidget()
50 FriendListView *view = new FriendListView();
52 User *user1 = new User(QString("Address"), GeoCoordinate(12.22, 23.33), QString("Name"),
53 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
54 QString("UserID1"), QString("Units"), 44.12);
55 user1->setProfileImage(QPixmap("situare_user.gif"));
57 User *user2 = new User(QString("Address"), GeoCoordinate(12.22, 23.33), QString("Name"),
58 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
59 QString("UserID2"), QString("Units"), 44.12);
60 user2->setProfileImage(QPixmap("situare_user.gif"));
62 FriendListItem *item1 = new FriendListItem(view);
63 item1->setData(user1);
64 FriendListItem *item2 = new FriendListItem(view);
65 item2->setData(user2);
67 view->addWidget(user1->userId(), item1);
68 view->addWidget(user2->userId(), item2);
70 QCOMPARE(view->layout()->count(), 2);
72 User *user3 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
73 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
74 QString("UserID3"), QString("Units"), 44.12);
75 user3->setProfileImage(QPixmap("situare_user.gif"));
77 FriendListItem *item3 = new FriendListItem(view);
78 item3->setData(user3);
79 view->addWidget(user3->userId(), item3);
81 QCOMPARE(view->layout()->count(), 3);
83 view->addWidget(user3->userId(), item3);
85 QCOMPARE(view->layout()->count(), 3);
88 void TestFriendList::friendListViewClearUnused()
90 FriendListView *view = new FriendListView();
92 User *user1 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
93 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
94 QString("UserID1"), QString("Units"), 44.12);
95 user1->setProfileImage(QPixmap("situare_user.gif"));
96 User *user2 = new User(QString("Address"), QPointF(12.22, 23.33), QString("Name"),
97 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
98 QString("UserID2"), QString("Units"), 44.12);
99 user2->setProfileImage(QPixmap("situare_user.gif"));
101 FriendListItem *item1 = new FriendListItem(view);
102 item1->setData(user1);
103 FriendListItem *item2 = new FriendListItem(view);
104 item2->setData(user2);
106 view->addWidget(user1->userId(), item1);
107 view->addWidget(user2->userId(), item2);
109 QCOMPARE(view->layout()->count(), 2);
111 QStringList newUserIDs;
112 newUserIDs.append(user2->userId());
113 view->clearUnused(newUserIDs);
115 QCOMPARE(view->layout()->count(), 1);
119 QTEST_MAIN(TestFriendList)
120 #include "testfriendlist.moc"