homescreenapp/hsapplication/tsrc/t_hsapplication/t_hsapplicationexe/src/t_hsstatemachine.cpp
changeset 90 3ac3aaebaee5
equal deleted inserted replaced
86:e4f038c420f7 90:3ac3aaebaee5
       
     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:  Main test class for test library.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QStateMachine>
       
    19 #include <QSignalSpy>
       
    20 #include <QDir>
       
    21 #include <hbinstance.h>
       
    22 
       
    23 #include "t_hsapplication.h"
       
    24 #include "hsstatemachine.h"
       
    25 #include "hsapp_defs.h"
       
    26 #include <qservicemanager.h>
       
    27 
       
    28 QTM_USE_NAMESPACE
       
    29 
       
    30 const QString xmlPath = "./hsresources/plugins/stateplugins/";
       
    31 const QString mockedStatePluginsXml = "mockstateplugins.xml";
       
    32 
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void t_hsapplication::testConstruction()
       
    39 {
       
    40     HsStateMachine* rt = new HsStateMachine();
       
    41     QVERIFY(rt);
       
    42     QVERIFY(rt->mContentService);    
       
    43     delete rt;
       
    44 }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void t_hsapplication::testStartStop()
       
    50 {
       
    51     HsStateMachine* rt = new HsStateMachine();
       
    52     QObject::connect(rt, SIGNAL(event_exit()), rt, SIGNAL(finished()), Qt::QueuedConnection);
       
    53     QSignalSpy startSpy(rt, SIGNAL(started()));
       
    54     QSignalSpy stopSpy(rt,SIGNAL(stopped()));
       
    55     rt->start();
       
    56     qApp->processEvents();
       
    57     rt->stop();
       
    58     qApp->processEvents();
       
    59 	
       
    60     QVERIFY(startSpy.count());
       
    61     QVERIFY(stopSpy.count());
       
    62     
       
    63     delete rt;
       
    64 }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void t_hsapplication::testOnIdleStateEntered()
       
    70 {
       
    71     HsStateMachine rt;
       
    72     rt.onIdleStateEntered();
       
    73     QVERIFY(rt.mIdleStateActive);
       
    74 }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void t_hsapplication::testOnIdleStateExited()
       
    80 {
       
    81     HsStateMachine rt;
       
    82     rt.onIdleStateExited();
       
    83     QVERIFY(!rt.mIdleStateActive);
       
    84 }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void t_hsapplication::testRuntimeEventFilter()
       
    90 {
       
    91     HsStateMachine rt;
       
    92     QVERIFY(!rt.eventFilter(0,&QEvent(QEvent::ActionAdded)));
       
    93 
       
    94     QEvent *e = new QEvent(QEvent::ApplicationActivate);
       
    95     QVERIFY(!rt.eventFilter(0,e));
       
    96     
       
    97     rt.onIdleStateEntered();
       
    98     
       
    99     delete e;    
       
   100 
       
   101     e = new QEvent(QEvent::ApplicationDeactivate);
       
   102     QVERIFY(!rt.eventFilter(0,e));
       
   103     delete e;
       
   104 }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void t_hsapplication::testActivityRequested()
       
   110 {
       
   111     HsStateMachine rt;
       
   112     rt.activityRequested(QString());
       
   113     rt.activityRequested(Hs::groupAppLibRecentView);
       
   114 }