phoneapp/phoneuistates/tsrc/ut_cphoneconferenceandsingle/Src/ut_cphoneconferenceandsingle.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_cphoneconferenceandsingle.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 "CPhoneConferenceAndSingle.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 #include "cphonestate.h"
       
    34 
       
    35 // - Construction -----------------------------------------------------------
       
    36 
       
    37 ut_cphoneconferenceandsingle* ut_cphoneconferenceandsingle::NewL()
       
    38     {
       
    39     ut_cphoneconferenceandsingle* self = ut_cphoneconferenceandsingle::NewLC();
       
    40     CleanupStack::Pop();
       
    41     return self;
       
    42     }
       
    43 
       
    44 ut_cphoneconferenceandsingle* ut_cphoneconferenceandsingle::NewLC()
       
    45     {
       
    46     ut_cphoneconferenceandsingle* self = new( ELeave ) ut_cphoneconferenceandsingle();
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     return self;
       
    50     }
       
    51 
       
    52 ut_cphoneconferenceandsingle::~ut_cphoneconferenceandsingle()
       
    53     {
       
    54     CSmcMockContext::Release();
       
    55     }
       
    56 
       
    57 ut_cphoneconferenceandsingle::ut_cphoneconferenceandsingle()
       
    58     {
       
    59     }
       
    60 
       
    61 void ut_cphoneconferenceandsingle::ConstructL()
       
    62     {
       
    63     CEUnitTestSuiteClass::ConstructL();
       
    64     iMockContext = CSmcMockContext::InstanceL();
       
    65     }
       
    66 
       
    67 // - Test methods -----------------------------------------------------------
       
    68 
       
    69 
       
    70 
       
    71 void ut_cphoneconferenceandsingle::SetupL(  )
       
    72     {
       
    73     iMockContext->InitializeL();
       
    74     iViewCommandHandle = CPhoneViewController::NewL();
       
    75     iStateMachine = CPhoneStateMachineStub::NewL(); 
       
    76     iViewCommandHandle->iCallId = 2; 
       
    77     iStateConferenceAndSingle  = CPhoneConferenceAndSingle::NewL(
       
    78            iStateMachine, iViewCommandHandle, NULL );
       
    79     
       
    80     }
       
    81     
       
    82 
       
    83 void ut_cphoneconferenceandsingle::Teardown(  )
       
    84     {
       
    85     delete CPhoneMainResourceResolver::Instance();
       
    86     delete iStateConferenceAndSingle;
       
    87     delete iViewCommandHandle;
       
    88     delete iStateMachine;
       
    89     iMockContext->Reset();
       
    90     }
       
    91     
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // Test  conference and waiting state in connecting 
       
    95 // -check commands
       
    96 // -----------------------------------------------------------------------------
       
    97 //  
       
    98 void ut_cphoneconferenceandsingle::T_HandleConnectedL(  )
       
    99     {
       
   100     iStateConferenceAndSingle->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageConnected, 2 );
       
   101 
       
   102     iViewCommandHandle->VerifyViewCommand( EPhoneViewUpdateBubble );
       
   103     
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // Test  idle
       
   108 // -check commands
       
   109 // -----------------------------------------------------------------------------
       
   110 //  
       
   111 void ut_cphoneconferenceandsingle::T_HandleIdleL()
       
   112     {
       
   113     
       
   114     iViewCommandHandle->SetViewGetCountOfActiveCalls(1);
       
   115     
       
   116     iStateConferenceAndSingle->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_cphoneconferenceandsingle::T_HandleConferenceIdleL( )
       
   129     {
       
   130           
       
   131     iViewCommandHandle->SetViewGetCountOfActiveCalls(1);
       
   132        
       
   133     iStateConferenceAndSingle->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_cphoneconferenceandsingle,
       
   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