162 HbAbstractViewItem *testItem = mItem->createItem(); |
164 HbAbstractViewItem *testItem = mItem->createItem(); |
163 QVERIFY(testItem); |
165 QVERIFY(testItem); |
164 delete testItem; |
166 delete testItem; |
165 } |
167 } |
166 |
168 |
|
169 /*! |
|
170 Test function for updating child items |
|
171 1. Test if child items are updated |
|
172 2. Just for coverage testing |
|
173 */ |
167 void TestCalenDayItem::testUpdateChildItems() |
174 void TestCalenDayItem::testUpdateChildItems() |
168 { |
175 { |
169 |
176 #ifndef __WINSCW__ |
|
177 //1) |
|
178 mItem->mUpdated = false; |
|
179 mItem->updateChildItems(); |
|
180 QCOMPARE(mItem->mUpdated, true); |
|
181 |
|
182 //2) |
|
183 mItem->mUpdated = true; |
|
184 mItem->updateChildItems(); |
|
185 QCOMPARE(mItem->mUpdated, true); |
|
186 #endif |
|
187 } |
|
188 |
|
189 /*! |
|
190 Test setting description of entry |
|
191 1. Setting description if only location is set |
|
192 2. Setting description if location and summary are set |
|
193 3. Setting description if location and summary are not set |
|
194 4. Setting description if summary is set and event is for all day |
|
195 5. Setting description if location and summary are set and event is |
|
196 for all day |
|
197 */ |
|
198 void TestCalenDayItem::testSetDescription() |
|
199 { |
|
200 #ifndef __WINSCW__ |
|
201 AgendaEntry entry; |
|
202 QString location("testLocation"); |
|
203 QString summary("testSummary"); |
|
204 |
|
205 //1) |
|
206 entry.setLocation(location); |
|
207 entry.setSummary(""); |
|
208 mItem->setDescription(entry, false); |
|
209 QCOMPARE(mItem->mEventDesc->text(), location); |
|
210 |
|
211 //2) |
|
212 entry.setLocation(location); |
|
213 entry.setSummary(summary); |
|
214 mItem->setDescription(entry, false); |
|
215 QString expected(summary); |
|
216 expected.append(", "); |
|
217 expected.append(location); |
|
218 QCOMPARE(mItem->mEventDesc->text(), expected); |
|
219 |
|
220 //3) |
|
221 entry.setLocation(""); |
|
222 entry.setSummary(""); |
|
223 mItem->setDescription(entry, false); |
|
224 QCOMPARE(mItem->mEventDesc->text(), hbTrId("txt_calendar_dblist_unnamed")); |
|
225 |
|
226 //4) |
|
227 entry.setLocation(""); |
|
228 entry.setSummary(summary); |
|
229 mItem->setDescription(entry, true); |
|
230 expected = ""; |
|
231 for (int i = 0; i < summary.count(); i++) { |
|
232 expected.append(QString(summary.at(i)) + "\n"); |
|
233 } |
|
234 QCOMPARE(mItem->mEventDesc->text(), expected); |
|
235 |
|
236 //5) |
|
237 entry.setLocation(location); |
|
238 entry.setSummary(summary); |
|
239 mItem->setDescription(entry, true); |
|
240 QString description(summary + ", " + location); |
|
241 expected = ""; |
|
242 for (int i = 0; i < description.count(); i++) { |
|
243 expected.append(QString(description.at(i)) + "\n"); |
|
244 } |
|
245 if (summary.count()) { |
|
246 expected.remove(2 * summary.count() - 1, 1); |
|
247 } |
|
248 QCOMPARE(mItem->mEventDesc->text(), expected); |
|
249 #endif |
|
250 } |
|
251 |
|
252 /*! |
|
253 Test setting status strip |
|
254 1. Setting status strip for event |
|
255 2. Setting status strip for all day event |
|
256 3. Setting status strip for confirmed event |
|
257 4. Setting status strip for tentative event |
|
258 5. Setting status strip for cancelled event |
|
259 */ |
|
260 void TestCalenDayItem::testSetStatusStrip() |
|
261 { |
|
262 #ifndef __WINSCW__ |
|
263 AgendaEntry entry; |
|
264 QDateTime startTimeIn(QDate(12, 07, 2010), QTime(7, 0)); |
|
265 QDateTime endTimeIn(QDate(12, 07, 2010), QTime(10, 0)); |
|
266 |
|
267 //1) |
|
268 entry.setStartAndEndTime(startTimeIn, endTimeIn); |
|
269 mItem->setStatusStrip(entry, false); |
|
270 |
|
271 QDateTime startTime; |
|
272 QDateTime endTime; |
|
273 QDateTime currentDateTime; |
|
274 currentDateTime.setDate(mItem->container()->date()); |
|
275 CalenDayUtils::instance()->getEventValidStartEndTime(startTime, endTime, |
|
276 entry, currentDateTime); |
|
277 QPair<QTime, QTime> startEndTime = mItem->mColorStripe->startEndTime(); |
|
278 QCOMPARE(startEndTime.first, startTime.time()); |
|
279 QCOMPARE(startEndTime.second, endTime.time()); |
|
280 |
|
281 //2) |
|
282 mItem->setStatusStrip(entry, true); |
|
283 startEndTime = mItem->mColorStripe->startEndTime(); |
|
284 QCOMPARE(startEndTime.first, startTime.time()); |
|
285 QCOMPARE(startEndTime.second, endTime.time().addSecs(-1)); |
|
286 |
|
287 //3) |
|
288 entry.setStatus(AgendaEntry::Confirmed); |
|
289 mItem->setStatusStrip(entry, false); |
|
290 QCOMPARE(CalenDayStatusStrip::Filled, |
|
291 mItem->mColorStripe->drawingStyle()); |
|
292 |
|
293 //4) |
|
294 entry.setStatus(AgendaEntry::Tentative); |
|
295 mItem->setStatusStrip(entry, false); |
|
296 QCOMPARE(CalenDayStatusStrip::StripWithLines, |
|
297 mItem->mColorStripe->drawingStyle()); |
|
298 |
|
299 //5) |
|
300 entry.setStatus(AgendaEntry::Cancelled); |
|
301 mItem->setStatusStrip(entry, false); |
|
302 QCOMPARE(CalenDayStatusStrip::OnlyFrame, |
|
303 mItem->mColorStripe->drawingStyle()); |
|
304 #endif |
170 } |
305 } |
171 |
306 |
172 void TestCalenDayItem::testHasEventDescription() |
307 void TestCalenDayItem::testHasEventDescription() |
173 { |
308 { |
174 #ifndef __WINSCW__ |
309 #ifndef __WINSCW__ |