phoneapp/phoneuistates/tsrc/ut_cphoneconferenceandsingleandwaiting/Src/ut_cphoneconferenceandsingleandwaiting.cpp
changeset 77 2be0b271d017
child 76 cfea66083b62
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ut_cphoneconferenceandsingleandwaiting.h"
       
    19 #include <csmcmockcontext.h>
       
    20 #include <smcdefaultvalue.h>
       
    21 #include <msmcmockspecbuilder.h>
       
    22 #include <smcobjecttotypemapper.h>
       
    23 #include <EUnitMacros.h>
       
    24 #include <EUnitDecorators.h>
       
    25 #include <featmgr.h>
       
    26 #include "CPhoneConferenceAndSingleAndWaiting.h"
       
    27 #include "PEVirtualEngine.h" 
       
    28 #include "CPhoneViewControllerStub.h"
       
    29 #include "CPhoneStateMachineStub.h"
       
    30 #include "MPhoneKeyEvents.h"
       
    31 #include "TPhoneCommandParam.h"
       
    32 #include "CPhoneMainResourceResolver.h"
       
    33 
       
    34 // - Construction -----------------------------------------------------------
       
    35 
       
    36 ut_cphoneconferenceandsingleandwaiting* ut_cphoneconferenceandsingleandwaiting::NewL()
       
    37     {
       
    38     ut_cphoneconferenceandsingleandwaiting* self = ut_cphoneconferenceandsingleandwaiting::NewLC();
       
    39     CleanupStack::Pop();
       
    40     return self;
       
    41     }
       
    42 
       
    43 ut_cphoneconferenceandsingleandwaiting* ut_cphoneconferenceandsingleandwaiting::NewLC()
       
    44     {
       
    45     ut_cphoneconferenceandsingleandwaiting* self = new( ELeave ) ut_cphoneconferenceandsingleandwaiting();
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     return self;
       
    49     }
       
    50 
       
    51 ut_cphoneconferenceandsingleandwaiting::~ut_cphoneconferenceandsingleandwaiting()
       
    52     {
       
    53     CSmcMockContext::Release();
       
    54     }
       
    55 
       
    56 ut_cphoneconferenceandsingleandwaiting::ut_cphoneconferenceandsingleandwaiting()
       
    57     {
       
    58     }
       
    59 
       
    60 void ut_cphoneconferenceandsingleandwaiting::ConstructL()
       
    61     {
       
    62     CEUnitTestSuiteClass::ConstructL();
       
    63     iMockContext = CSmcMockContext::InstanceL();
       
    64     }
       
    65 
       
    66 // - Test methods -----------------------------------------------------------
       
    67 
       
    68 
       
    69 
       
    70 void ut_cphoneconferenceandsingleandwaiting::SetupL(  )
       
    71     {
       
    72     iMockContext->InitializeL();
       
    73     iViewCommandHandle = CPhoneViewController::NewL();
       
    74     iStateMachine = CPhoneStateMachineStub::NewL(); 
       
    75     iViewCommandHandle->iCallId = 2; 
       
    76     iStateConferenceAndSingleAndWaiting  = CPhoneConferenceAndSingleAndWaiting::NewL(
       
    77            iStateMachine, iViewCommandHandle, NULL );
       
    78     
       
    79     }
       
    80     
       
    81 
       
    82 void ut_cphoneconferenceandsingleandwaiting::Teardown(  )
       
    83     {
       
    84     delete CPhoneMainResourceResolver::Instance();
       
    85     delete iStateConferenceAndSingleAndWaiting;
       
    86     delete iViewCommandHandle;
       
    87     delete iStateMachine;
       
    88     iMockContext->Reset();
       
    89     }
       
    90     
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // Test  conference and waiting state in connecting 
       
    94 // -check commands
       
    95 // -----------------------------------------------------------------------------
       
    96 //  
       
    97 void ut_cphoneconferenceandsingleandwaiting::T_HandleConnectedL(  )
       
    98     {
       
    99     
       
   100     iStateConferenceAndSingleAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConnected, 2 );
       
   101 
       
   102     iViewCommandHandle->VerifyViewCommand( EPhoneViewUpdateBubble );
       
   103     
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // Test  idle
       
   108 // -check commands
       
   109 // -----------------------------------------------------------------------------
       
   110 //  
       
   111 void ut_cphoneconferenceandsingleandwaiting::T_HandleIdleL()
       
   112     {
       
   113     
       
   114     iViewCommandHandle->SetViewGetCountOfActiveCalls(1);
       
   115     
       
   116     iStateConferenceAndSingleAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
       
   117     
       
   118     iViewCommandHandle->VerifyViewCommand( EPhoneViewRemoveCallHeader );
       
   119         
       
   120     
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // Test  conference idle
       
   125 // -check commands
       
   126 // -----------------------------------------------------------------------------
       
   127 //  
       
   128 void ut_cphoneconferenceandsingleandwaiting::T_HandleConferenceIdleL( )
       
   129     {
       
   130           
       
   131     iViewCommandHandle->SetViewGetCountOfActiveCalls(1);
       
   132        
       
   133     iStateConferenceAndSingleAndWaiting->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConferenceIdle, 0 );
       
   134     
       
   135     iViewCommandHandle->VerifyViewCommand( EPhoneViewRemoveConferenceBubble );
       
   136     
       
   137     
       
   138     }
       
   139 
       
   140 
       
   141 // - EUnit test table -------------------------------------------------------
       
   142 
       
   143 EUNIT_BEGIN_TEST_TABLE(
       
   144         ut_cphoneconferenceandsingleandwaiting,
       
   145     "Add test suite description here.",
       
   146     "UNIT" )
       
   147 
       
   148 EUNIT_TEST(
       
   149     "1- Test handle connecting",
       
   150     "",
       
   151     "Test0",
       
   152     "FUNCTIONALITY",
       
   153     SetupL, T_HandleConnectedL, Teardown)
       
   154     
       
   155 EUNIT_TEST(
       
   156     "2- Test handle idle",
       
   157     "",
       
   158     "Test0",
       
   159     "FUNCTIONALITY",
       
   160     SetupL, T_HandleIdleL, Teardown)
       
   161     
       
   162 EUNIT_TEST(
       
   163     "3- Test handle conference idle",
       
   164     "",
       
   165     "Test0",
       
   166     "FUNCTIONALITY",
       
   167     SetupL, T_HandleConferenceIdleL, Teardown)
       
   168     
       
   169 
       
   170 EUNIT_END_TEST_TABLE