phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneresourceadapter/unit_tests.cpp
changeset 78 baacf668fe89
parent 76 cfea66083b62
equal deleted inserted replaced
76:cfea66083b62 78:baacf668fe89
    50     void testDefaultToolbarResourceId();
    50     void testDefaultToolbarResourceId();
    51     void testConvertCommandToString();
    51     void testConvertCommandToString();
    52     void testConvertToHbActions();
    52     void testConvertToHbActions();
    53     void testConvertToToolBarCommandList();
    53     void testConvertToToolBarCommandList();
    54     void testBtToolBarCommandList();
    54     void testBtToolBarCommandList();
    55 
       
    56 private:
       
    57     void testIncallToolbar (int id); // helper function
       
    58     
    55     
    59 private:
    56 private:
    60     PhoneResourceAdapter *m_resourceAdapter; // class under test
    57     PhoneResourceAdapter *m_resourceAdapter; // class under test
    61 };
    58 };
    62 
    59 
    93     // For coverage
    90     // For coverage
    94     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
    91     m_resourceAdapter = PhoneResourceAdapter::Instance (this);
    95     PhoneUIQtButtonsController* buttonsController = 
    92     PhoneUIQtButtonsController* buttonsController = 
    96         m_resourceAdapter->buttonsController ();
    93         m_resourceAdapter->buttonsController ();
    97     
    94     
    98     QMap<PhoneAction::ActionType, PhoneAction *> map;
    95     QString result = 0;
    99     PhoneAction *action = map [PhoneAction::LeftButton];
    96     
   100     
    97     result = m_resourceAdapter->convert(R_PHONEUI_MTCAL_INCOMING_CALL);
   101     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_incoming_call") );        
    98     QCOMPARE (result, QString("txt_phone_other_incoming_call"));
   102     map = m_resourceAdapter->convert(R_PHONEUI_MTCAL_INCOMING_CALL);
    99 
   103     QVERIFY(verify());
   100     result = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_DISCONNECTED);
   104     QCOMPARE (map.size (), 1);
   101     QCOMPARE(result, QString("txt_phone_other_disconnected"));
   105 
   102     
   106     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_disconnected") );
   103     result = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_HELD);
   107     map = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_DISCONNECTED);
   104     QCOMPARE(result, QString("txt_phone_other_on_hold"));
   108     QVERIFY(verify());
   105 
   109     QCOMPARE (map.size (), 1);
   106     result = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
   110     
   107     QCOMPARE(result, QString("txt_phone_other_waiting"));
   111     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_on_hold") );
   108 
   112     map = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_HELD);
   109     result = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
   113     QVERIFY(verify());
   110     QCOMPARE(result, QString("%:0%H%:1%T%:2%S%:3"));
   114     QCOMPARE (map.size (), 1);
   111     
   115 
   112     result = m_resourceAdapter->convert (R_PHONEUI_OUT_GOING_CALL);
   116     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_waiting") );
   113     QCOMPARE(result, QString("txt_phone_other_calling"));
   117     map = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
   114 
   118     QVERIFY(verify());
   115     result = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
   119     QCOMPARE (map.size (), 1);
   116     QCOMPARE(result, QString("txt_phone_other_private_number"));
   120 
   117 
   121     EXPECT( PhoneAction, setText).with ( QString("%:0%H%:1%T%:2%S%:3") );
   118     result = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_UNKNOWN);
   122     map = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
   119     QCOMPARE(result, QString("txt_phone_other_unknown_number"));
   123     QVERIFY(verify());
   120 
   124     QCOMPARE (map.size (), 1);
   121     result = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
   125     
   122     QCOMPARE(result, QString("txt_phone_other_emergency_call"));
   126     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_calling") );
   123 
   127     map = m_resourceAdapter->convert (R_PHONEUI_OUT_GOING_CALL);
   124     result = m_resourceAdapter->convert (R_PHONEUI_ATTEMPTING_EMERGENCY_CALL_TEXT);
   128     QVERIFY(verify());
   125     QCOMPARE(result, QString("txt_phone_other_attempting"));
   129     QCOMPARE (map.size (), 1);
       
   130 
       
   131     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_private_number") );
       
   132     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
       
   133     QVERIFY(verify());
       
   134     QCOMPARE (map.size (), 1);
       
   135 
       
   136     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_unknown_number") );
       
   137     map = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_UNKNOWN);
       
   138     QVERIFY(verify());
       
   139     QCOMPARE (map.size (), 1);
       
   140 
       
   141     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_emergency_call") );
       
   142     map = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
       
   143     QVERIFY(verify());
       
   144     QCOMPARE (map.size (), 1);
       
   145 
       
   146     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_attempting") );
       
   147     map = m_resourceAdapter->convert (R_PHONEUI_ATTEMPTING_EMERGENCY_CALL_TEXT);
       
   148     QVERIFY(verify());
       
   149     QCOMPARE (map.size (), 1);
       
   150         
   126         
   151     EXPECT( PhoneAction, setText).with ( QString("txt_phone_other_conference_call") );
   127     result = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
   152     map = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
   128     QCOMPARE(result, QString("txt_phone_other_conference_call"));
   153     QVERIFY(verify());
       
   154     QCOMPARE (map.size (), 1);
       
   155     
   129     
   156     TBuf<10> buffer(_L("123"));
   130     TBuf<10> buffer(_L("123"));
   157     EXPECT( PhoneAction, setText).with ( QString("txt_phone_info_sending") );
   131     result = m_resourceAdapter->convert (R_PHONEUI_SENDING_DTMF_WAIT_NOTE_TEXT, &buffer);
   158     map = m_resourceAdapter->convert (R_PHONEUI_SENDING_DTMF_WAIT_NOTE_TEXT, &buffer);
   132     QCOMPARE(result, QString("txt_phone_info_sending"));
   159     QVERIFY(verify());
   133     
   160     QCOMPARE (map.size(), 1);
   134     result = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
   161     
   135     QCOMPARE(result, QString("txt_phone_info_send_string"));
   162     EXPECT( PhoneAction, setText).with ( QString("txt_phone_info_send_string") );
       
   163     map = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
       
   164     QVERIFY(verify());
       
   165     QCOMPARE(map.size(), 1);
       
   166     
   136     
   167     // TODO
   137     // TODO
   168     map = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
   138     result = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
   169     
   139     
   170     map = m_resourceAdapter->convert (0);
   140     result = m_resourceAdapter->convert (0);
   171     // QCOMPARE (map.size (), 0);
   141     // QCOMPARE (map.size (), 0);
   172 }
   142 }
   173 
   143 
   174 void TestPhoneResourceAdapter::testConvertToString ()
   144 void TestPhoneResourceAdapter::testConvertToString ()
   175 {
   145 {
   329     
   299     
   330     QVERIFY( false == testString.isEmpty() );
   300     QVERIFY( false == testString.isEmpty() );
   331        
   301        
   332     QString testString2 = m_resourceAdapter->convertToStringWithParam(0, QString()); 
   302     QString testString2 = m_resourceAdapter->convertToStringWithParam(0, QString()); 
   333     QCOMPARE( testString2, QString ("") );
   303     QCOMPARE( testString2, QString ("") );
   334 }
       
   335 
       
   336 void TestPhoneResourceAdapter::testIncallToolbar (int id)
       
   337 {
       
   338     QMap<PhoneAction::ActionType, PhoneAction *> map;
       
   339     PhoneAction *action;
       
   340     map = m_resourceAdapter->convert (id);
       
   341     QCOMPARE (map.size (), 4);
       
   342     
       
   343     switch(id) {
       
   344     case R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA:
       
   345         action = map [PhoneAction::ToolbarButton1];
       
   346         QCOMPARE (action->icon (), HbIcon("qtg_mono_dialer"));
       
   347         action = map [PhoneAction::ToolbarButton2];
       
   348         QCOMPARE (action->icon (), HbIcon("qtg_mono_mic_unmute"));
       
   349         QCOMPARE (action->command (), (int)EPhoneInCallCmdUnmute);    
       
   350         action = map [PhoneAction::ToolbarButton3];
       
   351         QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker"));
       
   352         QCOMPARE (action->command (), (int)EPhoneInCallCmdActivateIhf);        
       
   353         break;
       
   354     default:    
       
   355         action = map [PhoneAction::ToolbarButton1];
       
   356         QCOMPARE (action->icon (), HbIcon("qtg_mono_dialer"));
       
   357         action = map [PhoneAction::ToolbarButton2];
       
   358         QCOMPARE (action->icon (), HbIcon("qtg_mono_mic_mute"));
       
   359         QCOMPARE (action->command (), (int)EPhoneInCallCmdMute);    
       
   360         action = map [PhoneAction::ToolbarButton3];
       
   361         QCOMPARE (action->icon (), HbIcon("qtg_mono_speaker"));
       
   362         QCOMPARE (action->command (), (int)EPhoneInCallCmdActivateIhf);
       
   363         break;
       
   364     }
       
   365 }
   304 }
   366 
   305 
   367 void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
   306 void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
   368 {
   307 {
   369     QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
   308     QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
   422 {
   361 {
   423     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   362     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   424     PhoneUIQtButtonsController* buttonsController = 
   363     PhoneUIQtButtonsController* buttonsController = 
   425         m_resourceAdapter->buttonsController();
   364         m_resourceAdapter->buttonsController();
   426     
   365     
   427     QList<PhoneAction::ToolBarItem> testList;
   366     QList<XQTelUiCommandExtension::ToolBarCommand> testList;
   428     
   367     
   429     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
   368     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
   430     QCOMPARE(2,testList.count());
   369     QCOMPARE(2,testList.count());
   431     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   370     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   432     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
   371     QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
   433     QVERIFY(true == testList.at(0).mEnabled);
   372     QVERIFY(true == testList[0].mIsEnabled);
   434     QVERIFY(true == testList.at(1).mEnabled);
   373     QVERIFY(true == testList[1].mIsEnabled);
   435     testList.clear();
   374     testList.clear();
   436     
   375     
   437     // Set soft reject dimmed
   376     // Set soft reject dimmed
   438     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   377     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   439     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
   378     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
   440     QCOMPARE(2,testList.count());
   379     QCOMPARE(2,testList.count());
   441     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   380     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   442     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
   381     QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
   443     QVERIFY(false == testList.at(0).mEnabled);
   382     QVERIFY(false == testList[0].mIsEnabled);
   444     QVERIFY(true == testList.at(1).mEnabled);
   383     QVERIFY(true == testList[1].mIsEnabled);
   445     testList.clear();    
   384     testList.clear();    
   446     
   385     
   447     // Set soft reject
   386     // Set soft reject
   448     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   387     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   449     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
   388     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
   450     QCOMPARE(2,testList.count());
   389     QCOMPARE(2,testList.count());
   451     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   390     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   452     QVERIFY(PhoneInCallCmdReject == testList.at(1).mCommandId);
   391     QVERIFY(PhoneInCallCmdReject == testList[1].mCommandId);
   453     QVERIFY(true == testList.at(0).mEnabled);
   392     QVERIFY(true == testList[0].mIsEnabled);
   454     QVERIFY(true == testList.at(1).mEnabled);
   393     QVERIFY(true == testList[1].mIsEnabled);
   455     testList.clear(); 
   394     testList.clear(); 
   456     
   395     
   457     // Set soft reject dimmed
   396     // Set soft reject dimmed
   458     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   397     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   459     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
   398     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
   460     QCOMPARE(2,testList.count());
   399     QCOMPARE(2,testList.count());
   461     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   400     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   462     QVERIFY(PhoneInCallCmdReject == testList.at(1).mCommandId);
   401     QVERIFY(PhoneInCallCmdReject == testList[1].mCommandId);
   463     QVERIFY(false == testList.at(0).mEnabled);
   402     QVERIFY(false == testList[0].mIsEnabled);
   464     QVERIFY(true == testList.at(1).mEnabled);
   403     QVERIFY(true == testList[1].mIsEnabled);
   465     testList.clear(); 
   404     testList.clear(); 
   466     
   405     
   467     // Set soft reject
   406     // Set soft reject
   468     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   407     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   469     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
   408     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
   470     QCOMPARE(2,testList.count());
   409     QCOMPARE(2,testList.count());
   471     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   410     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   472     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
   411     QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
   473     QVERIFY(true == testList.at(0).mEnabled);
   412     QVERIFY(true == testList[0].mIsEnabled);
   474     QVERIFY(false == testList.at(1).mEnabled);
   413     QVERIFY(false == testList[1].mIsEnabled);
   475     testList.clear(); 
   414     testList.clear(); 
   476     
   415     
   477     // Set soft reject dimmed
   416     // Set soft reject dimmed
   478     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   417     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   479     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
   418     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
   480     QCOMPARE(2,testList.count());
   419     QCOMPARE(2,testList.count());
   481     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   420     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   482     QVERIFY(PhoneCallComingCmdSilent == testList.at(1).mCommandId);
   421     QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
   483     QVERIFY(false == testList.at(0).mEnabled);
   422     QVERIFY(false == testList[0].mIsEnabled);
   484     QVERIFY(false == testList.at(1).mEnabled);
   423     QVERIFY(false == testList[1].mIsEnabled);
   485     testList.clear(); 
   424     testList.clear(); 
   486     
   425     
   487     // Set soft reject
   426     // Set soft reject
   488     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   427     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   489     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
   428     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
   490     QCOMPARE(2,testList.count());
   429     QCOMPARE(2,testList.count());
   491     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   430     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   492     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(1).mCommandId);
   431     QVERIFY(PhoneInCallCmdJoinToConference == testList[1].mCommandId);
   493     QVERIFY(true == testList.at(0).mEnabled);
   432     QVERIFY(true == testList[0].mIsEnabled);
   494     QVERIFY(false == testList.at(1).mEnabled);
   433     QVERIFY(false == testList[1].mIsEnabled);
   495     testList.clear(); 
   434     testList.clear(); 
   496     
   435     
   497     // Set soft reject dimmed
   436     // Set soft reject dimmed
   498     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   437     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
   499     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
   438     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
   500     QCOMPARE(2,testList.count());
   439     QCOMPARE(2,testList.count());
   501     QVERIFY(PhoneCallComingCmdSoftReject == testList.at(0).mCommandId);
   440     QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
   502     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(1).mCommandId);
   441     QVERIFY(PhoneInCallCmdJoinToConference == testList[1].mCommandId);
   503     QVERIFY(false == testList.at(0).mEnabled);
   442     QVERIFY(false == testList[0].mIsEnabled);
   504     QVERIFY(false == testList.at(1).mEnabled);
   443     QVERIFY(false == testList[1].mIsEnabled);
   505     testList.clear(); 
   444     testList.clear(); 
   506     
   445     
   507     // Set soft reject
   446     // Set soft reject
   508     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   447     buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
   509     
   448     
   510     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
   449     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
   511     QCOMPARE(2,testList.count());
   450     QCOMPARE(2,testList.count());
   512     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
   451     QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
   513     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(1).mCommandId);
   452     QVERIFY(PhoneInCallCmdOpenDialer == testList[1].mCommandId);
   514     QVERIFY(true == testList.at(0).mEnabled);
   453     QVERIFY(true == testList[0].mIsEnabled);
   515     QVERIFY(true == testList.at(1).mEnabled);
   454     QVERIFY(true == testList[1].mIsEnabled);
   516     testList.clear(); 
   455     testList.clear(); 
   517     
   456     
   518     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_DIALER_CBA);
   457     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_DIALER_CBA);
   519     QCOMPARE(4,testList.count());
   458     QCOMPARE(4,testList.count());
   520     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
   459     QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
   521     QVERIFY(PhoneInCallCmdHold == testList.at(1).mCommandId);
   460     QVERIFY(PhoneInCallCmdHold == testList[1].mCommandId);
   522     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
   461     QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
   523     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   462     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   524     QVERIFY(true == testList.at(0).mEnabled);
   463     QVERIFY(true == testList[0].mIsEnabled);
   525     QVERIFY(true == testList.at(1).mEnabled);
   464     QVERIFY(true == testList[1].mIsEnabled);
   526     QVERIFY(true == testList.at(2).mEnabled);
   465     QVERIFY(true == testList[2].mIsEnabled);
   527     QVERIFY(true == testList.at(3).mEnabled);
   466     QVERIFY(true == testList[3].mIsEnabled);
   528     testList.clear(); 
   467     testList.clear(); 
   529     
   468     
   530     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   469     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   531     QCOMPARE(4,testList.count());
   470     QCOMPARE(4,testList.count());
   532     QVERIFY(PhoneInCallCmdActivateIhf == testList.at(0).mCommandId);
   471     QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
   533     QVERIFY(PhoneInCallCmdHold == testList.at(1).mCommandId);
   472     QVERIFY(PhoneInCallCmdHold == testList[1].mCommandId);
   534     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
   473     QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
   535     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   474     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   536     QVERIFY(true == testList.at(0).mEnabled);
   475     QVERIFY(true == testList[0].mIsEnabled);
   537     QVERIFY(true == testList.at(1).mEnabled);
   476     QVERIFY(true == testList[1].mIsEnabled);
   538     QVERIFY(true == testList.at(2).mEnabled);
   477     QVERIFY(true == testList[2].mIsEnabled);
   539     QVERIFY(true == testList.at(3).mEnabled);
   478     QVERIFY(true == testList[3].mIsEnabled);
   540     testList.clear(); 
   479     testList.clear(); 
   541     
   480     
   542     // Set flags hold and ihf
   481     // Set flags hold and ihf
   543     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Ihf,true);
   482     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Ihf,true);
   544     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Hold,true);
   483     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Hold,true);
   545     
   484     
   546     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
   485     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
   547     QCOMPARE(2,testList.count());
   486     QCOMPARE(2,testList.count());
   548     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   487     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   549     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(1).mCommandId);
   488     QVERIFY(PhoneInCallCmdOpenDialer == testList[1].mCommandId);
   550     QVERIFY(true == testList.at(0).mEnabled);
   489     QVERIFY(true == testList[0].mIsEnabled);
   551     QVERIFY(true == testList.at(1).mEnabled);
   490     QVERIFY(true == testList[1].mIsEnabled);
   552     testList.clear(); 
   491     testList.clear(); 
   553     
   492     
   554     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_INCALL_DIALER_CBA);
   493     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_INCALL_DIALER_CBA);
   555     QCOMPARE(4,testList.count());
   494     QCOMPARE(4,testList.count());
   556     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   495     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   557     QVERIFY(PhoneInCallCmdUnhold == testList.at(1).mCommandId);
   496     QVERIFY(PhoneInCallCmdUnhold == testList[1].mCommandId);
   558     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
   497     QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
   559     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   498     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   560     QVERIFY(true == testList.at(0).mEnabled);
   499     QVERIFY(true == testList[0].mIsEnabled);
   561     QVERIFY(true == testList.at(1).mEnabled);
   500     QVERIFY(true == testList[1].mIsEnabled);
   562     QVERIFY(true == testList.at(2).mEnabled);
   501     QVERIFY(true == testList[2].mIsEnabled);
   563     QVERIFY(true == testList.at(3).mEnabled);
   502     QVERIFY(true == testList[3].mIsEnabled);
   564     testList.clear(); 
   503     testList.clear(); 
   565     
   504     
   566     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   505     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   567     QCOMPARE(4,testList.count());
   506     QCOMPARE(4,testList.count());
   568     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   507     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   569     QVERIFY(PhoneInCallCmdUnhold == testList.at(1).mCommandId);
   508     QVERIFY(PhoneInCallCmdUnhold == testList[1].mCommandId);
   570     QVERIFY(PhoneInCallCmdOpenContacts == testList.at(2).mCommandId);
   509     QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
   571     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   510     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   572     QVERIFY(true == testList.at(0).mEnabled);
   511     QVERIFY(true == testList[0].mIsEnabled);
   573     QVERIFY(true == testList.at(1).mEnabled);
   512     QVERIFY(true == testList[1].mIsEnabled);
   574     QVERIFY(true == testList.at(2).mEnabled);
   513     QVERIFY(true == testList[2].mIsEnabled);
   575     QVERIFY(true == testList.at(3).mEnabled);
   514     QVERIFY(true == testList[3].mIsEnabled);
   576     testList.clear(); 
   515     testList.clear(); 
   577     
   516     
   578     // Set flag multi call
   517     // Set flag multi call
   579     buttonsController->setButtonFlags(PhoneUIQtButtonsController::MultiCall,true);
   518     buttonsController->setButtonFlags(PhoneUIQtButtonsController::MultiCall,true);
   580     
   519     
   581     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   520     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   582     QCOMPARE(4,testList.count());
   521     QCOMPARE(4,testList.count());
   583     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   522     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   584     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
   523     QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
   585     QVERIFY(PhoneInCallCmdCreateConference == testList.at(2).mCommandId);
   524     QVERIFY(PhoneInCallCmdCreateConference == testList[2].mCommandId);
   586     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   525     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   587     QVERIFY(true == testList.at(0).mEnabled);
   526     QVERIFY(true == testList[0].mIsEnabled);
   588     QVERIFY(true == testList.at(1).mEnabled);
   527     QVERIFY(true == testList[1].mIsEnabled);
   589     QVERIFY(true == testList.at(2).mEnabled);
   528     QVERIFY(true == testList[2].mIsEnabled);
   590     QVERIFY(true == testList.at(3).mEnabled);
   529     QVERIFY(true == testList[3].mIsEnabled);
   591     testList.clear();
   530     testList.clear();
   592     
   531     
   593     // Set flag outgoing and conference call
   532     // Set flag outgoing and conference call
   594     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Outgoing,true);
   533     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Outgoing,true);
   595     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Conference,true);
   534     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Conference,true);
   596     
   535     
   597     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA);
   536     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA);
   598     QCOMPARE(4,testList.count());
   537     QCOMPARE(4,testList.count());
   599     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   538     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   600     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
   539     QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
   601     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(2).mCommandId);
   540     QVERIFY(PhoneInCallCmdJoinToConference == testList[2].mCommandId);
   602     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   541     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   603     QVERIFY(true == testList.at(0).mEnabled);
   542     QVERIFY(true == testList[0].mIsEnabled);
   604     QVERIFY(false == testList.at(1).mEnabled);
   543     QVERIFY(false == testList[1].mIsEnabled);
   605     QVERIFY(false == testList.at(2).mEnabled);
   544     QVERIFY(false == testList[2].mIsEnabled);
   606     QVERIFY(true == testList.at(3).mEnabled);
   545     QVERIFY(true == testList[3].mIsEnabled);
   607     testList.clear(); 
   546     testList.clear(); 
   608     
   547     
   609     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   548     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
   610     QCOMPARE(4,testList.count());
   549     QCOMPARE(4,testList.count());
   611     QVERIFY(PhoneInCallCmdDeactivateIhf == testList.at(0).mCommandId);
   550     QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
   612     QVERIFY(PhoneInCallCmdSwap == testList.at(1).mCommandId);
   551     QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
   613     QVERIFY(PhoneInCallCmdJoinToConference == testList.at(2).mCommandId);
   552     QVERIFY(PhoneInCallCmdJoinToConference == testList[2].mCommandId);
   614     QVERIFY(PhoneInCallCmdOpenDialer == testList.at(3).mCommandId);
   553     QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
   615     QVERIFY(true == testList.at(0).mEnabled);
   554     QVERIFY(true == testList[0].mIsEnabled);
   616     QVERIFY(false == testList.at(1).mEnabled);
   555     QVERIFY(false == testList[1].mIsEnabled);
   617     QVERIFY(false == testList.at(2).mEnabled);
   556     QVERIFY(false == testList[2].mIsEnabled);
   618     QVERIFY(true == testList.at(3).mEnabled);
   557     QVERIFY(true == testList[3].mIsEnabled);
   619     testList.clear(); 
   558     testList.clear(); 
   620 }
   559 }
   621 
   560 
   622 void TestPhoneResourceAdapter::testBtToolBarCommandList ()
   561 void TestPhoneResourceAdapter::testBtToolBarCommandList ()
   623 {
   562 {
   624     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   563     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   625     PhoneUIQtButtonsController* buttonsController = 
   564     PhoneUIQtButtonsController* buttonsController = 
   626         m_resourceAdapter->buttonsController();
   565         m_resourceAdapter->buttonsController();
   627     
   566     
   628     QList<PhoneAction::ToolBarItem> testList;
   567     QList<XQTelUiCommandExtension::ToolBarCommand> testList;
   629     buttonsController->setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable,true);
   568     buttonsController->setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable,true);
   630     buttonsController->setButtonFlags(PhoneUIQtButtonsController::IhfAsPushButton,false);
   569     buttonsController->setButtonFlags(PhoneUIQtButtonsController::IhfAsPushButton,false);
   631     
   570     
   632     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
   571     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
   633     QVERIFY(0 < testList.count());
   572     QVERIFY(0 < testList.count());
   634     QVERIFY(PhoneInCallCmdBtHandsfree == testList.at(0).mCommandId);
   573     QVERIFY(PhoneInCallCmdBtHandsfree == testList[0].mCommandId);
   635     QVERIFY(true == testList.at(0).mEnabled);
   574     QVERIFY(true == testList[0].mIsEnabled);
   636     testList.clear();
   575     testList.clear();
   637     
   576     
   638     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Btaa,true);
   577     buttonsController->setButtonFlags(PhoneUIQtButtonsController::Btaa,true);
   639     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
   578     testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
   640     QVERIFY(0 < testList.count());
   579     QVERIFY(0 < testList.count());
   641     QVERIFY(PhoneInCallCmdHandset == testList.at(0).mCommandId);
   580     QVERIFY(PhoneInCallCmdHandset == testList[0].mCommandId);
   642     QVERIFY(true == testList.at(0).mEnabled);
   581     QVERIFY(true == testList[0].mIsEnabled);
   643     testList.clear(); 
   582     testList.clear(); 
   644 }
   583 }
   645 
   584 
   646 PHONE_TEST_MAIN(TestPhoneResourceAdapter)
   585 PHONE_TEST_MAIN(TestPhoneResourceAdapter)
   647 #include "unit_tests.moc"
   586 #include "unit_tests.moc"