phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneresourceadapter/unit_tests.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 30 ebdbd102c78a
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
    19 #include <QtGui>
    19 #include <QtGui>
    20 #include <hbapplication.h>
    20 #include <hbapplication.h>
    21 #include <QSignalSpy>
    21 #include <QSignalSpy>
    22 #include <QVariant>
    22 #include <QVariant>
    23 #include <hbaction.h>
    23 #include <hbaction.h>
    24 //#include <hbglobal_p.h>
       
    25 #include <phoneappvoipcommands.hrh>
    24 #include <phoneappvoipcommands.hrh>
       
    25 #include <xqphoneappcommands.h>
    26 #include "phoneresourceadapter.h"
    26 #include "phoneresourceadapter.h"
       
    27 #include "phoneuiqtbuttonscontroller.h"
    27 #include "phoneresourceids.h"
    28 #include "phoneresourceids.h"
    28 #include "phoneui.hrh"
    29 #include "phoneui.hrh"
    29 
    30 
    30 #define PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestObject) \
    31 #define PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestObject) \
    31 int main(int argc, char *argv[]) \
    32 int main(int argc, char *argv[]) \
    60     void testConvertToString ();
    61     void testConvertToString ();
    61     void testConvertToString2 ();
    62     void testConvertToString2 ();
    62     void testDefaultToolbarResourceId();
    63     void testDefaultToolbarResourceId();
    63     void testConvertCommandToString();
    64     void testConvertCommandToString();
    64     void testConvertToHbActions();
    65     void testConvertToHbActions();
       
    66     void testConvertToToolBarCommandList();
       
    67     void testBtToolBarCommandList();
    65 
    68 
    66 private:
    69 private:
    67     void testIncallToolbar (int id); // helper function
    70     void testIncallToolbar (int id); // helper function
    68     
    71     
    69 private:
    72 private:
   104         m_resourceAdapter->buttonsController ();
   107         m_resourceAdapter->buttonsController ();
   105     
   108     
   106 
   109 
   107     QMap<PhoneAction::ActionType, PhoneAction *> map;
   110     QMap<PhoneAction::ActionType, PhoneAction *> map;
   108     PhoneAction *action = map [PhoneAction::LeftButton];
   111     PhoneAction *action = map [PhoneAction::LeftButton];
   109 
       
   110     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
       
   111     QCOMPARE (map.size (), 2);
       
   112     action = map [PhoneAction::ToolbarButton1];
       
   113     QCOMPARE (action->icon (), HbIcon("qtg_mono_send"));    
       
   114     action = map [PhoneAction::ToolbarButton2];
       
   115     QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker_off"));
       
   116     QCOMPARE (action->command (), (int)EPhoneCallComingCmdSilent);    
       
   117     
       
   118     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
       
   119     QCOMPARE (map.size (), 2);
       
   120     action = map [PhoneAction::ToolbarButton1];
       
   121     QCOMPARE (action->icon (), HbIcon("qtg_mono_send"));    
       
   122     action = map [PhoneAction::ToolbarButton2];
       
   123     QCOMPARE (action->icon (), HbIcon("qtg_mono_reject_call"));
       
   124     //Command is disabled
       
   125     //QCOMPARE (action->command (), (int)EPhoneCallComingCmdReject);    
       
   126      
       
   127     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
       
   128     QCOMPARE (map.size (), 2);
       
   129     action = map [PhoneAction::ToolbarButton1];
       
   130     QCOMPARE (action->icon (), HbIcon("qtg_mono_send"));    
       
   131     action = map [PhoneAction::ToolbarButton2];
       
   132     QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker_off"));
       
   133     //Command is disabled
       
   134     //QCOMPARE (action->command (), (int)EPhoneCallComingCmdReject); 
       
   135 
       
   136     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
       
   137     QCOMPARE (map.size (), 2);
       
   138     action = map [PhoneAction::ToolbarButton1];
       
   139     QCOMPARE (action->icon (), HbIcon("qtg_mono_send"));    
       
   140     action = map [PhoneAction::ToolbarButton2];
       
   141     QCOMPARE (action->icon (), HbIcon("qtg_mono_join_call"));
       
   142     QCOMPARE (action->command (), (int)EPhoneInCallCmdJoin);    
       
   143     
       
   144     testIncallToolbar( R_PHONEUI_DIALER_CBA );
       
   145     testIncallToolbar( R_PHONEUI_INCALL_DIALER_CBA );
       
   146     testIncallToolbar( R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA );
       
   147     testIncallToolbar( R_PHONEUI_CALLHANDLING_INCALL_UNHOLD_CBA );
       
   148     testIncallToolbar( R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA );
       
   149     
   112     
   150     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_INCOMING_CALL);
   113     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_INCOMING_CALL);
   151     QCOMPARE (map.size (), 1);
   114     QCOMPARE (map.size (), 1);
   152     action = map [PhoneAction::Text];
   115     action = map [PhoneAction::Text];
   153     QVERIFY( false == action->text().isEmpty() );
   116     QVERIFY( false == action->text().isEmpty() );
   165     map = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
   128     map = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
   166     QCOMPARE (map.size (), 1);
   129     QCOMPARE (map.size (), 1);
   167     action = map [PhoneAction::Text];
   130     action = map [PhoneAction::Text];
   168     QVERIFY( false == action->text().isEmpty() );
   131     QVERIFY( false == action->text().isEmpty() );
   169 
   132 
   170     map = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_NUMBER, 3);
       
   171     QCOMPARE (map.size (), 1);
       
   172     action = map [PhoneAction::Text];
       
   173     QVERIFY( false == action->text().isEmpty() );
       
   174     
       
   175     map = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
   133     map = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
   176     QCOMPARE (map.size (), 1);
   134     QCOMPARE (map.size (), 1);
   177     action = map [PhoneAction::Text];
   135     action = map [PhoneAction::Text];
   178     QVERIFY( false == action->text().isEmpty() );
   136     QVERIFY( false == action->text().isEmpty() );
   179     
   137     
   184 
   142 
   185     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
   143     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
   186     QCOMPARE (map.size (), 1);
   144     QCOMPARE (map.size (), 1);
   187     action = map [PhoneAction::Text];
   145     action = map [PhoneAction::Text];
   188     QVERIFY( false == action->text().isEmpty() );
   146     QVERIFY( false == action->text().isEmpty() );
   189     
   147 
   190     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CALL);
   148     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_UNKNOWN);
   191     QCOMPARE (map.size (), 1);
   149     QCOMPARE (map.size (), 1);
   192     action = map [PhoneAction::Text];
   150     action = map [PhoneAction::Text];
   193     QVERIFY( false == action->text().isEmpty() );
   151     QVERIFY( false == action->text().isEmpty() );
   194     
   152 
   195     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
   153     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
   196     QCOMPARE (map.size (), 1);
   154     QCOMPARE (map.size (), 1);
   197     action = map [PhoneAction::Text];
   155     action = map [PhoneAction::Text];
   198     QVERIFY( false == action->text().isEmpty() );
   156     QVERIFY( false == action->text().isEmpty() );
   199 
   157 
   205     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_BUTTONS);
   163     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_BUTTONS);
   206     QCOMPARE (map.size (), 1);
   164     QCOMPARE (map.size (), 1);
   207     action = map [PhoneAction::LeftButton];
   165     action = map [PhoneAction::LeftButton];
   208     QVERIFY( false == action->text().isEmpty() );
   166     QVERIFY( false == action->text().isEmpty() );
   209     QCOMPARE (action->icon (), HbIcon("qtg_mono_end_call"));
   167     QCOMPARE (action->icon (), HbIcon("qtg_mono_end_call"));
   210     QCOMPARE (action->command (), (int)EPhoneCmdEnd);
   168     QCOMPARE (action->command (), (int)EPhoneCmdEnd);   
   211     
       
   212     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
       
   213     QCOMPARE (map.size (), 2);
       
   214     action = map [PhoneAction::ToolbarButton1];
       
   215     QCOMPARE (action->icon (), HbIcon("qtg_mono_dialer"));
       
   216     action = map [PhoneAction::ToolbarButton2];
       
   217     QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker"));
       
   218     QCOMPARE (action->command (), (int)EPhoneInCallCmdActivateIhf);        
       
   219     
   169     
   220     map = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
   170     map = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
   221     QCOMPARE (map.size (), 1);
   171     QCOMPARE (map.size (), 1);
   222     action = map [PhoneAction::Text];
   172     action = map [PhoneAction::Text];
   223     QVERIFY( false == action->text().isEmpty() );
   173     QVERIFY( false == action->text().isEmpty() );
   231     map = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
   181     map = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
   232     QCOMPARE(map.size(), 1);
   182     QCOMPARE(map.size(), 1);
   233     action = map[PhoneAction::Text];
   183     action = map[PhoneAction::Text];
   234     QVERIFY( false == action->text().isEmpty() );
   184     QVERIFY( false == action->text().isEmpty() );
   235     
   185     
   236     map = m_resourceAdapter->convert(R_PHONE_IMEI_STRING, &buffer);
       
   237     QCOMPARE(map.size(), 1);
       
   238     action = map[PhoneAction::Text];
       
   239     QVERIFY( false == action->text().isEmpty() );
       
   240 
       
   241     map = m_resourceAdapter->convert(R_PHONEUI_LIFE_TIMER_STRING, &buffer);
       
   242     QCOMPARE(map.size(), 1);
       
   243     action = map[PhoneAction::Text];
       
   244     QVERIFY( false == action->text().isEmpty() );
       
   245     
       
   246     // TODO
   186     // TODO
   247     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
   187     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
   248     
   188     
   249     map = m_resourceAdapter->convert (0);
   189     map = m_resourceAdapter->convert (0);
   250     QCOMPARE (map.size (), 0);
   190     QCOMPARE (map.size (), 0);
   267     QVERIFY( false == testString4.isEmpty() );
   207     QVERIFY( false == testString4.isEmpty() );
   268     
   208     
   269     QString testString5 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NUMBER_BUSY); 
   209     QString testString5 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NUMBER_BUSY); 
   270     QVERIFY( false == testString5.isEmpty() );
   210     QVERIFY( false == testString5.isEmpty() );
   271     
   211     
   272     QString testString6 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_MOCAL_WAITING_TEXT); 
   212     QString testString6 = m_resourceAdapter->convertToString(R_PHONE_ERROR_REQUEST_REJECTED); 
   273     QVERIFY( false == testString6.isEmpty() );
   213     QVERIFY( false == testString6.isEmpty() );
   274     
   214     
   275     QString testString7 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_INFO_HOLD_TEXT); 
   215     QString testString7 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_INFO_HOLD_TEXT); 
   276     QVERIFY( false == testString7.isEmpty() );
   216     QVERIFY( false == testString7.isEmpty() );
   277     
   217     
   279     QVERIFY( false == testString8.isEmpty() );
   219     QVERIFY( false == testString8.isEmpty() );
   280     
   220     
   281     QString testString9 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_ACTIVE_TEXT); 
   221     QString testString9 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_ACTIVE_TEXT); 
   282     QVERIFY( false == testString9.isEmpty() );
   222     QVERIFY( false == testString9.isEmpty() );
   283     
   223     
   284     QString testString10 = m_resourceAdapter->convertToString(R_INCAL_INFO_CONF_HOLD_TEXT); 
   224     /*QString testString10 = m_resourceAdapter->convertToString(R_INCAL_INFO_CONF_HOLD_TEXT); 
   285     QVERIFY( false == testString10.isEmpty() );
   225     QVERIFY( false == testString10.isEmpty() );*/
   286     
   226     
   287     QString testString11 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_NO_NETWORK_SUPPORT); 
   227     QString testString11 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_NO_NETWORK_SUPPORT); 
   288     QVERIFY( false == testString11.isEmpty() );
   228     QVERIFY( false == testString11.isEmpty() );
   289     
   229     
   290     QString testString12 = m_resourceAdapter->convertToString(R_PHONE_ERROR_EMERGENCY_CALLS_ONLY); 
   230     QString testString12 = m_resourceAdapter->convertToString(R_PHONE_ERROR_EMERGENCY_CALLS_ONLY); 
   306     QVERIFY( false == testString17.isEmpty() );    
   246     QVERIFY( false == testString17.isEmpty() );    
   307  
   247  
   308     QString testString18 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NO_SERVICE); 
   248     QString testString18 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NO_SERVICE); 
   309     QVERIFY( false == testString18.isEmpty() ); 
   249     QVERIFY( false == testString18.isEmpty() ); 
   310     
   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     
   311     QString testString99 = m_resourceAdapter->convertToString(0); 
   338     QString testString99 = m_resourceAdapter->convertToString(0); 
   312     QCOMPARE( testString99, QString ("") );
   339     QCOMPARE( testString99, QString ("") );
   313 }
   340 }
   314 
   341 
   315 void TestPhoneResourceAdapter::testConvertToString2 ()
   342 void TestPhoneResourceAdapter::testConvertToString2 ()
   316 {
   343 {
   317     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
   344     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
   318         
   345         
   319     QString testString = m_resourceAdapter->convertToString(
   346     QString testString = m_resourceAdapter->convertToStringWithParam(
   320             R_PHONE_TEXT_COLP_CONNECTED, QString("123456"));
   347             R_PHONE_TEXT_COLP_CONNECTED, QString("123456"));
   321     
   348     
   322     QVERIFY( false == testString.isEmpty() );
   349     QVERIFY( false == testString.isEmpty() );
   323        
   350        
   324     QString testString2 = m_resourceAdapter->convertToString(0, QString()); 
   351     QString testString2 = m_resourceAdapter->convertToStringWithParam(0, QString()); 
   325     QCOMPARE( testString2, QString ("") );
   352     QCOMPARE( testString2, QString ("") );
   326 }
   353 }
   327 
   354 
   328 void TestPhoneResourceAdapter::testIncallToolbar (int id)
   355 void TestPhoneResourceAdapter::testIncallToolbar (int id)
   329 {
   356 {
   357 }
   384 }
   358 
   385 
   359 void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
   386 void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
   360 {
   387 {
   361     QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
   388     QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
   362             R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
   389             R_PHONEUI_INCALL_DIALER_CBA);
   363 }
   390 }
   364 
   391 
   365 void TestPhoneResourceAdapter::testConvertCommandToString ()
   392 void TestPhoneResourceAdapter::testConvertCommandToString ()
   366 {
   393 {
   367     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
   394     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
   370             EPhoneInCallCmdEndAllCalls);    
   397             EPhoneInCallCmdEndAllCalls);    
   371     QVERIFY( false == testString.isEmpty() );
   398     QVERIFY( false == testString.isEmpty() );
   372     
   399     
   373     testString = m_resourceAdapter->convertCommandToString(
   400     testString = m_resourceAdapter->convertCommandToString(
   374             EPhoneInCallCmdTransfer);    
   401             EPhoneInCallCmdTransfer);    
   375     QVERIFY( false == testString.isEmpty() );
       
   376     
       
   377     testString = m_resourceAdapter->convertCommandToString(
       
   378             EPhoneInCallCmdSwitchToVideo);    
       
   379     QVERIFY( false == testString.isEmpty() );
   402     QVERIFY( false == testString.isEmpty() );
   380     
   403     
   381     testString = m_resourceAdapter->convertCommandToString(
   404     testString = m_resourceAdapter->convertCommandToString(
   382             EPhoneCmdHandoverToWlan);    
   405             EPhoneCmdHandoverToWlan);    
   383     QVERIFY( false == testString.isEmpty() );
   406     QVERIFY( false == testString.isEmpty() );
   412     
   435     
   413     testList = m_resourceAdapter->convertToHbActions(0);    
   436     testList = m_resourceAdapter->convertToHbActions(0);    
   414     QCOMPARE( testList.count(), 0 );
   437     QCOMPARE( testList.count(), 0 );
   415 }
   438 }
   416 
   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 
   417 PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestPhoneResourceAdapter)
   628 PHONE_QT_RESOURCE_ADAPTER_TEST_MAIN(TestPhoneResourceAdapter)
   418 #include "unit_tests.moc"
   629 #include "unit_tests.moc"