phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneresourceadapter/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 PhoneResourceAdapter.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QtGui>
       
    20 #include <hbapplication.h>
       
    21 #include <QSignalSpy>
       
    22 #include <QVariant>
       
    23 #include <hbaction.h>
       
    24 #include <phoneappvoipcommands.hrh>
       
    25 #include <xqphoneappcommands.h>
       
    26 #include "phoneresourceadapter.h"
       
    27 #include "phoneuiqtbuttonscontroller.h"
       
    28 #include "phoneresourceids.h"
       
    29 #include "phoneui.hrh"
       
    30 
       
    31 #define PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestObject) \
       
    32 int main(int argc, char *argv[]) \
       
    33 { \
       
    34     HbApplication app(argc, argv); \
       
    35     TestObject tc; \
       
    36     QResource::registerResource("../hbcore.rcc"); \
       
    37     int ret = QTest::qExec(&tc, argc, argv); \
       
    38     /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    39     /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    40     /* app.exec() where the signal is normally emitted is not called here. */ \
       
    41     /* So, invoking the signal explicitly. */ \
       
    42     QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
       
    43     return ret; \
       
    44 }
       
    45 
       
    46 class TestPhoneResourceAdapter : public QObject
       
    47 {
       
    48     Q_OBJECT
       
    49 public:
       
    50     TestPhoneResourceAdapter();
       
    51     virtual ~TestPhoneResourceAdapter();
       
    52 
       
    53 public slots:
       
    54     void initTestCase ();
       
    55     void cleanupTestCase ();
       
    56     void init ();
       
    57     void cleanup (); 
       
    58     
       
    59 private slots:
       
    60     void testConvert ();
       
    61     void testConvertToString ();
       
    62     void testConvertToString2 ();
       
    63     void testDefaultToolbarResourceId();
       
    64     void testConvertCommandToString();
       
    65     void testConvertToHbActions();
       
    66     void testConvertToToolBarCommandList();
       
    67     void testBtToolBarCommandList();
       
    68 
       
    69 private:
       
    70     void testIncallToolbar (int id); // helper function
       
    71     
       
    72 private:
       
    73     PhoneResourceAdapter *m_resourceAdapter; // class under test
       
    74 };
       
    75 
       
    76 TestPhoneResourceAdapter::TestPhoneResourceAdapter ()
       
    77 {
       
    78 }
       
    79 
       
    80 TestPhoneResourceAdapter::~TestPhoneResourceAdapter ()
       
    81 {
       
    82 }
       
    83 
       
    84 void TestPhoneResourceAdapter::initTestCase ()
       
    85 {
       
    86     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
    87 }
       
    88 
       
    89 void TestPhoneResourceAdapter::cleanupTestCase ()
       
    90 {
       
    91     delete m_resourceAdapter;
       
    92 }
       
    93 
       
    94 void TestPhoneResourceAdapter::init ()
       
    95 {
       
    96 }
       
    97 
       
    98 void TestPhoneResourceAdapter::cleanup ()
       
    99 {
       
   100 }
       
   101 
       
   102 void TestPhoneResourceAdapter::testConvert ()
       
   103 {
       
   104     // For coverage
       
   105     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
   106     PhoneUIQtButtonsController* buttonsController = 
       
   107         m_resourceAdapter->buttonsController ();
       
   108     
       
   109 
       
   110     QMap<PhoneAction::ActionType, PhoneAction *> map;
       
   111     PhoneAction *action = map [PhoneAction::LeftButton];
       
   112     
       
   113     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_INCOMING_CALL);
       
   114     QCOMPARE (map.size (), 1);
       
   115     action = map [PhoneAction::Text];
       
   116     QVERIFY( false == action->text().isEmpty() );
       
   117 
       
   118     map = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_DISCONNECTED);
       
   119     QCOMPARE (map.size (), 1);
       
   120     action = map [PhoneAction::Text];
       
   121     QVERIFY( false == action->text().isEmpty() );
       
   122     
       
   123     map = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_HELD);
       
   124     QCOMPARE (map.size (), 1);
       
   125     action = map [PhoneAction::Text];
       
   126     QVERIFY( false == action->text().isEmpty() );
       
   127 
       
   128     map = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
       
   129     QCOMPARE (map.size (), 1);
       
   130     action = map [PhoneAction::Text];
       
   131     QVERIFY( false == action->text().isEmpty() );
       
   132 
       
   133     map = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
       
   134     QCOMPARE (map.size (), 1);
       
   135     action = map [PhoneAction::Text];
       
   136     QVERIFY( false == action->text().isEmpty() );
       
   137     
       
   138     map = m_resourceAdapter->convert (R_PHONEUI_OUT_GOING_CALL);
       
   139     QCOMPARE (map.size (), 1);
       
   140     action = map [PhoneAction::Text];
       
   141     QVERIFY( false == action->text().isEmpty() );
       
   142 
       
   143     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
       
   144     QCOMPARE (map.size (), 1);
       
   145     action = map [PhoneAction::Text];
       
   146     QVERIFY( false == action->text().isEmpty() );
       
   147 
       
   148     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_UNKNOWN);
       
   149     QCOMPARE (map.size (), 1);
       
   150     action = map [PhoneAction::Text];
       
   151     QVERIFY( false == action->text().isEmpty() );
       
   152 
       
   153     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
       
   154     QCOMPARE (map.size (), 1);
       
   155     action = map [PhoneAction::Text];
       
   156     QVERIFY( false == action->text().isEmpty() );
       
   157 
       
   158     map = m_resourceAdapter->convert (R_PHONEUI_ATTEMPTING_EMERGENCY_CALL_TEXT);
       
   159     QCOMPARE (map.size (), 1);
       
   160     action = map [PhoneAction::Text];
       
   161     QVERIFY( false == action->text().isEmpty() );
       
   162     
       
   163     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_BUTTONS);
       
   164     QCOMPARE (map.size (), 1);
       
   165     action = map [PhoneAction::LeftButton];
       
   166     QVERIFY( false == action->text().isEmpty() );
       
   167     QCOMPARE (action->icon (), HbIcon("qtg_mono_end_call"));
       
   168     QCOMPARE (action->command (), (int)EPhoneCmdEnd);   
       
   169     
       
   170     map = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
       
   171     QCOMPARE (map.size (), 1);
       
   172     action = map [PhoneAction::Text];
       
   173     QVERIFY( false == action->text().isEmpty() );
       
   174     
       
   175     TBuf<10> buffer(_L("123"));
       
   176     map = m_resourceAdapter->convert (R_PHONEUI_SENDING_DTMF_WAIT_NOTE_TEXT, &buffer);
       
   177     QCOMPARE (map.size(), 1);
       
   178     action = map[PhoneAction::Text];
       
   179     QVERIFY( false == action->text().isEmpty() );
       
   180     
       
   181     map = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
       
   182     QCOMPARE(map.size(), 1);
       
   183     action = map[PhoneAction::Text];
       
   184     QVERIFY( false == action->text().isEmpty() );
       
   185     
       
   186     // TODO
       
   187     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
       
   188     
       
   189     map = m_resourceAdapter->convert (0);
       
   190     QCOMPARE (map.size (), 0);
       
   191 }
       
   192 
       
   193 void TestPhoneResourceAdapter::testConvertToString ()
       
   194 {
       
   195     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
   196         
       
   197     QString testString = m_resourceAdapter->convertToString(R_PHONE_ERROR_CALL_NOT_ALLOWED); 
       
   198     QVERIFY( false == testString.isEmpty() );
       
   199     
       
   200     QString testString2 = m_resourceAdapter->convertToString(R_ERROR_NOTE_NOT_ALLOWED); 
       
   201     QVERIFY( false == testString2.isEmpty() );
       
   202     
       
   203     QString testString3 = m_resourceAdapter->convertToString(R_NOTETEXT_INVALID_PHONENUMBER); 
       
   204     QVERIFY( false == testString3.isEmpty() );
       
   205     
       
   206     QString testString4 = m_resourceAdapter->convertToString(R_NOTETEXT_NO_ANSWER); 
       
   207     QVERIFY( false == testString4.isEmpty() );
       
   208     
       
   209     QString testString5 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NUMBER_BUSY); 
       
   210     QVERIFY( false == testString5.isEmpty() );
       
   211     
       
   212     QString testString6 = m_resourceAdapter->convertToString(R_PHONE_ERROR_REQUEST_REJECTED); 
       
   213     QVERIFY( false == testString6.isEmpty() );
       
   214     
       
   215     QString testString7 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_INFO_HOLD_TEXT); 
       
   216     QVERIFY( false == testString7.isEmpty() );
       
   217     
       
   218     QString testString8 = m_resourceAdapter->convertToString(R_INCAL_INFO_HOLD_TEXT); 
       
   219     QVERIFY( false == testString8.isEmpty() );
       
   220     
       
   221     QString testString9 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_ACTIVE_TEXT); 
       
   222     QVERIFY( false == testString9.isEmpty() );
       
   223     
       
   224     /*QString testString10 = m_resourceAdapter->convertToString(R_INCAL_INFO_CONF_HOLD_TEXT); 
       
   225     QVERIFY( false == testString10.isEmpty() );*/
       
   226     
       
   227     QString testString11 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_NO_NETWORK_SUPPORT); 
       
   228     QVERIFY( false == testString11.isEmpty() );
       
   229     
       
   230     QString testString12 = m_resourceAdapter->convertToString(R_PHONE_ERROR_EMERGENCY_CALLS_ONLY); 
       
   231     QVERIFY( false == testString12.isEmpty() );
       
   232     
       
   233     QString testString13 = m_resourceAdapter->convertToString(R_NOTETEXT_NUMBER_NOT_IN_USE); 
       
   234     QVERIFY( false == testString13.isEmpty() );
       
   235     
       
   236     QString testString14 = m_resourceAdapter->convertToString(R_NOTETEXT_NETWORK_BUSY); 
       
   237     QVERIFY( false == testString14.isEmpty() );
       
   238     
       
   239     QString testString15 = m_resourceAdapter->convertToString(R_NOTETEXT_ERROR_IN_CONNECTION); 
       
   240     QVERIFY( false == testString15.isEmpty() );
       
   241     
       
   242     QString testString16 = m_resourceAdapter->convertToString(R_PHONEUI_ERROR_EMERGENCY_ATTEMPT_FAILED); 
       
   243     QVERIFY( false == testString16.isEmpty() );   
       
   244     
       
   245     QString testString17 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_TRANSFERRED_TEXT); 
       
   246     QVERIFY( false == testString17.isEmpty() );    
       
   247  
       
   248     QString testString18 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NO_SERVICE); 
       
   249     QVERIFY( false == testString18.isEmpty() ); 
       
   250     
       
   251     QString testString19 = m_resourceAdapter->convertToString(R_NOTETEXT_NUMBER_BARRED); 
       
   252     QVERIFY( false == testString19.isEmpty() ); 
       
   253     
       
   254     /*QString testString20 = m_resourceAdapter->convertToString(R_PHONEUI_NO_VIDEO_NETWORK); 
       
   255     QVERIFY( false == testString20.isEmpty() );*/ 
       
   256     
       
   257     QString testString21 = m_resourceAdapter->convertToString(R_PHONEUI_VIDEO_CALL_NOT_POSSIBLE); 
       
   258     QVERIFY( false == testString21.isEmpty() ); 
       
   259     
       
   260     QString testString22 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE127); 
       
   261     QVERIFY( false == testString22.isEmpty() ); 
       
   262     
       
   263     QString testString23 = m_resourceAdapter->convertToString(R_CALL_INFO_NOT_SUPPORTED); 
       
   264     QVERIFY( false == testString23.isEmpty() ); 
       
   265     
       
   266     QString testString24 = m_resourceAdapter->convertToString(R_CALL_INFO_SERVICE_NOT_AVAILABLE); 
       
   267     QVERIFY( false == testString24.isEmpty() ); 
       
   268     
       
   269     QString testString25 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE38); 
       
   270     QVERIFY( false == testString25.isEmpty() ); 
       
   271     
       
   272     QString testString26 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE55); 
       
   273     QVERIFY( false == testString26.isEmpty() ); 
       
   274     
       
   275     QString testString27 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE58); 
       
   276     QVERIFY( false == testString27.isEmpty() ); 
       
   277     
       
   278     QString testString28 = m_resourceAdapter->convertToString(R_NOTE_PHONE_OUT_OF_3G_COVERAGE); 
       
   279     QVERIFY( false == testString28.isEmpty() ); 
       
   280     
       
   281     QString testString29 = m_resourceAdapter->convertToString(R_NOTE_VIDEO_CALL_ONLY_POSSIBLE_UNDER_3G_COVERAGE); 
       
   282     QVERIFY( false == testString29.isEmpty() ); 
       
   283     
       
   284     QString testString30 = m_resourceAdapter->convertToString(R_NOTE_CALLED_NUMBER_HAS_BARRED_INCOMING_CALLS); 
       
   285     QVERIFY( false == testString30.isEmpty() ); 
       
   286     
       
   287     QString testString31 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_CREATE_CONFERENCE_TEXT); 
       
   288     QVERIFY( false == testString31.isEmpty() ); 
       
   289     
       
   290     QString testString32 = m_resourceAdapter->convertToString(R_NOTETEXT_CALL_BARRINGS); 
       
   291     QVERIFY( false == testString32.isEmpty() ); 
       
   292     
       
   293     QString testString33 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE16); 
       
   294     QVERIFY( false == testString33.isEmpty() ); 
       
   295     
       
   296     QString testString34 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE18); 
       
   297     QVERIFY( false == testString34.isEmpty() ); 
       
   298     
       
   299     QString testString35 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE21); 
       
   300     QVERIFY( false == testString35.isEmpty() ); 
       
   301     
       
   302     QString testString36 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE22); 
       
   303     QVERIFY( false == testString36.isEmpty() ); 
       
   304     
       
   305     QString testString37 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE34); 
       
   306     QVERIFY( false == testString37.isEmpty() ); 
       
   307     
       
   308     QString testString38 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CALL_NOT_ALLOWED_FDN); 
       
   309     QVERIFY( false == testString38.isEmpty() ); 
       
   310     
       
   311     QString testString39 = m_resourceAdapter->convertToString(R_NOTE_UNABLE_TO_MAKE_VIDEO_CALL_NOT_SUPPORTED_BY_OTHER_PHONE); 
       
   312     QVERIFY( false == testString39.isEmpty() ); 
       
   313 
       
   314     QString testString40 = m_resourceAdapter->convertToString(R_NOTETEXT_DIVERTING_INCOMING_CALL); 
       
   315     QVERIFY( false == testString40.isEmpty() ); 
       
   316         
       
   317     QString testString41 = m_resourceAdapter->convertToString(R_NOTETEXT_DIVERTING); 
       
   318     QVERIFY( false == testString41.isEmpty() ); 
       
   319     
       
   320     QString testString42 = m_resourceAdapter->convertToString(R_NOTETEXT_ALL_INCOMING_CALLS_DIVERTED); 
       
   321     QVERIFY( false == testString42.isEmpty() ); 
       
   322         
       
   323     QString testString43 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CHECK_CLIR); 
       
   324     QVERIFY( false == testString43.isEmpty() ); 
       
   325     
       
   326     QString testString44 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_CLIR_SUPPR_REJECT_TEXT); 
       
   327     QVERIFY( false == testString44.isEmpty() ); 
       
   328     
       
   329     QString testString45 = m_resourceAdapter->convertToString(R_NOTE_TEXT_CLIR_CHANGE); 
       
   330     QVERIFY( false == testString45.isEmpty() ); 
       
   331     
       
   332     QString testString46 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CHECK_NETWORK_SERVICES); 
       
   333     QVERIFY( false == testString46.isEmpty() ); 
       
   334     
       
   335     QString testString47 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_VIDEO_CALL_NOT_ALLOWED_DURING_RESTORE); 
       
   336     QVERIFY( false == testString47.isEmpty() ); 
       
   337     
       
   338     QString testString99 = m_resourceAdapter->convertToString(0); 
       
   339     QCOMPARE( testString99, QString ("") );
       
   340 }
       
   341 
       
   342 void TestPhoneResourceAdapter::testConvertToString2 ()
       
   343 {
       
   344     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
   345         
       
   346     QString testString = m_resourceAdapter->convertToStringWithParam(
       
   347             R_PHONE_TEXT_COLP_CONNECTED, QString("123456"));
       
   348     
       
   349     QVERIFY( false == testString.isEmpty() );
       
   350        
       
   351     QString testString2 = m_resourceAdapter->convertToStringWithParam(0, QString()); 
       
   352     QCOMPARE( testString2, QString ("") );
       
   353 }
       
   354 
       
   355 void TestPhoneResourceAdapter::testIncallToolbar (int id)
       
   356 {
       
   357     QMap<PhoneAction::ActionType, PhoneAction *> map;
       
   358     PhoneAction *action;
       
   359     map = m_resourceAdapter->convert (id);
       
   360     QCOMPARE (map.size (), 4);
       
   361     
       
   362     switch(id) {
       
   363     case R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA:
       
   364         action = map [PhoneAction::ToolbarButton1];
       
   365         QCOMPARE (action->icon (), HbIcon("qtg_mono_dialer"));
       
   366         action = map [PhoneAction::ToolbarButton2];
       
   367         QCOMPARE (action->icon (), HbIcon("qtg_mono_mic_unmute"));
       
   368         QCOMPARE (action->command (), (int)EPhoneInCallCmdUnmute);    
       
   369         action = map [PhoneAction::ToolbarButton3];
       
   370         QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker"));
       
   371         QCOMPARE (action->command (), (int)EPhoneInCallCmdActivateIhf);        
       
   372         break;
       
   373     default:    
       
   374         action = map [PhoneAction::ToolbarButton1];
       
   375         QCOMPARE (action->icon (), HbIcon("qtg_mono_dialer"));
       
   376         action = map [PhoneAction::ToolbarButton2];
       
   377         QCOMPARE (action->icon (), HbIcon("qtg_mono_mic_mute"));
       
   378         QCOMPARE (action->command (), (int)EPhoneInCallCmdMute);    
       
   379         action = map [PhoneAction::ToolbarButton3];
       
   380         QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker"));
       
   381         QCOMPARE (action->command (), (int)EPhoneInCallCmdActivateIhf);
       
   382         break;
       
   383     }
       
   384 }
       
   385 
       
   386 void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
       
   387 {
       
   388     QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
       
   389             R_PHONEUI_INCALL_DIALER_CBA);
       
   390 }
       
   391 
       
   392 void TestPhoneResourceAdapter::testConvertCommandToString ()
       
   393 {
       
   394     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
   395     
       
   396     QString testString = m_resourceAdapter->convertCommandToString(
       
   397             EPhoneInCallCmdEndAllCalls);    
       
   398     QVERIFY( false == testString.isEmpty() );
       
   399     
       
   400     testString = m_resourceAdapter->convertCommandToString(
       
   401             EPhoneInCallCmdTransfer);    
       
   402     QVERIFY( false == testString.isEmpty() );
       
   403     
       
   404     testString = m_resourceAdapter->convertCommandToString(
       
   405             EPhoneCmdHandoverToWlan);    
       
   406     QVERIFY( false == testString.isEmpty() );
       
   407     
       
   408     testString = m_resourceAdapter->convertCommandToString(
       
   409             EPhoneCmdHandoverToGsm);    
       
   410     QVERIFY( false == testString.isEmpty() );
       
   411     
       
   412     testString = m_resourceAdapter->convertCommandToString(0); 
       
   413     QCOMPARE( testString, QString ("") );
       
   414 }
       
   415 
       
   416 void TestPhoneResourceAdapter::testConvertToHbActions()
       
   417 {
       
   418     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
       
   419     
       
   420     QList<HbAction*> testList = m_resourceAdapter->convertToHbActions(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY);    
       
   421     QCOMPARE( testList.count(), 2 );
       
   422     QCOMPARE( (int)EPhoneInCallCmdContinueSendingDtmfString, 
       
   423               testList.at(0)->data().toInt());
       
   424     QCOMPARE( (int)EPhoneInCallCmdCancelSendingDtmfString, 
       
   425               testList.at(1)->data().toInt());
       
   426     qDeleteAll(testList);
       
   427     testList.clear();
       
   428     
       
   429     testList = m_resourceAdapter->convertToHbActions(R_PHONEUI_SENDING_DTMF_WAIT_NOTE);    
       
   430     QCOMPARE( testList.count(), 1 );
       
   431     QCOMPARE( (int)EPhoneInCallCmdCancelSendingDtmfString, 
       
   432               testList.at(0)->data().toInt());
       
   433     qDeleteAll(testList);
       
   434     testList.clear();
       
   435     
       
   436     testList = m_resourceAdapter->convertToHbActions(0);    
       
   437     QCOMPARE( testList.count(), 0 );
       
   438 }
       
   439 
       
   440 void TestPhoneResourceAdapter::testConvertToToolBarCommandList ()
       
   441 {
       
   442     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
       
   443     PhoneUIQtButtonsController* buttonsController = 
       
   444         m_resourceAdapter->buttonsController();
       
   445     
       
   446     QList<PhoneAction::ToolBarItem> testList;
       
   447     
       
   448     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
       
   449     QCOMPARE(2,testList.count());
       
   450     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
       
   451     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
       
   452     QVERIFY(true == testList.at(0).mEnabled);
       
   453     QVERIFY(true == testList.at(1).mEnabled);
       
   454     testList.clear();
       
   455     
       
   456     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
       
   457     QCOMPARE(2,testList.count());
       
   458     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
       
   459     QVERIFY(PhoneInCallCmdReject == testList.at(1).mCommandId);
       
   460     QVERIFY(true == testList.at(0).mEnabled);
       
   461     QVERIFY(true == testList.at(1).mEnabled);
       
   462     testList.clear(); 
       
   463     
       
   464     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
       
   465     QCOMPARE(2,testList.count());
       
   466     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
       
   467     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
       
   468     QVERIFY(true == testList.at(0).mEnabled);
       
   469     QVERIFY(false == testList.at(1).mEnabled);
       
   470     testList.clear(); 
       
   471     
       
   472     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
       
   473     QCOMPARE(2,testList.count());
       
   474     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
       
   475     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(1).mCommandId);
       
   476     QVERIFY(true == testList.at(0).mEnabled);
       
   477     QVERIFY(false == testList.at(1).mEnabled);
       
   478     testList.clear(); 
       
   479     
       
   480     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
       
   481     QCOMPARE(2,testList.count());
       
   482     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
       
   483     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(1).mCommandId);
       
   484     QVERIFY(true == testList.at(0).mEnabled);
       
   485     QVERIFY(true == testList.at(1).mEnabled);
       
   486     testList.clear(); 
       
   487     
       
   488     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_DIALER_CBA);
       
   489     QCOMPARE(4,testList.count());
       
   490     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
       
   491     QVERIFY(PhoneInCallCmdHold == testList.at(1).mCommandId);
       
   492     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
       
   493     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   494     QVERIFY(true == testList.at(0).mEnabled);
       
   495     QVERIFY(true == testList.at(1).mEnabled);
       
   496     QVERIFY(true == testList.at(2).mEnabled);
       
   497     QVERIFY(true == testList.at(3).mEnabled);
       
   498     testList.clear(); 
       
   499     
       
   500     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
       
   501     QCOMPARE(4,testList.count());
       
   502     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
       
   503     QVERIFY(PhoneInCallCmdHold == testList.at(1).mCommandId);
       
   504     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
       
   505     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   506     QVERIFY(true == testList.at(0).mEnabled);
       
   507     QVERIFY(true == testList.at(1).mEnabled);
       
   508     QVERIFY(true == testList.at(2).mEnabled);
       
   509     QVERIFY(true == testList.at(3).mEnabled);
       
   510     testList.clear(); 
       
   511     
       
   512     // Set flags hold and ihf
       
   513     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Ihf,true);
       
   514     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Hold,true);
       
   515     
       
   516     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
       
   517     QCOMPARE(2,testList.count());
       
   518     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   519     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(1).mCommandId);
       
   520     QVERIFY(true == testList.at(0).mEnabled);
       
   521     QVERIFY(true == testList.at(1).mEnabled);
       
   522     testList.clear(); 
       
   523     
       
   524     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_INCALL_DIALER_CBA);
       
   525     QCOMPARE(4,testList.count());
       
   526     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   527     QVERIFY(PhoneInCallCmdUnhold == testList.at(1).mCommandId);
       
   528     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
       
   529     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   530     QVERIFY(true == testList.at(0).mEnabled);
       
   531     QVERIFY(true == testList.at(1).mEnabled);
       
   532     QVERIFY(true == testList.at(2).mEnabled);
       
   533     QVERIFY(true == testList.at(3).mEnabled);
       
   534     testList.clear(); 
       
   535     
       
   536     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
       
   537     QCOMPARE(4,testList.count());
       
   538     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   539     QVERIFY(PhoneInCallCmdUnhold == testList.at(1).mCommandId);
       
   540     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
       
   541     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   542     QVERIFY(true == testList.at(0).mEnabled);
       
   543     QVERIFY(true == testList.at(1).mEnabled);
       
   544     QVERIFY(true == testList.at(2).mEnabled);
       
   545     QVERIFY(true == testList.at(3).mEnabled);
       
   546     testList.clear(); 
       
   547     
       
   548     // Set flag multi call
       
   549     buttonsController->setButtonFlags(PhoneUIQtButtonsController::MultiCall,true);
       
   550     
       
   551     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_UNHOLD_CBA);
       
   552     QCOMPARE(4,testList.count());
       
   553     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   554     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
       
   555     QVERIFY(PhoneInCallCmdCreateConference == testList.at(2).mCommandId);
       
   556     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   557     QVERIFY(true == testList.at(0).mEnabled);
       
   558     QVERIFY(true == testList.at(1).mEnabled);
       
   559     QVERIFY(true == testList.at(2).mEnabled);
       
   560     QVERIFY(true == testList.at(3).mEnabled);
       
   561     testList.clear(); 
       
   562     
       
   563     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
       
   564     QCOMPARE(4,testList.count());
       
   565     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   566     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
       
   567     QVERIFY(PhoneInCallCmdCreateConference == testList.at(2).mCommandId);
       
   568     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   569     QVERIFY(true == testList.at(0).mEnabled);
       
   570     QVERIFY(true == testList.at(1).mEnabled);
       
   571     QVERIFY(true == testList.at(2).mEnabled);
       
   572     QVERIFY(true == testList.at(3).mEnabled);
       
   573     testList.clear();
       
   574     
       
   575     // Set flag outgoing and conference call
       
   576     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Outgoing,true);
       
   577     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Conference,true);
       
   578     
       
   579     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA);
       
   580     QCOMPARE(4,testList.count());
       
   581     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   582     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
       
   583     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(2).mCommandId);
       
   584     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   585     QVERIFY(true == testList.at(0).mEnabled);
       
   586     QVERIFY(false == testList.at(1).mEnabled);
       
   587     QVERIFY(false == testList.at(2).mEnabled);
       
   588     QVERIFY(true == testList.at(3).mEnabled);
       
   589     testList.clear(); 
       
   590     
       
   591     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
       
   592     QCOMPARE(4,testList.count());
       
   593     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
       
   594     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
       
   595     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(2).mCommandId);
       
   596     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
       
   597     QVERIFY(true == testList.at(0).mEnabled);
       
   598     QVERIFY(false == testList.at(1).mEnabled);
       
   599     QVERIFY(false == testList.at(2).mEnabled);
       
   600     QVERIFY(true == testList.at(3).mEnabled);
       
   601     testList.clear(); 
       
   602 }
       
   603 
       
   604 void TestPhoneResourceAdapter::testBtToolBarCommandList ()
       
   605 {
       
   606     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
       
   607     PhoneUIQtButtonsController* buttonsController = 
       
   608         m_resourceAdapter->buttonsController();
       
   609     
       
   610     QList<PhoneAction::ToolBarItem> testList;
       
   611     buttonsController->setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable,true);
       
   612     buttonsController->setButtonFlags(PhoneUIQtButtonsController::IhfAsPushButton,false);
       
   613     
       
   614     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
       
   615     QVERIFY(0 < testList.count());
       
   616     QVERIFY(PhoneInCallCmdBtHandsfree == testList.at(0).mCommandId);
       
   617     QVERIFY(true == testList.at(0).mEnabled);
       
   618     testList.clear();
       
   619     
       
   620     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Btaa,true);
       
   621     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
       
   622     QVERIFY(0 < testList.count());
       
   623     QVERIFY(PhoneInCallCmdHandset == testList.at(0).mCommandId);
       
   624     QVERIFY(true == testList.at(0).mEnabled);
       
   625     testList.clear(); 
       
   626 }
       
   627 
       
   628 PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestPhoneResourceAdapter)
       
   629 #include "unit_tests.moc"