phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuicommandcontroller/unit_tests.cpp
branchRCL_3
changeset 61 41a7f70b3818
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
       
     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:  Unit tests for PhoneUIQtViewAdapter.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QtGui>
       
    20 #include <QList>
       
    21 #include <hbapplication.h>
       
    22 #include <phoneappcommands.hrh>
       
    23 #include <xqphoneappcommands.h>
       
    24 #include "phoneuiqtviewif.h"
       
    25 #include "pevirtualengine.h"
       
    26 #include "bubblemanagerif.h"
       
    27 #include "phonebubblewrapper.h"
       
    28 #include "phoneuicommandcontroller.h"
       
    29 #include "phoneresourceids.h"
       
    30 #include "phoneresourceadapter.h"
       
    31 #include "phoneuiqtbuttonscontroller.h"
       
    32 
       
    33 extern bool m_setActions;
       
    34 extern bool m_setInvalidCommand;
       
    35 extern QList<HbAction*> m_menuActions;
       
    36 extern bool m_setInvalidButtonCommands;
       
    37 extern bool m_setInvalidToolBarCommands;
       
    38 extern bool m_setCustomToolBarCommands;
       
    39 extern int m_phoneButtonFlags;
       
    40 
       
    41 #define PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestObject) \
       
    42 int main(int argc, char *argv[]) \
       
    43     { \
       
    44         HbApplication app(argc, argv); \
       
    45         TestObject tc; \
       
    46         QResource::registerResource("../hbcore.rcc"); \
       
    47         int ret = QTest::qExec(&tc, argc, argv); \
       
    48         /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    49         /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    50         /* app.exec() where the signal is normally emitted is not called here. */ \
       
    51         /* So, invoking the signal explicitly. */ \
       
    52         QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
       
    53         return ret; \
       
    54     }
       
    55 
       
    56 
       
    57 class TestPhoneUiCommandController : public QObject, public PhoneUIQtViewIF, public BubbleManagerIF
       
    58 {
       
    59     Q_OBJECT
       
    60 public:
       
    61     TestPhoneUiCommandController();
       
    62     virtual ~TestPhoneUiCommandController();
       
    63 
       
    64     // From PhoneUIQtViewIF
       
    65     BubbleManagerIF& bubbleManager ();
       
    66     void addBubbleCommand (int bubbleId, const PhoneAction& action);
       
    67     void clearBubbleCommands (int bubbleId);
       
    68     void addParticipantListAction(
       
    69             int commandId,  
       
    70             const QString &text, 
       
    71             const HbIcon &icon);
       
    72     void clearParticipantListActions();
       
    73     void hideToolbar () { };
       
    74     void showToolbar () { m_showToolbarCalled = true; };
       
    75     void setToolbarActions (const QList<PhoneAction*>& actions) {m_toolbarActionCount = actions.count(); };
       
    76     int volumeSliderValue () { m_volumeSliderValueCalled = true; return 5; };
       
    77     void removeVolumeSlider () { m_removeVolumeSliderCalled = true; };
       
    78     void setVolumeSliderValue (
       
    79             int value, 
       
    80             int , 
       
    81             int , 
       
    82             int  ) { m_setVolumeSliderValueCalled = true; m_volumeSliderValue = value; };
       
    83 
       
    84     void setExpandAction(int bubbleId, int commandId) {m_expandAction[bubbleId]=commandId;};
       
    85     void removeExpandAction(int ) {};
       
    86     void showDialpad() {m_showDialpadCalled = true;};  
       
    87     void hideDialpad() {m_hideDialpadCalled = true;};  
       
    88     bool isDialpadVisible() 
       
    89         {m_dialpadVisibilityCalled = true;
       
    90     return m_isDialpadVisible; }
       
    91     QString dialpadText() {return m_dialpadText;};
       
    92     void clearAndHideDialpad() { m_clearAndHideDialpadCalled = true;};
       
    93     void clearDialpad() {};
       
    94     void bringToForeground() {};
       
    95     void setMenuActions(const QList<PhoneAction*>& ) { m_setMenuActionsCalled = true;};
       
    96     void shutdownPhoneApp() {};
       
    97     void setBackButtonVisible(bool ) {};
       
    98     HbMenu &menuReference(){return m_menu;};
       
    99     void captureKey(Qt::Key , bool ) {};
       
   100     
       
   101     // From BubbleManagerIF
       
   102     void startChanges () { m_startChangesCalled=true; };
       
   103     void endChanges () { m_endChangesCalled=true; };
       
   104     int createCallHeader () { return 0; };
       
   105     void removeCallHeader (int ) {};
       
   106     void setState (int , PhoneCallState ) {};
       
   107     void setLabel ( 
       
   108         int , 
       
   109         const QString& , 
       
   110         Qt::TextElideMode ) {};
       
   111     void setCli (int , 
       
   112                  const QString& , 
       
   113                  Qt::TextElideMode ) {};
       
   114     void updateCLI ( 
       
   115         int , 
       
   116         const QString& , 
       
   117         Qt::TextElideMode ) {};
       
   118     void setSecondaryCli ( 
       
   119         int , 
       
   120         const QString& , 
       
   121         Qt::TextElideMode clipDirection = Qt::ElideLeft) {};
       
   122     void setCallTime (int , const QString& ) {};
       
   123     void updateCallTime (int bubbleId, const QString& callTime) { m_updateCallTimeCalled=true; m_int=bubbleId; m_string=callTime; };
       
   124     void setCallObjectImage (int , const QString &) {};
       
   125     void setCallObjectFromTheme (int ) {};
       
   126     void setCallObjectText (int , const QString &) {};
       
   127     void setCallFlags (int , int ) {};
       
   128     void setCallFlag (int , PhoneCallFlags , bool ) {};
       
   129     void setNumberType (int , PhoneNumberType ) {};
       
   130     void updateCallHeaderText( 
       
   131         int , 
       
   132         const QString &, 
       
   133         const QString &, 
       
   134         Qt::TextElideMode ) {};
       
   135     void setPhoneMuted (bool muted) { m_setPhoneMutedCalled = muted; };
       
   136     int createConference (int , int ) { return 1; };
       
   137     void removeConference () {};
       
   138     void addRowToConference (int bubbleId) {};
       
   139     void removeRowFromConference (int bubbleId) {};
       
   140     int conferenceRowCount () const { return 2; };
       
   141     void setSelectionInConference (int rowNumber) {};
       
   142     void setSelectionIdInConference (int bubbleId) {};
       
   143     int selectionInConference () const { return 0; };
       
   144     int selectionIdInConference () const { return 0; };
       
   145     void moveHighlightOneUpInConference () {};
       
   146     void moveHighlightOneDownInConference () {};
       
   147     void setExpandedConferenceCallHeader (bool ) { m_ExpandConferenceCalled = true; };
       
   148     bool isConferenceExpanded () const { return false; };
       
   149     int shownHeaderCount () const { return 1; };
       
   150     void setParticipantListCli (int , ParticipantListCli ) {};
       
   151     void addAction (int , HbAction *) {};
       
   152     void clearActions (int ) {};
       
   153     QGraphicsWidget* graphicsWidgetForAction (HbAction *) const { return 0;};
       
   154     void addParticipantListAction (HbAction *) {};
       
   155     int expandedBubble() const { return 1; };
       
   156     void setExpandAction(int , HbAction* ) {};
       
   157     void setBubbleSelectionDisabled(bool ) {};
       
   158     void setRestrictedMode(bool ) {};
       
   159     
       
   160 signals:
       
   161     void dialpadAboutToClose();
       
   162     void keyPressReleased(QKeyEvent *event);
       
   163 
       
   164 public slots:
       
   165     void initTestCase ();
       
   166     void cleanupTestCase ();
       
   167     void init ();
       
   168     void cleanup ();
       
   169     
       
   170 private slots:
       
   171     void testSetCallMenuActions();
       
   172     void testSetDialpadMenuActions();
       
   173     void testPushButtonActionsForCall();
       
   174     void testToolBarActionsForCall();
       
   175 
       
   176 
       
   177 private:
       
   178     PhoneUiCommandController *m_commandController; // class under test
       
   179 
       
   180     bool m_showToolbarCalled;
       
   181     bool m_updateCallTimeCalled;
       
   182     int m_int;
       
   183     QString m_string;
       
   184     HbAction *m_action;
       
   185     int  m_toolbarActionCount;
       
   186     bool m_startChangesCalled;
       
   187     bool m_endChangesCalled;
       
   188     bool m_volumeSliderValueCalled;
       
   189     bool m_removeVolumeSliderCalled;
       
   190     bool m_setVolumeSliderValueCalled;
       
   191     int m_volumeSliderValue;
       
   192     bool m_setPhoneMutedCalled;
       
   193     QMap<int, QList<int> *> m_actionMap;
       
   194     QMap<int,int> m_expandAction;
       
   195     bool m_showDialpadCalled;
       
   196     bool m_hideDialpadCalled;
       
   197     bool m_dialpadVisibilityCalled;
       
   198     bool m_clearAndHideDialpadCalled;
       
   199     bool m_ExpandConferenceCalled;
       
   200     bool m_setMenuActionsCalled;
       
   201     bool m_isDialpadVisible;
       
   202     QString m_dialpadText;
       
   203     HbMenu m_menu;
       
   204 
       
   205 };
       
   206 
       
   207 TestPhoneUiCommandController::TestPhoneUiCommandController ()
       
   208 {
       
   209 }
       
   210 
       
   211 TestPhoneUiCommandController::~TestPhoneUiCommandController ()
       
   212 {
       
   213 }
       
   214 
       
   215 void TestPhoneUiCommandController::initTestCase ()
       
   216 {
       
   217     m_commandController = new PhoneUiCommandController (*this);
       
   218 }
       
   219 
       
   220 void TestPhoneUiCommandController::cleanupTestCase ()
       
   221 {
       
   222     delete m_commandController;
       
   223 }
       
   224 
       
   225 void TestPhoneUiCommandController::init ()
       
   226 {
       
   227     m_startChangesCalled = false;
       
   228     m_endChangesCalled = false;
       
   229 }
       
   230 
       
   231 void TestPhoneUiCommandController::cleanup ()
       
   232 {
       
   233 }
       
   234 
       
   235 BubbleManagerIF& TestPhoneUiCommandController::bubbleManager ()
       
   236 {
       
   237     return *this;
       
   238 }
       
   239 
       
   240 void TestPhoneUiCommandController::addBubbleCommand (
       
   241         int bubbleId, const PhoneAction& action)
       
   242 {
       
   243 
       
   244 }
       
   245 
       
   246 void TestPhoneUiCommandController::clearBubbleCommands (int bubbleId)
       
   247 {
       
   248 
       
   249 }
       
   250 
       
   251 void TestPhoneUiCommandController::addParticipantListAction(
       
   252     int commandId,
       
   253     const QString& text, 
       
   254     const HbIcon& icon)
       
   255 {
       
   256 
       
   257 }
       
   258 
       
   259 void TestPhoneUiCommandController::clearParticipantListActions()
       
   260 {
       
   261 
       
   262 }
       
   263 
       
   264 void TestPhoneUiCommandController::testSetCallMenuActions()
       
   265 {
       
   266     QMap<int,int> callStates;
       
   267     QMap<int,int> serviceIds;
       
   268     int serviceId(2);
       
   269     int expandedCallId(1);
       
   270     callStates[expandedCallId] = EPEStateConnected;
       
   271     serviceIds[expandedCallId] = serviceId;
       
   272     
       
   273     
       
   274     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   275     QVERIFY(m_setMenuActionsCalled);
       
   276     m_setMenuActionsCalled = false;
       
   277     
       
   278     m_setActions = true;
       
   279     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   280     QVERIFY(m_setMenuActionsCalled);
       
   281     m_setMenuActionsCalled = false;
       
   282     m_setActions = false;
       
   283     
       
   284     m_setInvalidCommand = true;
       
   285     callStates[expandedCallId] = EPEStateHeld;
       
   286     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   287     QVERIFY(m_setMenuActionsCalled);
       
   288     m_setMenuActionsCalled = false;
       
   289     m_setInvalidCommand = false;
       
   290     
       
   291     callStates[0] = EPEStateConnected;
       
   292     serviceIds[0] = serviceId;
       
   293     
       
   294     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   295     QVERIFY(m_setMenuActionsCalled);
       
   296     m_setMenuActionsCalled = false;
       
   297     
       
   298     callStates[0] = EPEStateRinging;
       
   299     
       
   300     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   301     QVERIFY(m_setMenuActionsCalled);
       
   302     m_setMenuActionsCalled = false;
       
   303     
       
   304     serviceIds[0] = 3;
       
   305     callStates[0] = EPEStateConnected;
       
   306     
       
   307     m_commandController->setCallMenuActions(callStates,serviceIds,3,expandedCallId);
       
   308     QVERIFY(m_setMenuActionsCalled);
       
   309     m_setMenuActionsCalled = false;
       
   310     
       
   311     callStates[2] = EPEStateRinging;
       
   312     serviceIds[2] = 3;
       
   313     
       
   314     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   315     QVERIFY(m_setMenuActionsCalled);
       
   316     m_setMenuActionsCalled = false;
       
   317     
       
   318     callStates[3] = EPEStateDisconnecting;
       
   319     serviceIds[3] = 3;
       
   320     
       
   321     m_commandController->setCallMenuActions(callStates,serviceIds,serviceId,expandedCallId);
       
   322     QVERIFY(m_setMenuActionsCalled);
       
   323     m_setMenuActionsCalled = false;
       
   324 }
       
   325 
       
   326 void TestPhoneUiCommandController::testSetDialpadMenuActions()
       
   327 {
       
   328     m_setMenuActionsCalled = false;
       
   329     m_commandController->setDialpadMenuActions();
       
   330     QVERIFY(m_setMenuActionsCalled);
       
   331 }
       
   332 
       
   333 void TestPhoneUiCommandController::testPushButtonActionsForCall()
       
   334 {
       
   335     int callState = EPEStateConnected;
       
   336     bool emergencyCall = false;
       
   337     QMap<int,int> callStates;
       
   338     QMap<int,int> serviceIds;
       
   339     int serviceId(2);
       
   340     int callId(1);
       
   341     callStates[callId] = EPEStateConnected;
       
   342     serviceIds[callId] = serviceId;
       
   343     
       
   344     QMap<PhoneAction::ActionType, PhoneAction *> actions = 
       
   345         m_commandController->pushButtonActionsForCall(
       
   346             callState,
       
   347             emergencyCall,
       
   348             callStates,
       
   349             serviceIds,
       
   350             serviceId,
       
   351             callId);
       
   352     
       
   353     QVERIFY(0<actions.values().count());
       
   354     
       
   355     qDeleteAll(actions.values());
       
   356     actions.clear();
       
   357     
       
   358     m_setInvalidButtonCommands = true;
       
   359     actions =  m_commandController->pushButtonActionsForCall(
       
   360             callState,
       
   361             emergencyCall,
       
   362             callStates,
       
   363             serviceIds,
       
   364             serviceId,
       
   365             callId);
       
   366     
       
   367     QVERIFY(0==actions.values().count());
       
   368     qDeleteAll(actions.values());
       
   369     actions.clear();  
       
   370     m_setInvalidButtonCommands = false;
       
   371     
       
   372     actions = m_commandController->pushButtonActionsForCall(
       
   373             callState,
       
   374             true,
       
   375             callStates,
       
   376             serviceIds,
       
   377             serviceId,
       
   378             callId);
       
   379  
       
   380     QVERIFY(0<actions.values().count());
       
   381     qDeleteAll(actions.values());
       
   382     actions.clear();
       
   383     
       
   384     PhoneResourceAdapter::Instance()->buttonsController()->
       
   385             setButtonFlags(PhoneUIQtButtonsController::Ihf, true);
       
   386     
       
   387     callStates[callId] = EPEStateHeld;
       
   388     callState = EPEStateHeld;
       
   389     actions = m_commandController->pushButtonActionsForCall(
       
   390             callState,
       
   391             emergencyCall,
       
   392             callStates,
       
   393             serviceIds,
       
   394             serviceId,
       
   395             callId);
       
   396  
       
   397     QVERIFY(0<actions.values().count());
       
   398     qDeleteAll(actions.values());
       
   399     actions.clear();
       
   400     
       
   401     callStates[callId] = EPEStateRinging;
       
   402     callState = EPEStateRinging;
       
   403     actions = m_commandController->pushButtonActionsForCall(
       
   404             callState,
       
   405             emergencyCall,
       
   406             callStates,
       
   407             serviceIds,
       
   408             serviceId,
       
   409             callId);
       
   410  
       
   411     QVERIFY(0<actions.values().count());
       
   412     qDeleteAll(actions.values());
       
   413     actions.clear();
       
   414     
       
   415     callStates[callId] = EPEStateIdle;
       
   416     callState = EPEStateIdle;
       
   417     actions = m_commandController->pushButtonActionsForCall(
       
   418             callState,
       
   419             emergencyCall,
       
   420             callStates,
       
   421             serviceIds,
       
   422             serviceId,
       
   423             callId);
       
   424  
       
   425     QVERIFY(0==actions.values().count());
       
   426     qDeleteAll(actions.values());
       
   427     actions.clear();
       
   428 
       
   429     callStates[callId] = EPEStateDisconnecting;
       
   430     callState = EPEStateDisconnecting;
       
   431     actions = m_commandController->pushButtonActionsForCall(
       
   432             callState,
       
   433             emergencyCall,
       
   434             callStates,
       
   435             serviceIds,
       
   436             serviceId,
       
   437             callId);
       
   438  
       
   439     QVERIFY(0==actions.values().count());
       
   440     qDeleteAll(actions.values());
       
   441     actions.clear();
       
   442     
       
   443     callStates[callId] = EPEStateConferenceIdle;
       
   444     callState = EPEStateConferenceIdle;
       
   445     actions = m_commandController->pushButtonActionsForCall(
       
   446             callState,
       
   447             emergencyCall,
       
   448             callStates,
       
   449             serviceIds,
       
   450             serviceId,
       
   451             callId);
       
   452  
       
   453     QVERIFY(0==actions.values().count());
       
   454     qDeleteAll(actions.values());
       
   455     actions.clear();
       
   456     
       
   457     callStates[callId] = EPEStateUnknown;
       
   458     callState = EPEStateUnknown;
       
   459     actions = m_commandController->pushButtonActionsForCall(
       
   460             callState,
       
   461             emergencyCall,
       
   462             callStates,
       
   463             serviceIds,
       
   464             serviceId,
       
   465             callId);
       
   466  
       
   467     QVERIFY(0==actions.values().count());
       
   468     qDeleteAll(actions.values());
       
   469     actions.clear();
       
   470     
       
   471     callStates[callId] = EPEStateDialing;
       
   472     callState = EPEStateDialing;
       
   473     actions = m_commandController->pushButtonActionsForCall(
       
   474             callState,
       
   475             emergencyCall,
       
   476             callStates,
       
   477             serviceIds,
       
   478             serviceId,
       
   479             callId);
       
   480  
       
   481     QVERIFY(0<actions.values().count());
       
   482     qDeleteAll(actions.values());
       
   483     actions.clear();
       
   484     
       
   485     callStates[callId] = EPEStateConnecting;
       
   486     callState = EPEStateConnecting;
       
   487     actions = m_commandController->pushButtonActionsForCall(
       
   488             callState,
       
   489             emergencyCall,
       
   490             callStates,
       
   491             serviceIds,
       
   492             serviceId,
       
   493             callId);
       
   494  
       
   495     QVERIFY(0<actions.values().count());
       
   496     qDeleteAll(actions.values());
       
   497     actions.clear();
       
   498     
       
   499     callStates[callId] = EPEStateConnectedConference;
       
   500     callState = EPEStateConnectedConference;
       
   501     actions = m_commandController->pushButtonActionsForCall(
       
   502             callState,
       
   503             emergencyCall,
       
   504             callStates,
       
   505             serviceIds,
       
   506             serviceId,
       
   507             callId);
       
   508  
       
   509     QVERIFY(0<actions.values().count());
       
   510     qDeleteAll(actions.values());
       
   511     actions.clear();
       
   512     
       
   513     callStates[callId] = EPEStateHeldConference;
       
   514     callState = EPEStateHeldConference;
       
   515     actions = m_commandController->pushButtonActionsForCall(
       
   516             callState,
       
   517             emergencyCall,
       
   518             callStates,
       
   519             serviceIds,
       
   520             serviceId,
       
   521             callId);
       
   522  
       
   523     QVERIFY(0<actions.values().count());
       
   524     qDeleteAll(actions.values());
       
   525     actions.clear();
       
   526     
       
   527     //////////////////////////////////////////////////////////////////////////
       
   528     //2 calls
       
   529     //////////////////////////////////////////////////////////////////////////
       
   530     
       
   531     PhoneResourceAdapter::Instance()->buttonsController()->
       
   532             setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable, true);
       
   533     
       
   534     callStates[2] = EPEStateHeldConference;
       
   535     actions = m_commandController->pushButtonActionsForCall(
       
   536             callState,
       
   537             emergencyCall,
       
   538             callStates,
       
   539             serviceIds,
       
   540             serviceId,
       
   541             callId);
       
   542     
       
   543     QVERIFY(0<actions.values().count());
       
   544     qDeleteAll(actions.values());
       
   545     actions.clear();
       
   546     
       
   547     callStates[2] = EPEStateHeldConference;
       
   548     callState = EPEStateHeldConference;
       
   549     actions = m_commandController->pushButtonActionsForCall(
       
   550             callState,
       
   551             emergencyCall,
       
   552             callStates,
       
   553             serviceIds,
       
   554             serviceId,
       
   555             callId);
       
   556     
       
   557     QVERIFY(0<actions.values().count());
       
   558     qDeleteAll(actions.values());
       
   559     actions.clear();
       
   560     
       
   561     serviceId = 3;
       
   562     serviceIds[callId] = serviceId;
       
   563     callStates[2] = EPEStateHeld;
       
   564     serviceIds[2] = serviceId;
       
   565     actions = m_commandController->pushButtonActionsForCall(
       
   566             callState,
       
   567             emergencyCall,
       
   568             callStates,
       
   569             serviceIds,
       
   570             serviceId,
       
   571             callId);
       
   572     
       
   573     QVERIFY(0<actions.values().count());
       
   574     qDeleteAll(actions.values());
       
   575     actions.clear();
       
   576     
       
   577     actions = m_commandController->pushButtonActionsForCall(
       
   578             callState,
       
   579             true,
       
   580             callStates,
       
   581             serviceIds,
       
   582             serviceId,
       
   583             callId);
       
   584     
       
   585     QVERIFY(0<actions.values().count());
       
   586     qDeleteAll(actions.values());
       
   587     actions.clear();
       
   588     
       
   589     callStates[2] = EPEStateHeldConference;
       
   590     callState = EPEStateHeldConference;
       
   591     actions = m_commandController->pushButtonActionsForCall(
       
   592             callState,
       
   593             emergencyCall,
       
   594             callStates,
       
   595             serviceIds,
       
   596             serviceId,
       
   597             callId);
       
   598     
       
   599     QVERIFY(0<actions.values().count());
       
   600     qDeleteAll(actions.values());
       
   601     actions.clear();
       
   602     
       
   603     callStates[2] = EPEStateConnectedConference;
       
   604     callState = EPEStateHeld;
       
   605     callStates[callId] = EPEStateHeld;
       
   606     actions = m_commandController->pushButtonActionsForCall(
       
   607             callState,
       
   608             emergencyCall,
       
   609             callStates,
       
   610             serviceIds,
       
   611             serviceId,
       
   612             callId);
       
   613     
       
   614     QVERIFY(0<actions.values().count());
       
   615     qDeleteAll(actions.values());
       
   616     actions.clear();
       
   617     
       
   618     callState = EPEStateConnectedConference;
       
   619     actions = m_commandController->pushButtonActionsForCall(
       
   620             callState,
       
   621             emergencyCall,
       
   622             callStates,
       
   623             serviceIds,
       
   624             serviceId,
       
   625             callId);
       
   626     
       
   627     QVERIFY(0<actions.values().count());
       
   628     qDeleteAll(actions.values());
       
   629     actions.clear();
       
   630     
       
   631     callStates[callId] = EPEStateConnected;
       
   632     callStates[2] = EPEStateHeldConference;
       
   633     callState = EPEStateConnected;
       
   634     
       
   635     callState = EPEStateConnectedConference;
       
   636     actions = m_commandController->pushButtonActionsForCall(
       
   637             callState,
       
   638             emergencyCall,
       
   639             callStates,
       
   640             serviceIds,
       
   641             serviceId,
       
   642             callId);
       
   643     
       
   644     QVERIFY(0<actions.values().count());
       
   645     qDeleteAll(actions.values());
       
   646     actions.clear();
       
   647     
       
   648     PhoneResourceAdapter::Instance()->buttonsController()->
       
   649             setButtonFlags(PhoneUIQtButtonsController::Btaa, true);
       
   650     
       
   651     callStates[callId] = EPEStateConnected;
       
   652     callStates[2] = EPEStateHeldConference;
       
   653     callState = EPEStateHeldConference;
       
   654     
       
   655     //////////////////////////////////////////////////////////////////////////
       
   656     //3 calls
       
   657     //////////////////////////////////////////////////////////////////////////
       
   658     callStates[3] = EPEStateRinging;
       
   659     serviceIds[3] = serviceId;
       
   660     actions = m_commandController->pushButtonActionsForCall(
       
   661             callState,
       
   662             emergencyCall,
       
   663             callStates,
       
   664             serviceIds,
       
   665             serviceId,
       
   666             callId);
       
   667     
       
   668     QVERIFY(0<actions.values().count());
       
   669     qDeleteAll(actions.values());
       
   670     actions.clear();
       
   671     
       
   672     actions = m_commandController->pushButtonActionsForCall(
       
   673             EPEStateRinging,
       
   674             emergencyCall,
       
   675             callStates,
       
   676             serviceIds,
       
   677             serviceId,
       
   678             3);
       
   679     
       
   680     QVERIFY(0<actions.values().count());
       
   681     qDeleteAll(actions.values());
       
   682     actions.clear();
       
   683     
       
   684     actions = m_commandController->pushButtonActionsForCall(
       
   685             EPEStateHeld,
       
   686             emergencyCall,
       
   687             callStates,
       
   688             serviceIds,
       
   689             serviceId,
       
   690             2);
       
   691     
       
   692     QVERIFY(0<actions.values().count());
       
   693     qDeleteAll(actions.values());
       
   694     actions.clear();
       
   695     
       
   696 }
       
   697 
       
   698 void TestPhoneUiCommandController::testToolBarActionsForCall()
       
   699 {
       
   700     m_phoneButtonFlags = 0;
       
   701     int callState = EPEStateConnected;
       
   702     QMap<int,int> callStates;
       
   703     QMap<int,int> serviceIds;
       
   704     int serviceId(2);
       
   705     int callId(1);
       
   706     callStates[callId] = EPEStateConnected;
       
   707     serviceIds[callId] = serviceId;
       
   708     m_setInvalidToolBarCommands = false;
       
   709     m_setCustomToolBarCommands = false;
       
   710     PhoneResourceAdapter::Instance()->buttonsController()->
       
   711             setButtonFlags(PhoneUIQtButtonsController::Btaa, false);
       
   712     PhoneResourceAdapter::Instance()->buttonsController()->
       
   713             setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable, false);
       
   714     PhoneResourceAdapter::Instance()->buttonsController()->
       
   715             setButtonFlags(PhoneUIQtButtonsController::IhfAsPushButton, false);
       
   716     PhoneResourceAdapter::Instance()->buttonsController()->
       
   717             setButtonFlags(PhoneUIQtButtonsController::Ihf, false);
       
   718     
       
   719     
       
   720     QList<PhoneAction *> actions = 
       
   721         m_commandController->toolBarActions(
       
   722             R_PHONEUI_DIALER_CBA,
       
   723             callStates,
       
   724             serviceIds,
       
   725             serviceId,
       
   726             callId);
       
   727     
       
   728     QVERIFY(4==actions.count());
       
   729     QVERIFY(EPhoneInCallCmdActivateIhf == actions.at(0)->command());
       
   730     QVERIFY(EPhoneInCallCmdHold == actions.at(1)->command());
       
   731     QVERIFY(EPhoneInCallCmdContacts == actions.at(2)->command());
       
   732     QVERIFY(EPhoneInCallCmdDialer == actions.at(3)->command());
       
   733     
       
   734     qDeleteAll(actions);
       
   735     actions.clear();
       
   736     
       
   737     // Invalid resource id
       
   738     actions = m_commandController->toolBarActions(
       
   739             -1,
       
   740             callStates,
       
   741             serviceIds,
       
   742             serviceId,
       
   743             callId);
       
   744     
       
   745     QVERIFY(0==actions.count());
       
   746     
       
   747     qDeleteAll(actions);
       
   748     actions.clear();
       
   749     
       
   750     // Service not found
       
   751     actions = m_commandController->toolBarActions(
       
   752             R_PHONEUI_DIALER_CBA,
       
   753             callStates,
       
   754             serviceIds,
       
   755             -1,
       
   756             -1);
       
   757     
       
   758     QVERIFY(4==actions.count());
       
   759     
       
   760     qDeleteAll(actions);
       
   761     actions.clear();
       
   762     
       
   763     // Invalid toolbar command by extension
       
   764     m_setInvalidToolBarCommands = true;
       
   765     
       
   766     actions = m_commandController->toolBarActions(
       
   767             R_PHONEUI_DIALER_CBA,
       
   768             callStates,
       
   769             serviceIds,
       
   770             serviceId,
       
   771             callId);
       
   772     
       
   773     QVERIFY(3==actions.count());
       
   774     
       
   775     qDeleteAll(actions);
       
   776     actions.clear();
       
   777     
       
   778     
       
   779     // Command list modified by extension
       
   780     m_setInvalidToolBarCommands = false;
       
   781     m_setCustomToolBarCommands = true;
       
   782 
       
   783     actions = m_commandController->toolBarActions(
       
   784             R_PHONEUI_DIALER_CBA,
       
   785             callStates,
       
   786             serviceIds,
       
   787             serviceId,
       
   788             callId);
       
   789     
       
   790     QVERIFY(4==actions.count());
       
   791     QVERIFY(EPhoneInCallCmdJoin == actions.at(0)->command());
       
   792     QVERIFY(EPhoneInCallCmdUnhold == actions.at(1)->command());
       
   793     QVERIFY(EPhoneInCallCmdEndThisOutgoingCall == actions.at(2)->command());
       
   794     QVERIFY(EPhoneCallComingCmdSilent == actions.at(3)->command());
       
   795     
       
   796     qDeleteAll(actions);
       
   797     actions.clear();
       
   798     
       
   799     m_setCustomToolBarCommands =false;
       
   800     
       
   801     // Multi call
       
   802     callStates[2] = EPEStateHeld;
       
   803     serviceIds[2] = 2;
       
   804     
       
   805     actions = m_commandController->toolBarActions(
       
   806             R_PHONEUI_INCALL_DIALER_CBA,
       
   807             callStates,
       
   808             serviceIds,
       
   809             serviceId,
       
   810             callId);
       
   811     
       
   812     QVERIFY(4==actions.count());
       
   813     
       
   814     // No extension
       
   815     serviceIds[1] = 1;
       
   816     serviceIds[2] = 1;
       
   817     serviceId = 1;
       
   818     
       
   819     actions = m_commandController->toolBarActions(
       
   820             R_PHONEUI_INCALL_DIALER_CBA,
       
   821             callStates,
       
   822             serviceIds,
       
   823             serviceId,
       
   824             callId);
       
   825     
       
   826     QVERIFY(4==actions.count());
       
   827 }
       
   828 
       
   829 PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestPhoneUiCommandController)
       
   830 #include "unit_tests.moc"