213 |
220 |
214 // no model: fails |
221 // no model: fails |
215 QVERIFY(mTestWidget->activate() == -1); |
222 QVERIFY(mTestWidget->activate() == -1); |
216 QCOMPARE(HbMenuData::mEnabledSetted, false); |
223 QCOMPARE(HbMenuData::mEnabledSetted, false); |
217 QCOMPARE(HbListView::mLatestVisibility, false); |
224 QCOMPARE(HbListView::mLatestVisibility, false); |
218 QVERIFY(!HbListView::mLatestModel); |
225 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0); |
219 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
226 |
220 |
227 // model exist, no current view default level: succeeds |
221 // no context menu, model exist: succeeds |
|
222 QVERIFY(mTestWidget->initialize(*model) == 0); |
228 QVERIFY(mTestWidget->initialize(*model) == 0); |
223 QVERIFY(mTestWidget->activate() == 0); |
229 QVERIFY(mTestWidget->activate() == 0); |
224 QCOMPARE(HbMenuData::mEnabledSetted, false); |
230 QCOMPARE(HbMenuData::mEnabledSetted, false); |
225 QCOMPARE(HbListView::mLatestVisibility, true); |
231 QCOMPARE(HbListView::mLatestVisibility, true); |
226 QCOMPARE(HbListView::mLatestModel, model); |
|
227 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
232 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
228 |
233 |
229 HbMenuData::mEnabledSetted = true; |
234 HbMenuData::mEnabledSetted = true; |
230 HbListView::mLatestVisibility = false; |
235 HbListView::mLatestVisibility = false; |
231 HbListView::mLatestEnableValue = false; |
236 HbListView::mLatestEnableValue = false; |
232 HbListView::mLatestModel = 0; |
|
233 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
237 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
234 |
238 |
235 // context menu exists, succeed (signal connecting failure cannot be tested here) |
239 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
236 mTestWidget->mContextMenu = new HbMenu; |
240 // no mNavKeyQuitAction |
|
241 HbView *tmpView = new HbView(); |
|
242 hbInstance->allMainWindows().value(0)->addView(tmpView); |
|
243 HbAction *tmpAction = mTestWidget->mNavKeyQuitAction; |
|
244 mTestWidget->mNavKeyQuitAction = 0; |
237 QVERIFY(mTestWidget->activate() == 0); |
245 QVERIFY(mTestWidget->activate() == 0); |
238 QCOMPARE(HbMenuData::mEnabledSetted, true); |
246 QCOMPARE(HbMenuData::mEnabledSetted, true); |
239 QCOMPARE(HbListView::mLatestVisibility, true); |
247 QCOMPARE(HbListView::mLatestVisibility, true); |
240 QCOMPARE(HbListView::mLatestModel, model); |
|
241 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
248 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
242 } |
249 QVERIFY(!tmpView->mNavigationAction); |
243 |
250 |
244 // --------------------------------------------------------------------------- |
251 HbMenuData::mEnabledSetted = true; |
245 // testDeactivate |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void TestListWidget::testDeactivate() |
|
249 { |
|
250 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
251 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
252 |
|
253 HbMenuData::mEnabledSetted = false; |
|
254 HbListView::mLatestVisibility = false; |
252 HbListView::mLatestVisibility = false; |
255 HbListView::mLatestEnableValue = false; |
253 HbListView::mLatestEnableValue = false; |
256 HbListView::mLatestModel = 0; |
|
257 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
254 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
258 VideoSortFilterProxyModel *nullModel = 0; |
255 mTestWidget->mNavKeyQuitAction = tmpAction; |
|
256 |
|
257 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
|
258 // mNavKeyQuitAction exists |
|
259 QVERIFY(mTestWidget->activate() == 0); |
|
260 QCOMPARE(HbMenuData::mEnabledSetted, true); |
|
261 QCOMPARE(HbListView::mLatestVisibility, true); |
|
262 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
|
263 QVERIFY(tmpView->mNavigationAction == tmpAction); |
|
264 |
|
265 HbMenuData::mEnabledSetted = true; |
|
266 HbListView::mLatestVisibility = false; |
|
267 HbListView::mLatestEnableValue = false; |
|
268 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
|
269 |
|
270 // model exists, current view exists, level is ELevelAlbum |
|
271 // no mNavKeyBackAction |
|
272 tmpView->mNavigationAction = 0; |
|
273 tmpAction = mTestWidget->mNavKeyBackAction; |
|
274 mTestWidget->mNavKeyBackAction = 0; |
|
275 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); |
|
276 QCOMPARE(HbMenuData::mEnabledSetted, true); |
|
277 QCOMPARE(HbListView::mLatestVisibility, true); |
|
278 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
|
279 QVERIFY(!tmpView->mNavigationAction); |
|
280 |
|
281 HbMenuData::mEnabledSetted = true; |
|
282 HbListView::mLatestVisibility = false; |
|
283 HbListView::mLatestEnableValue = false; |
|
284 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
|
285 |
|
286 mTestWidget->mNavKeyBackAction = tmpAction; |
|
287 // model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl, |
|
288 // mNavKeyBackAction exists |
|
289 QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0); |
|
290 QCOMPARE(HbMenuData::mEnabledSetted, true); |
|
291 QCOMPARE(HbListView::mLatestVisibility, true); |
|
292 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1); |
|
293 QVERIFY(tmpView->mNavigationAction == tmpAction); |
|
294 |
|
295 HbMenuData::mEnabledSetted = true; |
|
296 HbListView::mLatestVisibility = false; |
|
297 HbListView::mLatestEnableValue = false; |
|
298 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0; |
|
299 |
|
300 hbInstance->allMainWindows().value(0)->removeView(tmpView); |
|
301 delete tmpView; |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // testDeactivate |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void TestListWidget::testDeactivate() |
|
309 { |
|
310 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
311 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
312 |
|
313 HbListView::mLatestVisibility = true; |
|
314 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1; |
259 |
315 |
260 mTestWidget->activate(); |
316 mTestWidget->activate(); |
261 |
317 |
262 // no context menu and activated without model |
318 // no context menu and activated without model |
263 mTestWidget->deactivate(); |
319 mTestWidget->deactivate(); |
264 QCOMPARE(HbListView::mLatestVisibility, false); |
320 QCOMPARE(HbListView::mLatestVisibility, false); |
265 QCOMPARE(HbListView::mLatestModel, nullModel); |
|
266 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0); |
321 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0); |
|
322 |
|
323 HbListView::mLatestVisibility = true; |
|
324 VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1; |
267 |
325 |
268 // context menu exists and activated with model |
326 // context menu exists and activated with model |
269 mTestWidget->mContextMenu = new HbMenu; |
327 mTestWidget->mContextMenu = new HbMenu; |
270 QVERIFY(mTestWidget->initialize(*model) == 0); |
328 QVERIFY(mTestWidget->initialize(*model) == 0); |
271 mTestWidget->activate(); |
329 mTestWidget->activate(); |
272 mTestWidget->deactivate(); |
330 mTestWidget->deactivate(); |
273 QCOMPARE(HbListView::mLatestVisibility, true); |
331 QCOMPARE(HbListView::mLatestVisibility, false); |
274 QCOMPARE(HbListView::mLatestModel, model); |
|
275 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0); |
332 QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0); |
276 |
333 |
277 } |
334 } |
278 |
335 |
279 // --------------------------------------------------------------------------- |
336 // --------------------------------------------------------------------------- |
316 void TestListWidget::testEmitActivated() |
373 void TestListWidget::testEmitActivated() |
317 { |
374 { |
318 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
375 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
319 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
376 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
320 |
377 |
321 QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&))); |
378 QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&))); |
322 mTestWidget->initialize(*model); |
379 QSignalSpy spysignalFileUri(mTestWidget, SIGNAL(fileUri(const QString&))); |
323 mTestWidget->activate(); |
380 QSignalSpy spysignalActivated(mTestWidget, SIGNAL(activated(const QModelIndex&))); |
324 hbInstance->mWindowses.append(mDummyMainWnd); |
381 |
325 |
382 mTestWidget->initialize(*model); |
|
383 mTestWidget->activate(); |
|
384 |
|
385 VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); |
|
386 TMPXItemId savedId = TMPXItemId(1,1); |
|
387 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
388 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
389 QVariant data = QString("test"); |
|
390 VideoListDataModelData::setData( Qt::DisplayRole, data); |
|
391 setRowCount(2); |
|
392 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0,0)); |
|
393 |
|
394 QModelIndex fetchIndex = model->index(0, 0, QModelIndex()); |
|
395 |
|
396 // selection mode == HbAbstractItemView::MultiSelection |
|
397 mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
|
398 mTestWidget->callEmiteActivated(fetchIndex); |
|
399 QVERIFY(spysignal.count() == 0); |
|
400 QVERIFY(spysignalFileUri.count() == 0); |
|
401 QVERIFY(spysignalActivated.count() == 1); |
|
402 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
403 spysignal.clear(); |
|
404 spysignalFileUri.clear(); |
|
405 spysignalActivated.clear(); |
|
406 |
|
407 // modelIndex is not valid |
|
408 mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection); |
|
409 fetchIndex = QModelIndex(); |
|
410 mTestWidget->callEmiteActivated(fetchIndex); |
|
411 QVERIFY(spysignal.count() == 0); |
|
412 QVERIFY(spysignalFileUri.count() == 0); |
|
413 QVERIFY(spysignalActivated.count() == 0); |
|
414 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
415 |
|
416 // current level is ELevelCategory |
|
417 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
|
418 // --> variant is not valid |
|
419 VideoListDataModelData::setData( Qt::DisplayRole, QVariant()); |
|
420 fetchIndex = model->index(0, 0, QModelIndex()); |
|
421 mTestWidget->callEmiteActivated(fetchIndex); |
|
422 QVERIFY(spysignal.count() == 0); |
|
423 QVERIFY(spysignalFileUri.count() == 0); |
|
424 QVERIFY(spysignalActivated.count() == 0); |
|
425 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
426 |
|
427 |
|
428 // --> variant is valid, collectionOpened -signal should be emitted |
|
429 VideoListDataModelData::setData( Qt::DisplayRole, data); |
|
430 fetchIndex = model->index(1, 0, QModelIndex()); |
|
431 mTestWidget->callEmiteActivated(fetchIndex); |
|
432 QVERIFY(spysignal.count() == 1); |
|
433 QVERIFY(spysignalFileUri.count() == 0); |
|
434 QVERIFY(spysignalActivated.count() == 0); |
|
435 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
436 |
|
437 spysignal.clear(); |
|
438 spysignalFileUri.clear(); |
|
439 spysignalActivated.clear(); |
|
440 |
|
441 // current level is not ELevelCategory |
|
442 // mIsService is true, variant gotten is invalid |
|
443 VideoListDataModelData::setData( Qt::DisplayRole, QVariant()); |
|
444 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
|
445 mTestWidget->mIsService = true; |
|
446 fetchIndex = model->index(0, 0, QModelIndex()); |
|
447 mTestWidget->callEmiteActivated(fetchIndex); |
|
448 QVERIFY(spysignal.count() == 0); |
|
449 QVERIFY(spysignalFileUri.count() == 0); |
|
450 QVERIFY(spysignalActivated.count() == 0); |
|
451 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
452 |
|
453 // current level is not ELevelCategory |
|
454 // mIsService is true, variant gotten is valid |
|
455 VideoListDataModelData::setData( VideoCollectionCommon::KeyFilePath, data); |
|
456 fetchIndex = model->index(0, 0, QModelIndex()); |
|
457 mTestWidget->callEmiteActivated(fetchIndex); |
|
458 QVERIFY(spysignal.count() == 0); |
|
459 QVERIFY(spysignalFileUri.count() == 1); |
|
460 QVERIFY(spysignalActivated.count() == 0); |
|
461 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
462 |
|
463 spysignal.clear(); |
|
464 spysignalFileUri.clear(); |
|
465 spysignalActivated.clear(); |
|
466 |
|
467 // current level is not ELevelCategory |
|
468 // mIsService is false |
|
469 mTestWidget->mIsService = false; |
|
470 fetchIndex = model->index(0, 0, QModelIndex()); |
|
471 mTestWidget->callEmiteActivated(fetchIndex); |
|
472 QVERIFY(spysignal.count() == 0); |
|
473 QVERIFY(spysignalFileUri.count() == 0); |
|
474 QVERIFY(spysignalActivated.count() == 0); |
|
475 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); |
|
476 |
|
477 // context menu is visible |
|
478 if (!mTestWidget->mContextMenu) |
|
479 { |
|
480 mTestWidget->mContextMenu = new HbMenu; |
|
481 } |
|
482 mTestWidget->mContextMenu->show(); |
|
483 VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); |
|
484 fetchIndex = model->index(0, 0, QModelIndex()); |
|
485 mTestWidget->callEmiteActivated(fetchIndex); |
|
486 QVERIFY(spysignal.count() == 0); |
|
487 QVERIFY(spysignalFileUri.count() == 0); |
|
488 QVERIFY(spysignalActivated.count() == 0); |
|
489 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
490 } |
|
491 |
|
492 |
|
493 // --------------------------------------------------------------------------- |
|
494 // testLongPressGesture |
|
495 // --------------------------------------------------------------------------- |
|
496 // |
|
497 void TestListWidget::testLongPressGesture() |
|
498 { |
|
499 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
500 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
501 |
326 QVariant data = QString("test"); |
502 QVariant data = QString("test"); |
327 // correct data to index 0 |
503 // correct data to index 0 |
328 VideoListDataModelData::setData( Qt::DisplayRole, data); |
504 VideoListDataModelData::setData( Qt::DisplayRole, data); |
329 setRowCount(1); |
505 setRowCount(2); |
330 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0,0)); |
|
331 |
|
332 QModelIndex fetchIndex = model->index(0, 0, QModelIndex()); |
|
333 |
|
334 // selection mode == HbAbstractItemView::MultiSelection |
|
335 HbListView::mSelectionMode = HbAbstractItemView::MultiSelection; |
|
336 mTestWidget->callEmiteActivated(fetchIndex); |
|
337 QVERIFY(spysignal.count() == 0); |
|
338 QVERIFY(mDummyMainWnd->mSoftKeyAction == 0); |
|
339 QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); |
|
340 |
|
341 // modelIndex is not valid |
|
342 HbListView::mSelectionMode = HbAbstractItemView::NoSelection; |
|
343 fetchIndex = QModelIndex(); |
|
344 mTestWidget->callEmiteActivated(fetchIndex); |
|
345 QVERIFY(spysignal.count() == 0); |
|
346 QVERIFY(mDummyMainWnd->mSoftKeyAction == 0); |
|
347 QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); |
|
348 |
|
349 // current level is not ELevelCategory |
|
350 fetchIndex = model->index(0, 0, QModelIndex()); |
|
351 mTestWidget->callEmiteActivated(fetchIndex); |
|
352 QVERIFY(spysignal.count() == 0); |
|
353 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); |
|
354 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
|
355 |
|
356 // current level is ELevelCategory |
|
357 mTestWidget->mCurrentLevel= VideoCollectionCommon::ELevelCategory; |
|
358 |
|
359 // -> getType() != ECollections |
|
360 mTestWidget->callEmiteActivated(fetchIndex); |
|
361 QVERIFY(spysignal.count() == 0); |
|
362 QVERIFY(mDummyMainWnd->mSoftKeyAction == 0); |
|
363 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); |
|
364 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
|
365 |
|
366 // -> getType() == ECollections |
|
367 |
|
368 // --> variant is not valid (invalid data at row index 1) |
|
369 fetchIndex = model->index(1, 0, QModelIndex()); |
|
370 mTestWidget->callEmiteActivated(fetchIndex); |
|
371 QVERIFY(spysignal.count() == 0); |
|
372 QVERIFY(mDummyMainWnd->mSoftKeyAction == 0); |
|
373 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 1); |
|
374 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
|
375 |
|
376 // --> variant is valid (correct data at index 0),5 collectionOpened -signal should be emitted |
|
377 mDummyMainWnd->mSoftKeyAction = 0; |
|
378 fetchIndex = model->index(0, 0, QModelIndex()); |
|
379 mTestWidget->callEmiteActivated(fetchIndex); |
|
380 QVERIFY(spysignal.count() == 1); |
|
381 // QVERIFY(mDummyMainWnd->mSoftKeyAction == mTestWidget->mSecSkAction); |
|
382 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0); |
|
383 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
|
384 |
|
385 hbInstance->mWindowses.clear(); |
|
386 } |
|
387 |
|
388 |
|
389 // --------------------------------------------------------------------------- |
|
390 // testLongPressGesture |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 void TestListWidget::testLongPressGesture() |
|
394 { |
|
395 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
396 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
397 |
|
398 QVariant data = QString("test"); |
|
399 // correct data to index 0 |
|
400 VideoListDataModelData::setData( Qt::DisplayRole, data); |
|
401 setRowCount(1); |
|
402 |
506 |
403 QPointF point(1,1); |
507 QPointF point(1,1); |
404 |
508 mTestWidget->initialize(*model); |
405 QSignalSpy spysignal(mTestWidget, SIGNAL(command(int))); |
509 |
406 mTestWidget->initialize(*model); |
510 mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection); |
407 hbInstance->mWindowses.append(mDummyMainWnd); |
|
408 |
|
409 HbListView::mSelectionMode = HbAbstractItemView::MultiSelection; |
|
410 // mDetailsReady is false |
511 // mDetailsReady is false |
411 mTestWidget->callLongPressGesture(point); |
512 mTestWidget->callLongPressGesture(point); |
412 QVERIFY(spysignal.count() == 1); |
|
413 QVERIFY(HbMenuData::mExecPoint != point); |
513 QVERIFY(HbMenuData::mExecPoint != point); |
414 QVERIFY(HbListView::mLongPressedPoint != point); |
514 QVERIFY(HbListView::mLongPressedPoint != point); |
415 spysignal.clear(); |
|
416 |
515 |
417 // multiselection is on |
516 // multiselection is on |
418 mTestWidget->callLongPressGesture(point); |
517 mTestWidget->callLongPressGesture(point); |
419 QVERIFY(spysignal.count() == 0); |
518 QVERIFY(HbMenuData::mExecPoint != point); |
|
519 |
|
520 // selection mode is custom |
|
521 mTestWidget->setSelectionMode(-1); |
|
522 |
|
523 mTestWidget->callLongPressGesture(point); |
420 QVERIFY(HbMenuData::mExecPoint != point); |
524 QVERIFY(HbMenuData::mExecPoint != point); |
421 |
525 |
422 // current index is invalid |
526 // item at position is null |
423 HbListView::mSelectionMode = HbAbstractItemView::NoSelection; |
527 HbListViewItem *pTmp = mTestWidget->mItem; |
|
528 mTestWidget->mItem = 0; |
|
529 mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection); |
424 HbListView::mCurrentIndex = QModelIndex(); |
530 HbListView::mCurrentIndex = QModelIndex(); |
425 mTestWidget->callLongPressGesture(point); |
531 mTestWidget->callLongPressGesture(point); |
426 QVERIFY(spysignal.count() == 0); |
|
427 QVERIFY(HbMenuData::mExecPoint != point); |
532 QVERIFY(HbMenuData::mExecPoint != point); |
428 QVERIFY(HbListView::mLongPressedPoint == point); |
533 QVERIFY(HbListView::mLongPressedPoint == point); |
429 |
534 |
430 // current index is valid |
535 // item at position is not null, but returns invalid index |
|
536 mTestWidget->mItem = pTmp; |
|
537 mTestWidget->mItem->mModelIndex = QModelIndex(); |
|
538 mTestWidget->callLongPressGesture(point); |
|
539 QVERIFY(HbMenuData::mExecPoint != point); |
|
540 QVERIFY(HbListView::mLongPressedPoint == point); |
|
541 |
|
542 // item at position is not null, returns current index is valid |
431 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
543 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
544 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
432 |
545 |
433 // model is == 0 |
546 // model is == 0 |
434 VideoSortFilterProxyModel *tmp = mTestWidget->mModel; |
547 VideoSortFilterProxyModel *tmp = mTestWidget->mModel; |
435 mTestWidget->mModel = 0; |
548 mTestWidget->mModel = 0; |
436 mTestWidget->callLongPressGesture(point); |
549 mTestWidget->callLongPressGesture(point); |
437 QVERIFY(spysignal.count() == 0); |
|
438 QVERIFY(HbMenuData::mExecPoint != point); |
550 QVERIFY(HbMenuData::mExecPoint != point); |
439 QVERIFY(HbListView::mLongPressedPoint == point); |
551 QVERIFY(HbListView::mLongPressedPoint == point); |
440 mTestWidget->mModel = tmp; |
552 mTestWidget->mModel = tmp; |
441 |
553 HbListView::mLongPressedPoint = QPointF(); |
442 // mCurrentLevel != ELevelCategory |
554 |
443 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
555 // gotten id != KVcxMvcMediaTypeVideo, service is true and id != KVcxMvcMediaTypeAlbum |
444 mTestWidget->callLongPressGesture(point); |
556 VideoSortFilterProxyModelData::mItemIds.clear(); |
445 QVERIFY(spysignal.count() == 0); |
557 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
|
558 mTestWidget->mIsService = true; |
|
559 mTestWidget->callLongPressGesture(point); |
|
560 QVERIFY(HbMenuData::mExecPoint != point); |
|
561 QVERIFY(HbListView::mLongPressedPoint == point); |
|
562 HbListView::mLongPressedPoint = QPointF(); |
|
563 |
|
564 // gotten id != KVcxMvcMediaTypeVideo, service is false and id != KVcxMvcMediaTypeAlbum |
|
565 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
566 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1)); |
|
567 mTestWidget->mIsService = false; |
|
568 mTestWidget->callLongPressGesture(point); |
|
569 QVERIFY(HbMenuData::mExecPoint != point); |
|
570 QVERIFY(HbListView::mLongPressedPoint == point); |
|
571 HbListView::mLongPressedPoint = QPointF(); |
|
572 |
|
573 // gotten id != KVcxMvcMediaTypeVideo, service is false and id == KVcxMvcMediaTypeAlbum |
|
574 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
575 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2)); |
|
576 mTestWidget->mIsService = false; |
|
577 mTestWidget->callLongPressGesture(point); |
446 QVERIFY(HbMenuData::mExecPoint == point); |
578 QVERIFY(HbMenuData::mExecPoint == point); |
447 QVERIFY(HbListView::mLongPressedPoint == point); |
579 QVERIFY(HbListView::mLongPressedPoint == point); |
448 HbMenuData::mExecPoint = QPointF(); |
580 HbMenuData::mExecPoint = QPointF(); |
449 |
581 HbListView::mLongPressedPoint = QPointF(); |
450 // mCurrentLevel == ELevelCategory |
582 |
451 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
583 // gotten id == KVcxMvcMediaTypeVideo |
452 |
584 VideoSortFilterProxyModelData::mItemIds.clear(); |
453 // --> mpxId.iId2 != 1 |
585 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,02)); |
454 TMPXItemId itemId; |
586 mTestWidget->mIsService = false; |
455 itemId.iId2 = 0; |
587 mTestWidget->callLongPressGesture(point); |
456 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
|
457 mTestWidget->callLongPressGesture(point); |
|
458 QVERIFY(spysignal.count() == 0); |
|
459 QVERIFY(HbMenuData::mExecPoint == point); |
588 QVERIFY(HbMenuData::mExecPoint == point); |
460 QVERIFY(HbListView::mLongPressedPoint == point); |
589 QVERIFY(HbListView::mLongPressedPoint == point); |
461 HbMenuData::mExecPoint = QPointF(); |
590 HbMenuData::mExecPoint = QPointF(); |
462 VideoSortFilterProxyModelData::mItemIds.clear(); |
591 HbListView::mLongPressedPoint = QPointF(); |
463 |
592 |
464 // --> mpxId.iId2 == 1 |
593 // no context menu |
465 itemId.iId2 = 1; |
594 // (context menu setup fails, due invalid amount of correct actions) |
466 |
|
467 // ---> mpxId.iId1 == KVcxMvcCategoryIdDownloads |
|
468 itemId.iId1 = KVcxMvcCategoryIdDownloads; |
|
469 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
|
470 mTestWidget->callLongPressGesture(point); |
|
471 QVERIFY(spysignal.count() == 0); |
|
472 QVERIFY(HbMenuData::mExecPoint == point); |
|
473 QVERIFY(HbListView::mLongPressedPoint == point); |
|
474 HbMenuData::mExecPoint = QPointF(); |
|
475 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
476 |
|
477 // ---> mpxId.iId1 == KVcxMvcCategoryIdCaptured |
|
478 itemId.iId1 = KVcxMvcCategoryIdCaptured; |
|
479 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
|
480 mTestWidget->callLongPressGesture(point); |
|
481 QVERIFY(spysignal.count() == 0); |
|
482 QVERIFY(HbMenuData::mExecPoint == point); |
|
483 QVERIFY(HbListView::mLongPressedPoint == point); |
|
484 HbMenuData::mExecPoint = QPointF(); |
|
485 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
486 |
|
487 // ---> mpxId.iId1 != KVcxMvcCategoryIdDownloads and mpxId.iId1 != KVcxMvcCategoryIdCaptured |
|
488 itemId.iId1 = KVcxMvcCategoryIdAll; |
|
489 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
|
490 mTestWidget->callLongPressGesture(point); |
|
491 QVERIFY(spysignal.count() == 0); |
|
492 QVERIFY(HbMenuData::mExecPoint == point); |
|
493 QVERIFY(HbListView::mLongPressedPoint == point); |
|
494 HbMenuData::mExecPoint = QPointF(); |
|
495 |
|
496 // context menu setup fails, due invalid amount of correct actions |
|
497 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin(); |
595 QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin(); |
498 iter++; |
596 iter++; |
499 HbAction *nullAction = 0; |
597 HbAction *nullAction = 0; |
500 iter.value() = nullAction; |
598 iter.value() = nullAction; |
501 mTestWidget->callLongPressGesture(point); |
599 mTestWidget->callLongPressGesture(point); |
502 QVERIFY(spysignal.count() == 0); |
|
503 QVERIFY(HbMenuData::mExecPoint != point); |
600 QVERIFY(HbMenuData::mExecPoint != point); |
504 QVERIFY(HbListView::mLongPressedPoint == point); |
601 QVERIFY(HbListView::mLongPressedPoint == point); |
505 |
|
506 } |
602 } |
507 |
603 |
508 // --------------------------------------------------------------------------- |
604 // --------------------------------------------------------------------------- |
509 // testSetContextMenu |
605 // testSetContextMenu |
510 // --------------------------------------------------------------------------- |
606 // --------------------------------------------------------------------------- |
555 QVERIFY(!mTestWidget->mContextMenu); |
653 QVERIFY(!mTestWidget->mContextMenu); |
556 QVERIFY(mTestWidget->mContextMenuActions.count() == 0); |
654 QVERIFY(mTestWidget->mContextMenuActions.count() == 0); |
557 |
655 |
558 // mCurrentLevel == ELevelCategory |
656 // mCurrentLevel == ELevelCategory |
559 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
657 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory; |
560 // --> getType returns ECollections |
658 // mIsService is false |
561 // ---> default collection flag is on |
659 mTestWidget->mIsService = false; |
562 mTestWidget->callLongPressGesture(point); |
660 mTestWidget->callLongPressGesture(point); |
563 iter = mTestWidget->mContextMenuActions.begin(); |
661 iter = mTestWidget->mContextMenuActions.begin(); |
564 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
662 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
565 visibleCount = 0; |
663 visibleCount = 0; |
566 while(iter != mTestWidget->mContextMenuActions.end()) |
664 while(iter != mTestWidget->mContextMenuActions.end()) |
567 { |
665 { |
568 if(iter.value()->mVisible) |
666 if(iter.value()->mVisible) |
569 { |
667 { |
570 visibleCount++; |
668 visibleCount++; |
571 } |
669 } |
572 ++iter; |
670 ++iter; |
573 } |
671 } |
574 QVERIFY(visibleCount == 0); |
672 QVERIFY(visibleCount == 2); |
575 |
673 |
576 // ---> default collection flag is off |
674 // mIsService is true |
577 VideoSortFilterProxyModelData::mItemIds.clear(); |
675 mTestWidget->mIsService = true; |
578 itemId.iId2 = 1; |
676 mTestWidget->callLongPressGesture(point); |
579 itemId.iId1 = KVcxMvcCategoryIdAll; |
677 iter = mTestWidget->mContextMenuActions.begin(); |
580 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
678 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
581 mTestWidget->callLongPressGesture(point); |
679 visibleCount = 0; |
582 iter = mTestWidget->mContextMenuActions.begin(); |
680 while(iter != mTestWidget->mContextMenuActions.end()) |
583 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
681 { |
584 visibleCount = 0; |
682 if(iter.value()->mVisible) |
585 while(iter != mTestWidget->mContextMenuActions.end()) |
683 { |
586 { |
684 visibleCount++; |
587 if(iter.value()->mVisible) |
685 } |
588 { |
686 ++iter; |
589 visibleCount++; |
687 } |
590 } |
688 QVERIFY(visibleCount == 0); |
591 ++iter; |
689 |
592 } |
690 // mCurrentLevel == ELevelAlbum |
593 QVERIFY(visibleCount == 4); |
691 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
594 |
692 // mIsService is false |
595 // --> getType returns EUserColItems |
693 mTestWidget->mIsService = false; |
596 mTestWidget->callLongPressGesture(point); |
694 mTestWidget->callLongPressGesture(point); |
597 iter = mTestWidget->mContextMenuActions.begin(); |
695 iter = mTestWidget->mContextMenuActions.begin(); |
598 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
696 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
599 visibleCount = 0; |
697 visibleCount = 0; |
600 while(iter != mTestWidget->mContextMenuActions.end()) |
698 while(iter != mTestWidget->mContextMenuActions.end()) |
601 { |
699 { |
602 if(iter.value()->mVisible) |
700 if(iter.value()->mVisible) |
603 { |
701 { |
604 visibleCount++; |
702 visibleCount++; |
605 } |
703 } |
606 ++iter; |
704 ++iter; |
607 } |
705 } |
608 QVERIFY(visibleCount == 4); |
706 QVERIFY(visibleCount == 3); |
609 |
707 |
610 // --> getType returns EUnknow |
708 // mIsService is true |
611 mTestWidget->mCurrentLevel = (VideoCollectionCommon::TCollectionLevels)0; |
709 // object needs to be resetted for the service use |
612 mTestWidget->callLongPressGesture(point); |
710 cleanup(); |
613 iter = mTestWidget->mContextMenuActions.begin(); |
711 init(); |
614 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
712 setRowCount(1); |
615 visibleCount = 0; |
713 model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
616 while(iter != mTestWidget->mContextMenuActions.end()) |
714 mTestWidget->initialize(*model); |
617 { |
715 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
618 if(iter.value()->mVisible) |
716 mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ; |
619 { |
717 |
620 visibleCount++; |
718 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum; |
621 } |
719 VideoSortFilterProxyModelData::mItemIds.append(itemId); |
622 ++iter; |
720 mTestWidget->mIsService = true; |
623 } |
721 mTestWidget->callLongPressGesture(point); |
624 QVERIFY(visibleCount == 0); |
722 iter = mTestWidget->mContextMenuActions.begin(); |
625 } |
723 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
626 |
724 visibleCount = 0; |
627 // --------------------------------------------------------------------------- |
725 while(iter != mTestWidget->mContextMenuActions.end()) |
628 // testShareItemSlot |
726 { |
629 // --------------------------------------------------------------------------- |
727 if(iter.value()->mVisible) |
630 // |
728 { |
631 void TestListWidget::testShareItemSlot() |
729 visibleCount++; |
632 { |
730 } |
633 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
731 ++iter; |
634 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
732 } |
635 VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(model->sourceModel()); |
733 QVERIFY(visibleCount == 2); |
636 |
734 |
637 // nothing to test yet |
735 //invalid level |
638 HbMessageBoxData::mLatestTxt = ""; |
736 mTestWidget->mCurrentLevel = (VideoCollectionCommon::TCollectionLevels)0; |
639 mTestWidget->initialize(*model); |
737 mTestWidget->callLongPressGesture(point); |
640 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(shareItemSlot())); |
738 iter = mTestWidget->mContextMenuActions.begin(); |
641 emit testSignal(); |
739 QVERIFY(iter != mTestWidget->mContextMenuActions.end()); |
642 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
740 visibleCount = 0; |
643 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(shareItemSlot())); |
741 while(iter != mTestWidget->mContextMenuActions.end()) |
644 |
742 { |
645 } |
743 if(iter.value()->mVisible) |
646 |
744 { |
|
745 visibleCount++; |
|
746 } |
|
747 ++iter; |
|
748 } |
|
749 QVERIFY(visibleCount == 0); |
|
750 } |
|
751 |
|
752 void TestListWidget::testDoDelayedsSlot() |
|
753 { |
|
754 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot())); |
|
755 |
|
756 //dodelayed calls create context menu, which is already tested at |
|
757 // testSetContextMenu -method, these tests are just for coverity's sake |
|
758 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
759 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
760 mTestWidget->initialize(*model); |
|
761 |
|
762 delete mTestWidget->mContextMenu; |
|
763 mTestWidget->mContextMenu = 0; |
|
764 int visibleCount = 0; |
|
765 mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos; |
|
766 |
|
767 // no context menu |
|
768 emit testSignal(); |
|
769 |
|
770 QVERIFY(mTestWidget->mContextMenuActions.count() == 6); |
|
771 |
|
772 // context menu exists |
|
773 emit testSignal(); |
|
774 |
|
775 QVERIFY(mTestWidget->mContextMenuActions.count() == 6); |
|
776 |
|
777 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot())); |
|
778 } |
|
779 |
647 // --------------------------------------------------------------------------- |
780 // --------------------------------------------------------------------------- |
648 // testDeleteItemSlot |
781 // testDeleteItemSlot |
649 // --------------------------------------------------------------------------- |
782 // --------------------------------------------------------------------------- |
650 // |
783 // |
651 void TestListWidget::testDeleteItemSlot() |
784 void TestListWidget::testDeleteItemSlot() |
729 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
855 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
730 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
856 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot())); |
731 } |
857 } |
732 |
858 |
733 // --------------------------------------------------------------------------- |
859 // --------------------------------------------------------------------------- |
|
860 // testPlayItemSlot |
|
861 // --------------------------------------------------------------------------- |
|
862 // |
|
863 void TestListWidget::testPlayItemSlot() |
|
864 { |
|
865 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
866 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
867 mTestWidget->initialize(*model); |
|
868 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); |
|
869 setRowCount(1); |
|
870 TMPXItemId savedId = TMPXItemId(1,1); |
|
871 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
872 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
873 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
874 |
|
875 emit testSignal(); |
|
876 |
|
877 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId); |
|
878 |
|
879 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot())); |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
734 // testPlayAllSlot |
883 // testPlayAllSlot |
735 // --------------------------------------------------------------------------- |
884 // --------------------------------------------------------------------------- |
736 // |
885 // |
737 void TestListWidget::testPlayAllSlot() |
886 void TestListWidget::testPlayAllSlot() |
738 { |
887 { |
739 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
888 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
740 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
889 emit testSignal(); |
741 |
890 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
742 // nothing to test yet |
891 } |
|
892 |
|
893 // --------------------------------------------------------------------------- |
|
894 // testAddToCollectionSlot |
|
895 // --------------------------------------------------------------------------- |
|
896 // |
|
897 void TestListWidget::testAddToCollectionSlot() |
|
898 { |
|
899 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
900 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
901 |
|
902 VideoListSelectionDialogData::mSelectionType = -1; |
|
903 VideoListSelectionDialogData::mSettedMpxId = TMPXItemId::InvalidId(); |
|
904 |
|
905 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |
|
906 setRowCount(1); |
|
907 TMPXItemId savedId = TMPXItemId(1,1); |
|
908 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
909 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
910 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
911 |
|
912 // no model |
|
913 emit testSignal(); |
|
914 QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 ); |
|
915 QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId()); |
|
916 |
|
917 mTestWidget->initialize(*model); |
|
918 // dialog finding fails |
|
919 VideoCollectionUiLoaderData::mFindFailureNameList.append(DOCML_NAME_DIALOG); |
|
920 emit testSignal(); |
|
921 QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 ); |
|
922 QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId()); |
|
923 VideoCollectionUiLoaderData::mFindFailureNameList.clear(); |
|
924 |
|
925 // invalid id at current index |
|
926 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
927 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); |
|
928 emit testSignal(); |
|
929 QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 ); |
|
930 QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId()); |
|
931 |
|
932 // valid id at current index |
|
933 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
934 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
935 emit testSignal(); |
|
936 QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::ESelectCollection ); |
|
937 QVERIFY(VideoListSelectionDialogData::mSettedMpxId == savedId); |
|
938 |
|
939 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |
|
940 |
|
941 } |
|
942 |
|
943 // --------------------------------------------------------------------------- |
|
944 // testRemoveFromCollectionSlot |
|
945 // --------------------------------------------------------------------------- |
|
946 // |
|
947 void TestListWidget::testRemoveFromCollectionSlot() |
|
948 { |
|
949 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
950 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
951 |
|
952 VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = 0; |
|
953 VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId(); |
|
954 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
955 |
|
956 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot())); |
|
957 setRowCount(2); |
|
958 TMPXItemId savedId = TMPXItemId(1,1); |
|
959 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
960 // invalid id at index 0 |
|
961 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); |
|
962 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
963 HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); |
|
964 |
|
965 // no model |
|
966 emit testSignal(); |
|
967 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
968 |
|
969 mTestWidget->initialize(*model); |
|
970 VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId::InvalidId(); |
|
971 |
|
972 // collection id is invalid |
|
973 emit testSignal(); |
|
974 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
975 VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(1,2); |
|
976 |
|
977 // media at current index is invalid |
|
978 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
979 emit testSignal(); |
|
980 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId()); |
|
981 |
|
982 // all is ok |
|
983 HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); |
|
984 emit testSignal(); |
|
985 |
|
986 QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId(1,2)); |
|
987 // ids are to be saved at VideoSortFilterProxyModelData::mItemIds |
|
988 QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == savedId); |
|
989 |
|
990 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot())); |
|
991 } |
|
992 |
|
993 // --------------------------------------------------------------------------- |
|
994 // testRemoveCollectionSlot |
|
995 // --------------------------------------------------------------------------- |
|
996 // |
|
997 void TestListWidget::testRemoveCollectionSlot() |
|
998 { |
|
999 VideoSortFilterProxyModelData::mRemoveAlbumsFails = false; |
|
1000 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
1001 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
1002 |
|
1003 HbMessageBoxData::mQuestionReturnValue = true; |
743 HbMessageBoxData::mLatestTxt = ""; |
1004 HbMessageBoxData::mLatestTxt = ""; |
744 mTestWidget->initialize(*model); |
1005 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
745 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
1006 |
746 emit testSignal(); |
1007 setRowCount(1); |
|
1008 HbListView::mCurrentIndex = model->index(0, 0, QModelIndex()); |
|
1009 |
|
1010 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeCollectionSlot())); |
|
1011 |
|
1012 setRowCount(2); |
|
1013 TMPXItemId savedId = TMPXItemId(1,1); |
|
1014 VideoSortFilterProxyModelData::mItemIds.clear(); |
|
1015 // invalid id at index 0 |
|
1016 VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId()); |
|
1017 VideoSortFilterProxyModelData::mItemIds.append(savedId); |
|
1018 HbListView::mCurrentIndex = model->index(1, 0, QModelIndex()); |
|
1019 |
|
1020 // no model |
|
1021 emit testSignal(); |
|
1022 QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); |
|
1023 QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); |
|
1024 |
|
1025 mTestWidget->initialize(*model); |
|
1026 |
|
1027 // invalid data |
|
1028 VideoListDataModelData::setData( Qt::DisplayRole, QVariant()); |
|
1029 emit testSignal(); |
|
1030 QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); |
|
1031 QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty()); |
|
1032 |
|
1033 // valid data |
|
1034 VideoListDataModelData::setData( Qt::DisplayRole, "test"); |
|
1035 emit testSignal(); |
|
1036 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.isValid()); |
|
1037 QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 1); |
747 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
1038 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
748 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot())); |
1039 |
749 } |
1040 // msg box return false (for coverity) |
750 |
1041 VideoSortFilterProxyModelData::mLastIndex = QModelIndex(); |
751 // --------------------------------------------------------------------------- |
|
752 // testAddItemSlot |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 void TestListWidget::testAddItemSlot() |
|
756 { |
|
757 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
758 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
759 |
|
760 // nothing to test yet |
|
761 HbMessageBoxData::mLatestTxt = ""; |
1042 HbMessageBoxData::mLatestTxt = ""; |
762 mTestWidget->initialize(*model); |
1043 HbMessageBoxData::mQuestionReturnValue = false; |
763 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addItemSlot())); |
1044 emit testSignal(); |
764 emit testSignal(); |
1045 QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid()); |
765 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
1046 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
766 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addItemSlot())); |
1047 |
767 } |
1048 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeCollectionSlot())); |
768 |
1049 } |
769 // --------------------------------------------------------------------------- |
1050 |
770 // testAddToCollectionSlot |
|
771 // --------------------------------------------------------------------------- |
|
772 // |
|
773 void TestListWidget::testAddToCollectionSlot() |
|
774 { |
|
775 VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance(); |
|
776 VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos); |
|
777 |
|
778 // nothing to test yet |
|
779 HbMessageBoxData::mLatestTxt = ""; |
|
780 mTestWidget->initialize(*model); |
|
781 connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |
|
782 emit testSignal(); |
|
783 QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty()); |
|
784 disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot())); |
|
785 } |
|
786 |
|
787 // --------------------------------------------------------------------------- |
1051 // --------------------------------------------------------------------------- |
788 // testOpenDetailsSlot |
1052 // testOpenDetailsSlot |
789 // --------------------------------------------------------------------------- |
1053 // --------------------------------------------------------------------------- |
790 // |
1054 // |
791 void TestListWidget::testOpenDetailsSlot() |
1055 void TestListWidget::testOpenDetailsSlot() |