phoneapp/phoneuiqtviewadapter/tsrc/ut_phoneuiqtviewadapter/unit_tests.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*!
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Unit tests for PhoneUIQtViewAdapter.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtTest/QtTest>
       
    19 #include <QtGui>
       
    20 #include <QList>
       
    21 #include <QKeyEvent>
       
    22 #include <hbapplication.h>
       
    23 #include <QSignalSpy>
       
    24 #include <hbmainwindow.h>
       
    25 #include <phoneappcommands.hrh>
       
    26 #include <hbmenu.h>
       
    27 //#include <hbglobal_p.h>
       
    28 #include "phoneuiqtviewadapter.h"
       
    29 #include "tphonecmdparaminteger.h"
       
    30 #include "tphonecmdparamaudiooutput.h"
       
    31 #include "phoneuiqtviewif.h"
       
    32 #include "tphonecmdparamcallstatedata.h"
       
    33 #include "tphonecmdparamcallheaderdata.h"
       
    34 #include "tphonecmdparamemergencycallheaderdata.h"
       
    35 #include "tphonecmdparamboolean.h"
       
    36 #include "tphonecmdparamringtone.h"
       
    37 #include "pevirtualengine.h"
       
    38 #include "bubblemanagerif.h"
       
    39 #include "phoneresourceids.h"
       
    40 #include "phonebubblewrapper.h"
       
    41 #include "phoneuiqtbuttonscontroller.h"
       
    42 #include "tphonecmdparamglobalnote.h"
       
    43 #include "tphonecmdparamstring.h"
       
    44 
       
    45 extern int m_phoneButtonFlags;
       
    46 extern bool m_EPhoneViewMuteRingToneOnAnswer_called;
       
    47 extern bool m_EPhoneViewStopRingTone_called;
       
    48 extern bool m_EPhoneViewMuteRingTone_called;
       
    49 extern bool m_EPhoneViewPlayRingTone_called;
       
    50 extern bool m_showGlobalNoteCalled;
       
    51 extern bool m_removeCallHeaderCalled;
       
    52 extern bool m_addToConferenceBubbleCalled;
       
    53 extern bool m_showQueryCalled;
       
    54 extern bool m_removeDtmfNoteCalled;
       
    55 extern bool m_removeNoteCalled;
       
    56 extern bool m_removeQueryCalled;
       
    57 extern bool m_showNoteCalled;
       
    58 extern bool m_removeGlobalWaitNoteCalled;
       
    59 
       
    60 
       
    61 #define PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestObject) \
       
    62 int main(int argc, char *argv[]) \
       
    63     { \
       
    64         HbApplication app(argc, argv); \
       
    65         TestObject tc; \
       
    66         QResource::registerResource("../hbcore.rcc"); \
       
    67         int ret = QTest::qExec(&tc, argc, argv); \
       
    68         /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    69         /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    70         /* app.exec() where the signal is normally emitted is not called here. */ \
       
    71         /* So, invoking the signal explicitly. */ \
       
    72         QMetaObject::invokeMethod(&app, "aboutToQuit", Qt::DirectConnection); \
       
    73         return ret; \
       
    74     }
       
    75 
       
    76 // Own assert initialization  
       
    77 /*void qt_assert(const char *assertion, const char *file, int line)
       
    78 {
       
    79     qDebug () << "View test assert FAIL";
       
    80 }*/
       
    81 
       
    82 class TestPhoneUIQtViewAdapter : public QObject, public PhoneUIQtViewIF, public BubbleManagerIF
       
    83 {
       
    84     Q_OBJECT
       
    85 public:
       
    86     TestPhoneUIQtViewAdapter();
       
    87     virtual ~TestPhoneUIQtViewAdapter();
       
    88 
       
    89     // From PhoneUIQtViewIF
       
    90     BubbleManagerIF& bubbleManager ();
       
    91     void addBubbleCommand (int bubbleId, const PhoneAction& action);
       
    92     void clearBubbleCommands (int bubbleId);
       
    93     void addParticipantListAction(
       
    94             int commandId,  
       
    95             const QString &text, 
       
    96             const HbIcon &icon);
       
    97     void clearParticipantListActions();
       
    98     void hideToolbar () { };
       
    99     void showToolbar () { m_showToolbarCalled = true; };
       
   100     void setToolbarActions (const QList<PhoneAction*>& actions) {m_toolbarActionCount = actions.count(); };
       
   101     int volumeSliderValue () { m_volumeSliderValueCalled = true; return 5; };
       
   102     void removeVolumeSlider () { m_removeVolumeSliderCalled = true; };
       
   103     void setVolumeSliderValue (
       
   104             int value, 
       
   105             int commandId, 
       
   106             int maxVolumeValue, 
       
   107             int minVolumeValue ) { m_setVolumeSliderValueCalled = true; m_volumeSliderValue = value; };
       
   108 
       
   109     void setExpandAction(int bubbleId, int commandId) {m_expandAction[bubbleId]=commandId;};
       
   110     void removeExpandAction(int bubbleId) {};
       
   111     void showDialpad() {m_showDialpadCalled = true;};  
       
   112     void hideDialpad() {m_hideDialpadCalled = true;};  
       
   113     bool isDialpadVisible() 
       
   114         {m_dialpadVisibilityCalled = true;
       
   115     return m_isDialpadVisible; }
       
   116     QString dialpadText() {return m_dialpadText;};
       
   117     void clearAndHideDialpad() { m_clearAndHideDialpadCalled = true;};
       
   118     void bringToForeground() {;};
       
   119     void setMenuActions(const QList<PhoneAction*>& actions) { m_setMenuActionsCalled = true;};
       
   120     void shutdownPhoneApp() {;};
       
   121     void setBackButtonVisible(bool visible) {;};
       
   122     HbMenu &menuReference(){return m_menu;};
       
   123     
       
   124     // From BubbleManagerIF
       
   125     void startChanges () { m_startChangesCalled=true; };
       
   126     void endChanges () { m_endChangesCalled=true; };
       
   127     int createCallHeader () { return 0; };
       
   128     void removeCallHeader (int bubbleId) {};
       
   129     void setState (int bubbleId, PhoneCallState state) {};
       
   130     void setLabel ( 
       
   131         int bubbleId, 
       
   132         const QString& text, 
       
   133         Qt::TextElideMode clipDirection) {};
       
   134     void setCli (int bubbleId, 
       
   135                  const QString& cliText, 
       
   136                  Qt::TextElideMode clipDirection) {};
       
   137     void updateCLI ( 
       
   138         int bubbleId, 
       
   139         const QString& cliText, 
       
   140         Qt::TextElideMode clipDirection) {};
       
   141     void setSecondaryCli ( 
       
   142         int bubbleId, 
       
   143         const QString& cliText, 
       
   144         Qt::TextElideMode clipDirection = Qt::ElideLeft) {};
       
   145     void setCallTime (int bubbleId, const QString& callTime) {};
       
   146     void updateCallTime (int bubbleId, const QString& callTime) { m_updateCallTimeCalled=true; m_int=bubbleId; m_string=callTime; };
       
   147     void setCallObjectImage (int bubbleId, const QString &fileName) {};
       
   148     void setCallObjectFromTheme (int bubbleId) {};
       
   149     void setCallObjectText (int bubbleId, const QString &text) {};
       
   150     void setCallFlags (int bubbleId, int flags) {};
       
   151     void setCallFlag (int bubbleId, PhoneCallFlags flag, bool set) {};
       
   152     void setNumberType (int bubbleId, PhoneNumberType type) {};
       
   153     void updateCallHeaderText( 
       
   154         int bubbleId, 
       
   155         const QString &longText, 
       
   156         const QString &shortText, 
       
   157         Qt::TextElideMode clipDirection) {};
       
   158     void setPhoneMuted (bool muted) { m_setPhoneMutedCalled = muted; };
       
   159     int createConference (int bubble1, int bubble2) { return 1; };
       
   160     void removeConference () {};
       
   161     void addRowToConference (int bubbleId) {};
       
   162     void removeRowFromConference (int bubbleId) {};
       
   163     int conferenceRowCount () const { return 2; };
       
   164     void setSelectionInConference (int rowNumber) {};
       
   165     void setSelectionIdInConference (int bubbleId) {};
       
   166     int selectionInConference () const { return 0; };
       
   167     int selectionIdInConference () const { return 0; };
       
   168     void moveHighlightOneUpInConference () {};
       
   169     void moveHighlightOneDownInConference () {};
       
   170     void setExpandedConferenceCallHeader (bool expanded) { m_ExpandConferenceCalled = true; };
       
   171     bool isConferenceExpanded () const { return false; };
       
   172     int shownHeaderCount () const { return 1; };
       
   173     void setParticipantListCli (int aBubbleId, ParticipantListCli aParticipantCli) {};
       
   174     void addAction (int bubble, HbAction *action) {};
       
   175     void clearActions (int bubble) {};
       
   176     QGraphicsWidget* graphicsWidgetForAction (HbAction *action) const { return 0;};
       
   177     void addParticipantListAction (HbAction *action) {};
       
   178     int expandedBubble() const { return 1; };
       
   179     void setExpandAction(int bubbleId, HbAction* action) {};
       
   180     void setBubbleSelectionDisabled(bool b) {};
       
   181     
       
   182 signals:
       
   183     void dialpadAboutToClose();
       
   184     void keyPressReleased(QKeyEvent *event);
       
   185 
       
   186 public slots:
       
   187     void initTestCase ();
       
   188     void cleanupTestCase ();
       
   189     void init ();
       
   190     void cleanup ();
       
   191     
       
   192 private slots:
       
   193     void testEPhoneViewSetTopApplicationCommand ();
       
   194     void testEPhoneViewSetIdleTopApplicationCommand ();
       
   195     void testEPhoneViewUpdateCallHeaderCallDurationCommand ();
       
   196     void testEPhoneViewCreateCallHeaderCommand ();
       
   197     void testEPhoneViewCreateEmergencyCallHeader ();
       
   198     void testEPhoneViewUpdateBubble ();
       
   199     void testEPhoneViewUpdateCallHeaderRemoteInfoData ();
       
   200     void testEPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel();
       
   201     void testCallIdByState ();
       
   202     void testSetToolbarButtons ();
       
   203     void testHoldFlag ();
       
   204     void testEPhoneViewHideNaviPaneAudioVolume ();
       
   205     void testEPhoneViewSetNaviPaneAudioVolume ();
       
   206     void testEPhoneViewGetAudioVolumeLevel ();
       
   207     void testEPhoneViewActivateMuteUIChanges ();
       
   208     void testEPhoneViewGetCountOfActiveCallss ();
       
   209     void testExecuteCommandLwithCmdId ();
       
   210     void testExecuteCommandLwithCmdIdAndCallId ();
       
   211     void testExecuteCommandLwithCmdIdAndCmdParam ();
       
   212     void testSetTouchButtons ();
       
   213     void testCreateConferenceBubble ();
       
   214     void testHandleCommandL ();
       
   215     void testGetSelectedConferenceMember ();
       
   216     void testSetAudioPath ();
       
   217     void testMuteRingToneOnAnswer ();
       
   218     void testStopRingTone ();
       
   219     void testMuteRingTone ();
       
   220     void testPlayRingTone ();
       
   221     void testShowGlobalNote ();
       
   222     void testSetExpandActions();
       
   223     void testShowDialpad ();
       
   224     void testDialpadVisibility ();
       
   225     void removeAllCallHeaders ();
       
   226     void testRemoveDialpad();
       
   227     void testGetDialpadStringLength();
       
   228     void testGetDialpadString();
       
   229     void testAddToConference();
       
   230     void testSetConferenceExpanded();
       
   231     void testSetMenuActions();
       
   232     void testNoteController();
       
   233     void testHsToForegroundAfterCall();
       
   234     void testCipheringInfoChange();
       
   235     void testSetHidden();
       
   236     void testBeginEndUiUpdate();
       
   237 
       
   238 private:
       
   239     PhoneUIQtViewAdapter *m_adapter; // class under test
       
   240     bool m_showToolbarCalled;
       
   241     bool m_updateCallTimeCalled;
       
   242     int m_int;
       
   243     QString m_string;
       
   244     HbAction *m_action;
       
   245     int  m_toolbarActionCount;
       
   246     bool m_startChangesCalled;
       
   247     bool m_endChangesCalled;
       
   248     bool m_volumeSliderValueCalled;
       
   249     bool m_removeVolumeSliderCalled;
       
   250     bool m_setVolumeSliderValueCalled;
       
   251     int m_volumeSliderValue;
       
   252     bool m_setPhoneMutedCalled;
       
   253     QMap<int, QList<int> *> m_actionMap;
       
   254     QMap<int,int> m_expandAction;
       
   255     bool m_showDialpadCalled;
       
   256     bool m_hideDialpadCalled;
       
   257     bool m_dialpadVisibilityCalled;
       
   258     bool m_clearAndHideDialpadCalled;
       
   259     bool m_ExpandConferenceCalled;
       
   260     bool m_setMenuActionsCalled;
       
   261     bool m_isDialpadVisible;
       
   262     QString m_dialpadText;
       
   263     HbMenu m_menu;
       
   264 
       
   265 };
       
   266 
       
   267 TestPhoneUIQtViewAdapter::TestPhoneUIQtViewAdapter () :
       
   268     m_isDialpadVisible(false),
       
   269     m_dialpadText("1234567")
       
   270 {
       
   271 }
       
   272 
       
   273 TestPhoneUIQtViewAdapter::~TestPhoneUIQtViewAdapter ()
       
   274 {
       
   275 }
       
   276 
       
   277 void TestPhoneUIQtViewAdapter::initTestCase ()
       
   278 {
       
   279     m_adapter = new PhoneUIQtViewAdapter (*this);
       
   280 }
       
   281 
       
   282 void TestPhoneUIQtViewAdapter::cleanupTestCase ()
       
   283 {
       
   284     delete m_adapter;
       
   285 }
       
   286 
       
   287 void TestPhoneUIQtViewAdapter::init ()
       
   288 {
       
   289     m_startChangesCalled = false;
       
   290     m_endChangesCalled = false;
       
   291     m_setCipheringCalled = false;
       
   292 }
       
   293 
       
   294 void TestPhoneUIQtViewAdapter::cleanup ()
       
   295 {
       
   296 }
       
   297 
       
   298 BubbleManagerIF& TestPhoneUIQtViewAdapter::bubbleManager ()
       
   299 {
       
   300     return *this;
       
   301 }
       
   302 
       
   303 void TestPhoneUIQtViewAdapter::addBubbleCommand (
       
   304         int bubbleId, const PhoneAction& action)
       
   305 {
       
   306     if (m_actionMap.keys().contains(bubbleId)) {
       
   307         m_actionMap.value(bubbleId)->append(action.command());
       
   308     } else {
       
   309         QList<int> *list = new QList<int>();
       
   310         list->append(action.command());
       
   311         m_actionMap.insert( bubbleId, list);
       
   312     }
       
   313 }
       
   314 
       
   315 void TestPhoneUIQtViewAdapter::clearBubbleCommands (int bubbleId)
       
   316 {
       
   317     if (m_actionMap.keys().contains(bubbleId)) {
       
   318         QList<int> *list = m_actionMap.value(bubbleId);
       
   319         list->clear();
       
   320         delete list;
       
   321         m_actionMap.remove(bubbleId);
       
   322     }
       
   323 }
       
   324 
       
   325 void TestPhoneUIQtViewAdapter::addParticipantListAction(
       
   326     int commandId,
       
   327     const QString& text, 
       
   328     const HbIcon& icon)
       
   329 {
       
   330 
       
   331 }
       
   332 
       
   333 void TestPhoneUIQtViewAdapter::clearParticipantListActions()
       
   334 {
       
   335 
       
   336 }
       
   337 
       
   338 void TestPhoneUIQtViewAdapter::testEPhoneViewSetTopApplicationCommand ()
       
   339 {
       
   340     TPhoneCmdParamInteger intParam;
       
   341     intParam.SetInteger (12345);
       
   342     m_adapter->ExecuteCommandL (EPhoneViewSetTopApplication, &intParam);
       
   343 }
       
   344 
       
   345 void TestPhoneUIQtViewAdapter::testEPhoneViewSetIdleTopApplicationCommand ()
       
   346 {
       
   347     m_adapter->ExecuteCommandL (EPhoneViewSetIdleTopApplication);
       
   348 }
       
   349 
       
   350 void TestPhoneUIQtViewAdapter::testEPhoneViewUpdateCallHeaderCallDurationCommand ()
       
   351 {
       
   352     TPhoneCmdParamInteger time;
       
   353     time.SetInteger(73);
       
   354     m_adapter->ExecuteCommandL (EPhoneViewUpdateCallHeaderCallDuration, 1, &time);	
       
   355     QCOMPARE (m_updateCallTimeCalled, true);
       
   356     QCOMPARE (m_int, 2);
       
   357     QVERIFY (m_string == "0:01:13");
       
   358 }
       
   359 
       
   360 void TestPhoneUIQtViewAdapter::testEPhoneViewCreateCallHeaderCommand ()
       
   361 {
       
   362     TPhoneCmdParamCallHeaderData callHeader;
       
   363     callHeader.SetDiverted (ETrue);
       
   364     callHeader.SetCallState (3);
       
   365     callHeader.SetLabelText (_L("Foo"));
       
   366     callHeader.SetCLIText (_L("Bar"), TPhoneCmdParamCallHeaderData::ERight);
       
   367     callHeader.SetCNAPText (_L("CNAP"), TPhoneCmdParamCallHeaderData::ERight);
       
   368     callHeader.SetCallType (3);
       
   369     callHeader.SetCipheringIndicatorAllowed(true);
       
   370     callHeader.SetCiphering(false);
       
   371     m_adapter->ExecuteCommandL (EPhoneViewCreateCallHeader, 2, &callHeader);
       
   372 
       
   373     QVERIFY (m_startChangesCalled == true);
       
   374 
       
   375     QVERIFY (m_createCallHeaderCalled == true);
       
   376     QCOMPARE (m_createCallHeaderInt, 2);
       
   377 
       
   378     QVERIFY (m_setStateCalled == true); 
       
   379     QCOMPARE (m_setStateCallId, 2);
       
   380     QCOMPARE (m_setStateBubbleId, 1);
       
   381     QCOMPARE (m_setStateCallState, 3); 
       
   382     
       
   383     QVERIFY (m_setLabelCalled == true);
       
   384     QString labelText = QString::fromUtf16 (m_setLabelText->Ptr (), m_setLabelText->Length ());
       
   385     QCOMPARE (m_setLabelBubbleId, 1);
       
   386     QCOMPARE (labelText, QString("Foo"));
       
   387 
       
   388     QVERIFY (m_setCliCalled == true);
       
   389     QString cliText = QString::fromUtf16 (m_setCliText->Ptr (), m_setCliText->Length ());
       
   390     QCOMPARE (m_setCliBubbleId, 1);
       
   391     QCOMPARE (cliText, QString("Bar"));
       
   392     
       
   393     QVERIFY (m_setSecondaryCliCalled == true);
       
   394     QString cnapText = QString::fromUtf16 (m_setSecondaryCliText->Ptr (), m_setSecondaryCliText->Length ());
       
   395     QCOMPARE (m_setSecondaryCliBubbleId, 1);
       
   396     QCOMPARE (cnapText, QString("CNAP"));
       
   397     
       
   398     QVERIFY (m_setCallTypeCalled == true);
       
   399     QCOMPARE (m_setCallTypeBubbleId, 1);
       
   400     QCOMPARE (m_setCallTypeType, 3);
       
   401     
       
   402     QVERIFY (m_setDivertCalled == true);
       
   403     QVERIFY (m_bubblewrapperbool == true);
       
   404     QCOMPARE (m_bubblewrapperint, 1);
       
   405     
       
   406     QVERIFY (m_setCipheringCalled == true);
       
   407     
       
   408     QVERIFY (m_endChangesCalled == true);
       
   409 }
       
   410 
       
   411 void TestPhoneUIQtViewAdapter::testEPhoneViewCreateEmergencyCallHeader ()
       
   412 {
       
   413     TPhoneCmdParamEmergencyCallHeaderData callHeader;
       
   414     callHeader.SetLabelText (_L("Attempting"));
       
   415     callHeader.SetHeaderText (_L("emergency") );
       
   416     m_adapter->ExecuteCommandL (EPhoneViewCreateEmergencyCallHeader, 2, &callHeader);
       
   417     callHeader.SetCipheringIndicatorAllowed(true);
       
   418     callHeader.SetCiphering(false);    
       
   419 
       
   420     QVERIFY (m_startChangesCalled == true);
       
   421 
       
   422     QVERIFY (m_createCallHeaderCalled == true);
       
   423     QCOMPARE (m_createCallHeaderInt, 2);
       
   424 
       
   425     QVERIFY (m_setLabelCalled == true);
       
   426     QString labelText = QString::fromUtf16 (m_setLabelText->Ptr (), m_setLabelText->Length ());
       
   427     QCOMPARE (m_setLabelBubbleId, 1);
       
   428     QCOMPARE (labelText, QString("Attempting"));
       
   429 
       
   430     QVERIFY (m_setCliCalled == true);
       
   431     QString cliText = QString::fromUtf16 (m_setCliText->Ptr (), m_setCliText->Length ());
       
   432     QCOMPARE (m_setCliBubbleId, 1);
       
   433     QCOMPARE (cliText, QString("emergency"));
       
   434     
       
   435     QVERIFY (m_setCipheringCalled == true);
       
   436     
       
   437     QVERIFY (m_endChangesCalled == true);    
       
   438 }
       
   439 
       
   440 void TestPhoneUIQtViewAdapter::testEPhoneViewUpdateBubble ()
       
   441 {
       
   442     // Bubble id will return -1
       
   443     m_bubble_id = -1;
       
   444     
       
   445     TPhoneCmdParamCallHeaderData callHeader;
       
   446     callHeader.SetCallState (2);
       
   447     callHeader.SetLabelText (_L("Foo2"));
       
   448     callHeader.SetDiverted (EFalse);
       
   449     m_adapter->ExecuteCommandL (EPhoneViewUpdateBubble, 3, &callHeader);
       
   450     QVERIFY (m_startChangesCalled == false);
       
   451     
       
   452     //Test with available bubble id
       
   453     m_bubble_id = -2;
       
   454     
       
   455     m_adapter->ExecuteCommandL (EPhoneViewUpdateBubble, 3, &callHeader);
       
   456     
       
   457     QVERIFY (m_startChangesCalled == true);
       
   458     
       
   459     QVERIFY (m_bubbleIdCalled == true);
       
   460     QCOMPARE (m_bubbleIdCallId, 3);
       
   461 
       
   462     QVERIFY (m_setStateCalled == true); 
       
   463     QCOMPARE (m_setStateCallId, 3);
       
   464     QCOMPARE (m_setStateBubbleId, 2);
       
   465     QCOMPARE (m_setStateCallState, 2); 
       
   466 
       
   467     QVERIFY (m_setLabelCalled == true);
       
   468     QString labelText = QString::fromUtf16 (m_setLabelText->Ptr (), m_setLabelText->Length ());
       
   469     QCOMPARE (m_setLabelBubbleId, 2);
       
   470     QCOMPARE (labelText, QString("Foo2"));
       
   471 
       
   472     QVERIFY (m_setDivertCalled == true);
       
   473     QVERIFY (m_bubblewrapperbool == false);
       
   474     QCOMPARE (m_bubblewrapperint, 2);
       
   475 
       
   476     QVERIFY (m_endChangesCalled == true);	
       
   477 }
       
   478 
       
   479 void TestPhoneUIQtViewAdapter::testEPhoneViewUpdateCallHeaderRemoteInfoData ()
       
   480 {
       
   481     // Bubble id will return -1
       
   482     m_bubble_id = -1;
       
   483     TPhoneCmdParamCallHeaderData callHeader;
       
   484     callHeader.SetCLIText (_L("Bar3"), TPhoneCmdParamCallHeaderData::ERight);
       
   485     callHeader.SetCNAPText (_L("CNAP3"), TPhoneCmdParamCallHeaderData::ERight);
       
   486     callHeader.SetDiverted (ETrue);
       
   487     m_adapter->ExecuteCommandL (EPhoneViewUpdateCallHeaderRemoteInfoData, 4, &callHeader);
       
   488     QVERIFY (m_startChangesCalled == false);
       
   489     
       
   490     //Test with available bubble id
       
   491     m_bubble_id = -2;
       
   492     
       
   493     m_adapter->ExecuteCommandL (EPhoneViewUpdateCallHeaderRemoteInfoData, 4, &callHeader);
       
   494     
       
   495     QVERIFY (m_startChangesCalled == true);
       
   496 
       
   497     QVERIFY (m_bubbleIdCalled == true);
       
   498     QCOMPARE (m_bubbleIdCallId, 4);
       
   499 
       
   500     QVERIFY (m_setCliCalled == true);
       
   501     QString cliText = QString::fromUtf16 (m_setCliText->Ptr (), m_setCliText->Length ());
       
   502     QCOMPARE (m_setCliBubbleId, 2);
       
   503     QCOMPARE (cliText, QString("Bar3"));
       
   504 
       
   505     QVERIFY (m_setSecondaryCliCalled == true);
       
   506     QString cnapText = QString::fromUtf16 (m_setSecondaryCliText->Ptr (), m_setSecondaryCliText->Length ());
       
   507     QCOMPARE (m_setSecondaryCliBubbleId, 2);
       
   508     QCOMPARE (cnapText, QString("CNAP3"));
       
   509 
       
   510     QVERIFY (m_setDivertCalled == true);
       
   511     QVERIFY (m_bubblewrapperbool == true);
       
   512     QCOMPARE (m_bubblewrapperint, 2);
       
   513 
       
   514     QVERIFY (m_endChangesCalled == true);	
       
   515 }
       
   516 
       
   517 void TestPhoneUIQtViewAdapter::testEPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel ()
       
   518 {
       
   519     // Bubble id will return -1
       
   520     m_bubble_id = -1;
       
   521     TPhoneCmdParamCallHeaderData callHeader;
       
   522     callHeader.SetLabelText (_L("Foo4"));
       
   523     callHeader.SetCLIText (_L("Bar4"), TPhoneCmdParamCallHeaderData::ERight);
       
   524     callHeader.SetCNAPText (_L("CNAP4"), TPhoneCmdParamCallHeaderData::ERight);
       
   525     callHeader.SetDiverted (ETrue);
       
   526     m_adapter->ExecuteCommandL (EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel, 4, &callHeader);
       
   527 
       
   528     QVERIFY (m_startChangesCalled == false);
       
   529     
       
   530     
       
   531     //Test with available bubble id
       
   532     m_bubble_id = -2;    
       
   533     m_adapter->ExecuteCommandL (EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel, 4, &callHeader);
       
   534 
       
   535     QVERIFY (m_startChangesCalled == true);
       
   536 
       
   537     QVERIFY (m_bubbleIdCalled == true);
       
   538     QCOMPARE (m_bubbleIdCallId, 4);
       
   539 
       
   540     QVERIFY (m_setLabelCalled == true);
       
   541     QString labelText = QString::fromUtf16 (m_setLabelText->Ptr (), m_setLabelText->Length ());
       
   542     QCOMPARE (m_setLabelBubbleId, 2);
       
   543     QCOMPARE (labelText, QString("Foo4"));
       
   544 
       
   545     QVERIFY (m_setCliCalled == true);
       
   546     QString cliText = QString::fromUtf16 (m_setCliText->Ptr (), m_setCliText->Length ());
       
   547     QCOMPARE (m_setCliBubbleId, 2);
       
   548     QCOMPARE (cliText, QString("Bar4"));
       
   549 
       
   550     QVERIFY (m_setSecondaryCliCalled == true);
       
   551     QString cnapText = QString::fromUtf16 (m_setSecondaryCliText->Ptr (), m_setSecondaryCliText->Length ());
       
   552     QCOMPARE (m_setSecondaryCliBubbleId, 2);
       
   553     QCOMPARE (cnapText, QString("CNAP4"));
       
   554 
       
   555     QVERIFY (m_setDivertCalled == true);
       
   556     QVERIFY (m_bubblewrapperbool == true);
       
   557     QCOMPARE (m_bubblewrapperint, 2);
       
   558 
       
   559     QVERIFY (m_endChangesCalled == true);   
       
   560 }
       
   561 
       
   562 void TestPhoneUIQtViewAdapter::testCallIdByState ()
       
   563 {
       
   564     TPhoneCmdParamCallHeaderData callHeader;
       
   565     TPhoneCmdParamCallStateData data;
       
   566     callHeader.SetCallState (EPEStateConnected);
       
   567     m_adapter->ExecuteCommandL (EPhoneViewUpdateBubble, 0, &callHeader);
       
   568     data.SetCallState (EPEStateConnected);
       
   569     m_adapter->HandleCommandL (EPhoneViewGetCallIdByState, &data);
       
   570     QCOMPARE (data.CallId(), 0);
       
   571 }
       
   572 
       
   573 void TestPhoneUIQtViewAdapter::testSetToolbarButtons ()
       
   574 {
       
   575     m_toolbarActionCount = 0;
       
   576     TPhoneCmdParamInteger intParam;
       
   577     intParam.SetInteger (R_PHONEUI_CALLHANDLING_INCOMINGCALL_CBA);
       
   578     m_adapter->ExecuteCommandL (EPhoneViewUpdateCba, &intParam);
       
   579     QCOMPARE(m_toolbarActionCount,2);
       
   580 
       
   581     m_toolbarActionCount = 0;
       
   582     intParam.SetInteger (R_PHONEUI_DIALER_CBA);
       
   583     m_adapter->ExecuteCommandL (EPhoneViewUpdateCba, &intParam);
       
   584     QCOMPARE(m_toolbarActionCount,4);
       
   585 }
       
   586 
       
   587 void TestPhoneUIQtViewAdapter::testHoldFlag ()
       
   588 {
       
   589     TPhoneCmdParamBoolean boolParam;
       
   590     m_adapter->ExecuteCommandL (EPhoneViewGetHoldFlag, &boolParam);
       
   591     QCOMPARE ((bool)boolParam.Boolean (), false);
       
   592 
       
   593     boolParam.SetBoolean (ETrue);
       
   594     m_adapter->ExecuteCommandL (EPhoneViewSetHoldFlag, &boolParam);
       
   595     m_adapter->ExecuteCommandL (EPhoneViewGetHoldFlag, &boolParam);
       
   596     QCOMPARE ((bool)boolParam.Boolean (), true);
       
   597     
       
   598     boolParam.SetBoolean (EFalse);
       
   599     m_adapter->ExecuteCommandL (EPhoneViewSetHoldFlag, &boolParam);
       
   600     m_adapter->ExecuteCommandL (EPhoneViewGetHoldFlag, &boolParam);
       
   601     QCOMPARE ((bool)boolParam.Boolean (), false);
       
   602 }
       
   603 
       
   604 void TestPhoneUIQtViewAdapter::testEPhoneViewHideNaviPaneAudioVolume ()
       
   605 {
       
   606     m_adapter->ExecuteCommandL (EPhoneViewHideNaviPaneAudioVolume);
       
   607     QCOMPARE (m_removeVolumeSliderCalled, true);
       
   608 }
       
   609 
       
   610 void TestPhoneUIQtViewAdapter::testEPhoneViewSetNaviPaneAudioVolume ()
       
   611 {
       
   612     TPhoneCmdParamInteger intParam;
       
   613     intParam.SetInteger (3);
       
   614     m_adapter->ExecuteCommandL (EPhoneViewSetNaviPaneAudioVolume, &intParam);
       
   615     QCOMPARE (m_setVolumeSliderValueCalled, true);
       
   616     QCOMPARE (m_volumeSliderValue, 3);
       
   617 }
       
   618 
       
   619 void TestPhoneUIQtViewAdapter::testEPhoneViewGetAudioVolumeLevel ()
       
   620 {
       
   621     TPhoneCmdParamInteger intParam;
       
   622     m_adapter->ExecuteCommand (EPhoneViewGetAudioVolumeLevel, &intParam);
       
   623     QCOMPARE (m_volumeSliderValueCalled, true);
       
   624     QCOMPARE (intParam.Integer (), 5);
       
   625 }
       
   626 
       
   627 void TestPhoneUIQtViewAdapter::testEPhoneViewActivateMuteUIChanges ()
       
   628 {
       
   629     TPhoneCmdParamBoolean boolParam;
       
   630     boolParam.SetBoolean (true);
       
   631     m_adapter->ExecuteCommandL (EPhoneViewActivateMuteUIChanges, &boolParam);
       
   632     QCOMPARE (m_setPhoneMutedCalled, true);
       
   633 }
       
   634 
       
   635 void TestPhoneUIQtViewAdapter::testEPhoneViewGetCountOfActiveCallss ()
       
   636 {
       
   637     TPhoneCmdParamInteger intParam;
       
   638     m_adapter->ExecuteCommandL (EPhoneViewGetCountOfActiveCalls, &intParam);
       
   639     QVERIFY (m_activeCallCountCalled == true);
       
   640 }
       
   641 
       
   642 void TestPhoneUIQtViewAdapter::testExecuteCommandLwithCmdId ()
       
   643 {
       
   644     // Default
       
   645     m_adapter->ExecuteCommandL (0);    
       
   646 }
       
   647 
       
   648 void TestPhoneUIQtViewAdapter::testExecuteCommandLwithCmdIdAndCallId ()
       
   649 {
       
   650     // Default
       
   651     m_adapter->ExecuteCommandL (0, 0);
       
   652 
       
   653     m_adapter->ExecuteCommandL (EPhoneViewRemoveCallHeader, 0);
       
   654     QVERIFY (m_startChangesCalled == true);
       
   655     QVERIFY (m_endChangesCalled == true);
       
   656     
       
   657     m_removeCallFromConference = false;
       
   658     m_adapter->ExecuteCommandL (EPhoneViewRemoveFromConference, 0);   
       
   659     QVERIFY (m_startChangesCalled == true);
       
   660     QVERIFY (m_endChangesCalled == true);
       
   661     QVERIFY (m_removeCallFromConference == true);
       
   662     
       
   663     m_removeCallFromConference = false;
       
   664     m_adapter->ExecuteCommandL (EPhoneViewPrivateFromConference, 0);   
       
   665     QVERIFY (m_startChangesCalled == true);
       
   666     QVERIFY (m_endChangesCalled == true); 
       
   667     QVERIFY (m_removeCallFromConference == true);      
       
   668 }
       
   669 
       
   670 void TestPhoneUIQtViewAdapter::testExecuteCommandLwithCmdIdAndCmdParam ()
       
   671 {
       
   672     TPhoneCmdParamBoolean boolParam;
       
   673     // Default
       
   674     m_adapter->ExecuteCommandL (0, &boolParam);
       
   675     
       
   676     
       
   677     // Is conference
       
   678     m_adapter->ExecuteCommandL (EPhoneViewGetIsConference, &boolParam);
       
   679     QCOMPARE ((bool)boolParam.Boolean (), false);
       
   680     
       
   681     
       
   682     // Get expand bubble call id
       
   683     TPhoneCmdParamInteger intParam;
       
   684     m_adapter->ExecuteCommandL (EPhoneViewGetExpandedBubbleCallId, &intParam);
       
   685     QCOMPARE ((int)intParam.Integer(), -1);
       
   686     
       
   687     m_callStateMap.insert(0, EPEStateConnected);
       
   688     m_bubblesMap.insert(0, 0); 
       
   689     m_callStateMap.insert(1, EPEStateHeld);
       
   690     m_bubblesMap.insert(1, 1);  
       
   691     
       
   692     m_adapter->ExecuteCommandL (EPhoneViewGetExpandedBubbleCallId, &intParam);
       
   693     QCOMPARE ((int)intParam.Integer(), 1);
       
   694     
       
   695     m_callStateMap.clear();
       
   696     m_bubblesMap.clear();
       
   697 }
       
   698 
       
   699 void TestPhoneUIQtViewAdapter::testSetTouchButtons ()
       
   700 {
       
   701     TPhoneCmdParamBoolean boolParam;
       
   702     boolParam.SetBoolean( false );
       
   703     
       
   704     
       
   705     
       
   706     //Connected call
       
   707     m_callStateMap.insert(0, EPEStateConnected);
       
   708     m_bubblesMap.insert(0, 0);
       
   709     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);    
       
   710     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
       
   711     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   712     
       
   713     //Emergency
       
   714     boolParam.SetBoolean(true);
       
   715     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   716     QVERIFY(false == m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
       
   717     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   718     
       
   719     //Held and active
       
   720     boolParam.SetBoolean(false);
       
   721     m_callStateMap.insert(1, EPEStateHeld);
       
   722     m_bubblesMap.insert(1, 1);    
       
   723     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   724     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdCreateConference));
       
   725     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   726     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdCreateConference));
       
   727     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   728     clearBubbleCommands(0);
       
   729     clearBubbleCommands(1);
       
   730 
       
   731     //Connected call and waiting
       
   732     m_callStateMap.insert(0, EPEStateConnected);
       
   733     m_bubblesMap.insert(0, 0);
       
   734    
       
   735     boolParam.SetBoolean(false);
       
   736     m_callStateMap.insert(1, EPEStateRinging);
       
   737     m_bubblesMap.insert(1, 1);    
       
   738     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   739     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
       
   740     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   741     QVERIFY(m_actionMap.value(1)->contains(EPhoneCallComingCmdReject));
       
   742     clearBubbleCommands(0);
       
   743     clearBubbleCommands(1);
       
   744 
       
   745     //Held call and waiting
       
   746     m_callStateMap.insert(0, EPEStateHeld);
       
   747     m_bubblesMap.insert(0, 0);
       
   748    
       
   749     boolParam.SetBoolean(false);
       
   750     m_callStateMap.insert(1, EPEStateRinging);
       
   751     m_bubblesMap.insert(1, 1);    
       
   752     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   753     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdUnhold));
       
   754     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   755     QVERIFY(m_actionMap.value(1)->contains(EPhoneCallComingCmdReject));
       
   756     clearBubbleCommands(0);
       
   757     clearBubbleCommands(1);    
       
   758     
       
   759     //Idle
       
   760     m_callStateMap.clear();
       
   761     m_bubblesMap.clear();
       
   762     m_callStateMap.insert(0, EPEStateIdle);
       
   763     m_bubblesMap.insert(0, 0);
       
   764     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   765     QVERIFY(0==m_actionMap.keys().size());
       
   766     clearBubbleCommands(0);
       
   767     
       
   768     //Conference Idle
       
   769     m_callStateMap.clear();
       
   770     m_bubblesMap.clear();
       
   771     m_callStateMap.insert(0, EPEStateConferenceIdle);
       
   772     m_bubblesMap.insert(0, 0);
       
   773     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   774     QVERIFY(0==m_actionMap.keys().size());
       
   775     clearBubbleCommands(0);
       
   776     
       
   777     //Disconnecting
       
   778     m_callStateMap.clear();
       
   779     m_bubblesMap.clear();
       
   780     m_callStateMap.insert(0, EPEStateDisconnecting);
       
   781     m_bubblesMap.insert(0, 0);
       
   782     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   783     QVERIFY(0==m_actionMap.keys().size());
       
   784     clearBubbleCommands(0);
       
   785     
       
   786     //Dialling
       
   787     m_callStateMap.clear();
       
   788     m_bubblesMap.clear();
       
   789     m_callStateMap.insert(0, EPEStateDialing);
       
   790     m_bubblesMap.insert(0, 0);
       
   791     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   792     QVERIFY(1==m_actionMap.value(0)->size());
       
   793     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisOutgoingCall));
       
   794     clearBubbleCommands(0);
       
   795     
       
   796     //Ringing
       
   797     m_callStateMap.clear();
       
   798     m_bubblesMap.clear();
       
   799     m_callStateMap.insert(0, EPEStateRinging);
       
   800     m_bubblesMap.insert(0, 0);
       
   801     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   802     QVERIFY(2==m_actionMap.value(0)->size());
       
   803     QVERIFY(m_actionMap.value(0)->contains(EPhoneCallComingCmdAnswer));
       
   804     QVERIFY(m_actionMap.value(0)->contains(EPhoneCallComingCmdReject));
       
   805     clearBubbleCommands(0);
       
   806     
       
   807     //Connecting
       
   808     m_callStateMap.clear();
       
   809     m_bubblesMap.clear();
       
   810     m_callStateMap.insert(0, EPEStateConnecting);
       
   811     m_bubblesMap.insert(0, 0);
       
   812     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   813     QVERIFY(1==m_actionMap.value(0)->size());
       
   814     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisOutgoingCall));
       
   815     clearBubbleCommands(0);
       
   816 
       
   817     //Connected Conference
       
   818     m_callStateMap.clear();
       
   819     m_bubblesMap.clear();
       
   820     m_callStateMap.insert(0, EPEStateConnectedConference);
       
   821     m_bubblesMap.insert(0, 0);
       
   822     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   823     QVERIFY(2==m_actionMap.value(0)->size());
       
   824     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdHold));
       
   825     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   826 
       
   827     // Conference and held
       
   828     m_callStateMap.insert(1, EPEStateHeld);
       
   829     m_bubblesMap.insert(1, 1);    
       
   830     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   831     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdSwap));
       
   832     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   833     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdJoin));
       
   834     QVERIFY(m_actionMap.value(1)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   835     clearBubbleCommands(0);
       
   836     clearBubbleCommands(1);
       
   837     
       
   838     //Held conference
       
   839     m_conferenceCallList.append(1); //for coverage
       
   840     m_callStateMap.clear();
       
   841     m_bubblesMap.clear();
       
   842     m_callStateMap.insert(0, EPEStateHeldConference);
       
   843     m_bubblesMap.insert(0, 0);
       
   844     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   845     QVERIFY(2==m_actionMap.value(0)->size());
       
   846     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdEndThisActiveCall));
       
   847     QVERIFY(m_actionMap.value(0)->contains(EPhoneInCallCmdUnhold));
       
   848     clearBubbleCommands(0);
       
   849     m_conferenceCallList.clear();
       
   850     
       
   851     //Unknown state
       
   852     m_callStateMap.clear();
       
   853     m_bubblesMap.clear();
       
   854     m_callStateMap.insert(0, EPEStateUnknown);
       
   855     m_bubblesMap.insert(0, 0);
       
   856     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   857     QVERIFY(0==m_actionMap.keys().size());
       
   858     clearBubbleCommands(0);
       
   859     
       
   860     //Default case
       
   861     m_callStateMap.clear();
       
   862     m_bubblesMap.clear();
       
   863     m_callStateMap.insert(0, 100);
       
   864     m_bubblesMap.insert(0, 0);
       
   865     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
   866     QVERIFY(0==m_actionMap.keys().size());
       
   867     clearBubbleCommands(0);
       
   868 }
       
   869 
       
   870 void TestPhoneUIQtViewAdapter::testCreateConferenceBubble ()
       
   871 {
       
   872     m_callStateMap.clear();
       
   873     m_bubblesMap.clear();
       
   874     m_callStateMap.insert(0, EPEStateConnected);
       
   875     m_bubblesMap.insert(0, 0);
       
   876     m_callStateMap.insert(1, EPEStateHeld);
       
   877     m_bubblesMap.insert(1, 1);  
       
   878  
       
   879     //Create conference
       
   880     TPhoneCmdParamCallHeaderData callHeader;
       
   881     callHeader.SetCallState (2);
       
   882     callHeader.SetLabelText (_L("Foo2"));
       
   883     callHeader.SetDiverted (EFalse);
       
   884     callHeader.SetCipheringIndicatorAllowed(true);
       
   885     callHeader.SetCiphering(false);
       
   886     
       
   887     m_adapter->ExecuteCommandL (EPhoneViewCreateConference, 3, &callHeader);    
       
   888     QVERIFY (m_creataConferenceCalled == true);
       
   889     
       
   890     //
       
   891     TPhoneCmdParamBoolean  conferenceDataValue;
       
   892     m_adapter->ExecuteCommandL (EPhoneViewGetCallExistsInConference, 0, &conferenceDataValue);
       
   893     QVERIFY (conferenceDataValue.Boolean() == true);
       
   894     
       
   895     m_adapter->ExecuteCommandL(EPhoneViewRemoveConferenceBubble);
       
   896     QVERIFY (m_removeConferenceCalled == true);
       
   897     
       
   898     m_adapter->ExecuteCommandL (EPhoneViewGetCallExistsInConference, 0, &conferenceDataValue);
       
   899     QVERIFY (conferenceDataValue.Boolean() == false);
       
   900     
       
   901     QVERIFY (m_setCipheringCalled == true);
       
   902 }
       
   903 
       
   904 void TestPhoneUIQtViewAdapter::testHandleCommandL ()
       
   905 {
       
   906     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   907             EPhoneIsDTMFDialerVisible) );    
       
   908     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   909             EPhoneViewIsDTMFEditorVisible) ); 
       
   910     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   911             EPhoneViewGetNumberEntryIsVisibleStatus) ); 
       
   912     /*QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   913             EPhoneViewGetNumberEntryIsUsedStatus) );*/ 
       
   914     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   915             EPhoneIsCustomizedDialerVisible) ); 
       
   916     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL (
       
   917             EPhoneViewGetNeedToSendToBackgroundStatus) );
       
   918     
       
   919     //Default handling for coverage
       
   920     QVERIFY( EPhoneViewResponseSuccess == m_adapter->HandleCommandL (0) ); 
       
   921     TPhoneCmdParamBoolean boolean;
       
   922     QVERIFY( EPhoneViewResponseSuccess == m_adapter->HandleCommandL (0, &boolean) );
       
   923     
       
   924     m_adapter->ExecuteCommand(0);
       
   925     m_adapter->ExecuteCommand(EPhoneViewSetDtmfOptionsFlag, &boolean);
       
   926     m_adapter->ExecuteCommand(EPhoneViewSetVideoCallDTMFVisibilityFlag, &boolean);
       
   927     m_adapter->ExecuteCommand(0, &boolean);
       
   928     m_adapter->ExecuteCommandL(0, 0, &boolean);
       
   929     _LIT (KText, "test");
       
   930     TBufC<8> textBuf (KText);
       
   931     m_adapter->ExecuteCommandL(0, 0, textBuf);
       
   932     m_adapter->FetchContent();
       
   933     
       
   934 }
       
   935 
       
   936 void TestPhoneUIQtViewAdapter::testGetSelectedConferenceMember ()
       
   937 {
       
   938     m_callStateMap.clear();
       
   939     m_bubblesMap.clear();
       
   940 
       
   941     TPhoneCmdParamInteger  integerParam;
       
   942     QVERIFY( EPhoneViewResponseFailed == m_adapter->HandleCommandL(
       
   943             EPhoneViewSelectedConfMember, &integerParam) );    
       
   944     
       
   945     m_callStateMap.insert(1, EPEStateConnected);
       
   946     m_bubblesMap.insert(1, 0);
       
   947     
       
   948     QVERIFY( EPhoneViewResponseSuccess == m_adapter->HandleCommandL(
       
   949             EPhoneViewSelectedConfMember, &integerParam) ); 
       
   950     
       
   951     QVERIFY( integerParam.Integer() == 1 );    
       
   952 }
       
   953 
       
   954 void TestPhoneUIQtViewAdapter::testSetAudioPath ()
       
   955 {
       
   956     TPhoneCmdParamAudioOutput audioOutput;
       
   957     audioOutput.SetAudioOutput( EPELoudspeaker );
       
   958     m_adapter->ExecuteCommandL(EPhoneViewActivateAudioPathUIChanges, &audioOutput);
       
   959     QVERIFY( m_phoneButtonFlags == PhoneUIQtButtonsController::Ihf );
       
   960     
       
   961     audioOutput.SetAudioOutput( EPEWiredAudioAccessory );
       
   962     m_adapter->ExecuteCommandL(EPhoneViewActivateAudioPathUIChanges, &audioOutput);
       
   963     QVERIFY( m_phoneButtonFlags == PhoneUIQtButtonsController::Wired );
       
   964     
       
   965     audioOutput.SetAudioOutput( EPEBTAudioAccessory );
       
   966     m_adapter->ExecuteCommandL(EPhoneViewActivateAudioPathUIChanges, &audioOutput);
       
   967     QVERIFY( m_phoneButtonFlags == PhoneUIQtButtonsController::Btaa );
       
   968 
       
   969 }
       
   970 
       
   971 void TestPhoneUIQtViewAdapter::testMuteRingToneOnAnswer ()
       
   972 {
       
   973     m_adapter->ExecuteCommandL(EPhoneViewMuteRingToneOnAnswer);
       
   974     QVERIFY( m_EPhoneViewMuteRingToneOnAnswer_called == true );
       
   975 }
       
   976 
       
   977 void TestPhoneUIQtViewAdapter::testStopRingTone ()
       
   978 {
       
   979     m_adapter->ExecuteCommandL(EPhoneViewStopRingTone);
       
   980     QVERIFY( m_EPhoneViewStopRingTone_called == true );
       
   981 }
       
   982 
       
   983 void TestPhoneUIQtViewAdapter::testMuteRingTone ()
       
   984 {
       
   985     m_adapter->ExecuteCommandL(EPhoneViewMuteRingTone);
       
   986     QVERIFY( m_EPhoneViewMuteRingTone_called == true );
       
   987 }
       
   988 
       
   989 void TestPhoneUIQtViewAdapter::testPlayRingTone ()
       
   990 {
       
   991     TPhoneCmdParamRingTone ringToneParam;
       
   992     m_adapter->ExecuteCommandL(EPhoneViewPlayRingTone, &ringToneParam);
       
   993     QVERIFY( m_EPhoneViewPlayRingTone_called == true );
       
   994 }
       
   995 
       
   996 void TestPhoneUIQtViewAdapter::testShowGlobalNote ()
       
   997 {
       
   998     TPhoneCmdParamGlobalNote param;
       
   999     m_adapter->ExecuteCommandL(EPhoneViewShowGlobalNote, &param);
       
  1000     QVERIFY( m_showGlobalNoteCalled == true );
       
  1001 }
       
  1002 
       
  1003 void TestPhoneUIQtViewAdapter::testSetExpandActions()
       
  1004 {
       
  1005     TPhoneCmdParamBoolean boolParam;
       
  1006     boolParam.SetBoolean( false );
       
  1007 
       
  1008     m_callStateMap.clear();
       
  1009     m_bubblesMap.clear();
       
  1010     m_callStateMap.insert(0, EPEStateConnected);
       
  1011     m_callStateMap.insert(1, EPEStateHeld);
       
  1012     m_bubblesMap.insert(0, 0);
       
  1013     m_bubblesMap.insert(1, 1);
       
  1014     m_expandAction.clear();
       
  1015     
       
  1016     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
  1017     QVERIFY(m_expandAction.contains(0));        
       
  1018     QVERIFY(m_expandAction[0]==EPhoneCmdUpdateUiControls);
       
  1019     QVERIFY(m_expandAction.contains(1));        
       
  1020     QVERIFY(m_expandAction[1]==EPhoneInCallCmdSwap);
       
  1021 } 
       
  1022 
       
  1023 void TestPhoneUIQtViewAdapter::testShowDialpad ()
       
  1024 {
       
  1025     m_adapter->ExecuteCommandL(EPhoneViewOpenDialer);
       
  1026     QVERIFY( m_showDialpadCalled == true );
       
  1027 }
       
  1028 
       
  1029 void TestPhoneUIQtViewAdapter::testDialpadVisibility ()
       
  1030 {
       
  1031     m_showDialpadCalled = false;
       
  1032     m_hideDialpadCalled = false;
       
  1033     
       
  1034     TPhoneCmdParamBoolean param;
       
  1035     param.SetBoolean(ETrue);
       
  1036     m_adapter->ExecuteCommandL(EPhoneViewSetNumberEntryVisible, &param);
       
  1037     QVERIFY( m_showDialpadCalled == true );
       
  1038     QVERIFY( m_hideDialpadCalled == false );
       
  1039     
       
  1040     m_showDialpadCalled = false;
       
  1041     m_hideDialpadCalled = false;
       
  1042     
       
  1043     param.SetBoolean(EFalse);
       
  1044     m_adapter->ExecuteCommandL(EPhoneViewSetNumberEntryVisible, &param);
       
  1045     QVERIFY( m_showDialpadCalled == false );
       
  1046     QVERIFY( m_hideDialpadCalled == true );
       
  1047 }
       
  1048 
       
  1049 void TestPhoneUIQtViewAdapter::removeAllCallHeaders()
       
  1050 {
       
  1051     m_removeConferenceCalled = false;
       
  1052     m_removeCallHeaderCalled = false;
       
  1053     m_conferenceCallList.clear();
       
  1054     m_conferenceCallList.append(0);
       
  1055     m_conferenceCallList.append(1);
       
  1056     
       
  1057     m_bubblesMap.clear();
       
  1058     m_bubblesMap.insert(0,0);
       
  1059     m_bubblesMap.insert(1,1);
       
  1060     m_bubblesMap.insert(2,2);
       
  1061     m_bubblesMap.insert(7,3);
       
  1062     
       
  1063     m_callStateMap.clear();
       
  1064     m_callStateMap.insert(0,0);
       
  1065     m_callStateMap.insert(1,1);
       
  1066     m_callStateMap.insert(2,2);
       
  1067     m_callStateMap.insert(7,3);
       
  1068     
       
  1069     m_adapter->ExecuteCommandL(EPhoneViewRemoveAllCallHeaders);
       
  1070     
       
  1071     QVERIFY(m_removeConferenceCalled);
       
  1072     QVERIFY(m_removeCallHeaderCalled);
       
  1073 }
       
  1074 
       
  1075 void TestPhoneUIQtViewAdapter::testRemoveDialpad ()
       
  1076 {
       
  1077     m_clearAndHideDialpadCalled = false;
       
  1078 
       
  1079     m_adapter->ExecuteCommandL(EPhoneViewRemoveNumberEntry);
       
  1080     QVERIFY( m_clearAndHideDialpadCalled == true );
       
  1081     
       
  1082     m_clearAndHideDialpadCalled = false;
       
  1083 
       
  1084     m_adapter->ExecuteCommandL(EPhoneViewClearNumberEntryContent);
       
  1085     QVERIFY( m_clearAndHideDialpadCalled == true );
       
  1086 }
       
  1087 
       
  1088 void TestPhoneUIQtViewAdapter::testGetDialpadStringLength ()
       
  1089 {
       
  1090     TPhoneCmdParamInteger integerParam;
       
  1091 
       
  1092     m_adapter->ExecuteCommandL(EPhoneViewGetNumberEntryCount, &integerParam );
       
  1093     QVERIFY( integerParam.Integer() == 7 );
       
  1094     
       
  1095 }
       
  1096 
       
  1097 void TestPhoneUIQtViewAdapter::testGetDialpadString ()
       
  1098 {
       
  1099     HBufC *numberEntryContent = 0;
       
  1100     
       
  1101     TRAP_IGNORE( numberEntryContent = HBufC::NewL( KPhoneNumberEntryBufferSize ) );
       
  1102     if (numberEntryContent) {    
       
  1103         TPtr ptr( numberEntryContent->Des() );
       
  1104         ptr.Zero();   
       
  1105                        
       
  1106         TPhoneCmdParamString stringParam;
       
  1107         stringParam.SetString( &ptr );
       
  1108         m_adapter->ExecuteCommand(
       
  1109                 EPhoneViewGetNumberFromEntry,
       
  1110                 &stringParam );  
       
  1111     
       
  1112         QVERIFY( 0 == numberEntryContent->Des().Compare(_L("1234567")) );
       
  1113         
       
  1114         TPtr ptr2( numberEntryContent->Des() );
       
  1115         ptr2.Zero();
       
  1116         TPhoneCmdParamString stringParam2;
       
  1117         stringParam2.SetString( &ptr2 );
       
  1118         m_adapter->ExecuteCommandL(
       
  1119                 EPhoneViewGetNumberFromEntry,
       
  1120                 &stringParam2 );  
       
  1121     
       
  1122         QVERIFY( 0 == numberEntryContent->Des().Compare(_L("1234567")) );
       
  1123     }
       
  1124 }
       
  1125 
       
  1126 void TestPhoneUIQtViewAdapter::testAddToConference()
       
  1127 {
       
  1128     m_adapter->ExecuteCommandL(EPhoneViewAddToConference);
       
  1129     QVERIFY( m_addToConferenceBubbleCalled == true );
       
  1130     
       
  1131 }
       
  1132 
       
  1133 void TestPhoneUIQtViewAdapter::testSetConferenceExpanded()
       
  1134 {
       
  1135     m_adapter->ExecuteCommand(EPhoneSetConferenceExpanded);
       
  1136     QVERIFY( m_ExpandConferenceCalled == true );
       
  1137     
       
  1138 }
       
  1139 
       
  1140 void TestPhoneUIQtViewAdapter::testSetMenuActions()
       
  1141 {
       
  1142     m_setMenuActionsCalled = false;
       
  1143     m_isDialpadVisible = false;
       
  1144     TPhoneCmdParamBoolean boolParam;
       
  1145     boolParam.SetBoolean( false );
       
  1146     
       
  1147     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam); 
       
  1148     
       
  1149     QVERIFY(m_setMenuActionsCalled);
       
  1150     
       
  1151     m_setMenuActionsCalled = false;
       
  1152     m_isDialpadVisible = true;
       
  1153     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
  1154     QVERIFY(m_setMenuActionsCalled);
       
  1155     
       
  1156     m_dialpadText = QString("");
       
  1157     m_setMenuActionsCalled = false;
       
  1158     m_isDialpadVisible = true;
       
  1159     m_adapter->ExecuteCommandL (EPhoneViewSetTouchPaneButtons, &boolParam);
       
  1160     QVERIFY(m_setMenuActionsCalled);
       
  1161     
       
  1162     connect(this, SIGNAL(dialpadAboutToClose()), m_adapter, SLOT(dialpadClosed()));
       
  1163     connect(this, SIGNAL(keyPressReleased(QKeyEvent*)), 
       
  1164             m_adapter, SLOT(keyReleased(QKeyEvent*)));
       
  1165     
       
  1166     m_setMenuActionsCalled = false;
       
  1167     m_isDialpadVisible = true;
       
  1168     QKeyEvent keyEvent(QEvent::MouseButtonPress, 0, Qt::NoModifier);
       
  1169     
       
  1170     emit keyPressReleased(&keyEvent);
       
  1171     QVERIFY(m_setMenuActionsCalled);
       
  1172     
       
  1173     m_setMenuActionsCalled = false;
       
  1174     m_isDialpadVisible = false;
       
  1175     emit keyPressReleased(&keyEvent);
       
  1176     QVERIFY(false == m_setMenuActionsCalled);
       
  1177     
       
  1178     m_setMenuActionsCalled = false;
       
  1179     m_isDialpadVisible = true;
       
  1180     emit dialpadAboutToClose();
       
  1181     QVERIFY(m_setMenuActionsCalled);
       
  1182     
       
  1183     m_setMenuActionsCalled = false;
       
  1184     emit keyPressReleased(&keyEvent);
       
  1185     QVERIFY(false == m_setMenuActionsCalled);
       
  1186 }
       
  1187 
       
  1188 void TestPhoneUIQtViewAdapter::testNoteController()
       
  1189 {
       
  1190     m_showQueryCalled = false;
       
  1191     m_removeDtmfNoteCalled = false;
       
  1192     m_removeNoteCalled = false;
       
  1193     m_removeQueryCalled = false;
       
  1194     m_showNoteCalled = false;
       
  1195     m_removeGlobalWaitNoteCalled = false;
       
  1196     
       
  1197     QVERIFY( (0 != m_adapter->noteController()) );
       
  1198     
       
  1199     m_adapter->ExecuteCommandL(EPhoneViewRemoveDtmfNote);
       
  1200     QVERIFY( m_removeDtmfNoteCalled == true );
       
  1201     
       
  1202     m_adapter->ExecuteCommandL(EPhoneViewRemoveNote);
       
  1203     QVERIFY( m_removeNoteCalled == true );
       
  1204     
       
  1205     m_adapter->ExecuteCommandL(EPhoneViewRemoveQuery);
       
  1206     QVERIFY( m_removeQueryCalled == true );
       
  1207     
       
  1208     TPhoneCmdParamGlobalNote param;
       
  1209     m_adapter->ExecuteCommandL(EPhoneViewShowQuery, &param);
       
  1210     QVERIFY( m_showQueryCalled == true );
       
  1211     
       
  1212     m_adapter->ExecuteCommandL(EPhoneViewShowNote, &param);
       
  1213     QVERIFY( m_showNoteCalled == true );
       
  1214     
       
  1215     m_adapter->ExecuteCommandL(EPhoneViewRemoveGlobalNote);
       
  1216     QVERIFY( m_removeGlobalWaitNoteCalled == true );
       
  1217     
       
  1218     m_removeGlobalWaitNoteCalled = false;
       
  1219     m_adapter->ExecuteCommandL(EPhoneViewRemoveGlobalWaitNote);
       
  1220     QVERIFY( m_removeGlobalWaitNoteCalled == true );
       
  1221     
       
  1222     m_showQueryCalled = false;
       
  1223     m_removeDtmfNoteCalled = false;
       
  1224     m_removeNoteCalled = false;
       
  1225     m_removeQueryCalled = false;
       
  1226     m_showNoteCalled = false;
       
  1227     
       
  1228     m_adapter->ExecuteCommandL(EPhoneViewRemovePhoneDialogs);
       
  1229     QVERIFY( m_removeQueryCalled == true );
       
  1230     QVERIFY( m_removeNoteCalled == true );
       
  1231     
       
  1232 }
       
  1233 
       
  1234 void TestPhoneUIQtViewAdapter::testHsToForegroundAfterCall()
       
  1235 {
       
  1236     TPhoneCmdParamBoolean booleanParam;
       
  1237     booleanParam.SetBoolean( ETrue );
       
  1238     m_adapter->ExecuteCommand( EPhoneViewHsToForegroundAfterCall,
       
  1239         &booleanParam );
       
  1240 }
       
  1241 
       
  1242 void TestPhoneUIQtViewAdapter::testCipheringInfoChange()
       
  1243 {
       
  1244 	m_bubble_id = 1;
       
  1245     TPhoneCmdParamCallHeaderData callHeader;
       
  1246     callHeader.SetCipheringIndicatorAllowed(true);
       
  1247     callHeader.SetCiphering(false);
       
  1248     m_adapter->ExecuteCommandL (EPhoneViewCipheringInfoChange, 1, &callHeader);
       
  1249     QVERIFY (m_startChangesCalled == true);
       
  1250     QVERIFY (m_setCipheringCalled == true);
       
  1251     QVERIFY (m_endChangesCalled == true);
       
  1252     m_setCipheringCalled = false;
       
  1253 	m_bubble_id = -1;
       
  1254     m_adapter->ExecuteCommandL (EPhoneViewCipheringInfoChange, -1, &callHeader);
       
  1255     QVERIFY (m_setCipheringCalled == false);
       
  1256 }
       
  1257 
       
  1258 void TestPhoneUIQtViewAdapter::testSetHidden()
       
  1259 {
       
  1260     m_adapter->ExecuteCommandL(EPhoneViewUpdateFSW);
       
  1261 }
       
  1262 
       
  1263 void TestPhoneUIQtViewAdapter::testBeginEndUiUpdate()
       
  1264 {
       
  1265     m_adapter->ExecuteCommand(EPhoneViewBeginUpdate);
       
  1266     QVERIFY (m_startChangesCalled == true);
       
  1267     
       
  1268     m_adapter->ExecuteCommand(EPhoneViewEndUpdate);
       
  1269     QVERIFY (m_endChangesCalled == true);
       
  1270 }
       
  1271 
       
  1272 PHONE_QT_VIEW_ADAPTER_TEST_MAIN(TestPhoneUIQtViewAdapter)
       
  1273 #include "unit_tests.moc"