phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneresourceadapter/unit_tests.cpp
author hgs
Fri, 15 Oct 2010 12:58:46 +0300
changeset 78 baacf668fe89
parent 76 cfea66083b62
permissions -rw-r--r--
201041

/*!
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Unit tests for PhoneResourceAdapter.
*
*/

#include <QtTest/QtTest>
#include <QtGui>
#include <hbapplication.h>
#include <QSignalSpy>
#include <QVariant>
#include <hbaction.h>
#include <phoneappvoipcommands.hrh>
#include <xqphoneappcommands.h>
#include <mockservice.h>
#include "phonetestmain.h"
#include "phoneresourceadapter.h"
#include "phoneuiqtbuttonscontroller.h"
#include "phoneresourceids.h"
#include "phoneui.hrh"

class TestPhoneResourceAdapter : public QObject, MockService
{
    Q_OBJECT
public:
    TestPhoneResourceAdapter();
    virtual ~TestPhoneResourceAdapter();

public slots:
    void initTestCase ();
    void cleanupTestCase ();
    void init ();
    void cleanup (); 
    
private slots:
    void testConvert ();
    void testConvertToString ();
    void testConvertToString2 ();
    void testDefaultToolbarResourceId();
    void testConvertCommandToString();
    void testConvertToHbActions();
    void testConvertToToolBarCommandList();
    void testBtToolBarCommandList();
    
private:
    PhoneResourceAdapter *m_resourceAdapter; // class under test
};

TestPhoneResourceAdapter::TestPhoneResourceAdapter ()
{
}

TestPhoneResourceAdapter::~TestPhoneResourceAdapter ()
{
}

void TestPhoneResourceAdapter::initTestCase ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
}

void TestPhoneResourceAdapter::cleanupTestCase ()
{
    delete m_resourceAdapter;
}

void TestPhoneResourceAdapter::init ()
{
    initialize();
}

void TestPhoneResourceAdapter::cleanup ()
{
    reset();
}

void TestPhoneResourceAdapter::testConvert ()
{
    // For coverage
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
    PhoneUIQtButtonsController* buttonsController = 
        m_resourceAdapter->buttonsController ();
    
    QString result = 0;
    
    result = m_resourceAdapter->convert(R_PHONEUI_MTCAL_INCOMING_CALL);
    QCOMPARE (result, QString("txt_phone_other_incoming_call"));

    result = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_DISCONNECTED);
    QCOMPARE(result, QString("txt_phone_other_disconnected"));
    
    result = m_resourceAdapter->convert (R_PHONEUI_INCALL_CALL_HELD);
    QCOMPARE(result, QString("txt_phone_other_on_hold"));

    result = m_resourceAdapter->convert (R_PHONEUI_MULTC_WAITING);
    QCOMPARE(result, QString("txt_phone_other_waiting"));

    result = m_resourceAdapter->convert (R_PHONEUI_TIME_DURAT_LONG_WITH_ZERO);
    QCOMPARE(result, QString("%:0%H%:1%T%:2%S%:3"));
    
    result = m_resourceAdapter->convert (R_PHONEUI_OUT_GOING_CALL);
    QCOMPARE(result, QString("txt_phone_other_calling"));

    result = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_WITHHELD);
    QCOMPARE(result, QString("txt_phone_other_private_number"));

    result = m_resourceAdapter->convert (R_PHONEUI_MTCAL_CLI_UNKNOWN);
    QCOMPARE(result, QString("txt_phone_other_unknown_number"));

    result = m_resourceAdapter->convert (R_PHONEUI_EMERGENCY_CALL_HEADER);
    QCOMPARE(result, QString("txt_phone_other_emergency_call"));

    result = m_resourceAdapter->convert (R_PHONEUI_ATTEMPTING_EMERGENCY_CALL_TEXT);
    QCOMPARE(result, QString("txt_phone_other_attempting"));
        
    result = m_resourceAdapter->convert (R_PHONEUI_CONFERENCE_CALL);
    QCOMPARE(result, QString("txt_phone_other_conference_call"));
    
    TBuf<10> buffer(_L("123"));
    result = m_resourceAdapter->convert (R_PHONEUI_SENDING_DTMF_WAIT_NOTE_TEXT, &buffer);
    QCOMPARE(result, QString("txt_phone_info_sending"));
    
    result = m_resourceAdapter->convert(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY_TEXT, &buffer);
    QCOMPARE(result, QString("txt_phone_info_send_string"));
    
    // TODO
    result = m_resourceAdapter->convert (R_PHONEUI_CALLHANDLING_INCALL_HANDSET_CBA);
    
    result = m_resourceAdapter->convert (0);
    // QCOMPARE (map.size (), 0);
}

