phoneuis/bubblemanager2/tsrc/unit/ut_bubbleeffecthandler/ut_bubbleeffecthandler.cpp
changeset 27 2f8f8080a020
child 46 bc5a64e5bc3c
equal deleted inserted replaced
22:6bb1b21d2484 27:2f8f8080a020
       
     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 #include <QtGui>
       
    19 #include <QtTest/QtTest>
       
    20 #include <hbapplication.h>
       
    21 #include <hbwidget.h>
       
    22 #include <hblabel.h>
       
    23 #include <hbmainwindow.h>
       
    24 #include <hbfontspec.h>
       
    25 
       
    26 #include "bubbletest.h"
       
    27 #include "bubbleeffecthandler.h"
       
    28 
       
    29 class Container : public HbWidget
       
    30 {
       
    31 public:
       
    32     Container();
       
    33     ~Container();
       
    34 
       
    35     HbLabel *mLabel;
       
    36 };
       
    37 
       
    38 Container::Container()
       
    39 {
       
    40     mLabel = new HbLabel(this);
       
    41     mLabel->setAlignment(Qt::AlignCenter);
       
    42     HbFontSpec spec;
       
    43     spec.setRole(HbFontSpec::Primary);
       
    44     spec.setTextHeight(30);
       
    45     mLabel->setFontSpec(spec);
       
    46     QGraphicsLinearLayout* layout =
       
    47         new QGraphicsLinearLayout(Qt::Vertical);
       
    48     layout->addItem(mLabel);
       
    49 
       
    50     setLayout(layout);
       
    51 }
       
    52 
       
    53 Container::~Container()
       
    54 {
       
    55 }
       
    56 
       
    57 class ut_BubbleEffectHandler : public QObject
       
    58 {
       
    59     Q_OBJECT
       
    60 
       
    61 private slots:
       
    62     void initTestCase();
       
    63     void cleanupTestCase();
       
    64 
       
    65     void testMuteAppearEffect();
       
    66     void testMuteDisappearEffect();
       
    67 
       
    68 private:
       
    69     HbMainWindow* mWindow;
       
    70     BubbleEffectHandler *mEffectHandler;
       
    71     Container *mContainer;
       
    72 };
       
    73 
       
    74 void ut_BubbleEffectHandler::initTestCase()
       
    75 {
       
    76     mWindow = new HbMainWindow();
       
    77     mEffectHandler = new BubbleEffectHandler();
       
    78     mContainer = new Container();
       
    79     mContainer->mLabel->setVisible(false);
       
    80     mWindow->addView(mContainer);
       
    81     mWindow->show();
       
    82 }
       
    83 
       
    84 void ut_BubbleEffectHandler::cleanupTestCase()
       
    85 {
       
    86     delete mEffectHandler;
       
    87     delete mWindow;
       
    88 }
       
    89 
       
    90 void ut_BubbleEffectHandler::testMuteAppearEffect()
       
    91 {
       
    92     QVERIFY(mContainer->mLabel->isVisible()==false);
       
    93     QTest::qWait(500);
       
    94 
       
    95     mContainer->mLabel->setPlainText("Appearing");
       
    96 
       
    97     mEffectHandler->addEffect(mContainer->mLabel,BubbleMutedAppear);
       
    98     mEffectHandler->startEffect(BubbleMutedAppear);
       
    99     QTest::qWait(1000);
       
   100 
       
   101     QVERIFY(mContainer->mLabel->isVisible()==true);
       
   102 
       
   103     mEffectHandler->removeEffect(mContainer->mLabel,BubbleMutedAppear);
       
   104 }
       
   105 
       
   106 void ut_BubbleEffectHandler::testMuteDisappearEffect()
       
   107 {
       
   108     QVERIFY(mContainer->mLabel->isVisible()==true);
       
   109 
       
   110     mContainer->mLabel->setPlainText("Disappearing");
       
   111 
       
   112     mEffectHandler->addEffect(mContainer->mLabel,BubbleMutedDisappear);
       
   113     mEffectHandler->startEffect(BubbleMutedDisappear);
       
   114     QTest::qWait(1000);
       
   115 
       
   116     QVERIFY(mContainer->mLabel->isVisible()==false);
       
   117 
       
   118     mEffectHandler->removeEffect(mContainer->mLabel,BubbleMutedDisappear);
       
   119 }
       
   120 
       
   121 BUBBLE_TEST_MAIN(ut_BubbleEffectHandler)
       
   122 #include "ut_bubbleeffecthandler.moc"