26 |
26 |
27 |
27 |
28 #include <alwaysonlinemanagercommon.h> |
28 #include <alwaysonlinemanagercommon.h> |
29 #include <alwaysonlinemanagerclient.h> |
29 #include <alwaysonlinemanagerclient.h> |
30 #include <digia/eunit/eunitmacros.h> |
30 #include <digia/eunit/eunitmacros.h> |
31 #include "FeatMgr.h" |
31 #include <digia/eunit/eunitdecorators.h> |
32 |
|
33 |
|
34 |
32 |
35 #pragma warn_illtokenpasting off |
33 #pragma warn_illtokenpasting off |
36 |
34 |
37 _LIT( KEmptyTelNumber, ""); |
35 _LIT( KEmptyTelNumber, ""); |
|
36 _LIT( KEmptyProviderName, ""); |
|
37 |
|
38 _LIT(KTestTelNumber,"+3585050"); |
38 |
39 |
39 |
40 |
40 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
41 // Symbian two-phase constructor. |
42 // Symbian two-phase constructor. |
42 // ----------------------------------------------------------------------------- |
43 // ----------------------------------------------------------------------------- |
99 void UT_CMusAoPlugin::Teardown( ) |
100 void UT_CMusAoPlugin::Teardown( ) |
100 { |
101 { |
101 delete iPlugin; |
102 delete iPlugin; |
102 iPlugin = NULL ; |
103 iPlugin = NULL ; |
103 PropertyHelper::Close(); |
104 PropertyHelper::Close(); |
104 |
105 } |
105 } |
106 |
106 |
107 |
107 |
108 // ----------------------------------------------------------------------------- |
108 //// ----------------------------------------------------------------------------- |
109 // |
109 //// |
110 // ----------------------------------------------------------------------------- |
110 //// ----------------------------------------------------------------------------- |
111 // |
111 //// |
112 void UT_CMusAoPlugin::DefinePropertiesLL() |
112 void UT_CMusAoPlugin::NewLL() |
113 { |
113 { |
114 /* Test 1 */ |
114 |
|
115 TInt res = KErrNone; |
115 TInt res = KErrNone; |
116 TInt ret = KErrNone; |
116 TInt err = KErrNone; |
117 FeatureManager::MultimediaSharingNotSupported(); |
|
118 iPlugin->DeleteProperties(); |
|
119 delete iPlugin; |
|
120 iPlugin = NULL ; |
|
121 iPlugin = CMusAoPlugin::NewL(); |
|
122 EUNIT_ASSERT( iPlugin ); |
|
123 EUNIT_ASSERT( iPlugin->iTsyPropertyMonitor == NULL); |
|
124 EUNIT_ASSERT( iPlugin->iPropertyMonitor == NULL); |
|
125 // camera information property |
|
126 ret = RProperty::Get( NMusResourceApi::KCategoryUid, |
|
127 NMusResourceApi::KCameraInformation, |
|
128 res ); |
|
129 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
130 ret = KErrNone; |
|
131 |
|
132 // call event |
|
133 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
134 NMusSessionInformationApi::KMusCallEvent, |
|
135 res ); |
|
136 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
137 ret = KErrNone; |
|
138 |
|
139 // phone number |
|
140 TBuf<15> telnumber; // TODO change to des |
|
141 User::LeaveIfError( RProperty::Get( |
|
142 NMusSessionInformationApi::KCategoryUid, |
|
143 NMusSessionInformationApi::KMusTelNumber, |
|
144 telnumber ) ); |
|
145 EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone ) |
|
146 |
|
147 // Mus allowed |
|
148 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
149 NMusSessionInformationApi::KMUSForbidden, |
|
150 res ); |
|
151 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
152 ret = KErrNone; |
|
153 |
|
154 // Call direction |
|
155 ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
156 NMusSessionInformationApi::KMusCallDirection, |
|
157 res ); |
|
158 EUNIT_ASSERT_EQUALS( ret, KErrNotFound ) |
|
159 FeatureManager::MultimediaSharingSupported(); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void UT_CMusAoPlugin::DefinePropertiesLL() |
|
167 { |
|
168 /* Test 1 */ |
|
169 /* Set Product Mode variation key value to |
117 /* Set Product Mode variation key value to |
170 00 - VideoPlayer always available |
118 00 - VideoPlayer always available |
171 0-Keypad available dynamic |
119 0-Keypad available dynamic |
172 00-Keypad Usuable in portrait |
120 00-Keypad Usuable in portrait |
173 0-Camera available static |
121 0-Camera available static |
178 MultimediaSharingSettings::SetPropertyValueL( |
126 MultimediaSharingSettings::SetPropertyValueL( |
179 MusSettingsKeys::KProductModeVariation,keyValue); |
127 MusSettingsKeys::KProductModeVariation,keyValue); |
180 iPlugin->DefinePropertiesL(); |
128 iPlugin->DefinePropertiesL(); |
181 // It should not configure any PS keys for camera |
129 // It should not configure any PS keys for camera |
182 // Check the stub whether define is called. |
130 // Check the stub whether define is called. |
183 TInt err = RProperty::Get( NMusResourceApi::KCategoryUid, |
131 err = RProperty::Get( NMusResourceApi::KCategoryUid, |
184 NMusResourceApi::KCameraAvailability, |
132 NMusResourceApi::KCameraAvailability, |
185 keyValue ); |
133 keyValue ); |
186 EUNIT_ASSERT(keyValue == KErrNotFound ); |
134 EUNIT_ASSERT(keyValue == KErrNotFound ); |
187 // Keypad availability is static . |
135 // Keypad availability is static . |
188 // Check the stub whether define is called. |
136 // Check the stub whether define is called. |
248 NMusSessionInformationApi::KCategoryUid, |
197 NMusSessionInformationApi::KCategoryUid, |
249 NMusSessionInformationApi::KMusTelNumber, |
198 NMusSessionInformationApi::KMusTelNumber, |
250 telnumber ) ); |
199 telnumber ) ); |
251 EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone ) |
200 EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone ) |
252 |
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 |
253 // Mus allowed |
213 // Mus allowed |
254 RProperty::Get(NMusSessionInformationApi::KCategoryUid, |
214 RProperty::Get(NMusSessionInformationApi::KCategoryUid, |
255 NMusSessionInformationApi::KMUSForbidden, |
215 NMusSessionInformationApi::KMUSForbidden, |
256 keyValue ) ; |
216 keyValue ) ; |
257 EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::EMUSAllowed ) |
217 EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::EMUSAllowed ) |
421 { |
374 { |
422 TAny* a = iPlugin->HandleServerCommandL( EAOManagerPluginStart, NULL ); |
375 TAny* a = iPlugin->HandleServerCommandL( EAOManagerPluginStart, NULL ); |
423 EUNIT_ASSERT( a ) |
376 EUNIT_ASSERT( a ) |
424 } |
377 } |
425 |
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 } |
426 |
476 |
427 // TEST TABLE |
477 // TEST TABLE |
428 |
478 |
429 EUNIT_BEGIN_TEST_TABLE( |
479 EUNIT_BEGIN_TEST_TABLE( |
430 UT_CMusAoPlugin, |
480 UT_CMusAoPlugin, |
431 "UT_CMusAoPlugin", |
481 "UT_CMusAoPlugin", |
432 "UNIT") |
482 "UNIT") |
433 |
483 |
434 EUNIT_TEST( |
484 EUNIT_TEST( |
435 "UT_NewLL", |
|
436 "CMusAoPlugin", |
|
437 "NewL", |
|
438 "FUNCTIONALITY", |
|
439 SetupL, NewLL, Teardown) |
|
440 |
|
441 EUNIT_TEST( |
|
442 "DefinePropertiesLL", |
485 "DefinePropertiesLL", |
443 "CMusAoPlugin", |
486 "CMusAoPlugin", |
444 "DefinePropertiesL", |
487 "DefinePropertiesL", |
445 "FUNCTIONALITY", |
488 "FUNCTIONALITY", |
446 SetupL, DefinePropertiesLL, Teardown) |
489 SetupL, DefinePropertiesLL, Teardown) |
464 "CMusAoPlugin", |
507 "CMusAoPlugin", |
465 "DeleteProperties", |
508 "DeleteProperties", |
466 "FUNCTIONALITY", |
509 "FUNCTIONALITY", |
467 SetupL, DeletePropertiesL, Teardown) |
510 SetupL, DeletePropertiesL, Teardown) |
468 |
511 |
469 |
|
470 |
|
471 EUNIT_TEST( |
512 EUNIT_TEST( |
472 "HandleServerCommandL", |
513 "HandleServerCommandL", |
473 "CMusAoPlugin", |
514 "CMusAoPlugin", |
474 "HandleServerCommandL", |
515 "HandleServerCommandL", |
475 "FUNCTIONALITY", |
516 "FUNCTIONALITY", |
476 SetupL, UT_HandleServerCommandLL, Teardown) |
517 SetupL, UT_HandleServerCommandLL, Teardown) |
477 |
518 |
478 |
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 |
479 EUNIT_END_TEST_TABLE |
541 EUNIT_END_TEST_TABLE |
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|