void TestPhoneResourceAdapter::testConvertToString ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
        
    QString testString = m_resourceAdapter->convertToString(R_PHONE_ERROR_CALL_NOT_ALLOWED); 
    QVERIFY( false == testString.isEmpty() );
    
    QString testString2 = m_resourceAdapter->convertToString(R_ERROR_NOTE_NOT_ALLOWED); 
    QVERIFY( false == testString2.isEmpty() );
    
    QString testString3 = m_resourceAdapter->convertToString(R_NOTETEXT_INVALID_PHONENUMBER); 
    QVERIFY( false == testString3.isEmpty() );
    
    QString testString4 = m_resourceAdapter->convertToString(R_NOTETEXT_NO_ANSWER); 
    QVERIFY( false == testString4.isEmpty() );
    
    QString testString5 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NUMBER_BUSY); 
    QVERIFY( false == testString5.isEmpty() );
    
    QString testString6 = m_resourceAdapter->convertToString(R_PHONE_ERROR_REQUEST_REJECTED); 
    QVERIFY( false == testString6.isEmpty() );
    
    QString testString7 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_INFO_HOLD_TEXT); 
    QVERIFY( false == testString7.isEmpty() );
    
    QString testString8 = m_resourceAdapter->convertToString(R_INCAL_INFO_HOLD_TEXT); 
    QVERIFY( false == testString8.isEmpty() );
    
    QString testString9 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_ACTIVE_TEXT); 
    QVERIFY( false == testString9.isEmpty() );
    
    /*QString testString10 = m_resourceAdapter->convertToString(R_INCAL_INFO_CONF_HOLD_TEXT); 
    QVERIFY( false == testString10.isEmpty() );*/
    
    QString testString11 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_NO_NETWORK_SUPPORT); 
    QVERIFY( false == testString11.isEmpty() );
    
    QString testString12 = m_resourceAdapter->convertToString(R_PHONE_ERROR_EMERGENCY_CALLS_ONLY); 
    QVERIFY( false == testString12.isEmpty() );
    
    QString testString13 = m_resourceAdapter->convertToString(R_NOTETEXT_NUMBER_NOT_IN_USE); 
    QVERIFY( false == testString13.isEmpty() );
    
    QString testString14 = m_resourceAdapter->convertToString(R_NOTETEXT_NETWORK_BUSY); 
    QVERIFY( false == testString14.isEmpty() );
    
    QString testString15 = m_resourceAdapter->convertToString(R_NOTETEXT_ERROR_IN_CONNECTION); 
    QVERIFY( false == testString15.isEmpty() );
    
    QString testString16 = m_resourceAdapter->convertToString(R_PHONEUI_ERROR_EMERGENCY_ATTEMPT_FAILED); 
    QVERIFY( false == testString16.isEmpty() );   
    
    QString testString17 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_INCAL_TRANSFERRED_TEXT); 
    QVERIFY( false == testString17.isEmpty() );    
 
    QString testString18 = m_resourceAdapter->convertToString(R_PHONE_ERROR_NO_SERVICE); 
    QVERIFY( false == testString18.isEmpty() ); 
    
    QString testString19 = m_resourceAdapter->convertToString(R_NOTETEXT_NUMBER_BARRED); 
    QVERIFY( false == testString19.isEmpty() ); 
    
    /*QString testString20 = m_resourceAdapter->convertToString(R_PHONEUI_NO_VIDEO_NETWORK); 
    QVERIFY( false == testString20.isEmpty() );*/ 
    
    QString testString21 = m_resourceAdapter->convertToString(R_PHONEUI_VIDEO_CALL_NOT_POSSIBLE); 
    QVERIFY( false == testString21.isEmpty() ); 
    
    QString testString22 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE127); 
    QVERIFY( false == testString22.isEmpty() ); 
    
    QString testString23 = m_resourceAdapter->convertToString(R_CALL_INFO_NOT_SUPPORTED); 
    QVERIFY( false == testString23.isEmpty() ); 
    
    QString testString24 = m_resourceAdapter->convertToString(R_CALL_INFO_SERVICE_NOT_AVAILABLE); 
    QVERIFY( false == testString24.isEmpty() ); 
    
    QString testString25 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE38); 
    QVERIFY( false == testString25.isEmpty() ); 
    
    QString testString26 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE55); 
    QVERIFY( false == testString26.isEmpty() ); 
    
    QString testString27 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE58); 
    QVERIFY( false == testString27.isEmpty() ); 
    
    QString testString28 = m_resourceAdapter->convertToString(R_NOTE_PHONE_OUT_OF_3G_COVERAGE); 
    QVERIFY( false == testString28.isEmpty() ); 
    
    QString testString29 = m_resourceAdapter->convertToString(R_NOTE_VIDEO_CALL_ONLY_POSSIBLE_UNDER_3G_COVERAGE); 
    QVERIFY( false == testString29.isEmpty() ); 
    
    QString testString30 = m_resourceAdapter->convertToString(R_NOTE_CALLED_NUMBER_HAS_BARRED_INCOMING_CALLS); 
    QVERIFY( false == testString30.isEmpty() ); 
    
    QString testString31 = m_resourceAdapter->convertToString(R_INCAL_REMOTE_CREATE_CONFERENCE_TEXT); 
    QVERIFY( false == testString31.isEmpty() ); 
    
    QString testString32 = m_resourceAdapter->convertToString(R_NOTETEXT_CALL_BARRINGS); 
    QVERIFY( false == testString32.isEmpty() ); 
    
    QString testString33 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE16); 
    QVERIFY( false == testString33.isEmpty() ); 
    
    QString testString34 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE18); 
    QVERIFY( false == testString34.isEmpty() ); 
    
    QString testString35 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE21); 
    QVERIFY( false == testString35.isEmpty() ); 
    
    QString testString36 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE22); 
    QVERIFY( false == testString36.isEmpty() ); 
    
    QString testString37 = m_resourceAdapter->convertToString(R_CALL_INFO_CAUSE_VALUE34); 
    QVERIFY( false == testString37.isEmpty() ); 
    
    QString testString38 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CALL_NOT_ALLOWED_FDN); 
    QVERIFY( false == testString38.isEmpty() ); 
    
    QString testString39 = m_resourceAdapter->convertToString(R_NOTE_UNABLE_TO_MAKE_VIDEO_CALL_NOT_SUPPORTED_BY_OTHER_PHONE); 
    QVERIFY( false == testString39.isEmpty() ); 

    QString testString40 = m_resourceAdapter->convertToString(R_NOTETEXT_DIVERTING_INCOMING_CALL); 
    QVERIFY( false == testString40.isEmpty() ); 
        
    QString testString41 = m_resourceAdapter->convertToString(R_NOTETEXT_DIVERTING); 
    QVERIFY( false == testString41.isEmpty() ); 
    
    QString testString42 = m_resourceAdapter->convertToString(R_NOTETEXT_ALL_INCOMING_CALLS_DIVERTED); 
    QVERIFY( false == testString42.isEmpty() ); 
        
    QString testString43 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CHECK_CLIR); 
    QVERIFY( false == testString43.isEmpty() ); 
    
    QString testString44 = m_resourceAdapter->convertToString(R_PHONE_SS_NOTIFICATION_CLIR_SUPPR_REJECT_TEXT); 
    QVERIFY( false == testString44.isEmpty() ); 
    
    QString testString45 = m_resourceAdapter->convertToString(R_NOTE_TEXT_CLIR_CHANGE); 
    QVERIFY( false == testString45.isEmpty() ); 
    
    QString testString46 = m_resourceAdapter->convertToString(R_PHONE_ERROR_CHECK_NETWORK_SERVICES); 
    QVERIFY( false == testString46.isEmpty() ); 
    
    QString testString47 = m_resourceAdapter->convertToString(R_PHONE_INCALL_INFO_VIDEO_CALL_NOT_ALLOWED_DURING_RESTORE); 
    QVERIFY( false == testString47.isEmpty() ); 
    
    QString testString99 = m_resourceAdapter->convertToString(0); 
    QCOMPARE( testString99, QString ("") );
}

