phoneapp/phoneuistates/tsrc/ut_cphonetwosingles/Src/ut_cphonetwosingles.cpp
changeset 77 2be0b271d017
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_cphonetwosingles.h"
       
    19 #include <EUnitMacros.h>
       
    20 #include <EUnitDecorators.h>
       
    21 #include <featmgr.h>
       
    22 #include "PEVirtualEngine.h" 
       
    23 #include "CPhoneViewControllerStub.h"
       
    24 #include "CPhoneStateMachineStub.h"
       
    25 #include "MPhoneKeyEvents.h"
       
    26 #include "TPhoneCommandParam.h"
       
    27 #include "CPhoneMainResourceResolver.h"
       
    28 #include "phoneappcommands.hrh"
       
    29 #include <csmcmockcontext.h>
       
    30 #include <smcdefaultvalue.h>
       
    31 #include <msmcmockspecbuilder.h>
       
    32 #include <smcobjecttotypemapper.h>
       
    33 #include <smcmacros.h>
       
    34 #include <msmcmockaction.h>
       
    35 #include "phonestatedefinitions.h"
       
    36 
       
    37 #define protected public
       
    38 #include "CPhoneTwoSingles.h"
       
    39 
       
    40 // - Construction -----------------------------------------------------------
       
    41 
       
    42 ut_cphonetwosingles* ut_cphonetwosingles::NewL()
       
    43     {
       
    44     ut_cphonetwosingles* self = ut_cphonetwosingles::NewLC();
       
    45     CleanupStack::Pop();
       
    46     return self;
       
    47     }
       
    48     
       
    49     ut_cphonetwosingles* ut_cphonetwosingles::NewLC()
       
    50     {
       
    51     ut_cphonetwosingles* self = new( ELeave ) ut_cphonetwosingles();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     return self;
       
    55     }
       
    56 
       
    57 ut_cphonetwosingles::~ut_cphonetwosingles()
       
    58     {
       
    59     CSmcMockContext::Release();
       
    60     }
       
    61 
       
    62 ut_cphonetwosingles::ut_cphonetwosingles()
       
    63     {
       
    64     }
       
    65 
       
    66 void ut_cphonetwosingles::ConstructL()
       
    67     {
       
    68     CEUnitTestSuiteClass::ConstructL();
       
    69     iMockContext = CSmcMockContext::InstanceL();
       
    70     }
       
    71 
       
    72 // - Test methods -----------------------------------------------------------
       
    73 
       
    74 
       
    75 
       
    76 void ut_cphonetwosingles::SetupL(  )
       
    77     {
       
    78     iMockContext->InitializeL();
       
    79     
       
    80     iViewCommandHandle = CPhoneViewController::NewL();
       
    81     iStateMachine = CPhoneStateMachineStub::NewL(); 
       
    82     iViewCommandHandle->iCallId = 2; 
       
    83     
       
    84     iStateTwoSingles  = CPhoneTwoSingles::NewL(
       
    85            iStateMachine, iViewCommandHandle, NULL );
       
    86     
       
    87     }
       
    88     
       
    89 
       
    90 void ut_cphonetwosingles::Teardown(  )
       
    91     {
       
    92     delete CPhoneMainResourceResolver::Instance();
       
    93     delete iStateTwoSingles;
       
    94     delete iViewCommandHandle;
       
    95     delete iStateMachine;
       
    96     
       
    97     iMockContext->Reset();
       
    98     }
       
    99    
       
   100 // -----------------------------------------------------------------------------
       
   101 // Test  conference idle
       
   102 // -check commands
       
   103 // -----------------------------------------------------------------------------
       
   104 //  
       
   105 void ut_cphonetwosingles::T_HandleIdleL( )
       
   106     {
       
   107     
       
   108     iViewCommandHandle->SetViewGetCountOfActiveCalls(1);
       
   109 
       
   110     iMockContext->ExpectCallL( "CPhoneNumberEntryManager::SetVisibilityIfNumberEntryUsedL" ).
       
   111             WithL( ETrue );
       
   112     iStateTwoSingles->HandlePhoneEngineMessageL( MEngineMonitor::EPEMessageIdle, 0 );
       
   113 
       
   114     EUNIT_ASSERT_EQUALS( EPhoneStateSingle, iStateMachine->iState ); 
       
   115     EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() ); 
       
   116     }
       
   117 
       
   118 // - EUnit test table -------------------------------------------------------
       
   119 
       
   120 EUNIT_BEGIN_TEST_TABLE(
       
   121         ut_cphonetwosingles,
       
   122     "Add test suite description here.",
       
   123     "UNIT" )
       
   124     
       
   125 EUNIT_TEST(
       
   126     "1- CPhoneTwoSingles: Test idle",
       
   127     "",
       
   128     "Test0",
       
   129     "FUNCTIONALITY",
       
   130     SetupL, T_HandleIdleL, Teardown)    
       
   131     
       
   132 EUNIT_END_TEST_TABLE