|
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_cphonecallsetup.h" |
|
19 #include <EUnitMacros.h> |
|
20 #include <EUnitDecorators.h> |
|
21 |
|
22 #include "cphonecallsetup.h" |
|
23 |
|
24 #include "CPhoneState.h" |
|
25 |
|
26 #include "cphonestatecallsetupstub.h" |
|
27 #include "CPhoneStateMachineStub.h" |
|
28 #include "CPhoneViewControllerStub.h" |
|
29 #include "CPhoneMainResourceResolver.h" |
|
30 |
|
31 CallSetupWrapperClass* CallSetupWrapperClass::NewL( |
|
32 MPhoneStateMachine* aStateMachine, |
|
33 MPhoneViewCommandHandle* aViewCommandHandle, |
|
34 MPhoneCustomization* aPhoneCustomization ) |
|
35 { |
|
36 CallSetupWrapperClass* self = new( ELeave ) CallSetupWrapperClass( |
|
37 aStateMachine, |
|
38 aViewCommandHandle, |
|
39 aPhoneCustomization ); |
|
40 |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 CallSetupWrapperClass::~CallSetupWrapperClass() |
|
48 { |
|
49 } |
|
50 |
|
51 CallSetupWrapperClass::CallSetupWrapperClass( |
|
52 MPhoneStateMachine* aStateMachine, |
|
53 MPhoneViewCommandHandle* aViewCommandHandle, |
|
54 MPhoneCustomization* aPhoneCustomization ) : |
|
55 CPhoneCallSetup( aStateMachine, aViewCommandHandle, aPhoneCustomization ) |
|
56 { |
|
57 } |
|
58 |
|
59 void CallSetupWrapperClass::ConstructL() |
|
60 { |
|
61 CPhoneCallSetup::ConstructL(); |
|
62 } |
|
63 |
|
64 |
|
65 void CallSetupWrapperClass::HandleConnectingL( TInt aCallId ) |
|
66 { |
|
67 CPhoneCallSetup::HandleConnectingL(aCallId); |
|
68 } |
|
69 |
|
70 // - Construction ----------------------------------------------------------- |
|
71 |
|
72 ut_cphonecallsetup* ut_cphonecallsetup::NewL() |
|
73 { |
|
74 ut_cphonecallsetup* self = ut_cphonecallsetup::NewLC(); |
|
75 CleanupStack::Pop(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 ut_cphonecallsetup* ut_cphonecallsetup::NewLC() |
|
80 { |
|
81 ut_cphonecallsetup* self = new( ELeave ) ut_cphonecallsetup(); |
|
82 CleanupStack::PushL( self ); |
|
83 self->ConstructL(); |
|
84 return self; |
|
85 } |
|
86 |
|
87 ut_cphonecallsetup::~ut_cphonecallsetup() |
|
88 { |
|
89 } |
|
90 |
|
91 ut_cphonecallsetup::ut_cphonecallsetup() |
|
92 { |
|
93 } |
|
94 |
|
95 void ut_cphonecallsetup::ConstructL() |
|
96 { |
|
97 CEUnitTestSuiteClass::ConstructL(); |
|
98 } |
|
99 |
|
100 // - Test methods ----------------------------------------------------------- |
|
101 |
|
102 |
|
103 void ut_cphonecallsetup::SetupL( ) |
|
104 { |
|
105 iViewCommandHandle = CPhoneViewController::NewL(); |
|
106 iStateMachine = CPhoneStateMachineStub::NewL(); |
|
107 iWrapper = CallSetupWrapperClass::NewL( iStateMachine, iViewCommandHandle, NULL ); |
|
108 } |
|
109 |
|
110 |
|
111 void ut_cphonecallsetup::Teardown( ) |
|
112 { |
|
113 delete iWrapper; |
|
114 iWrapper = NULL; |
|
115 delete iStateMachine; |
|
116 iStateMachine = NULL; |
|
117 delete iViewCommandHandle; |
|
118 iViewCommandHandle = NULL; |
|
119 delete iStubResourceResolver; |
|
120 iStubResourceResolver = NULL; |
|
121 } |
|
122 |
|
123 |
|
124 void ut_cphonecallsetup::T_CPhoneCallSetup__CPhoneCallSetupL( ) |
|
125 { |
|
126 } |
|
127 |
|
128 void ut_cphonecallsetup::T_CPhoneCallSetup_HandleHandleConnectingMessageL( ) |
|
129 { |
|
130 TInt callId(1); |
|
131 iWrapper->HandleConnectingL( callId ); |
|
132 VerifyEPhoneViewRemoveGlobalNoteIsNotUsed(); |
|
133 } |
|
134 |
|
135 void ut_cphonecallsetup::VerifyEPhoneViewRemoveGlobalNoteIsNotUsed( ) |
|
136 { |
|
137 EUNIT_PRINT( _L( "Checking that command EPhoneViewRemoveGlobalNote is not used!" ) ); |
|
138 TInt command = EPhoneViewRemoveGlobalNote; |
|
139 TInt count = iViewCommandHandle->iCmds->Count(); |
|
140 TBool cmdFound = EFalse; |
|
141 TInt i = 0; |
|
142 for ( ; i < count; i++ ) |
|
143 { |
|
144 TCmds cmd = iViewCommandHandle->iCmds->At(i); |
|
145 if( cmd.iCmd == EPhoneViewRemoveGlobalNote ) |
|
146 { |
|
147 EUNIT_FAIL_TEST( "EPhoneViewRemoveGlobalNote Command found -> FAIL! " ); |
|
148 cmdFound = ETrue; |
|
149 break; |
|
150 } |
|
151 } |
|
152 } |
|
153 |
|
154 TInt ut_cphonecallsetup::VerifyViewCommand( const TInt& aCmd ) |
|
155 { |
|
156 _LIT(KDesC, "Checking command id = %d "); |
|
157 EUNIT_PRINT( KDesC(), aCmd ); |
|
158 |
|
159 TInt count = iViewCommandHandle->iCmds->Count(); |
|
160 TBool cmdFound = EFalse; |
|
161 TInt i = 0; |
|
162 for ( ; i < count; i++ ) |
|
163 { |
|
164 TCmds cmd = iViewCommandHandle->iCmds->At(i); |
|
165 if( cmd.iCmd == aCmd ) |
|
166 { |
|
167 cmdFound = ETrue; |
|
168 break; |
|
169 } |
|
170 } |
|
171 EUNIT_ASSERT_DESC( cmdFound, "View Command not ok" ); |
|
172 return i; |
|
173 } |
|
174 |
|
175 // - EUnit test table ------------------------------------------------------- |
|
176 |
|
177 EUNIT_BEGIN_TEST_TABLE( |
|
178 ut_cphonecallsetup, |
|
179 "Add test suite description here.", |
|
180 "UNIT" ) |
|
181 |
|
182 EUNIT_TEST( |
|
183 "CPhoneCallSetup const./desct.", |
|
184 "CPhoneCallSetup", |
|
185 "Setup-teardown", |
|
186 "FUNCTIONALITY", |
|
187 SetupL, T_CPhoneCallSetup__CPhoneCallSetupL, Teardown) |
|
188 |
|
189 EUNIT_TEST( |
|
190 "CPhoneCallSetup - HandleConnectingL", |
|
191 "CPhoneCallSetup", |
|
192 "HandlePhoneEngineMessageL - HandleConnectingL", |
|
193 "FUNCTIONALITY", |
|
194 SetupL, T_CPhoneCallSetup_HandleHandleConnectingMessageL, Teardown) |
|
195 |
|
196 EUNIT_END_TEST_TABLE |