void TestPhoneResourceAdapter::testConvertToString2 ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
        
    QString testString = m_resourceAdapter->convertToStringWithParam(
            R_PHONE_TEXT_COLP_CONNECTED, QString("123456"));
    
    QVERIFY( false == testString.isEmpty() );
       
    QString testString2 = m_resourceAdapter->convertToStringWithParam(0, QString()); 
    QCOMPARE( testString2, QString ("") );
}

void TestPhoneResourceAdapter::testDefaultToolbarResourceId()
{
    QVERIFY(m_resourceAdapter->defaultToolbarResourceId()==
            R_PHONEUI_INCALL_DIALER_CBA);
}

void TestPhoneResourceAdapter::testConvertCommandToString ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
    
    QString testString = m_resourceAdapter->convertCommandToString(
            EPhoneInCallCmdEndAllCalls);    
    QVERIFY( false == testString.isEmpty() );
    
    testString = m_resourceAdapter->convertCommandToString(
            EPhoneInCallCmdTransfer);    
    QVERIFY( false == testString.isEmpty() );
    
    testString = m_resourceAdapter->convertCommandToString(
            EPhoneCmdHandoverToWlan);    
    QVERIFY( false == testString.isEmpty() );
    
    testString = m_resourceAdapter->convertCommandToString(
            EPhoneCmdHandoverToGsm);    
    QVERIFY( false == testString.isEmpty() );
    
    testString = m_resourceAdapter->convertCommandToString(0); 
    QCOMPARE( testString, QString ("") );
}

