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_mustsypropertymonitor.h" |
|
23 #include "mustsypropertymonitor.h" |
|
24 #include "mussettings.h" |
|
25 |
|
26 |
|
27 // SYSTEM INCLUDES |
|
28 #include <digia/eunit/eunitmacros.h> |
|
29 #include <CTSYDomainPSKeys.h> |
|
30 |
|
31 _LIT(KTelNo,"1234"); |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 UT_CMusTsyPropertyMonitor* UT_CMusTsyPropertyMonitor::NewL() |
|
39 { |
|
40 UT_CMusTsyPropertyMonitor* self = UT_CMusTsyPropertyMonitor::NewLC(); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 UT_CMusTsyPropertyMonitor* UT_CMusTsyPropertyMonitor::NewLC() |
|
51 { |
|
52 UT_CMusTsyPropertyMonitor* self = new( ELeave ) UT_CMusTsyPropertyMonitor(); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 UT_CMusTsyPropertyMonitor::~UT_CMusTsyPropertyMonitor() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Default constructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor() |
|
73 { |
|
74 // NOP |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Second phase construct |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void UT_CMusTsyPropertyMonitor::ConstructL() |
|
83 { |
|
84 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
85 // It generates the test case table. |
|
86 CEUnitTestSuiteClass::ConstructL(); |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void UT_CMusTsyPropertyMonitor::SetupL() |
|
95 { |
|
96 RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
97 NMusSessionInformationApi::KMusCallEvent, |
|
98 0 ); |
|
99 MultimediaSharingSettings::SetPropertyValueL( |
|
100 MusSettingsKeys::KPrivacyExchange, |
|
101 MusSettingsKeys::EPrivacy ); |
|
102 |
|
103 iMusTsyPropertyMonitor = CMusTsyPropertyMonitor::NewL( iPhone ); |
|
104 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateUninitialized; |
|
105 |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void UT_CMusTsyPropertyMonitor::Setup2L() |
|
113 { |
|
114 RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
115 NMusSessionInformationApi::KMusCallEvent, |
|
116 0 ); |
|
117 MultimediaSharingSettings::SetPropertyValueL( |
|
118 MusSettingsKeys::KPrivacyExchange, |
|
119 MusSettingsKeys::ENoPrivacy ); |
|
120 |
|
121 iMusTsyPropertyMonitor = CMusTsyPropertyMonitor::NewL( iPhone ); |
|
122 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateUninitialized; |
|
123 |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void UT_CMusTsyPropertyMonitor::Teardown() |
|
132 { |
|
133 delete iMusTsyPropertyMonitor; |
|
134 PropertyHelper::Close(); |
|
135 iPhone.Close(); |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 |
|
141 // TEST CASES |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_NewLL() |
|
148 { |
|
149 EUNIT_ASSERT( iMusTsyPropertyMonitor); |
|
150 EUNIT_ASSERT( MultimediaSharingSettings::PrivacySetting() );//feature is on by default |
|
151 EUNIT_ASSERT( iMusTsyPropertyMonitor->iClirMonitor ); |
|
152 |
|
153 MultimediaSharingSettings::SetPropertyValueL( MusSettingsKeys::KPrivacyExchange, |
|
154 MusSettingsKeys::ENoPrivacy ); |
|
155 delete iMusTsyPropertyMonitor; |
|
156 iMusTsyPropertyMonitor = NULL; |
|
157 |
|
158 iMusTsyPropertyMonitor = CMusTsyPropertyMonitor::NewL( iPhone ); |
|
159 EUNIT_ASSERT( !MultimediaSharingSettings::PrivacySetting() );//feature is on by default |
|
160 EUNIT_ASSERT( !iMusTsyPropertyMonitor->iClirMonitor ); |
|
161 |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RunLL() |
|
170 { |
|
171 EUNIT_ASSERT( iMusTsyPropertyMonitor); |
|
172 TInt val = KErrNone; |
|
173 |
|
174 iMusTsyPropertyMonitor->Cancel(); |
|
175 iMusTsyPropertyMonitor->RunL(); |
|
176 |
|
177 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
178 |
|
179 |
|
180 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateNone; |
|
181 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
182 |
|
183 iMusTsyPropertyMonitor->Cancel(); |
|
184 iMusTsyPropertyMonitor->RunL(); |
|
185 |
|
186 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
187 NMusSessionInformationApi::KMusCallEvent, |
|
188 val ); |
|
189 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
190 |
|
191 |
|
192 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateDisconnecting; |
|
193 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
194 |
|
195 iMusTsyPropertyMonitor->Cancel(); |
|
196 iMusTsyPropertyMonitor->RunL(); |
|
197 |
|
198 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
199 NMusSessionInformationApi::KMusCallEvent, |
|
200 val ); |
|
201 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
202 |
|
203 |
|
204 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateAnswering; |
|
205 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
206 |
|
207 iMusTsyPropertyMonitor->Cancel(); |
|
208 iMusTsyPropertyMonitor->RunL(); |
|
209 |
|
210 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
211 NMusSessionInformationApi::KMusCallEvent, |
|
212 val ); |
|
213 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
214 |
|
215 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateConnected; |
|
216 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
217 |
|
218 iMusTsyPropertyMonitor->Cancel(); |
|
219 iMusTsyPropertyMonitor->RunL(); |
|
220 |
|
221 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
222 NMusSessionInformationApi::KMusCallEvent, |
|
223 val ); |
|
224 EUNIT_ASSERT( val==NMusSessionInformationApi::ENoCall); |
|
225 |
|
226 iMusTsyPropertyMonitor->iPropertyEvent.iPValue = EPSCTsyCallStateHold; |
|
227 iMusTsyPropertyMonitor->SetStateL( NMusSessionInformationApi::ENoCall ); |
|
228 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
229 NMusSessionInformationApi::KMusCallCount, |
|
230 1 ) != KErrNone ) |
|
231 { |
|
232 User::Leave( KErrNoMemory ); |
|
233 } |
|
234 |
|
235 //simulate multicall scenario |
|
236 TName callName(_L("Voice1")); |
|
237 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
238 callName.Copy(_L("Voice2")); |
|
239 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
240 iMusTsyPropertyMonitor->Cancel(); |
|
241 iMusTsyPropertyMonitor->RunL(); |
|
242 // |
|
243 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
244 NMusSessionInformationApi::KMusCallEvent, |
|
245 val ); |
|
246 EUNIT_ASSERT( val==NMusSessionInformationApi::ECallHold); |
|
247 |
|
248 } |
|
249 |
|
250 |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_DoCancelL() |
|
257 { |
|
258 EUNIT_ASSERT( iMusTsyPropertyMonitor ); |
|
259 iMusTsyPropertyMonitor->Cancel(); |
|
260 EUNIT_ASSERT( PropertyHelper::GetCalledFunction() == |
|
261 RProperty::ECancel ) |
|
262 } |
|
263 |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RunErrorL() |
|
270 { |
|
271 EUNIT_ASSERT( iMusTsyPropertyMonitor ); |
|
272 TInt error = KErrNotFound; |
|
273 iMusTsyPropertyMonitor->RunError(error); |
|
274 } |
|
275 |
|
276 |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_AddCallMonitorLL() |
|
283 { |
|
284 TName name = KTelNo(); |
|
285 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
286 NMusSessionInformationApi::KMusCallCount, |
|
287 0 ) != KErrNone ) |
|
288 { |
|
289 User::Leave( KErrNoMemory ); |
|
290 } |
|
291 iMusTsyPropertyMonitor->AddCallMonitorL( name ); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RemoveCallMonitorL() |
|
299 { |
|
300 TName name = KTelNo(); |
|
301 iMusTsyPropertyMonitor->RemoveCallMonitor( name ); |
|
302 |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_MonitorCallLL() |
|
310 { |
|
311 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusIdle ); |
|
312 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
313 |
|
314 iMusTsyPropertyMonitor->MonitorCallL(); |
|
315 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
316 |
|
317 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusHangingUp ); |
|
318 |
|
319 iMusTsyPropertyMonitor->MonitorCallL(); |
|
320 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
321 |
|
322 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusConnected ); |
|
323 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
324 NMusSessionInformationApi::KMusCallCount, |
|
325 0 ) != KErrNone ) |
|
326 { |
|
327 User::Leave( KErrNoMemory ); |
|
328 } |
|
329 iMusTsyPropertyMonitor->MonitorCallL(); |
|
330 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
331 |
|
332 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusAnswering ); |
|
333 //already exist |
|
334 iMusTsyPropertyMonitor->MonitorCallL(); |
|
335 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
336 |
|
337 |
|
338 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusUnknown ); |
|
339 |
|
340 iMusTsyPropertyMonitor->MonitorCallL(); |
|
341 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
342 |
|
343 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusIdle ); |
|
344 iMusTsyPropertyMonitor->MonitorCallL(); |
|
345 |
|
346 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_MonitorCallL_2L() |
|
354 { |
|
355 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 0 ); |
|
356 EUNIT_ASSERT( !iMusTsyPropertyMonitor->iClirMonitor ); |
|
357 |
|
358 RTelHelper::SetCallStatus( (RMobileCall::TMobileCallStatus)RCall::EStatusConnected ); |
|
359 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
360 NMusSessionInformationApi::KMusCallCount, |
|
361 0 ) != KErrNone ) |
|
362 { |
|
363 User::Leave( KErrNoMemory ); |
|
364 } |
|
365 iMusTsyPropertyMonitor->MonitorCallL(); |
|
366 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count() == 1 ); |
|
367 |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 void UT_CMusTsyPropertyMonitor::UT_CMusTsyPropertyMonitor_RemoveUnUsedCallMonitorsL() |
|
375 { |
|
376 TName callName(_L("Voice1")); |
|
377 if ( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
378 NMusSessionInformationApi::KMusCallCount, |
|
379 0 ) != KErrNone ) |
|
380 { |
|
381 User::Leave( KErrNoMemory ); |
|
382 } |
|
383 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
384 callName.Copy(_L("Voice2")); |
|
385 iMusTsyPropertyMonitor->AddCallMonitorL( callName ); |
|
386 RTelHelper::SetCallStatus(RMobileCall::EStatusUnknown); |
|
387 iMusTsyPropertyMonitor->RemoveUnUsedCallMonitors(); |
|
388 EUNIT_ASSERT( iMusTsyPropertyMonitor->iCallMonitorArray.Count()==0 ); |
|
389 } |
|
390 |
|
391 |
|
392 |
|
393 // TEST TABLE |
|
394 |
|
395 EUNIT_BEGIN_TEST_TABLE( |
|
396 UT_CMusTsyPropertyMonitor, |
|
397 "UT_CMusTsyPropertyMonitor", |
|
398 "UNIT" ) |
|
399 |
|
400 |
|
401 EUNIT_TEST( |
|
402 "NewL - test", |
|
403 "CMusTsyPropertyMonitor", |
|
404 "NewL", |
|
405 "FUNCTIONALITY", |
|
406 SetupL, UT_CMusTsyPropertyMonitor_NewLL, Teardown) |
|
407 |
|
408 EUNIT_TEST( |
|
409 "RunL - test", |
|
410 "CMusTsyPropertyMonitor", |
|
411 "RunL", |
|
412 "FUNCTIONALITY", |
|
413 SetupL, UT_CMusTsyPropertyMonitor_RunLL, Teardown) |
|
414 |
|
415 EUNIT_TEST( |
|
416 "DoCancel - test", |
|
417 "CMusTsyPropertyMonitor", |
|
418 "DoCancel", |
|
419 "FUNCTIONALITY", |
|
420 SetupL, UT_CMusTsyPropertyMonitor_DoCancelL, Teardown) |
|
421 |
|
422 EUNIT_TEST( |
|
423 "RunError - test", |
|
424 "CMusTsyPropertyMonitor", |
|
425 "RunError", |
|
426 "FUNCTIONALITY", |
|
427 SetupL, UT_CMusTsyPropertyMonitor_RunErrorL, Teardown) |
|
428 |
|
429 EUNIT_TEST( |
|
430 "RemoveUnUsedCallMonitorsL", |
|
431 "CMusCallStatusMonitor", |
|
432 "RemoveUnUsedCallMonitors", |
|
433 "FUNCTIONALITY", |
|
434 SetupL, UT_CMusTsyPropertyMonitor_RemoveUnUsedCallMonitorsL, Teardown) |
|
435 |
|
436 EUNIT_TEST( |
|
437 "AddCallMonitorL - test", |
|
438 "CMusTsyPropertyMonitor", |
|
439 "AddCallMonitorL", |
|
440 "FUNCTIONALITY", |
|
441 SetupL, UT_CMusTsyPropertyMonitor_AddCallMonitorLL, Teardown) |
|
442 |
|
443 EUNIT_TEST( |
|
444 "RemoveCallMonitor - test", |
|
445 "CMusTsyPropertyMonitor", |
|
446 "RemoveCallMonitor", |
|
447 "FUNCTIONALITY", |
|
448 SetupL, UT_CMusTsyPropertyMonitor_RemoveCallMonitorL, Teardown) |
|
449 |
|
450 EUNIT_TEST( |
|
451 "MonitorCallL - test", |
|
452 "CMusTsyPropertyMonitor", |
|
453 "MonitorCallL", |
|
454 "FUNCTIONALITY", |
|
455 SetupL, UT_CMusTsyPropertyMonitor_MonitorCallLL, Teardown) |
|
456 |
|
457 EUNIT_TEST( |
|
458 "MonitorCallL no clir - test", |
|
459 "CMusTsyPropertyMonitor", |
|
460 "MonitorCallL", |
|
461 "FUNCTIONALITY", |
|
462 Setup2L, UT_CMusTsyPropertyMonitor_MonitorCallL_2L, Teardown) |
|
463 |
|
464 EUNIT_END_TEST_TABLE |
|
465 |
|
466 // END OF FILE |
|
467 |
|
468 |
|