logsui/logsapp/tsrc/ut_logsapp/src/ut_logseffecthandler.cpp
changeset 0 4a5361db8937
child 8 6c9acdc6adc0
equal deleted inserted replaced
-1:000000000000 0:4a5361db8937
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 //USER
       
    19 #include "ut_logseffecthandler.h"
       
    20 #include "logseffecthandler.h"
       
    21 
       
    22 //SYSTEM
       
    23 #include <QtTest/QtTest>
       
    24 #include <hblabel.h>
       
    25 #include <hbmainwindow.h>
       
    26 
       
    27 
       
    28 void UT_LogsEffectHandler::initTestCase()
       
    29 {
       
    30 }
       
    31 
       
    32 void UT_LogsEffectHandler::cleanupTestCase()
       
    33 {
       
    34 }
       
    35 
       
    36 
       
    37 void UT_LogsEffectHandler::init()
       
    38 {
       
    39     mEffect = new LogsEffectHandler();
       
    40     mLabel = new HbLabel();
       
    41     mLabel2 = new HbLabel();
       
    42 }
       
    43 
       
    44 void UT_LogsEffectHandler::cleanup()
       
    45 {
       
    46     delete mEffect;
       
    47     mEffect = 0;
       
    48     delete mLabel;
       
    49     mLabel = 0;
       
    50     delete mLabel2;
       
    51     mLabel2 = 0;
       
    52 }
       
    53 
       
    54 void UT_LogsEffectHandler::testConstructor()
       
    55 {
       
    56     QVERIFY( mEffect );
       
    57 }
       
    58 
       
    59 void UT_LogsEffectHandler::testStartDissappearAppearByFadingEffect()
       
    60 {
       
    61     QVERIFY( mEffect->mFadeGroup->state() == QAbstractAnimation::Stopped );
       
    62     mEffect->startDissappearAppearByFadingEffect(*mLabel);
       
    63     QVERIFY( mEffect->mFadeGroup->state() == QAbstractAnimation::Running );
       
    64     
       
    65     // Simulate animation progess, when dissappearing has completed effecthandler
       
    66     // sends signal, other progress in anim does not cause signal to be sent
       
    67     QSignalSpy spy(mEffect, SIGNAL(dissappearByFadingComplete()));
       
    68     mEffect->fadeAnimationChanged(mEffect->mFadeGroup->animationAt(1));
       
    69     QVERIFY(spy.count() == 1 );
       
    70     mEffect->fadeAnimationChanged(0);
       
    71     QVERIFY(spy.count() == 1 );
       
    72     
       
    73     // When effect is running and new effect is requested, previous effect is stopped
       
    74     mEffect->startDissappearAppearByFadingEffect(*mLabel); 
       
    75 }
       
    76 
       
    77 void UT_LogsEffectHandler::testStartDissappearAppearByMovingEffect()
       
    78 {
       
    79     QVERIFY( mEffect->mMoveGroup->state() == QAbstractAnimation::Stopped );
       
    80     mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, false, 0);
       
    81     QVERIFY( mEffect->mMoveGroup->state() == QAbstractAnimation::Running );
       
    82     QVERIFY( mEffect->mMoveGroup2->state() == QAbstractAnimation::Running );
       
    83     
       
    84     // Simulate animation progess, when dissappearing has completed effecthandler
       
    85     // sends signal, other progress in anim does not cause signal to be sent
       
    86     QSignalSpy spy(mEffect, SIGNAL(dissappearByMovingComplete()));
       
    87     mEffect->moveAnimationChanged(mEffect->mMoveGroup->animationAt(1));
       
    88     QVERIFY(spy.count() == 1 );
       
    89     mEffect->moveAnimationChanged(0);
       
    90     QVERIFY(spy.count() == 1 );
       
    91     
       
    92     // When effect is running and new effect is requested, previous effect is stopped
       
    93     mEffect->startDissappearAppearByMovingEffect(*mLabel, *mLabel2, true, 0); 
       
    94 }
       
    95 
       
    96 void UT_LogsEffectHandler::testStartMoveNotPossibleEffect()
       
    97 {
       
    98     QVERIFY( mEffect->mMoveNotPossibleGroup->state() == QAbstractAnimation::Stopped );
       
    99     mEffect->startMoveNotPossibleEffect(*mLabel, false, 0);
       
   100     QVERIFY( mEffect->mMoveNotPossibleGroup->state() == QAbstractAnimation::Running );
       
   101 }