homescreenapp/hsutils/tsrc/t_hsutils/src/t_hspropertyanimationwrapper.cpp
changeset 96 458d8c8d9580
equal deleted inserted replaced
92:6727c5d0afc7 96:458d8c8d9580
       
     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 #ifndef ONLY_MENU_TESTCASES
       
    19 
       
    20 #include "t_hsutils.h"
       
    21 #include "hspropertyanimationwrapper.h"
       
    22 
       
    23 class TestObject: public QObject
       
    24 {
       
    25     Q_OBJECT
       
    26     Q_PROPERTY(int number READ number WRITE setNumber)
       
    27 public:
       
    28     TestObject(QObject *parent=0):QObject(parent),mNumber(0){}
       
    29     int number()const { return mNumber; }
       
    30     void setNumber(int num) {mNumber = num; }
       
    31 private:
       
    32     int mNumber;
       
    33 };
       
    34 #include "t_hspropertyanimationwrapper.moc"
       
    35 
       
    36 void  t_hsUtils::testPropertyAnimationWrapper()
       
    37 {
       
    38     HsPropertyAnimationWrapper propertyAnimation;
       
    39     TestObject target;
       
    40    
       
    41     propertyAnimation.setTargetObject(&target);
       
    42     propertyAnimation.setDuration(1);
       
    43     propertyAnimation.setEndValue(5);
       
    44     propertyAnimation.setPropertyName("number");
       
    45     
       
    46     QSignalSpy spy(&propertyAnimation,SIGNAL(finished()));
       
    47     propertyAnimation.start();
       
    48     QTest::qWait(100);
       
    49     
       
    50     QVERIFY(!propertyAnimation.isRunning());
       
    51     QCOMPARE(spy.count(),1);
       
    52     QVERIFY(target.number() == 5);
       
    53     propertyAnimation.stop();
       
    54     
       
    55     propertyAnimation.setForward();
       
    56     QVERIFY(propertyAnimation.isForward());
       
    57 
       
    58     propertyAnimation.setBackward();
       
    59     QVERIFY(!propertyAnimation.isForward());
       
    60     
       
    61     propertyAnimation.setEasingCurve(QEasingCurve::Linear);
       
    62 }
       
    63 
       
    64 #endif // ONLY_MENU_TESTCASES