2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@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,
22 #include <QtTest/QtTest>
29 #include "../../src/user/user.h"
32 class TestUser : public QObject
44 void testCoordinates();
56 const QString address = "Kuja 3 A, 90560 Oulu, Finland";
57 const QPointF coordinates(65.3, 25.5);
58 const QString name = "Jukka Kukka";
59 const QString note = "Testing";
60 const QUrl imageUrl = QUrl("http://profile.ak.fbcdn.net/v225/874/99/q100000139211584_3252.jpg");
61 const QString timestamp = "1 minute ago";
62 const bool userType = false;
63 const QString units = "km";
64 const QString userId = "111000222";
65 const double value = 12.1;
67 user = new User(address, coordinates, name, note, imageUrl, timestamp, userType, userId, units, value);
75 void TestUser::testAddress()
77 QString newValue = "Kalmakuja 6 B, 90650 Oulu, Finland";
78 QString oldValue = user->address();
82 user->setAddress(newValue);
84 QString currentValue = user->address();
86 qDebug() << currentValue;
88 QCOMPARE(currentValue, newValue);
91 void TestUser::testCoordinates()
93 QPointF oldValue = user->coordinates();
97 QPointF newValue(64.3, 25.8);
99 user->setCoordinates(newValue);
101 QPointF currentValue = user->coordinates();
103 qDebug() << currentValue;
105 QCOMPARE(currentValue, newValue);
108 void TestUser::testName()
110 QString currentValue = user->name();
112 qDebug() << currentValue;
114 QCOMPARE(currentValue, QString("Jukka Kukka"));
117 void TestUser::testNote()
119 QString oldValue = user->note();
121 qDebug() << oldValue;
123 QString newValue = "Still testing";
125 user->setNote(newValue);
127 QString currentValue = user->note();
129 qDebug() << currentValue;
131 QCOMPARE(currentValue, newValue);
134 void TestUser::testImageUrl()
136 QUrl oldValue = user->profileImageUrl();
138 qDebug() << oldValue;
140 QUrl newValue = QUrl("http://profile.ak.fbcdn.net/v225/874/99/xxxxxxx.jpg");
142 user->setProfileImageUrl(newValue);
144 QUrl currentValue = user->profileImageUrl();
146 qDebug() << currentValue;
148 QCOMPARE(currentValue, newValue);
151 void TestUser::testTimestamp()
153 QString oldValue = user->timestamp();
155 qDebug() << oldValue;
157 QString newValue = "2 minutes ago";
159 user->setTimestamp(newValue);
161 QString currentValue = user->timestamp();
163 qDebug() << currentValue;
165 QCOMPARE(currentValue, newValue);
168 void TestUser::testUserType()
170 bool currentValue = user->type();
172 qDebug() << currentValue;
174 QCOMPARE(currentValue, false);
177 void TestUser::testDistance()
179 QString oldUnitValue;
180 double oldDistanceValue;
182 user->distance(oldDistanceValue, oldUnitValue);
184 qDebug() << oldDistanceValue << oldUnitValue;
186 QString newUnitValue = "miles";
187 double newDistanceValue = 2.13;
189 user->setDistance(newDistanceValue, newUnitValue);
191 QString currentUnitValue;
192 double currentDistanceValue;
194 user->distance(currentDistanceValue, currentUnitValue);
196 qDebug() << currentDistanceValue << currentUnitValue;
198 QCOMPARE(currentDistanceValue, newDistanceValue);
199 QCOMPARE(currentUnitValue, newUnitValue);
202 void TestUser::testUserId()
204 QString currentValue = user->userId();
206 qDebug() << currentValue;
208 QCOMPARE(currentValue, QString("111000222"));
212 #include "testuser.moc"