void TestPhoneResourceAdapter::testConvertToHbActions()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance (this);
    
    QList<HbAction*> testList = m_resourceAdapter->convertToHbActions(R_PHONEUI_DTMF_WAIT_CHARACTER_CONFIRMATION_QUERY);    
    QCOMPARE( testList.count(), 2 );
    QCOMPARE( (int)EPhoneInCallCmdContinueSendingDtmfString, 
              testList.at(0)->data().toInt());
    QCOMPARE( (int)EPhoneInCallCmdCancelSendingDtmfString, 
              testList.at(1)->data().toInt());
    qDeleteAll(testList);
    testList.clear();
    
    testList = m_resourceAdapter->convertToHbActions(R_PHONEUI_SENDING_DTMF_WAIT_NOTE);    
    QCOMPARE( testList.count(), 1 );
    QCOMPARE( (int)EPhoneInCallCmdCancelSendingDtmfString, 
              testList.at(0)->data().toInt());
    qDeleteAll(testList);
    testList.clear();
    
    testList = m_resourceAdapter->convertToHbActions(0);    
    QCOMPARE( testList.count(), 0 );
}

void TestPhoneResourceAdapter::testConvertToToolBarCommandList ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance(this);
    PhoneUIQtButtonsController* buttonsController = 
        m_resourceAdapter->buttonsController();
    
    QList<XQTelUiCommandExtension::ToolBarCommand> testList;
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear();
    
    // Set soft reject dimmed
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
    QVERIFY(false == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear();    
    
    // Set soft reject
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdReject == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject dimmed
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_REJECT_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdReject == testList[1].mCommandId);
    QVERIFY(false == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject dimmed
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCOMINGCALL_SOFT_REJECT_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneCallComingCmdSilent == testList[1].mCommandId);
    QVERIFY(false == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdJoinToConference == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject dimmed
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,true);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLWAITING_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneCallComingCmdSoftReject == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdJoinToConference == testList[1].mCommandId);
    QVERIFY(false == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    testList.clear(); 
    
    // Set soft reject
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::DisableSoftReject,false);
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear(); 
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_DIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdHold == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    QVERIFY(true == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdActivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdHold == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    QVERIFY(true == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
    
    // Set flags hold and ihf
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::Ihf,true);
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::Hold,true);
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_EMERGENCY_CBA);
    QCOMPARE(2,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[1].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    testList.clear(); 
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_INCALL_DIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdUnhold == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    QVERIFY(true == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdUnhold == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdOpenContacts == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    QVERIFY(true == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
    
    // Set flag multi call
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::MultiCall,true);
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdCreateConference == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(true == testList[1].mIsEnabled);
    QVERIFY(true == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear();
    
    // Set flag outgoing and conference call
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::Outgoing,true);
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::Conference,true);
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_UNMUTE_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdJoinToConference == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    QVERIFY(false == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_CALLSETUP_EMPTY_DTMFDIALER_CBA);
    QCOMPARE(4,testList.count());
    QVERIFY(PhoneInCallCmdDeactivateIhf == testList[0].mCommandId);
    QVERIFY(PhoneInCallCmdSwap == testList[1].mCommandId);
    QVERIFY(PhoneInCallCmdJoinToConference == testList[2].mCommandId);
    QVERIFY(PhoneInCallCmdOpenDialer == testList[3].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    QVERIFY(false == testList[1].mIsEnabled);
    QVERIFY(false == testList[2].mIsEnabled);
    QVERIFY(true == testList[3].mIsEnabled);
    testList.clear(); 
}

void TestPhoneResourceAdapter::testBtToolBarCommandList ()
{
    m_resourceAdapter = PhoneResourceAdapter::Instance(this);
    PhoneUIQtButtonsController* buttonsController = 
        m_resourceAdapter->buttonsController();
    
    QList<XQTelUiCommandExtension::ToolBarCommand> testList;
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::BluetoothAvailable,true);
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::IhfAsPushButton,false);
    
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
    QVERIFY(0 < testList.count());
    QVERIFY(PhoneInCallCmdBtHandsfree == testList[0].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    testList.clear();
    
    buttonsController->setButtonFlags(PhoneUIQtButtonsController::Btaa,true);
    testList = m_resourceAdapter->convertToToolBarCommandList(R_PHONEUI_CALLHANDLING_INCALL_BTAA_CBA);
    QVERIFY(0 < testList.count());
    QVERIFY(PhoneInCallCmdHandset == testList[0].mCommandId);
    QVERIFY(true == testList[0].mIsEnabled);
    testList.clear(); 
}

PHONE_TEST_MAIN(TestPhoneResourceAdapter)
#include "unit_tests.moc"