386 pos = mContentScrollArea->contentWidget()->pos(); |
388 pos = mContentScrollArea->contentWidget()->pos(); |
387 QCOMPARE(abs(pos.x()), abs(mContentScrollArea->contentWidget()->pos().x())); |
389 QCOMPARE(abs(pos.x()), abs(mContentScrollArea->contentWidget()->pos().x())); |
388 QCOMPARE(abs(pos.y()), abs(mContentScrollArea->contentWidget()->pos().y())); |
390 QCOMPARE(abs(pos.y()), abs(mContentScrollArea->contentWidget()->pos().y())); |
389 QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange); |
391 QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange); |
390 |
392 |
391 //2) |
393 //3) |
392 newPos = QPointF(-20,0); |
394 newPos = QPointF(-20,0); |
393 mContentScrollArea->mMoveDirection = ECalenScrollToNext; |
395 mContentScrollArea->mMoveDirection = ECalenScrollToNext; |
394 mContentScrollArea->moveTo(newPos); |
396 mContentScrollArea->moveTo(newPos); |
395 pos = mContentScrollArea->contentWidget()->pos(); |
397 pos = mContentScrollArea->contentWidget()->pos(); |
396 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().x()), abs(pos.x())); |
398 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().x()), abs(pos.x())); |
397 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().y()), abs(pos.y())); |
399 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().y()), abs(pos.y())); |
398 QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange); |
400 QCOMPARE(mContentScrollArea->mMoveDirection, ECalenScrollNoDayChange); |
|
401 |
|
402 //4) |
|
403 newPos = QPointF(20,0); |
|
404 pos = mContentScrollArea->contentWidget()->pos(); |
|
405 mContentScrollArea->mDisallowedDirection = ECalenScrollToNext; |
|
406 mContentScrollArea->mMoveDirection = ECalenScrollToNext; |
|
407 mContentScrollArea->moveTo(newPos); |
|
408 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().x()), abs(pos.x())); |
|
409 QCOMPARE(abs(mContentScrollArea->contentWidget()->pos().y()), abs(pos.y())); |
399 #endif /* __WINSCW__ */ |
410 #endif /* __WINSCW__ */ |
400 } |
411 } |
401 |
412 |
402 /*! |
413 /*! |
403 Test function for checking if swipe is horizontal or not |
414 Test function for checking if swipe is horizontal or not |
457 mContentScrollArea->orientationChanged(Qt::Vertical); |
468 mContentScrollArea->orientationChanged(Qt::Vertical); |
458 QCOMPARE(mContentScrollArea->mOrientation, Qt::Vertical); |
469 QCOMPARE(mContentScrollArea->mOrientation, Qt::Vertical); |
459 #endif /* __WINSCW__ */ |
470 #endif /* __WINSCW__ */ |
460 } |
471 } |
461 |
472 |
|
473 /*! |
|
474 Test checkPanDirection function |
|
475 1) test pan direction, gesture cancelled, vertical orientation |
|
476 2) test pan direction, gesture started, vertical orientation, vertical movement |
|
477 3) test pan direction, gesture started, vertical orientation, horizontal movement |
|
478 4) test pan direction, gesture started, horizontal orientation, vertical movement |
|
479 5) test pan direction, gesture started, horizontal orientation, horizontal movement |
|
480 */ |
|
481 void TestCalenDayContentScrollArea::testCheckPanDirection() |
|
482 { |
|
483 #ifndef __WINSCW__ |
|
484 QPanGesture *gesture = new QPanGesture(); |
|
485 |
|
486 //1) |
|
487 gesture->setOffset(QPointF(10, 100)); |
|
488 gTestGestureState = Qt::GestureCanceled; |
|
489 mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet; |
|
490 mContentScrollArea->mOrientation = Qt::Vertical; |
|
491 mContentScrollArea->checkPanDirection(gesture); |
|
492 QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanNotSet); |
|
493 |
|
494 // Cases 2-5 temporarily unavailable |
|
495 /* |
|
496 //2) |
|
497 gesture->setOffset(QPointF(10, 100)); |
|
498 gTestGestureState = Qt::GestureStarted; |
|
499 mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet; |
|
500 mContentScrollArea->mOrientation = Qt::Vertical; |
|
501 mContentScrollArea->checkPanDirection(gesture); |
|
502 QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanVertical); |
|
503 |
|
504 //3) |
|
505 gesture->setOffset(QPointF(100, 10)); |
|
506 gTestGestureState = Qt::GestureStarted; |
|
507 mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet; |
|
508 mContentScrollArea->mOrientation = Qt::Vertical; |
|
509 mContentScrollArea->checkPanDirection(gesture); |
|
510 QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanHorizontal); |
|
511 |
|
512 //4) |
|
513 gesture->setOffset(QPointF(10, 100)); |
|
514 gTestGestureState = Qt::GestureStarted; |
|
515 mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet; |
|
516 mContentScrollArea->mOrientation = Qt::Horizontal; |
|
517 mContentScrollArea->checkPanDirection(gesture); |
|
518 QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanHorizontal); |
|
519 |
|
520 //5) |
|
521 gesture->setOffset(QPointF(100, 10)); |
|
522 gTestGestureState = Qt::GestureStarted; |
|
523 mContentScrollArea->mPanDayDirection = CalenDayContentScrollArea::ECalenPanNotSet; |
|
524 mContentScrollArea->mOrientation = Qt::Horizontal; |
|
525 mContentScrollArea->checkPanDirection(gesture); |
|
526 QCOMPARE(mContentScrollArea->mPanDayDirection, CalenDayContentScrollArea::ECalenPanVertical); |
|
527 */ |
|
528 #endif /* __WINSCW__ */ |
|
529 } |
|
530 |
|
531 /*! |
|
532 Test setter and getter for disallowed direction |
|
533 1) test setter |
|
534 2) test getter |
|
535 */ |
|
536 void TestCalenDayContentScrollArea::testSetGetDisallowedScrollDirection() |
|
537 { |
|
538 QCOMPARE(mContentScrollArea->mDisallowedDirection, ECalenScrollNoDayChange); |
|
539 |
|
540 //1) |
|
541 mContentScrollArea->setDisallowedScrollDirection(ECalenScrollToNext); |
|
542 QCOMPARE(mContentScrollArea->mDisallowedDirection, ECalenScrollToNext); |
|
543 |
|
544 //2) |
|
545 QCOMPARE(mContentScrollArea->disallowedScrollDirection(), ECalenScrollToNext); |
|
546 } |
|
547 |
462 QTEST_MAIN(TestCalenDayContentScrollArea); |
548 QTEST_MAIN(TestCalenDayContentScrollArea); |
463 #include "unittest_calendaycontentscrollarea.moc" |
549 #include "unittest_calendaycontentscrollarea.moc" |