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