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 "ut_musengmceutils.h" |
|
21 #include "musengmceutils.h" |
|
22 #include "mussipprofilehandler.h" |
|
23 #include "musengstubs.h" |
|
24 #include "musengtestdefs.h" |
|
25 |
|
26 |
|
27 // SYSTEM INCLUDES |
|
28 #include <digia/eunit/eunitmacros.h> |
|
29 |
|
30 #include <mcemanager.h> |
|
31 #include <mceoutsession.h> |
|
32 #include <mcevideostream.h> |
|
33 #include <mceaudiostream.h> |
|
34 #include <mcertpsink.h> |
|
35 #include <mcedisplaysink.h> |
|
36 #include <mcecamerasource.h> |
|
37 #include <mcefilesource.h> |
|
38 #include <mcespeakersink.h> |
|
39 #include <mcertpsource.h> |
|
40 #include <mcefilesink.h> |
|
41 |
|
42 const TUint KSipProfileId( 1 ); |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 UT_MusEngMceUtils* UT_MusEngMceUtils::NewL() |
|
49 { |
|
50 UT_MusEngMceUtils* self = UT_MusEngMceUtils::NewLC(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 UT_MusEngMceUtils* UT_MusEngMceUtils::NewLC() |
|
61 { |
|
62 UT_MusEngMceUtils* self = new( ELeave ) UT_MusEngMceUtils(); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 UT_MusEngMceUtils::~UT_MusEngMceUtils() |
|
74 { |
|
75 // NOP |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Default constructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 UT_MusEngMceUtils::UT_MusEngMceUtils() |
|
84 { |
|
85 // NOP |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Second phase construct |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void UT_MusEngMceUtils::ConstructL() |
|
94 { |
|
95 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
96 // It generates the test case table. |
|
97 CEUnitTestSuiteClass::ConstructL(); |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // From MMusSipProfileUser |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TBool UT_MusEngMceUtils::IsRoamingBetweenAPsAllowed() |
|
106 { |
|
107 return ETrue; // Dummy implementation |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void UT_MusEngMceUtils::SetupL() |
|
116 { |
|
117 iManager = CMceManager::NewL( TUid::Null(), NULL ); |
|
118 iProfileHandler = CMusSipProfileHandler::NewL( *this ); |
|
119 |
|
120 iProfileHandler->CreateProfileL( KSipProfileId ); |
|
121 iEmptySession = CMceOutSession::NewL( *iManager, |
|
122 *iProfileHandler->Profile(), |
|
123 KTestRecipientSipUri8() ); |
|
124 |
|
125 // Contruct an outgoing video sesssion |
|
126 iVideoOutSession = CMceOutSession::NewL( *iManager, |
|
127 *iProfileHandler->Profile(), |
|
128 KTestRecipientSipUri8() ); |
|
129 |
|
130 |
|
131 CMceVideoStream* videoOut = CMceVideoStream::NewLC(); |
|
132 |
|
133 videoOut->AddSinkL( CMceRtpSink::NewLC() ); |
|
134 CleanupStack::Pop(); |
|
135 |
|
136 videoOut->AddSinkL( CMceDisplaySink::NewLC( *iManager ) ); |
|
137 CleanupStack::Pop(); |
|
138 |
|
139 videoOut->SetSourceL( CMceCameraSource::NewLC( *iManager ) ); |
|
140 CleanupStack::Pop(); |
|
141 |
|
142 iVideoOutSession->AddStreamL( videoOut ); |
|
143 CleanupStack::Pop( videoOut ); |
|
144 |
|
145 // Consruct a video session with incoming video and audio stream |
|
146 // Audio part |
|
147 iVideoInSession = CMceOutSession::NewL( *iManager, |
|
148 *iProfileHandler->Profile(), |
|
149 KTestRecipientSipUri8() ); |
|
150 |
|
151 CMceAudioStream* audioIn = CMceAudioStream::NewLC(); |
|
152 |
|
153 audioIn->AddSinkL( CMceSpeakerSink::NewLC() ); |
|
154 CleanupStack::Pop(); |
|
155 |
|
156 audioIn->SetSourceL( CMceRtpSource::NewLC() ); |
|
157 CleanupStack::Pop(); |
|
158 |
|
159 iVideoInSession->AddStreamL( audioIn ); |
|
160 CleanupStack::Pop( audioIn ); |
|
161 |
|
162 // Video part |
|
163 CMceVideoStream* videoIn = CMceVideoStream::NewLC(); |
|
164 |
|
165 videoIn->AddSinkL( CMceDisplaySink::NewLC( *iManager ) ); |
|
166 CleanupStack::Pop(); |
|
167 |
|
168 videoIn->SetSourceL( CMceRtpSource::NewLC() ); |
|
169 CleanupStack::Pop(); |
|
170 |
|
171 iVideoInSession->AddStreamL( videoIn ); |
|
172 CleanupStack::Pop( videoIn ); |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void UT_MusEngMceUtils::Teardown() |
|
181 { |
|
182 delete iEmptySession; |
|
183 delete iVideoOutSession; |
|
184 delete iVideoInSession; |
|
185 delete iProfileHandler; |
|
186 delete iManager; |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 // TEST CASES |
|
192 |
|
193 |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void UT_MusEngMceUtils::UT_MusEngMceUtils_IsVideoInStreamL() |
|
200 { |
|
201 // Stream 0 is audio stream |
|
202 EUNIT_ASSERT( !MusEngMceUtils::IsVideoInStream( |
|
203 *iVideoInSession->Streams()[0] ) ) |
|
204 |
|
205 // No source |
|
206 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
207 EUNIT_ASSERT( !MusEngMceUtils::IsVideoInStream( *videoStream ) ) |
|
208 CleanupStack::PopAndDestroy( videoStream ); |
|
209 |
|
210 // Camera source |
|
211 EUNIT_ASSERT( !MusEngMceUtils::IsVideoInStream( |
|
212 *iVideoOutSession->Streams()[0] ) ) |
|
213 |
|
214 // Video in stream |
|
215 EUNIT_ASSERT( MusEngMceUtils::IsVideoInStream( |
|
216 *iVideoInSession->Streams()[1] ) ) |
|
217 } |
|
218 |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void UT_MusEngMceUtils::UT_MusEngMceUtils_IsAudioInStreamL() |
|
225 { |
|
226 // Stream 0 is video stream |
|
227 EUNIT_ASSERT( !MusEngMceUtils::IsAudioInStream( |
|
228 *iVideoOutSession->Streams()[0] ) ) |
|
229 |
|
230 // No source |
|
231 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
232 EUNIT_ASSERT( !MusEngMceUtils::IsAudioInStream( *audioStream ) ) |
|
233 |
|
234 // File source |
|
235 audioStream->SetSourceL( CMceFileSource::NewLC( *iManager, KNullDesC() ) ); |
|
236 CleanupStack::Pop(); |
|
237 |
|
238 EUNIT_ASSERT( !MusEngMceUtils::IsAudioInStream( *audioStream ) ) |
|
239 CleanupStack::PopAndDestroy( audioStream ); |
|
240 |
|
241 // Audio in stream |
|
242 EUNIT_ASSERT( MusEngMceUtils::IsAudioInStream( |
|
243 *iVideoInSession->Streams()[0] ) ) |
|
244 } |
|
245 |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetVideoOutStreamLL() |
|
252 { |
|
253 // No streams, must fail |
|
254 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
255 MusEngMceUtils::GetVideoOutStreamL( *iEmptySession ), |
|
256 KErrNotFound ) |
|
257 |
|
258 // Add an audio out stream to empty sessionand and try again, still fails |
|
259 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
260 |
|
261 audioStream->AddSinkL( CMceRtpSink::NewLC() ); |
|
262 CleanupStack::Pop(); |
|
263 |
|
264 iEmptySession->AddStreamL( audioStream ); |
|
265 CleanupStack::Pop(audioStream); |
|
266 |
|
267 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
268 MusEngMceUtils::GetVideoOutStreamL( *iEmptySession ), |
|
269 KErrNotFound ) |
|
270 |
|
271 // Incoming video stream, fails |
|
272 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
273 MusEngMceUtils::GetVideoOutStreamL( *iVideoInSession ), |
|
274 KErrNotFound ) |
|
275 |
|
276 // One outgoing video stream, succeeds |
|
277 CMceVideoStream* videoStream = MusEngMceUtils::GetVideoOutStreamL( |
|
278 *iVideoOutSession ); |
|
279 EUNIT_ASSERT( videoStream ) |
|
280 EUNIT_ASSERT( videoStream->Type() == KMceVideo ) |
|
281 EUNIT_ASSERT( videoStream->Sinks().Count() == 2 ) // Rtp, Display |
|
282 EUNIT_ASSERT( videoStream->Sinks()[0]->Type() == KMceRTPSink ) |
|
283 EUNIT_ASSERT( videoStream->Sinks()[1]->Type() == KMceDisplaySink ) |
|
284 |
|
285 // Add another stream |
|
286 CMceVideoStream* videoOut = CMceVideoStream::NewLC(); |
|
287 |
|
288 videoOut->AddSinkL( CMceRtpSink::NewLC() ); |
|
289 CleanupStack::Pop(); |
|
290 |
|
291 videoOut->SetSourceL( CMceFileSource::NewLC( *iManager, |
|
292 KTestVideoFileName() ) ); |
|
293 CleanupStack::Pop(); |
|
294 |
|
295 iVideoOutSession->AddStreamL( videoOut ); |
|
296 CleanupStack::Pop( videoOut ); |
|
297 |
|
298 // Now there are two outgoing video streams, must fail |
|
299 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
300 MusEngMceUtils::GetVideoOutStreamL( *iVideoOutSession ), |
|
301 KErrOverflow ) |
|
302 } |
|
303 |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetVideoInStreamLL() |
|
310 { |
|
311 // No streams, must fail |
|
312 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
313 MusEngMceUtils::GetVideoInStreamL( *iEmptySession ), |
|
314 KErrNotFound ) |
|
315 |
|
316 // Outgoing video stream, fails |
|
317 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
318 MusEngMceUtils::GetVideoInStreamL( *iVideoOutSession ), |
|
319 KErrNotFound ) |
|
320 |
|
321 // Add stream without source and try again, still fails |
|
322 CMceVideoStream* newVideoStream = CMceVideoStream::NewLC(); |
|
323 iVideoOutSession->AddStreamL( newVideoStream ); |
|
324 CleanupStack::Pop( newVideoStream ); |
|
325 |
|
326 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
327 MusEngMceUtils::GetVideoInStreamL( *iVideoOutSession ), |
|
328 KErrNotFound ) |
|
329 |
|
330 // One incoming video stream, succeeds |
|
331 CMceVideoStream* videoStream = MusEngMceUtils::GetVideoInStreamL( |
|
332 *iVideoInSession ); |
|
333 |
|
334 EUNIT_ASSERT( videoStream ) |
|
335 EUNIT_ASSERT( videoStream->Type() == KMceVideo ) |
|
336 EUNIT_ASSERT( videoStream->Sinks().Count() == 1 ) // Display |
|
337 EUNIT_ASSERT( videoStream->Sinks()[0]->Type() == KMceDisplaySink ) |
|
338 EUNIT_ASSERT( videoStream->Source() ) |
|
339 EUNIT_ASSERT( videoStream->Source()->Type() == KMceRTPSource ) |
|
340 |
|
341 // Add another video in stream |
|
342 |
|
343 CMceVideoStream* videoIn = CMceVideoStream::NewLC(); |
|
344 |
|
345 videoIn->AddSinkL( CMceDisplaySink::NewLC( *iManager ) ); |
|
346 CleanupStack::Pop(); |
|
347 |
|
348 videoIn->SetSourceL( CMceRtpSource::NewLC() ); |
|
349 CleanupStack::Pop(); |
|
350 |
|
351 iVideoInSession->AddStreamL( videoIn ); |
|
352 CleanupStack::Pop( videoIn ); |
|
353 |
|
354 // Now there are two incoming video streams, must fail |
|
355 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
356 MusEngMceUtils::GetVideoInStreamL( *iVideoInSession ), |
|
357 KErrOverflow ) |
|
358 } |
|
359 |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetRecordingStreamL() |
|
366 { |
|
367 CMceVideoStream* recordingStream = |
|
368 MusEngMceUtils::GetRecordingStream( *iVideoInSession ); |
|
369 EUNIT_ASSERT( !recordingStream ) |
|
370 |
|
371 recordingStream = MusEngMceUtils::GetRecordingStream( *iVideoOutSession ); |
|
372 EUNIT_ASSERT( !recordingStream ) |
|
373 |
|
374 // Create recording stream |
|
375 CMceVideoStream* streamForRecording = CMceVideoStream::NewLC(); |
|
376 |
|
377 CMceFileSink* fileSink = CMceFileSink::NewLC( KTestVideoFileName() ); |
|
378 streamForRecording->AddSinkL( fileSink ); |
|
379 CleanupStack::Pop( fileSink ); |
|
380 |
|
381 iVideoOutSession->AddStreamL( streamForRecording ); |
|
382 CleanupStack::Pop( streamForRecording ); |
|
383 |
|
384 // Test that it is found |
|
385 recordingStream = MusEngMceUtils::GetRecordingStream( *iVideoOutSession ); |
|
386 EUNIT_ASSERT( recordingStream ) |
|
387 EUNIT_ASSERT( recordingStream == streamForRecording ) |
|
388 } |
|
389 |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // From stream |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkL() |
|
396 { |
|
397 CMceMediaSink* sink = MusEngMceUtils::GetMediaSink( |
|
398 *(iVideoInSession->Streams()[0]), |
|
399 KMceRTPSink ); |
|
400 EUNIT_ASSERT( !sink ) |
|
401 |
|
402 sink = MusEngMceUtils::GetMediaSink( *(iVideoOutSession->Streams()[0]), |
|
403 KMceRTPSink ); |
|
404 |
|
405 EUNIT_ASSERT( sink ) |
|
406 EUNIT_ASSERT( sink->Type() == KMceRTPSink ) |
|
407 |
|
408 } |
|
409 |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // From stream |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkLL() |
|
416 { |
|
417 CMceMediaSink* sink = NULL; |
|
418 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
419 MusEngMceUtils::GetMediaSinkL( *(iVideoInSession->Streams()[0]), |
|
420 KMceRTPSink ), |
|
421 KErrNotFound ) |
|
422 |
|
423 sink = MusEngMceUtils::GetMediaSinkL( *(iVideoOutSession->Streams()[0]), |
|
424 KMceRTPSink ); |
|
425 EUNIT_ASSERT( sink->Type() == KMceRTPSink ) |
|
426 } |
|
427 |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // From session |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSink2L() |
|
434 { |
|
435 CMceMediaSink* sink = MusEngMceUtils::GetMediaSink( *iEmptySession, |
|
436 KMceRTPSink ); |
|
437 EUNIT_ASSERT( !sink ) |
|
438 |
|
439 sink = MusEngMceUtils::GetMediaSink( *iVideoOutSession, KMceRTPSink ); |
|
440 |
|
441 EUNIT_ASSERT( sink ) |
|
442 EUNIT_ASSERT( sink->Type() == KMceRTPSink ) |
|
443 } |
|
444 |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // From session |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkL2L() |
|
451 { |
|
452 CMceMediaSink* sink = NULL; |
|
453 EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetMediaSinkL( *iEmptySession, |
|
454 KMceRTPSink ), |
|
455 KErrNotFound ) |
|
456 |
|
457 sink = MusEngMceUtils::GetMediaSinkL( *iVideoOutSession, KMceRTPSink ); |
|
458 EUNIT_ASSERT( sink->Type() == KMceRTPSink ) |
|
459 } |
|
460 |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetCameraLL() |
|
467 { |
|
468 // empty session fails |
|
469 EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetCameraL( *iEmptySession ), |
|
470 KErrNotFound ) |
|
471 |
|
472 // succeed |
|
473 CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iVideoOutSession ); |
|
474 |
|
475 EUNIT_ASSERT( camera ) |
|
476 EUNIT_ASSERT( camera->Type() == KMceCameraSource ) |
|
477 |
|
478 // delete source from video out stream and try without it, fails |
|
479 iVideoOutSession->Streams()[0]->SetSourceL( NULL ); |
|
480 |
|
481 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
482 MusEngMceUtils::GetCameraL( *iVideoOutSession ), |
|
483 KErrNotFound ) |
|
484 |
|
485 // Add file source and try again, still fails |
|
486 iVideoOutSession->Streams()[0]->SetSourceL( |
|
487 CMceFileSource::NewLC( *iManager, KTestVideoFileName() ) ); |
|
488 CleanupStack::Pop(); |
|
489 |
|
490 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
491 MusEngMceUtils::GetCameraL( *iVideoOutSession ), |
|
492 KErrNotFound ) |
|
493 } |
|
494 |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetFileSourceLL() |
|
501 { |
|
502 // empty session fails |
|
503 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
504 MusEngMceUtils::GetFileSourceL( *iEmptySession ), |
|
505 KErrNotFound ) |
|
506 |
|
507 // delete source from video out stream and try without it, fails |
|
508 iVideoOutSession->Streams()[0]->SetSourceL( NULL ); |
|
509 |
|
510 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
511 MusEngMceUtils::GetFileSourceL( *iVideoOutSession ), |
|
512 KErrNotFound ) |
|
513 |
|
514 // Add camera source and try again, still fails |
|
515 iVideoOutSession->Streams()[0]->SetSourceL( |
|
516 CMceCameraSource::NewLC( *iManager ) ); |
|
517 CleanupStack::Pop(); |
|
518 |
|
519 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
520 MusEngMceUtils::GetFileSourceL( *iVideoOutSession ), |
|
521 KErrNotFound ) |
|
522 |
|
523 // Replace camera with file source, now succeeds |
|
524 iVideoOutSession->Streams()[0]->SetSourceL( |
|
525 CMceFileSource::NewLC( *iManager, KTestVideoFileName() ) ); |
|
526 CleanupStack::Pop(); |
|
527 |
|
528 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iVideoOutSession ); |
|
529 |
|
530 EUNIT_ASSERT( file ) |
|
531 EUNIT_ASSERT( file->Type() == KMceFileSource ) |
|
532 |
|
533 |
|
534 } |
|
535 |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetDisplayL() |
|
542 { |
|
543 CMceDisplaySink* display = MusEngMceUtils::GetDisplay( *iEmptySession ); |
|
544 |
|
545 EUNIT_ASSERT( !display ) |
|
546 |
|
547 display = MusEngMceUtils::GetDisplay( *iVideoOutSession ); |
|
548 |
|
549 EUNIT_ASSERT( display ) |
|
550 EUNIT_ASSERT( display->Type() == KMceDisplaySink ) |
|
551 } |
|
552 |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 void UT_MusEngMceUtils::UT_MusEngMceUtils_GetDisplayLL() |
|
559 { |
|
560 CMceDisplaySink* display = NULL; |
|
561 |
|
562 EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetDisplayL( *iEmptySession ), |
|
563 KErrNotFound ) |
|
564 |
|
565 display = MusEngMceUtils::GetDisplayL( *iVideoOutSession ); |
|
566 |
|
567 EUNIT_ASSERT( display ) |
|
568 EUNIT_ASSERT( display->Type() == KMceDisplaySink ) |
|
569 } |
|
570 |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void UT_MusEngMceUtils::UT_MusEngMceUtils_AddDisplayLL() |
|
577 { |
|
578 |
|
579 TRect rect( 110, 111, 112, 113 ); |
|
580 |
|
581 // Check that display cannot be added to audio stream |
|
582 |
|
583 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
584 EUNIT_ASSERT_SPECIFIC_LEAVE ( |
|
585 MusEngMceUtils::AddDisplayL( *audioStream, *iManager, rect ), |
|
586 KErrArgument ) |
|
587 CleanupStack::PopAndDestroy( audioStream ); |
|
588 |
|
589 // Check that display can be added to video stream |
|
590 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
591 |
|
592 MusEngMceUtils::AddDisplayL( *videoStream, *iManager, rect ); |
|
593 |
|
594 EUNIT_ASSERT_EQUALS( videoStream->Sinks().Count(), 1 ) |
|
595 EUNIT_ASSERT_EQUALS( videoStream->Sinks()[0]->Type(), KMceDisplaySink ) |
|
596 EUNIT_ASSERT( videoStream->Sinks()[0]->IsEnabled() ) |
|
597 |
|
598 // Check the rect |
|
599 CMceDisplaySink* display = |
|
600 static_cast<CMceDisplaySink*>(videoStream->Sinks()[0]); |
|
601 |
|
602 EUNIT_ASSERT_EQUALS( display->DisplayRectL(), rect ); |
|
603 |
|
604 // Enable display and check that another display is not added on request. |
|
605 // Still existing display must be enabled and new rect set |
|
606 display->EnableL(); |
|
607 TRect newRect( 115, 116, 117, 118 ); |
|
608 MusEngMceUtils::AddDisplayL( *videoStream, *iManager, newRect ); |
|
609 |
|
610 EUNIT_ASSERT_EQUALS( videoStream->Sinks().Count(), 1 ) |
|
611 EUNIT_ASSERT_EQUALS( videoStream->Sinks()[0]->Type(), KMceDisplaySink ) |
|
612 EUNIT_ASSERT( videoStream->Sinks()[0]->IsEnabled() ) |
|
613 |
|
614 EUNIT_ASSERT( videoStream->Sinks()[0] == display ) |
|
615 |
|
616 // Check that rect is still changed |
|
617 EUNIT_ASSERT_EQUALS( display->DisplayRectL(), newRect ); |
|
618 |
|
619 CleanupStack::PopAndDestroy( videoStream ); |
|
620 } |
|
621 |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 // ----------------------------------------------------------------------------- |
|
626 // |
|
627 void UT_MusEngMceUtils::UT_MusEngMceUtils_AddSpeakerLL() |
|
628 { |
|
629 // Check that speaker cannot be added to video stream |
|
630 |
|
631 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
632 EUNIT_ASSERT_SPECIFIC_LEAVE ( |
|
633 MusEngMceUtils::AddSpeakerL( *videoStream ), |
|
634 KErrArgument ) |
|
635 CleanupStack::PopAndDestroy( videoStream ); |
|
636 |
|
637 // Check that speaker can be added to audio stream |
|
638 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
639 |
|
640 MusEngMceUtils::AddSpeakerL( *videoStream ); |
|
641 |
|
642 EUNIT_ASSERT_EQUALS( audioStream->Sinks().Count(), 1 ) |
|
643 EUNIT_ASSERT_EQUALS( audioStream->Sinks()[0]->Type(), KMceSpeakerSink ) |
|
644 EUNIT_ASSERT( audioStream->Sinks()[0]->IsEnabled() ) |
|
645 |
|
646 // Enable speaker and check that another speaker is not added on request |
|
647 // Still existing speaker must be enabled |
|
648 CMceSpeakerSink* speaker = |
|
649 static_cast<CMceSpeakerSink*>(videoStream->Sinks()[0]); |
|
650 |
|
651 speaker->EnableL(); |
|
652 |
|
653 MusEngMceUtils::AddSpeakerL( *audioStream ); |
|
654 |
|
655 EUNIT_ASSERT_EQUALS( audioStream->Sinks().Count(), 1 ) |
|
656 EUNIT_ASSERT_EQUALS( audioStream->Sinks()[0]->Type(), KMceSpeakerSink ) |
|
657 EUNIT_ASSERT( audioStream->Sinks()[0]->IsEnabled() ) |
|
658 |
|
659 EUNIT_ASSERT( audioStream->Sinks()[0] == speaker ) |
|
660 |
|
661 CleanupStack::PopAndDestroy( audioStream ); |
|
662 } |
|
663 |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 // ----------------------------------------------------------------------------- |
|
668 // |
|
669 void UT_MusEngMceUtils::UT_MusEngMceUtils_DisableStreamLL() |
|
670 { |
|
671 CMceAudioStream* audioStream = CMceAudioStream::NewLC(); |
|
672 |
|
673 // Disable only stream |
|
674 EUNIT_ASSERT( audioStream->IsEnabled() ) |
|
675 MusEngMceUtils::DisableStreamL( *audioStream ); |
|
676 EUNIT_ASSERT( !audioStream->IsEnabled() ) |
|
677 |
|
678 audioStream->EnableL(); |
|
679 |
|
680 // Disable stream and source |
|
681 CMceRtpSource* rtpSource = CMceRtpSource::NewLC(); |
|
682 audioStream->SetSourceL( rtpSource ); |
|
683 CleanupStack::Pop( rtpSource ); |
|
684 |
|
685 EUNIT_ASSERT( audioStream->IsEnabled() ) |
|
686 EUNIT_ASSERT( rtpSource->IsEnabled() ) |
|
687 MusEngMceUtils::DisableStreamL( *audioStream ); |
|
688 EUNIT_ASSERT( !audioStream->IsEnabled() ) |
|
689 EUNIT_ASSERT( !rtpSource->IsEnabled() ) |
|
690 |
|
691 audioStream->EnableL(); |
|
692 rtpSource->EnableL(); |
|
693 |
|
694 // Disable stream, source and sinks |
|
695 CMceSpeakerSink* speaker = CMceSpeakerSink::NewLC(); |
|
696 audioStream->AddSinkL( speaker ); |
|
697 CleanupStack::Pop( speaker ); |
|
698 |
|
699 EUNIT_ASSERT( audioStream->IsEnabled() ) |
|
700 EUNIT_ASSERT( rtpSource->IsEnabled() ) |
|
701 EUNIT_ASSERT( speaker->IsEnabled() ) |
|
702 MusEngMceUtils::DisableStreamL( *audioStream ); |
|
703 EUNIT_ASSERT( !audioStream->IsEnabled() ) |
|
704 EUNIT_ASSERT( !rtpSource->IsEnabled() ) |
|
705 EUNIT_ASSERT( !speaker->IsEnabled() ) |
|
706 |
|
707 CleanupStack::PopAndDestroy( audioStream ); |
|
708 } |
|
709 |
|
710 |
|
711 |
|
712 // TEST TABLE |
|
713 |
|
714 EUNIT_BEGIN_TEST_TABLE( |
|
715 UT_MusEngMceUtils, |
|
716 "UT_MusEngMceUtils", |
|
717 "UNIT" ) |
|
718 |
|
719 EUNIT_TEST( |
|
720 "IsVideoInStream - test ", |
|
721 "MusEngMceUtils", |
|
722 "IsVideoInStream", |
|
723 "FUNCTIONALITY", |
|
724 SetupL, UT_MusEngMceUtils_IsVideoInStreamL, Teardown) |
|
725 |
|
726 EUNIT_TEST( |
|
727 "IsAudioInStream - test ", |
|
728 "MusEngMceUtils", |
|
729 "IsAudioInStream", |
|
730 "FUNCTIONALITY", |
|
731 SetupL, UT_MusEngMceUtils_IsAudioInStreamL, Teardown) |
|
732 |
|
733 EUNIT_TEST( |
|
734 "GetVideoOutStreamL - test ", |
|
735 "MusEngMceUtils", |
|
736 "GetVideoOutStreamL", |
|
737 "FUNCTIONALITY", |
|
738 SetupL, UT_MusEngMceUtils_GetVideoOutStreamLL, Teardown) |
|
739 |
|
740 EUNIT_TEST( |
|
741 "GetVideoInStreamL - test ", |
|
742 "MusEngMceUtils", |
|
743 "GetVideoInStreamL", |
|
744 "FUNCTIONALITY", |
|
745 SetupL, UT_MusEngMceUtils_GetVideoInStreamLL, Teardown) |
|
746 |
|
747 EUNIT_TEST( |
|
748 "GetRecordingStream - test ", |
|
749 "MusEngMceUtils", |
|
750 "GetRecordingStream", |
|
751 "FUNCTIONALITY", |
|
752 SetupL, UT_MusEngMceUtils_GetRecordingStreamL, Teardown) |
|
753 |
|
754 EUNIT_TEST( |
|
755 "GetMediaSink - test ", |
|
756 "MusEngMceUtils", |
|
757 "GetMediaSink", |
|
758 "FUNCTIONALITY", |
|
759 SetupL, UT_MusEngMceUtils_GetMediaSinkL, Teardown) |
|
760 |
|
761 EUNIT_TEST( |
|
762 "GetMediaSinkL - test ", |
|
763 "MusEngMceUtils", |
|
764 "GetMediaSinkL", |
|
765 "FUNCTIONALITY", |
|
766 SetupL, UT_MusEngMceUtils_GetMediaSinkLL, Teardown) |
|
767 |
|
768 EUNIT_TEST( |
|
769 "GetMediaSink2 - test ", |
|
770 "MusEngMceUtils", |
|
771 "GetMediaSink2", |
|
772 "FUNCTIONALITY", |
|
773 SetupL, UT_MusEngMceUtils_GetMediaSink2L, Teardown) |
|
774 |
|
775 EUNIT_TEST( |
|
776 "GetMediaSinkL2 - test ", |
|
777 "MusEngMceUtils", |
|
778 "GetMediaSinkL2", |
|
779 "FUNCTIONALITY", |
|
780 SetupL, UT_MusEngMceUtils_GetMediaSinkL2L, Teardown) |
|
781 |
|
782 EUNIT_TEST( |
|
783 "GetCameraL - test ", |
|
784 "MusEngMceUtils", |
|
785 "GetCameraL", |
|
786 "FUNCTIONALITY", |
|
787 SetupL, UT_MusEngMceUtils_GetCameraLL, Teardown) |
|
788 |
|
789 EUNIT_TEST( |
|
790 "GetFileSourceL - test ", |
|
791 "MusEngMceUtils", |
|
792 "GetFileSourceL", |
|
793 "FUNCTIONALITY", |
|
794 SetupL, UT_MusEngMceUtils_GetFileSourceLL, Teardown) |
|
795 |
|
796 EUNIT_TEST( |
|
797 "GetDisplay - test ", |
|
798 "MusEngMceUtils", |
|
799 "GetDisplay", |
|
800 "FUNCTIONALITY", |
|
801 SetupL, UT_MusEngMceUtils_GetDisplayL, Teardown) |
|
802 |
|
803 EUNIT_TEST( |
|
804 "GetDisplayL - test ", |
|
805 "MusEngMceUtils", |
|
806 "GetDisplayL", |
|
807 "FUNCTIONALITY", |
|
808 SetupL, UT_MusEngMceUtils_GetDisplayLL, Teardown) |
|
809 |
|
810 EUNIT_TEST( |
|
811 "AddDisplayL - test ", |
|
812 "MusEngMceUtils", |
|
813 "AddDisplayL", |
|
814 "FUNCTIONALITY", |
|
815 SetupL, UT_MusEngMceUtils_AddDisplayLL, Teardown) |
|
816 |
|
817 EUNIT_TEST( |
|
818 "AddSpeakerL - test ", |
|
819 "MusEngMceUtils", |
|
820 "AddSpeakerL", |
|
821 "FUNCTIONALITY", |
|
822 SetupL, UT_MusEngMceUtils_AddSpeakerLL, Teardown) |
|
823 |
|
824 EUNIT_TEST( |
|
825 "DisableStreamL - test ", |
|
826 "MusEngMceUtils", |
|
827 "DisableStreamL", |
|
828 "FUNCTIONALITY", |
|
829 SetupL, UT_MusEngMceUtils_DisableStreamLL, Teardown) |
|
830 |
|
831 |
|
832 EUNIT_END_TEST_TABLE |
|
833 |
|
834 // END OF FILE |
|
835 |
|
836 |
|