|
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 "centralrepository.h" |
|
23 #include "ut_mustsypropertymonitor.h" |
|
24 #include "mustsypropertymonitor.h" |
|
25 #include "muscallmonitor.h" |
|
26 #include "musvoipcallmonitor.h" |
|
27 #include "muscallconferencemonitor.h" |
|
28 |
|
29 // SYSTEM INCLUDES |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 #include <CTSYDomainPSKeys.h> |
|
32 #include <telremotepartyinformationpskeys.h> |
|
33 |
|
34 |
|
35 _LIT(KTelNo,"1234"); |
|
36 _LIT( KTestProvideName, "VoIP" ); |
|
37 _LIT( KDefaultSipUri, "sip:default@uri" ); |
|
38 |
|
39 TName cs_call_1(_L("cs_call_1")); |
|
40 TName cs_call_2(_L("cs_call_2")); |
|
41 TName voip_call_1(_L("voip_call_1")); |
|
42 TName voip_call_2(_L("voip_call_2")); |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 UT_CMusTsyPropertyMonitor* UT_CMusTsyPropertyMonitor::NewL() |
|
49 { |
|
50 UT_CMusTsyPropertyMonitor* self = UT_CMusTsyPropertyMonitor::NewLC(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 UT_CMusTsyPropertyMonitor* UT_CMusTsyPropertyMonitor::NewLC() |
|
61 { |
|
62 UT_CMusTsyPropertyMonitor* self = new( ELeave ) UT_CMusTsyPropertyMonitor(); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 UT_CMusTsyPropertyMonitor::~UT_CMusTsyPropertyMonitor() |
|
74 { |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Default constructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor() |
|
83 { |
|
84 // NOP |
|
85 } |
|
86 |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // Second phase construct |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void UT_CMusTsyPropertyMonitor::ConstructL() |
|
93 { |
|
94 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
95 // It generates the test case table. |
|
96 CEUnitTestSuiteClass::ConstructL(); |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void UT_CMusTsyPropertyMonitor::SetupL() |
|
105 { |
|
106 iMusCentralRepository = CRepository::NewL( MusSettingsKeys::KRepositoryUid ); |
|
107 RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
108 NMusSessionInformationApi::KMusCallEvent, |
|
109 0 ); |
|
110 |
|
111 iMusTsyPropertyMonitor = CMusTsyPropertyMonitor::NewL( iPhone, *this ); |
|
112 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateUninitialized; |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void UT_CMusTsyPropertyMonitor::Teardown() |
|
121 { |
|
122 delete iMusCentralRepository; |
|
123 iMusCentralRepository = NULL; |
|
124 delete iMusTsyPropertyMonitor; |
|
125 PropertyHelper::Close(); |
|
126 iPhone.Close(); |
|
127 |
|
128 } |
|
129 |
|
130 |
|
131 |
|
132 // TEST CASES |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RunLL() |
|
139 { |
|
140 |
|
141 // Set intial call type too unintialiazed. |
|
142 if ( RProperty::Set( KPSUidCtsyCallInformation,KCTsyCallType, |
|
143 EPSCTsyCallTypeUninitialized )) |
|
144 { |
|
145 User::Leave( KErrNoMemory ); |
|
146 } |
|
147 // Set intial call count |
|
148 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
149 NMusSessionInformationApi::KMusCallCount, |
|
150 0 ) != KErrNone ) |
|
151 { |
|
152 User::Leave( KErrNoMemory ); |
|
153 } |
|
154 |
|
155 EUNIT_ASSERT( iMusTsyPropertyMonitor); |
|
156 TInt val = KErrNone; |
|
157 |
|
158 iMusTsyPropertyMonitor->Cancel(); |
|
159 iMusTsyPropertyMonitor->RunL(); |
|
160 |
|
161 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
162 |
|
163 |
|
164 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateNone; |
|
165 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
166 |
|
167 iMusTsyPropertyMonitor->Cancel(); |
|
168 iMusTsyPropertyMonitor->RunL(); |
|
169 |
|
170 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
171 NMusSessionInformationApi::KMusCallEvent, |
|
172 val ); |
|
173 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
174 |
|
175 |
|
176 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateDisconnecting; |
|
177 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
178 |
|
179 iMusTsyPropertyMonitor->Cancel(); |
|
180 iMusTsyPropertyMonitor->RunL(); |
|
181 |
|
182 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
183 NMusSessionInformationApi::KMusCallEvent, |
|
184 val ); |
|
185 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
186 |
|
187 |
|
188 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateAnswering; |
|
189 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
190 |
|
191 iMusTsyPropertyMonitor->Cancel(); |
|
192 iMusTsyPropertyMonitor->RunL(); |
|
193 |
|
194 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
195 NMusSessionInformationApi::KMusCallEvent, |
|
196 val ); |
|
197 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
198 |
|
199 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateConnected; |
|
200 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
201 |
|
202 iMusTsyPropertyMonitor->Cancel(); |
|
203 iMusTsyPropertyMonitor->RunL(); |
|
204 |
|
205 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
206 NMusSessionInformationApi::KMusCallEvent, |
|
207 val ); |
|
208 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
209 |
|
210 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateHold; |
|
211 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
212 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
213 NMusSessionInformationApi::KMusCallCount, |
|
214 1 ) != KErrNone ) |
|
215 { |
|
216 User::Leave( KErrNoMemory ); |
|
217 } |
|
218 //simulate multicall scenario |
|
219 TName callName(_L("Voice1")); |
|
220 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
221 callName.Copy(_L("Voice2")); |
|
222 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
223 iMusTsyPropertyMonitor->Cancel(); |
|
224 iMusTsyPropertyMonitor->RunL(); |
|
225 // |
|
226 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
227 NMusSessionInformationApi::KMusCallEvent, |
|
228 val ); |
|
229 EUNIT_ASSERT( val==NMusSessionInformationApi::ECallHold); |
|
230 |
|
231 } |
|
232 |
|
233 |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_DoCancelL() |
|
240 { |
|
241 EUNIT_ASSERT( iMusTsyPropertyMonitor ); |
|
242 iMusTsyPropertyMonitor->Cancel(); |
|
243 EUNIT_ASSERT( PropertyHelper::GetCalledFunction() == |
|
244 RProperty::ECancel ) |
|
245 } |
|
246 |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RunErrorL() |
|
253 { |
|
254 EUNIT_ASSERT( iMusTsyPropertyMonitor ); |
|
255 TInt error = KErrNotFound; |
|
256 iMusTsyPropertyMonitor->RunError(error); |
|
257 } |
|
258 |
|
259 |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_AddCallMonitorLL() |
|
266 { |
|
267 TName name = KTelNo(); |
|
268 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
269 NMusSessionInformationApi::KMusCallCount, |
|
270 0 ) != KErrNone ) |
|
271 { |
|
272 User::Leave( KErrNoMemory ); |
|
273 } |
|
274 iMusTsyPropertyMonitor->AddCallMonitorL( name ); |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RemoveCallMonitorL() |
|
282 { |
|
283 TName name = KTelNo(); |
|
284 iMusTsyPropertyMonitor->RemoveCallMonitor( name ); |
|
285 |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_MonitorCSCallLL() |
|
293 { |
|
294 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
295 NMusSessionInformationApi::KMusCallCount, |
|
296 0 ) != KErrNone ) |
|
297 { |
|
298 User::Leave( KErrNoMemory ); |
|
299 } |
|
300 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusIdle ); |
|
301 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
302 iMusTsyPropertyMonitor->MonitorCSCallL(); |
|
303 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
304 |
|
305 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusHangingUp ); |
|
306 iMusTsyPropertyMonitor->MonitorCSCallL(); |
|
307 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
308 |
|
309 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusConnected ); |
|
310 iMusTsyPropertyMonitor->MonitorCSCallL(); |
|
311 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
312 |
|
313 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
314 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusAnswering ); |
|
315 iMusTsyPropertyMonitor->MonitorCSCallL(); |
|
316 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
317 |
|
318 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
319 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusIdle ); |
|
320 iMusTsyPropertyMonitor->MonitorCSCallL(); |
|
321 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
322 |
|
323 } |
|
324 |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_MonitorVoipCallLL() |
|
331 { |
|
332 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
333 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
334 NMusSessionInformationApi::KMusCallCount, |
|
335 0 ) != KErrNone ) |
|
336 { |
|
337 User::Leave( KErrNoMemory ); |
|
338 } |
|
339 |
|
340 // State connected |
|
341 TPSCTsyCallState callState = EPSCTsyCallStateConnected; |
|
342 iMusTsyPropertyMonitor->MonitorVoipCallL( callState ); |
|
343 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 1 ); |
|
344 |
|
345 // State answering |
|
346 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
347 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
348 callState = EPSCTsyCallStateAnswering ; |
|
349 iMusTsyPropertyMonitor->MonitorVoipCallL( callState ); |
|
350 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 1 ); |
|
351 |
|
352 // State disconnecting ( Atleast one previous voip call is present ) |
|
353 callState = EPSCTsyCallStateDisconnecting; |
|
354 iMusTsyPropertyMonitor->MonitorVoipCallL( callState ); |
|
355 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
356 } |
|
357 |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_MonitorCallLL() |
|
364 { |
|
365 TInt tmp = 0; |
|
366 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
367 NMusSessionInformationApi::KMusCallCount, |
|
368 0 ) != KErrNone ) |
|
369 { |
|
370 User::Leave( KErrNoMemory ); |
|
371 } |
|
372 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
373 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
374 // Test : Cs call and call state is connected |
|
375 TPSCTsyCallState callState = EPSCTsyCallStateConnected; |
|
376 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusConnected ); |
|
377 TPSCTsyCallType callType = EPSCTsyCallTypeCSVoice; |
|
378 iMusTsyPropertyMonitor->MonitorCallL(callState,callType); |
|
379 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
380 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
381 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
382 NMusSessionInformationApi::KMusCallEvent, |
|
383 tmp ); |
|
384 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallConnected); |
|
385 |
|
386 // Test : unknown call type |
|
387 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
388 callType = EPSCTsyCallTypeNone; |
|
389 iMusTsyPropertyMonitor->MonitorCallL(callState,callType); |
|
390 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
391 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
392 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
393 NMusSessionInformationApi::KMusCallEvent, |
|
394 tmp ); |
|
395 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ENoCall); |
|
396 |
|
397 // Test : Voip call and call state is connected and factory settings not found |
|
398 // if key not found then it should behave default = AllowedAllCalls. |
|
399 callState = EPSCTsyCallStateConnected; |
|
400 callType = EPSCTsyCallTypeVoIP; |
|
401 iMusTsyPropertyMonitor->MonitorCallL(callState,callType); |
|
402 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
403 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 1 ); |
|
404 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
405 NMusSessionInformationApi::KMusCallEvent, |
|
406 tmp ); |
|
407 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallConnected); |
|
408 |
|
409 |
|
410 // Test : Voip call and call state is connected and factory settings set to |
|
411 // all call supported. |
|
412 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
413 iMusCentralRepository->Set(MusSettingsKeys::KAllowOnlyWithActiveCSCall, |
|
414 MusSettingsKeys::EAllowedAllCalls); |
|
415 callState = EPSCTsyCallStateConnected; |
|
416 callType = EPSCTsyCallTypeVoIP; |
|
417 iMusTsyPropertyMonitor->MonitorCallL(callState,callType); |
|
418 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
419 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 1 ); |
|
420 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
421 NMusSessionInformationApi::KMusCallEvent, |
|
422 tmp ); |
|
423 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallConnected); |
|
424 |
|
425 // Test : Voip call and call state is connected but factory settings are cs only |
|
426 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
427 iMusCentralRepository->Set(MusSettingsKeys::KAllowOnlyWithActiveCSCall,MusSettingsKeys::EAllowedCSOnly); |
|
428 callState = EPSCTsyCallStateConnected; |
|
429 callType = EPSCTsyCallTypeVoIP; |
|
430 iMusTsyPropertyMonitor->MonitorCallL(callState,callType); |
|
431 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
432 if ( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() != 0 ) |
|
433 { |
|
434 User::Leave( KErrNoMemory ); // Call was not removed because of memory running out was "silenty" handled. |
|
435 } |
|
436 EUNIT_ASSERT( iMusTsyPropertyMonitor->iVoipCallMonitorArray.Count() == 0 ); |
|
437 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
438 NMusSessionInformationApi::KMusCallEvent, |
|
439 tmp ); |
|
440 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ENoCall); |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RemoveUnUsedCallMonitorsL() |
|
448 { |
|
449 TName callName(_L("Voice1")); |
|
450 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
451 NMusSessionInformationApi::KMusCallCount, |
|
452 0 ) != KErrNone ) |
|
453 { |
|
454 User::Leave( KErrNoMemory ); |
|
455 } |
|
456 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
457 callName.Copy(_L("Voice2")); |
|
458 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
459 RTelHelper::SetCallStatus(RMobileCall::EStatusUnknown); |
|
460 iMusTsyPropertyMonitor->RemoveUnUsedCallMonitors(); |
|
461 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count()==0 ); |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_CheckCallCriteriaLL() |
|
469 { |
|
470 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
471 NMusSessionInformationApi::KMusCallCount, |
|
472 0 ) != KErrNone ) |
|
473 { |
|
474 User::Leave( KErrNoMemory ); |
|
475 } |
|
476 TInt tmp = 0; |
|
477 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
478 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
479 |
|
480 User::LeaveIfError( RProperty::Set( KPSUidTelRemotePartyInformation, |
|
481 KTelCLINumber, |
|
482 _L( "sip:somebody@somewhere" ) ) ); |
|
483 |
|
484 // Test : no cs call , one voip call |
|
485 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
486 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
487 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
488 NMusSessionInformationApi::KMusCallEvent, |
|
489 tmp ); |
|
490 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallConnected); |
|
491 // Test : one cs call , multiple voip calls |
|
492 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
493 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
494 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
495 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
496 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_2 ); |
|
497 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
498 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
499 NMusSessionInformationApi::KMusCallEvent, |
|
500 tmp ); |
|
501 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallHold); |
|
502 // Test: multiple cs call, one voip call |
|
503 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
504 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
505 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
506 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_2 ); |
|
507 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
508 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
509 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
510 NMusSessionInformationApi::KMusCallEvent, |
|
511 tmp ); |
|
512 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallHold); |
|
513 |
|
514 // Test : multiple cs call , multiple voip calls |
|
515 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
516 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
517 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
518 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_2 ); |
|
519 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
520 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_2 ); |
|
521 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
522 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
523 NMusSessionInformationApi::KMusCallEvent, |
|
524 tmp ); |
|
525 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallHold); |
|
526 // Test : one cs call , one voip call |
|
527 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
528 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
529 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
530 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
531 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
532 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
533 NMusSessionInformationApi::KMusCallEvent, |
|
534 tmp ); |
|
535 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallHold); |
|
536 // Test: one cs call , no voip call |
|
537 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
538 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
539 RTelHelper::SetCallStatus( RMobileCall::EStatusConnected ); |
|
540 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
541 iMusTsyPropertyMonitor->CheckCallCriteriaL(); |
|
542 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
543 NMusSessionInformationApi::KMusCallEvent, |
|
544 tmp ); |
|
545 EUNIT_ASSERT( tmp==NMusSessionInformationApi::ECallConnected); |
|
546 } |
|
547 |
|
548 |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_IsDataReadyLL() |
|
552 // Test to query from corresponding monitors if they are ready. |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 |
|
556 |
|
557 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_IsDataReadyLL() |
|
558 { |
|
559 TBool dataReady = EFalse; |
|
560 |
|
561 // Test-1: CS Call Ready: |
|
562 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
563 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
564 |
|
565 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
566 NMusSessionInformationApi::KMusCallCount, |
|
567 0 ) != KErrNone ) |
|
568 { |
|
569 User::Leave( KErrNoMemory ); |
|
570 } |
|
571 |
|
572 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
573 NMusSessionInformationApi::KMusTelNumber, |
|
574 KTelNo )); |
|
575 |
|
576 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
577 NMusSessionInformationApi::KMusCallDirection, |
|
578 NMusSessionInformationApi::ECallOrginated )); |
|
579 |
|
580 iMusTsyPropertyMonitor->AddCallMonitorL( cs_call_1 ); |
|
581 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
582 EUNIT_ASSERT_EQUALS( dataReady, ETrue ) |
|
583 |
|
584 // Test-2: CS Call NotReady: |
|
585 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
586 NMusSessionInformationApi::KMusTelNumber, |
|
587 KNullDesC )); |
|
588 |
|
589 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
590 EUNIT_ASSERT_EQUALS( dataReady, EFalse ) |
|
591 |
|
592 // Test-3 VoIP Call Ready |
|
593 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
594 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
595 |
|
596 User::LeaveIfError( RProperty::Set( |
|
597 NMusSessionInformationApi::KCategoryUid, |
|
598 NMusSessionInformationApi::KMusTelNumber, |
|
599 KDefaultSipUri )); |
|
600 |
|
601 User::LeaveIfError(RProperty::Set( |
|
602 NMusSessionInformationApi::KCategoryUid, |
|
603 NMusSessionInformationApi::KMUSCallProvider, |
|
604 KTestProvideName )); |
|
605 |
|
606 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
607 EUNIT_ASSERT_EQUALS( dataReady, ETrue ) |
|
608 |
|
609 |
|
610 // Test-4 VoIP Call Not Ready |
|
611 User::LeaveIfError( RProperty::Set( |
|
612 NMusSessionInformationApi::KCategoryUid, |
|
613 NMusSessionInformationApi::KMUSCallProvider, |
|
614 KNullDesC )); |
|
615 |
|
616 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
617 |
|
618 EUNIT_ASSERT_EQUALS( dataReady, EFalse ) |
|
619 |
|
620 // Test-5: Conference Case |
|
621 iMusTsyPropertyMonitor->iCallMonitorArray.ResetAndDestroy(); |
|
622 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
623 |
|
624 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_1 ); |
|
625 iMusTsyPropertyMonitor->AddVoipCallMonitorL( voip_call_2 ); |
|
626 |
|
627 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
628 EUNIT_ASSERT_EQUALS( dataReady, EFalse ) |
|
629 iMusTsyPropertyMonitor->iVoipCallMonitorArray.ResetAndDestroy(); |
|
630 |
|
631 // Test-3 Handling conference case. |
|
632 iMusTsyPropertyMonitor->iConferenceMonitor->iConfStatus = RMobileConferenceCall::EConferenceActive; |
|
633 dataReady = iMusTsyPropertyMonitor->IsDataReadyL(); |
|
634 EUNIT_ASSERT_EQUALS( dataReady, ETrue ) |
|
635 iMusTsyPropertyMonitor->iConferenceMonitor->iConfStatus = RMobileConferenceCall::EConferenceIdle; |
|
636 } |
|
637 |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // MusCallStateChanged from the MusCallStateObserver |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 void UT_CMusTsyPropertyMonitor::MusCallStateChanged() |
|
644 { |
|
645 // NOP |
|
646 } |
|
647 |
|
648 // TEST TABLE |
|
649 |
|
650 EUNIT_BEGIN_TEST_TABLE( |
|
651 UT_CMusTsyPropertyMonitor, |
|
652 "UT_CMusTsyPropertyMonitor", |
|
653 "UNIT" ) |
|
654 |
|
655 EUNIT_TEST( |
|
656 "RunL - test", |
|
657 "CMusTsyPropertyMonitor", |
|
658 "RunL", |
|
659 "FUNCTIONALITY", |
|
660 SetupL, UT_CMusTsyPropertyMonitor_RunLL, Teardown) |
|
661 |
|
662 EUNIT_TEST( |
|
663 "DoCancel - test", |
|
664 "CMusTsyPropertyMonitor", |
|
665 "DoCancel", |
|
666 "FUNCTIONALITY", |
|
667 SetupL, UT_CMusTsyPropertyMonitor_DoCancelL, Teardown) |
|
668 |
|
669 EUNIT_TEST( |
|
670 "RunError - test", |
|
671 "CMusTsyPropertyMonitor", |
|
672 "RunError", |
|
673 "FUNCTIONALITY", |
|
674 SetupL, UT_CMusTsyPropertyMonitor_RunErrorL, Teardown) |
|
675 |
|
676 EUNIT_TEST( |
|
677 "UT_CMusTsyPropertyMonitor_RemoveUnUsedCallMonitorsL", |
|
678 "CMusCallStatusMonitor", |
|
679 "RemoveUnUsedCallMonitors", |
|
680 "FUNCTIONALITY", |
|
681 SetupL, UT_CMusTsyPropertyMonitor_RemoveUnUsedCallMonitorsL, Teardown) |
|
682 |
|
683 EUNIT_TEST( |
|
684 "AddCallMonitorL - test", |
|
685 "CMusTsyPropertyMonitor", |
|
686 "AddCallMonitorL", |
|
687 "FUNCTIONALITY", |
|
688 SetupL, UT_CMusTsyPropertyMonitor_AddCallMonitorLL, Teardown) |
|
689 |
|
690 EUNIT_TEST( |
|
691 "RemoveCallMonitor - test", |
|
692 "CMusTsyPropertyMonitor", |
|
693 "RemoveCallMonitor", |
|
694 "FUNCTIONALITY", |
|
695 SetupL, UT_CMusTsyPropertyMonitor_RemoveCallMonitorL, Teardown) |
|
696 |
|
697 EUNIT_TEST( |
|
698 "MonitorCallL - test", |
|
699 "CMusTsyPropertyMonitor", |
|
700 "MonitorCallL", |
|
701 "FUNCTIONALITY", |
|
702 SetupL, UT_CMusTsyPropertyMonitor_MonitorCallLL, Teardown) |
|
703 |
|
704 EUNIT_TEST( |
|
705 "MonitorCsCallL - test", |
|
706 "CMusTsyPropertyMonitor", |
|
707 "MonitorCsCallL", |
|
708 "FUNCTIONALITY", |
|
709 SetupL, UT_CMusTsyPropertyMonitor_MonitorCSCallLL, Teardown) |
|
710 |
|
711 EUNIT_TEST( |
|
712 "MonitorVoipCallL - test", |
|
713 "CMusTsyPropertyMonitor", |
|
714 "MonitorVoipCallL", |
|
715 "FUNCTIONALITY", |
|
716 SetupL, UT_CMusTsyPropertyMonitor_MonitorVoipCallLL, Teardown) |
|
717 |
|
718 EUNIT_TEST( |
|
719 "CheckCallCriteriaL - test", |
|
720 "CMusTsyPropertyMonitor", |
|
721 "CheckCallCriteriaL", |
|
722 "FUNCTIONALITY", |
|
723 SetupL, UT_CMusTsyPropertyMonitor_CheckCallCriteriaLL, Teardown) |
|
724 |
|
725 EUNIT_TEST( |
|
726 "IsDataReadyL - test", |
|
727 "CMusTsyPropertyMonitor", |
|
728 "IsDataReadyL", |
|
729 "FUNCTIONALITY", |
|
730 SetupL, UT_CMusTsyPropertyMonitor_IsDataReadyLL, Teardown) |
|
731 |
|
732 EUNIT_END_TEST_TABLE |
|
733 |
|
734 // END OF FILE |
|
735 |
|
736 |