|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Main plugin class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ut_musaoplugin.h" |
|
20 #include "muscallmonitor.h" |
|
21 #include "musaoplugin.h" |
|
22 #include "mustsypropertymonitor.h" |
|
23 #include "musresourceproperties.h" |
|
24 #include "mussesseioninformationapi.h" |
|
25 #include "mussettings.inl" |
|
26 |
|
27 |
|
28 #include <alwaysonlinemanagercommon.h> |
|
29 #include <alwaysonlinemanagerclient.h> |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 #include <digia/eunit/eunitdecorators.h> |
|
32 |
|
33 #pragma warn_illtokenpasting off |
|
34 |
|
35 _LIT( KEmptyTelNumber, ""); |
|
36 _LIT( KEmptyProviderName, ""); |
|
37 |
|
38 _LIT(KTestTelNumber,"+3585050"); |
|
39 |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // Symbian two-phase constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 UT_CMusAoPlugin* UT_CMusAoPlugin::NewLC() |
|
46 { |
|
47 UT_CMusAoPlugin* self = new (ELeave) UT_CMusAoPlugin(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // C++ destructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 UT_CMusAoPlugin::~UT_CMusAoPlugin() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // C++ constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 UT_CMusAoPlugin::UT_CMusAoPlugin() |
|
68 : CEUnitTestSuiteClass() |
|
69 { |
|
70 } |
|
71 |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // Symbian second-phase constructor. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void UT_CMusAoPlugin::ConstructL() |
|
78 { |
|
79 CEUnitTestSuiteClass::ConstructL(); |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void UT_CMusAoPlugin::SetupL( ) |
|
88 { |
|
89 TInt keyValue = 0; |
|
90 MultimediaSharingSettings::SetPropertyValueL( |
|
91 MusSettingsKeys::KProductModeVariation,keyValue); |
|
92 iPlugin = CMusAoPlugin::NewL(); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void UT_CMusAoPlugin::Teardown( ) |
|
101 { |
|
102 delete iPlugin; |
|
103 iPlugin = NULL ; |
|
104 PropertyHelper::Close(); |
|
105 } |
|
106 |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void UT_CMusAoPlugin::DefinePropertiesLL() |
|
113 { |
|
114 /* Test 1 */ |
|
115 TInt res = KErrNone; |
|
116 TInt err = KErrNone; |
|
117 /* Set Product Mode variation key value to |
|
118 00 - VideoPlayer always available |
|
119 0-Keypad available dynamic |
|
120 00-Keypad Usuable in portrait |
|
121 0-Camera available static |
|
122 00-Usuable Always |
|
123 00000000 = 0 (Int) |
|
124 */ |
|
125 TInt keyValue = 0; |
|
126 MultimediaSharingSettings::SetPropertyValueL( |
|
127 MusSettingsKeys::KProductModeVariation,keyValue); |
|
128 iPlugin->DefinePropertiesL(); |
|
129 // It should not configure any PS keys for camera |
|
130 // Check the stub whether define is called. |
|
131 err = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
132 NMusResourceApi::KCameraAvailability, |
|
133 keyValue ); |
|
134 EUNIT_ASSERT(keyValue == KErrNotFound ); |
|
135 // Keypad availability is static . |
|
136 // Check the stub whether define is called. |
|
137 err = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
138 NMusResourceApi::KKeypadAvailability, |
|
139 keyValue ); |
|
140 |
|
141 EUNIT_ASSERT(keyValue == KErrNotFound ); |
|
142 |
|
143 iPlugin->DeleteProperties(); |
|
144 |
|
145 |
|
146 /* Test 2 */ |
|
147 |
|
148 /* Set Product Mode variation key value to |
|
149 11 - VideoPlayer always available |
|
150 1-Keypad available dynamic |
|
151 11-Keypad Usuable in portrait |
|
152 1-Camera available static |
|
153 11-Usuable Always |
|
154 11111111 = 255 (Int) |
|
155 */ |
|
156 keyValue = 255; |
|
157 MultimediaSharingSettings::SetPropertyValueL( |
|
158 MusSettingsKeys::KProductModeVariation,keyValue); |
|
159 PropertyHelper::SetErrorCode(KErrNone); |
|
160 iPlugin->DefinePropertiesL(); |
|
161 // It should configure any PS keys for Keypad |
|
162 // Check the stub whether define is called. |
|
163 err = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
164 NMusResourceApi::KKeypadAvailability, |
|
165 keyValue ); |
|
166 EUNIT_ASSERT(keyValue ==NMusResourceApi::ENotAvailable ); |
|
167 |
|
168 // camera availability is dynamic . |
|
169 // so it must define a property |
|
170 // Check the stub whether define is called. |
|
171 err = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
172 NMusResourceApi::KCameraAvailability, |
|
173 keyValue ); |
|
174 EUNIT_ASSERT(keyValue == NMusResourceApi::ENotAvailable ); |
|
175 iPlugin->DeleteProperties(); |
|
176 |
|
177 /* Test 3 */ |
|
178 |
|
179 iPlugin->DefinePropertiesL(); |
|
180 |
|
181 res = KErrNone; |
|
182 // camera information property |
|
183 res = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
184 NMusResourceApi::KCameraInformation, |
|
185 keyValue ); |
|
186 EUNIT_ASSERT_EQUALS( keyValue, NMusResourceApi::EUsePrimaryCamera ) |
|
187 |
|
188 // call event |
|
189 RProperty::Get(NMusSessionInformationApi::KCategoryUid, |
|
190 NMusSessionInformationApi::KMusCallEvent, |
|
191 keyValue ); |
|
192 EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::ENoCall ) |
|
193 |
|
194 // phone number |
|
195 TBuf<15> telnumber; // TODO change to des |
|
196 User::LeaveIfError( RProperty::Get( |
|
197 NMusSessionInformationApi::KCategoryUid, |
|
198 NMusSessionInformationApi::KMusTelNumber, |
|
199 telnumber ) ); |
|
200 EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone ) |
|
201 |
|
202 // callprovider |
|
203 TBuf<15> callprovider; |
|
204 User::LeaveIfError( RProperty::Get( |
|
205 NMusSessionInformationApi::KCategoryUid, |
|
206 NMusSessionInformationApi::KMUSCallProvider, |
|
207 callprovider ) ); |
|
208 EUNIT_ASSERT_EQUALS( callprovider.Compare( KEmptyProviderName ), KErrNone ) |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 // Mus allowed |
|
214 RProperty::Get(NMusSessionInformationApi::KCategoryUid, |
|
215 NMusSessionInformationApi::KMUSForbidden, |
|
216 keyValue ) ; |
|
217 EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::EMUSAllowed ) |
|
218 |
|
219 // Call direction |
|
220 RProperty::Get(NMusSessionInformationApi::KCategoryUid, |
|
221 NMusSessionInformationApi::KMusCallDirection, |
|
222 keyValue ) ; |
|
223 EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::ENoDirection ) |
|
224 |
|
225 } |
|
226 |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 void UT_CMusAoPlugin::DefinePropertyL_IntPropertyL() |
|
233 { |
|
234 // Normal succcesfull case |
|
235 const TInt KTestAvailability( 0x10282300 ); // Imaginary test value |
|
236 const TInt KTestValue = 50; // Imaginary test value |
|
237 iPlugin->DefinePropertyL( KTestAvailability, RProperty::EInt, KTestValue ); |
|
238 |
|
239 TInt keyValueInPS( 0 ); |
|
240 User::LeaveIfError( RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
241 KTestAvailability, |
|
242 keyValueInPS ) ); |
|
243 EUNIT_ASSERT_EQUALS( keyValueInPS, KTestValue ) |
|
244 |
|
245 // When trying to define existing property, we are not supposed to |
|
246 // overwrite already existing value |
|
247 const TInt KTestValue100 = 100; // Imaginary test value |
|
248 PropertyHelper::SetErrorCode( KErrAlreadyExists ); |
|
249 iPlugin->DefinePropertyL( KTestAvailability, |
|
250 RProperty::EInt, |
|
251 KTestValue100 ); |
|
252 PropertyHelper::SetErrorCode( KErrNone ); |
|
253 |
|
254 User::LeaveIfError( RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
255 KTestAvailability, |
|
256 keyValueInPS ) ); |
|
257 EUNIT_ASSERT_EQUALS( keyValueInPS, KTestValue ) // Value not changed |
|
258 } |
|
259 |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void UT_CMusAoPlugin::DefinePropertyL_DesCPropertyL() |
|
266 { |
|
267 // Normal succcesfull case |
|
268 const TInt KTestAvailability( 0x10282300 ); // Imaginary test value |
|
269 _LIT( KTestValue, "TestValue" ); // Imaginary test value |
|
270 iPlugin->DefinePropertyL( KTestAvailability, RProperty::EText, KTestValue ); |
|
271 |
|
272 TBuf<100> keyValueInPS( KNullDesC ); |
|
273 User::LeaveIfError( RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
274 KTestAvailability, |
|
275 keyValueInPS ) ); |
|
276 EUNIT_ASSERT_EQUALS( keyValueInPS, KTestValue ) |
|
277 |
|
278 // When trying to define existing property, we are not supposed to |
|
279 // overwrite already existing value |
|
280 _LIT( KNewTestValue, "NewTestValue" ); // Imaginary test value |
|
281 PropertyHelper::SetErrorCode( KErrAlreadyExists ); |
|
282 iPlugin->DefinePropertyL( KTestAvailability, |
|
283 RProperty::EText, |
|
284 KNewTestValue ); |
|
285 PropertyHelper::SetErrorCode( KErrNone ); |
|
286 |
|
287 User::LeaveIfError( RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
288 KTestAvailability, |
|
289 keyValueInPS ) ); |
|
290 EUNIT_ASSERT_EQUALS( keyValueInPS, KTestValue ) // Value not changed |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void UT_CMusAoPlugin::DeletePropertiesL() |
|
298 { |
|
299 // Initialize |
|
300 iPlugin->DefinePropertiesL(); |
|
301 // and delete all |
|
302 iPlugin->DeleteProperties(); |
|
303 |
|
304 TInt res = KErrNone; |
|
305 TInt ret = KErrNone; |
|
306 // camera availability |
|
307 ret = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
308 NMusResourceApi::KCameraAvailability, |
|
309 res ); |
|
310 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
311 ret = KErrNone; |
|
312 |
|
313 |
|
314 // keybad availability |
|
315 ret = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
316 NMusResourceApi::KKeypadAvailability, |
|
317 res ); |
|
318 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
319 ret = KErrNone; |
|
320 |
|
321 // videoplayer availability |
|
322 ret = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
323 NMusResourceApi::KVideoPlayerAvailability, |
|
324 res ); |
|
325 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
326 ret = KErrNone; |
|
327 |
|
328 // camera information property |
|
329 ret = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
330 NMusResourceApi::KCameraInformation, |
|
331 res ); |
|
332 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
333 ret = KErrNone; |
|
334 |
|
335 // call event |
|
336 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
337 NMusSessionInformationApi::KMusCallEvent, |
|
338 res ); |
|
339 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
340 ret = KErrNone; |
|
341 |
|
342 // phone number |
|
343 /* hard to provide stub impl |
|
344 TBuf<15> telnumber; // TODO change to des |
|
345 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
346 NMusSessionInformationApi::KMusTelNumber, |
|
347 telnumber ); |
|
348 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
349 */ |
|
350 |
|
351 ret = KErrNone; |
|
352 |
|
353 // Mus allowed |
|
354 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
355 NMusSessionInformationApi::KMUSForbidden, |
|
356 res ); |
|
357 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
358 ret = KErrNone; |
|
359 |
|
360 // Call direction |
|
361 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
362 NMusSessionInformationApi::KMusCallDirection, |
|
363 res ); |
|
364 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
365 |
|
366 } |
|
367 |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 void UT_CMusAoPlugin::UT_HandleServerCommandLL() |
|
374 { |
|
375 TAny* a = iPlugin->HandleServerCommandL( EAOManagerPluginStart, NULL ); |
|
376 EUNIT_ASSERT( a ) |
|
377 } |
|
378 |
|
379 |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // Test Starting MushClient |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 |
|
386 void UT_CMusAoPlugin::UT_StartMusClientL() |
|
387 { |
|
388 // Ensure MushAO Plugin Exisit |
|
389 EUNIT_ASSERT( iPlugin); |
|
390 // Mush Manager Client process is not Created |
|
391 EUNIT_ASSERT( !iPlugin->iManager ); |
|
392 |
|
393 // Test1: Ensure Start really creates the MushClient process |
|
394 iPlugin->StartMusClientL(); |
|
395 EUNIT_ASSERT( iPlugin->iManager ); |
|
396 |
|
397 // Test2: Trying to Create Client process again if it already exisit. |
|
398 iPlugin->StartMusClientL(); |
|
399 EUNIT_ASSERT( iPlugin->iManager ); |
|
400 |
|
401 //Reset Plugin Data. |
|
402 iPlugin->StopMusClient(); |
|
403 } |
|
404 |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // Test Starting MushClient |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 |
|
411 void UT_CMusAoPlugin::UT_StopMusClientL() |
|
412 { |
|
413 EUNIT_ASSERT( iPlugin); |
|
414 EUNIT_ASSERT( !iPlugin->iManager ); |
|
415 |
|
416 // Test1: Deleteing Mush Cient when it does not exisit |
|
417 iPlugin->StopMusClient(); |
|
418 EUNIT_ASSERT( !iPlugin->iManager ); |
|
419 |
|
420 // Create Mush Client process |
|
421 iPlugin->StartMusClientL(); |
|
422 EUNIT_ASSERT( iPlugin->iManager ); |
|
423 |
|
424 // Test2: Deleting Mush Client when it Exisit. |
|
425 iPlugin->StopMusClient(); |
|
426 EUNIT_ASSERT( !iPlugin->iManager ); |
|
427 } |
|
428 |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // From MMusCallStateObserver |
|
432 // Test MushCall State Changed |
|
433 // ----------------------------------------------------------------------------- |
|
434 // |
|
435 |
|
436 void UT_CMusAoPlugin::UT_MusCallStateChangedL() |
|
437 { |
|
438 TName cs_call_1(_L("cs_call_1")); |
|
439 |
|
440 // Test 1: Data Ready: Call Connected: -> Start Mush |
|
441 |
|
442 // Add Some dummy CS Call |
|
443 // Set Call Connected: |
|
444 // Set the Required Data. |
|
445 iPlugin->iTsyPropertyMonitor->AddCallMonitorL( cs_call_1); |
|
446 |
|
447 User::LeaveIfError(RProperty::Set( |
|
448 NMusSessionInformationApi::KCategoryUid, |
|
449 NMusSessionInformationApi::KMusCallEvent, |
|
450 NMusSessionInformationApi::ECallConnected )); |
|
451 |
|
452 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
453 NMusSessionInformationApi::KMusTelNumber, |
|
454 KTestTelNumber )); |
|
455 |
|
456 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
457 NMusSessionInformationApi::KMusCallDirection, |
|
458 NMusSessionInformationApi::ECallOrginated )); |
|
459 |
|
460 // This can not be tested easily wit M-ALLOC |
|
461 EUNIT_DISABLE_ALLOC_DECORATOR; |
|
462 iPlugin->MusCallStateChanged(); |
|
463 |
|
464 EUNIT_ASSERT( iPlugin->iManager ) |
|
465 EUNIT_ENABLE_ALLOC_DECORATOR; |
|
466 |
|
467 // Test 2: Data Not Ready: Call Connected: -> Stop Mush |
|
468 User::LeaveIfError(RProperty::Set( |
|
469 NMusSessionInformationApi::KCategoryUid, |
|
470 NMusSessionInformationApi::KMusCallEvent, |
|
471 NMusSessionInformationApi::ENoCall )); |
|
472 |
|
473 iPlugin->MusCallStateChanged(); |
|
474 EUNIT_ASSERT( !iPlugin->iManager ) |
|
475 } |
|
476 |
|
477 // TEST TABLE |
|
478 |
|
479 EUNIT_BEGIN_TEST_TABLE( |
|
480 UT_CMusAoPlugin, |
|
481 "UT_CMusAoPlugin", |
|
482 "UNIT") |
|
483 |
|
484 EUNIT_TEST( |
|
485 "DefinePropertiesLL", |
|
486 "CMusAoPlugin", |
|
487 "DefinePropertiesL", |
|
488 "FUNCTIONALITY", |
|
489 SetupL, DefinePropertiesLL, Teardown) |
|
490 |
|
491 EUNIT_TEST( |
|
492 "DefinePropertyL (int param)", |
|
493 "CMusAoPlugin", |
|
494 "DefinePropertyL", |
|
495 "FUNCTIONALITY", |
|
496 SetupL, DefinePropertyL_IntPropertyL, Teardown) |
|
497 |
|
498 EUNIT_TEST( |
|
499 "DefinePropertyL (desc param)", |
|
500 "CMusAoPlugin", |
|
501 "DefinePropertyL", |
|
502 "FUNCTIONALITY", |
|
503 SetupL, DefinePropertyL_DesCPropertyL, Teardown) |
|
504 |
|
505 EUNIT_TEST( |
|
506 "DeleteProperties", |
|
507 "CMusAoPlugin", |
|
508 "DeleteProperties", |
|
509 "FUNCTIONALITY", |
|
510 SetupL, DeletePropertiesL, Teardown) |
|
511 |
|
512 EUNIT_TEST( |
|
513 "HandleServerCommandL", |
|
514 "CMusAoPlugin", |
|
515 "HandleServerCommandL", |
|
516 "FUNCTIONALITY", |
|
517 SetupL, UT_HandleServerCommandLL, Teardown) |
|
518 |
|
519 EUNIT_TEST( |
|
520 "StartMusClient", |
|
521 "CMusAoPlugin", |
|
522 "StartMusClient", |
|
523 "FUNCTIONALITY", |
|
524 SetupL, UT_StartMusClientL, Teardown) |
|
525 |
|
526 EUNIT_TEST( |
|
527 "StopMusClient", |
|
528 "CMusAoPlugin", |
|
529 "StopMusClient", |
|
530 "FUNCTIONALITY", |
|
531 SetupL, UT_StopMusClientL, Teardown) |
|
532 |
|
533 EUNIT_TEST( |
|
534 "MusCallStateChanged", |
|
535 "CMusAoPlugin", |
|
536 "MusCallStateChanged", |
|
537 "FUNCTIONALITY", |
|
538 SetupL, UT_MusCallStateChangedL, Teardown) |
|
539 |
|
540 |
|
541 EUNIT_END_TEST_TABLE |