116 void UT_CMusManagerServerCore::SetupL() |
118 void UT_CMusManagerServerCore::SetupL() |
117 { |
119 { |
118 iCore = CMusManagerServerCore::NewL( *this ); |
120 iCore = CMusManagerServerCore::NewL( *this ); |
119 iStopServerCalled = EFalse; |
121 iStopServerCalled = EFalse; |
120 iAvailabilityChangedLCalled = EFalse; |
122 iAvailabilityChangedLCalled = EFalse; |
121 iSessionCount = 0; |
123 iSessionCount = 0; |
122 TApaTask::iApaTaskCalledFunction = TApaTask::ENone; |
|
123 } |
124 } |
124 |
125 |
125 |
126 |
126 // --------------------------------------------------------------------------- |
127 // --------------------------------------------------------------------------- |
127 // Finalizes test by deleting instance of tested class. |
128 // Finalizes test by deleting instance of tested class. |
128 // --------------------------------------------------------------------------- |
129 // --------------------------------------------------------------------------- |
129 // |
130 // |
130 void UT_CMusManagerServerCore::Teardown() |
131 void UT_CMusManagerServerCore::Teardown() |
131 { |
132 { |
132 delete iCore; |
133 delete iCore; |
133 PropertyHelper::Close(); |
134 PropertyHelper::Close(); |
|
135 Dll::FreeTls(); // Used by the RProcess and TFindProcess stubs |
134 } |
136 } |
135 |
137 |
136 |
138 |
137 // ======== TEST METHODS ======== |
139 // ======== TEST METHODS ======== |
138 |
140 |
188 // Asserts that invitation with inappropriate UID should leave. |
190 // Asserts that invitation with inappropriate UID should leave. |
189 // --------------------------------------------------------------------------- |
191 // --------------------------------------------------------------------------- |
190 // |
192 // |
191 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_InvitationReceivedLL() |
193 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_InvitationReceivedLL() |
192 { |
194 { |
|
195 // 1. The cases with MuS engine |
|
196 iCore->iPluginName = KMusEngineName; |
|
197 |
193 TUid uid = { 0x10101010 }; // Not a valid UID in musmanager.h |
198 TUid uid = { 0x10101010 }; // Not a valid UID in musmanager.h |
194 // since used UID is not in appropriate, this should leave |
199 // since used UID is not in appropriate, this should leave |
195 EUNIT_ASSERT_SPECIFIC_LEAVE( |
200 EUNIT_ASSERT_SPECIFIC_LEAVE( |
196 iCore->InvitationReceivedL( uid ), KErrNotReady ); |
201 iCore->InvitationReceivedL( uid ), KErrNotReady ); |
197 |
202 |
198 uid.iUid = 0x1028238D; // ESipInviteNotDesired from musmanager.h |
203 uid.iUid = 0x1028238D; // ESipInviteNotDesired from musmanager.h |
199 EUNIT_ASSERT_NO_LEAVE( iCore->InvitationReceivedL( uid ) ); |
204 iCore->InvitationReceivedL( uid ); |
200 |
205 |
201 uid.iUid = 0x10282391; // ESipInviteDesired from musmanager.h |
206 uid.iUid = 0x10282391; // ESipInviteDesired from musmanager.h |
202 EUNIT_ASSERT_SPECIFIC_LEAVE( |
207 EUNIT_ASSERT_SPECIFIC_LEAVE( |
203 iCore->InvitationReceivedL( uid ), KErrNotReady ); |
208 iCore->InvitationReceivedL( uid ), KErrNotReady ); |
|
209 |
|
210 // 2. The cases with non-MuS engine |
|
211 iCore->iPluginName = KAnotherEngineName; |
|
212 |
|
213 uid.iUid = 0x10101010; // Not a valid UID in musmanager.h |
|
214 iCore->InvitationReceivedL( uid ); |
|
215 |
|
216 uid.iUid = 0x1028238D; // ESipInviteNotDesired from musmanager.h |
|
217 iCore->InvitationReceivedL( uid ); |
|
218 |
|
219 uid.iUid = 0x10282391; // ESipInviteDesired from musmanager.h |
|
220 iCore->InvitationReceivedL( uid ); |
204 } |
221 } |
205 |
222 |
206 |
223 |
207 // --------------------------------------------------------------------------- |
224 // --------------------------------------------------------------------------- |
208 // Dummy test to increase execution coverage. |
225 // Dummy test to increase execution coverage. |
209 // --------------------------------------------------------------------------- |
226 // --------------------------------------------------------------------------- |
210 // |
227 // |
211 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_OptionsReceivedLL() |
228 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_OptionsReceivedLL() |
212 { |
229 { |
213 TUid uid = { 0x10101010 }; |
230 TUid uid = { 0x10101010 }; |
|
231 iCore->iPluginName = KMusEngineName; |
|
232 iCore->iPluginManager->iPluginStarted = EFalse; |
214 iCore->OptionsReceivedL( uid ); |
233 iCore->OptionsReceivedL( uid ); |
215 EUNIT_ASSERT( iCore->iPluginManager->iPluginStarted ); |
234 EUNIT_ASSERT( iCore->iPluginManager->iPluginStarted ); |
|
235 |
|
236 iCore->iPluginName = KAnotherEngineName; |
|
237 iCore->iPluginManager->iPluginStarted = EFalse; |
|
238 iCore->OptionsReceivedL( uid ); |
|
239 EUNIT_ASSERT ( !(iCore->iPluginManager->iPluginStarted) ); |
216 } |
240 } |
217 |
241 |
218 |
242 |
219 // --------------------------------------------------------------------------- |
243 // --------------------------------------------------------------------------- |
220 // Asserts that tested method does not leave. In certain case it could leave |
244 // Asserts that tested method does not leave. In certain case it could leave |
221 // with KErrPermissionDenied, but with this this test, used capabilities |
245 // with KErrPermissionDenied, but with this this test, used capabilities |
222 // and used stubs, tested method shouldn't leave. Checks also that |
246 // and used stubs, tested method shouldn't leave. |
223 // TApaTask function TaskExists is called. |
|
224 // --------------------------------------------------------------------------- |
247 // --------------------------------------------------------------------------- |
225 // |
248 // |
226 void UT_CMusManagerServerCore:: |
249 void UT_CMusManagerServerCore:: |
227 UT_CMusManagerServerCore_StartMultimediaSharingLL() |
250 UT_CMusManagerServerCore_StartMultimediaSharingLL() |
228 { |
251 { |
239 |
262 |
240 // ----------------------------------------------------------------------- |
263 // ----------------------------------------------------------------------- |
241 // Test for "if( !iApplicationManager->ApplicationRunning() && |
264 // Test for "if( !iApplicationManager->ApplicationRunning() && |
242 // iPluginManager->ApplicationAllowed() ) branch -> |
265 // iPluginManager->ApplicationAllowed() ) branch -> |
243 // ----------------------------------------------------------------------- |
266 // ----------------------------------------------------------------------- |
244 |
|
245 // CMusApplicationManager::ApplicationRunning = EFalse |
|
246 TApaTask::iApplicationExist = EFalse; |
|
247 |
|
248 // CMusAvailabilityPluginManager::ApplicationAllowed = ETrue |
267 // CMusAvailabilityPluginManager::ApplicationAllowed = ETrue |
249 abilityStub->iNameStub = MMusAvaObserver::EMusAvaNameRegistration; |
268 abilityStub->iNameStub = MMusAvaObserver::EMusAvaNameRegistration; |
250 abilityStub->iStatusStub = MMusAvaObserver::EMusAvaStatusAvailable; |
269 abilityStub->iStatusStub = MMusAvaObserver::EMusAvaStatusAvailable; |
251 interface2->iCurrentAvailability =MMusAvaObserver::EMusAvaOptionHandler; |
270 interface2->iCurrentAvailability =MMusAvaObserver::EMusAvaOptionHandler; |
252 |
271 |
261 |
280 |
262 // Should go all the way to StartApplicationL |
281 // Should go all the way to StartApplicationL |
263 MUS_EUNIT_ASSERT_NO_LEAVE( |
282 MUS_EUNIT_ASSERT_NO_LEAVE( |
264 iCore->StartMultimediaSharingL( MultimediaSharing::EMusLiveVideo ) ); |
283 iCore->StartMultimediaSharingL( MultimediaSharing::EMusLiveVideo ) ); |
265 EUNIT_ASSERT( PropertyHelper::GetCalledFunction() == RProperty::EDefine ); |
284 EUNIT_ASSERT( PropertyHelper::GetCalledFunction() == RProperty::EDefine ); |
266 EUNIT_ASSERT( TApaTask::iApaTaskCalledFunction == TApaTask::EExists ); |
|
267 |
285 |
268 // <- Test for "if( !iApplicationManager->ApplicationRunning() && |
286 // <- Test for "if( !iApplicationManager->ApplicationRunning() && |
269 // iPluginManager->ApplicationAllowed() ) branch |
287 // iPluginManager->ApplicationAllowed() ) branch |
270 |
288 |
271 // ----------------------------------------------------------------------- |
289 // ----------------------------------------------------------------------- |
277 abilityStub->iStatusStub = MMusAvaObserver::EMusAvaStatusNotExecuted; |
295 abilityStub->iStatusStub = MMusAvaObserver::EMusAvaStatusNotExecuted; |
278 interface2->iCurrentAvailability =MMusAvaObserver::EMusAvaNameRegistration; |
296 interface2->iCurrentAvailability =MMusAvaObserver::EMusAvaNameRegistration; |
279 |
297 |
280 |
298 |
281 // CMusApplicationManager::ApplicationRunning = EFalse |
299 // CMusApplicationManager::ApplicationRunning = EFalse |
282 TApaTask::iApplicationExist = EFalse; |
|
283 MUS_EUNIT_ASSERT_NO_LEAVE( |
300 MUS_EUNIT_ASSERT_NO_LEAVE( |
284 iCore->StartMultimediaSharingL( MultimediaSharing::EMusLiveVideo ) ); |
301 iCore->StartMultimediaSharingL( MultimediaSharing::EMusLiveVideo ) ); |
285 EUNIT_ASSERT( TApaTask::iApaTaskCalledFunction == TApaTask::EExists ); |
|
286 |
|
287 // <- Test for else branch |
|
288 } |
302 } |
289 |
303 |
290 |
304 |
291 // --------------------------------------------------------------------------- |
305 // --------------------------------------------------------------------------- |
292 // Asserts that tested method checks if task exists and calls |
306 // Asserts that tested method checks if task exists and calls |
294 // --------------------------------------------------------------------------- |
308 // --------------------------------------------------------------------------- |
295 // |
309 // |
296 void UT_CMusManagerServerCore:: |
310 void UT_CMusManagerServerCore:: |
297 UT_CMusManagerServerCore_StopMultimediaSharingLL() |
311 UT_CMusManagerServerCore_StopMultimediaSharingLL() |
298 { |
312 { |
299 TApaTask::iApplicationExist = EFalse; |
313 // MuS not running |
300 iCore->StopMultimediaSharingL(); |
314 iCore->StopMultimediaSharingL(); |
301 EUNIT_ASSERT( TApaTask::iApaTaskCalledFunction == TApaTask::EExists ) |
|
302 |
315 |
303 TApaTask::iApplicationExist = ETrue; |
316 // MuS running |
|
317 User::LeaveIfError( |
|
318 Dll::SetTls( reinterpret_cast< TAny* >( 1 ) ) ); |
|
319 // TLS is used by TFindProcess stub |
304 iCore->StopMultimediaSharingL(); |
320 iCore->StopMultimediaSharingL(); |
305 TInt availability = MultimediaSharing::EMultimediaSharingAvailable; |
321 TInt availability = MultimediaSharing::EMultimediaSharingAvailable; |
306 TUint key(NMusSessionApi::KStatus); |
322 TUint key( NMusSessionApi::KStatus ); |
307 RProperty::Get( key,availability); |
323 RProperty::Get( key, availability ); |
308 EUNIT_ASSERT_EQUALS( PropertyHelper::GetCalledFunction(), RProperty::EDefine ) |
324 EUNIT_ASSERT_EQUALS( PropertyHelper::GetCalledFunction(), RProperty::EDefine ) |
309 EUNIT_ASSERT_EQUALS( availability, |
325 EUNIT_ASSERT_EQUALS( availability, |
310 MultimediaSharing::EMultimediaSharingNotAvailable ) |
326 MultimediaSharing::EMultimediaSharingNotAvailable ) |
311 } |
327 } |
312 |
328 |
316 // called. |
332 // called. |
317 // --------------------------------------------------------------------------- |
333 // --------------------------------------------------------------------------- |
318 // |
334 // |
319 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_EventNoSessionsL() |
335 void UT_CMusManagerServerCore::UT_CMusManagerServerCore_EventNoSessionsL() |
320 { |
336 { |
|
337 iCore->iPluginName = KMusEngineName; |
|
338 iCore->iPluginManager->iPluginStarted = ETrue; |
321 iCore->EventNoSessions(); |
339 iCore->EventNoSessions(); |
|
340 EUNIT_ASSERT ( !(iCore->iPluginManager->iPluginStarted) ); |
|
341 EUNIT_ASSERT( iStopServerCalled ); |
|
342 |
|
343 iCore->iPluginName = KAnotherEngineName; |
|
344 iCore->iPluginManager->iPluginStarted = ETrue; |
|
345 iCore->EventNoSessions(); |
|
346 EUNIT_ASSERT ( iCore->iPluginManager->iPluginStarted ); |
322 EUNIT_ASSERT( iStopServerCalled ); |
347 EUNIT_ASSERT( iStopServerCalled ); |
323 } |
348 } |
324 |
349 |
325 |
350 |
326 // --------------------------------------------------------------------------- |
351 // --------------------------------------------------------------------------- |
347 // --------------------------------------------------------------------------- |
372 // --------------------------------------------------------------------------- |
348 // |
373 // |
349 void UT_CMusManagerServerCore:: |
374 void UT_CMusManagerServerCore:: |
350 UT_CMusManagerServerCore_AvailabilityChangedLL() |
375 UT_CMusManagerServerCore_AvailabilityChangedLL() |
351 { |
376 { |
|
377 iCore->iPluginName = KMusEngineName; |
352 MUS_EUNIT_ASSERT_NO_LEAVE( iCore->AvailabilityChangedL( |
378 MUS_EUNIT_ASSERT_NO_LEAVE( iCore->AvailabilityChangedL( |
353 (MultimediaSharing::TMusAvailabilityStatus) KErrNone ) ); |
379 (MultimediaSharing::TMusAvailabilityStatus) KErrNone ) ); |
354 |
|
355 EUNIT_ASSERT( iCore->iAvailabilityMonitors.Count() == 0 ); |
380 EUNIT_ASSERT( iCore->iAvailabilityMonitors.Count() == 0 ); |
356 |
381 |
|
382 iCore->iPluginName = KAnotherEngineName; |
|
383 MUS_EUNIT_ASSERT_NO_LEAVE( iCore->AvailabilityChangedL( |
|
384 (MultimediaSharing::TMusAvailabilityStatus) KErrNone ) ); |
|
385 EUNIT_ASSERT( iCore->iAvailabilityMonitors.Count() == 0 ); |
357 } |
386 } |
358 |
387 |
359 |
388 |
360 // --------------------------------------------------------------------------- |
389 // --------------------------------------------------------------------------- |
361 // Asserts that called method removes *this* monitor. |
390 // Asserts that called method removes *this* monitor. |