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 "coordinates/geocoordinate.h"
26 #include "ui/friendlistitem.h"
27 #include "ui/friendlistview.h"
28 #include "user/user.h"
29 #include "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"), GeoCoordinate(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"), GeoCoordinate(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"));
97 User *user2 = new User(QString("Address"), GeoCoordinate(12.22, 23.33), QString("Name"),
98 QString("Note"), QUrl("http://image.url"), QString("Timestamp"), true,
99 QString("UserID2"), QString("Units"), 44.12);
100 user2->setProfileImage(QPixmap("situare_user.gif"));
102 FriendListItem *item1 = new FriendListItem(view);
103 item1->setData(user1);
104 FriendListItem *item2 = new FriendListItem(view);
105 item2->setData(user2);
107 view->addWidget(user1->userId(), item1);
108 view->addWidget(user2->userId(), item2);
110 QCOMPARE(view->layout()->count(), 2);
112 QStringList newUserIDs;
113 newUserIDs.append(user2->userId());
114 view->clearUnused(newUserIDs);
116 QCOMPARE(view->layout()->count(), 1);
120 QTEST_MAIN(TestFriendList)
121 #include "testfriendlist.moc"