|
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 |
|
19 // INTERNAL INCLUDES |
|
20 #include "etelmm.h" |
|
21 #include "e32property.h" |
|
22 #include "ut_muspropertymonitor.h" |
|
23 #include "muspropertymonitor.h" |
|
24 #include "mussesseioninformationapi.h" |
|
25 |
|
26 |
|
27 // SYSTEM INCLUDES |
|
28 #include <digia/eunit/eunitmacros.h> |
|
29 |
|
30 _LIT(KTelNo,"1234"); |
|
31 |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 UT_CMusPropertyMonitor* UT_CMusPropertyMonitor::NewL() |
|
38 { |
|
39 UT_CMusPropertyMonitor* self = UT_CMusPropertyMonitor::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 UT_CMusPropertyMonitor* UT_CMusPropertyMonitor::NewLC() |
|
50 { |
|
51 UT_CMusPropertyMonitor* self = new( ELeave ) UT_CMusPropertyMonitor(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 UT_CMusPropertyMonitor::~UT_CMusPropertyMonitor() |
|
63 { |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // Default constructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 UT_CMusPropertyMonitor::UT_CMusPropertyMonitor() |
|
72 { |
|
73 // NOP |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // Second phase construct |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void UT_CMusPropertyMonitor::ConstructL() |
|
82 { |
|
83 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
84 // It generates the test case table. |
|
85 CEUnitTestSuiteClass::ConstructL(); |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void UT_CMusPropertyMonitor::SetupL() |
|
94 { |
|
95 iMusPropertyMonitor = CMusPropertyMonitor::NewL(*this); |
|
96 iMusPropertyMonitor->iPropertyEvent.iPValue = NMusSessionInformationApi::ENoCall; |
|
97 iMusCallStateObserverInovked = EFalse; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void UT_CMusPropertyMonitor::Teardown() |
|
106 { |
|
107 delete iMusPropertyMonitor; |
|
108 PropertyHelper::Close(); |
|
109 } |
|
110 |
|
111 |
|
112 // TEST CASES |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void UT_CMusPropertyMonitor::UT_CMusPropertyMonitor_RunLL() |
|
119 { |
|
120 EUNIT_ASSERT( iMusPropertyMonitor); |
|
121 EUNIT_ASSERT( !iMusCallStateObserverInovked ); |
|
122 iMusPropertyMonitor->iPropertyEvent.iPValue = NMusSessionInformationApi::ENoCall; |
|
123 iMusPropertyMonitor->Cancel(); |
|
124 iMusPropertyMonitor->RunL(); |
|
125 EUNIT_ASSERT( iMusCallStateObserverInovked ); |
|
126 } |
|
127 |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void UT_CMusPropertyMonitor::UT_CMusPropertyMonitor_DoCancelL() |
|
135 { |
|
136 EUNIT_ASSERT( iMusPropertyMonitor ); |
|
137 iMusPropertyMonitor->DoCancel(); |
|
138 EUNIT_ASSERT( PropertyHelper::GetCalledFunction() == |
|
139 RProperty::ECancel ) |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void UT_CMusPropertyMonitor::UT_CMusPropertyMonitor_RunErrorL() |
|
148 { |
|
149 EUNIT_ASSERT( !iMusCallStateObserverInovked ); |
|
150 EUNIT_ASSERT( iMusPropertyMonitor ); |
|
151 TInt CallState; |
|
152 TInt error = KErrNotFound; |
|
153 |
|
154 // Call is Established: |
|
155 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
156 NMusSessionInformationApi::KMusCallEvent, |
|
157 NMusSessionInformationApi::ECallConnected ) ); |
|
158 |
|
159 // Test1: Invoking Error Situation, Ensure Calll is disconected. |
|
160 User::LeaveIfError( iMusPropertyMonitor->RunError(error)); |
|
161 User::LeaveIfError( RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
162 NMusSessionInformationApi::KMusCallEvent, |
|
163 CallState ) ); |
|
164 EUNIT_ASSERT( CallState == NMusSessionInformationApi::ENoCall ); |
|
165 EUNIT_ASSERT( iMusCallStateObserverInovked ); |
|
166 } |
|
167 |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // UT_CMusPropertyMonitor::UT_CMusPropertyMonitor_IsCallConnected() |
|
171 // Checks from the P/S keys if the Call is connected. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void UT_CMusPropertyMonitor::UT_CMusPropertyMonitor_IsCallConnected() |
|
175 { |
|
176 // Test1: Call Not Connected: |
|
177 TBool callConnected = EFalse; |
|
178 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
179 NMusSessionInformationApi::KMusCallEvent, |
|
180 NMusSessionInformationApi::ENoCall ) ); |
|
181 |
|
182 callConnected = iMusPropertyMonitor->IsCallConnected(); |
|
183 EUNIT_ASSERT( callConnected == EFalse ); |
|
184 |
|
185 // Test2: Call Connected: |
|
186 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
187 NMusSessionInformationApi::KMusCallEvent, |
|
188 NMusSessionInformationApi::ECallConnected ) ); |
|
189 |
|
190 callConnected = iMusPropertyMonitor->IsCallConnected(); |
|
191 EUNIT_ASSERT( callConnected == ETrue ); |
|
192 |
|
193 |
|
194 // Test3: Hold and Conference are concidered as call connected |
|
195 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
196 NMusSessionInformationApi::KMusCallEvent, |
|
197 NMusSessionInformationApi::ECallHold ) ); |
|
198 |
|
199 callConnected = iMusPropertyMonitor->IsCallConnected(); |
|
200 EUNIT_ASSERT( callConnected == ETrue ); |
|
201 } |
|
202 |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // MusCallStateChanged from the MusCallStateObserver |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void UT_CMusPropertyMonitor::MusCallStateChanged() |
|
209 { |
|
210 iMusCallStateObserverInovked = ETrue; |
|
211 } |
|
212 |
|
213 |
|
214 |
|
215 // TEST TABLE |
|
216 |
|
217 EUNIT_BEGIN_TEST_TABLE( |
|
218 UT_CMusPropertyMonitor, |
|
219 "UT_CMusPropertyMonitor", |
|
220 "UNIT" ) |
|
221 |
|
222 EUNIT_TEST( |
|
223 "RunL - test", |
|
224 "CMusCallStatusMonitor", |
|
225 "RunL", |
|
226 "FUNCTIONALITY", |
|
227 SetupL, UT_CMusPropertyMonitor_RunLL, Teardown) |
|
228 |
|
229 EUNIT_TEST( |
|
230 "DoCancel - test", |
|
231 "CMusCallStatusMonitor", |
|
232 "DoCancel", |
|
233 "FUNCTIONALITY", |
|
234 SetupL, UT_CMusPropertyMonitor_DoCancelL, Teardown) |
|
235 |
|
236 EUNIT_TEST( |
|
237 "RunError - test", |
|
238 "CMusCallStatusMonitor", |
|
239 "RunErrorL", |
|
240 "FUNCTIONALITY", |
|
241 SetupL, UT_CMusPropertyMonitor_RunErrorL, Teardown) |
|
242 |
|
243 EUNIT_TEST( |
|
244 "IsCallConnected - test", |
|
245 "CMusCallStatusMonitor", |
|
246 "IsCallConnected", |
|
247 "FUNCTIONALITY", |
|
248 SetupL, UT_CMusPropertyMonitor_IsCallConnected, Teardown) |
|
249 |
|
250 EUNIT_END_TEST_TABLE |
|
251 |
|
252 // END OF FILE |
|
253 |
|
254 |