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_musenglivevideoplayer.h" |
|
21 #include "musenglivevideoplayer.h" |
|
22 #include "musengtestdefs.h" |
|
23 |
|
24 // SYSTEM INCLUDES |
|
25 #include <eunitmacros.h> |
|
26 #include <mceoutsession.h> |
|
27 #include <mcevideostream.h> |
|
28 #include <mcertpsink.h> |
|
29 #include <mcecamerasource.h> |
|
30 #include <mcefilesink.h> |
|
31 |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 UT_CMusEngLiveVideoPlayer* UT_CMusEngLiveVideoPlayer::NewL() |
|
38 { |
|
39 UT_CMusEngLiveVideoPlayer* self = UT_CMusEngLiveVideoPlayer::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 UT_CMusEngLiveVideoPlayer* UT_CMusEngLiveVideoPlayer::NewLC() |
|
49 { |
|
50 UT_CMusEngLiveVideoPlayer* self = new( ELeave ) UT_CMusEngLiveVideoPlayer(); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 UT_CMusEngLiveVideoPlayer::~UT_CMusEngLiveVideoPlayer() |
|
61 { |
|
62 // NOP |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // Default constructor |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 UT_CMusEngLiveVideoPlayer::UT_CMusEngLiveVideoPlayer() |
|
70 { |
|
71 // NOP |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // Second phase construct |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void UT_CMusEngLiveVideoPlayer::ConstructL() |
|
79 { |
|
80 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
81 // It generates the test case table. |
|
82 CEUnitTestSuiteClass::ConstructL(); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void UT_CMusEngLiveVideoPlayer::SetupL() |
|
90 { |
|
91 iMceSession = CMceOutSession::NewL(); |
|
92 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
93 CMceRtpSink* rtpsink = CMceRtpSink::NewLC(); |
|
94 videoStream->AddSinkL( rtpsink ); |
|
95 CleanupStack::Pop( rtpsink ); |
|
96 CMceCameraSource* camera = CMceCameraSource::NewLC(); |
|
97 iCameraHandler.InitializeL( *camera ); |
|
98 videoStream->SetSourceL( camera ); |
|
99 CleanupStack::Pop( camera ); |
|
100 iMceSession->AddStreamL( videoStream ); |
|
101 CleanupStack::Pop( videoStream ); |
|
102 |
|
103 iCameraHandler.SetSession( iMceSession ); |
|
104 iLiveVideoPlayer = |
|
105 CMusEngLiveVideoPlayer::NewL( |
|
106 iDisplayHandlerStub, |
|
107 iCameraHandler, |
|
108 iLcAudioControlStub ); |
|
109 iLiveVideoPlayer->SetMceSession( iMceSession ); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void UT_CMusEngLiveVideoPlayer::Teardown() |
|
117 { |
|
118 delete iLiveVideoPlayer; |
|
119 delete iMceSession; |
|
120 iLcAudioControlStub.Reset(); |
|
121 } |
|
122 |
|
123 |
|
124 |
|
125 // TEST CASES |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void UT_CMusEngLiveVideoPlayer::UT_NewLL() |
|
132 { |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void UT_CMusEngLiveVideoPlayer::UT_LcVideoPlayerStateL() |
|
140 { |
|
141 // iMceSession not set |
|
142 iLiveVideoPlayer->SetMceSession( NULL ); |
|
143 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
144 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
145 iLiveVideoPlayer->SetMceSession( iMceSession ); |
|
146 |
|
147 // Establish Session and simulate media playing. |
|
148 iMceSession->iState = CMceSession::EEstablished; |
|
149 for ( TInt i = 0; i < iMceSession->Streams().Count(); i++ ) |
|
150 { |
|
151 iMceSession->Streams()[i]->iState = CMceMediaStream::EStreaming; |
|
152 } |
|
153 |
|
154 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPlaying ), |
|
155 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
156 |
|
157 // Media streams unavailable |
|
158 iMceSession->Streams()[0]->iState = CMceMediaStream::EUninitialized; |
|
159 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
160 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
161 |
|
162 // All other stream states |
|
163 iMceSession->Streams()[0]->iState = CMceMediaStream::EInitialized; |
|
164 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EInit ), |
|
165 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
166 |
|
167 iMceSession->Streams()[0]->iState = CMceMediaStream::EBuffering; |
|
168 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EBuffering ), |
|
169 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
170 |
|
171 iMceSession->Streams()[0]->iState = CMceMediaStream::EIdle; |
|
172 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPaused ), |
|
173 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
174 |
|
175 iMceSession->Streams()[0]->iState = CMceMediaStream::EDisabled; |
|
176 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPaused ), |
|
177 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
178 |
|
179 iMceSession->Streams()[0]->iState = CMceMediaStream::EStreaming; |
|
180 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPlaying ), |
|
181 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
182 |
|
183 iMceSession->Streams()[0]->iState = CMceMediaStream::ENoResources; |
|
184 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
185 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
186 |
|
187 iMceSession->Streams()[0]->iState = CMceMediaStream::ETranscodingRequired; |
|
188 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
189 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
190 |
|
191 iMceSession->Streams()[0]->iState = CMceMediaStream::ETranscoding; |
|
192 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
193 TInt( iLiveVideoPlayer->LcVideoPlayerState() ) ) |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void UT_CMusEngLiveVideoPlayer::UT_LcPlayL() |
|
201 { |
|
202 // Play |
|
203 iLiveVideoPlayer->LcPlayL(); |
|
204 EUNIT_ASSERT( iLiveVideoPlayer->LcIsPlayingL() ); |
|
205 |
|
206 // Pause |
|
207 iLiveVideoPlayer->LcPauseL(); |
|
208 EUNIT_ASSERT( !iLiveVideoPlayer->LcIsPlayingL() ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void UT_CMusEngLiveVideoPlayer::UT_LcWindowL() |
|
216 { |
|
217 EUNIT_ASSERT( iLiveVideoPlayer->LcWindow() == iLiveVideoPlayer ) |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void UT_CMusEngLiveVideoPlayer::UT_LcCameraControlL() |
|
225 { |
|
226 EUNIT_ASSERT( iLiveVideoPlayer->LcCameraControl() == &iCameraHandler ) |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void UT_CMusEngLiveVideoPlayer::UT_LcSourceFileControlL() |
|
234 { |
|
235 EUNIT_ASSERT( iLiveVideoPlayer->LcSourceFileControl() == NULL ) |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 void UT_CMusEngLiveVideoPlayer::UT_LcDestinationFileControlL() |
|
243 { |
|
244 EUNIT_ASSERT( |
|
245 iLiveVideoPlayer->LcDestinationFileControl() == iLiveVideoPlayer ) |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void UT_CMusEngLiveVideoPlayer::UT_LcAudioControlL() |
|
253 { |
|
254 EUNIT_ASSERT( iLiveVideoPlayer->LcAudioControl() == &iLcAudioControlStub ) |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void UT_CMusEngLiveVideoPlayer::UT_LcZoomControlL() |
|
262 { |
|
263 EUNIT_ASSERT( iLiveVideoPlayer->LcZoomControl() == &iCameraHandler ) |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 void UT_CMusEngLiveVideoPlayer::UT_LcBrightnessControlL() |
|
271 { |
|
272 EUNIT_ASSERT( iLiveVideoPlayer->LcBrightnessControl() == &iCameraHandler ) |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 void UT_CMusEngLiveVideoPlayer::UT_EnableLcWindowL() |
|
280 { |
|
281 EUNIT_ASSERT( !iLiveVideoPlayer->IsLcWindowEnabled() ) |
|
282 |
|
283 // Enable |
|
284 iLiveVideoPlayer->EnableLcWindowL( ETrue ); |
|
285 EUNIT_ASSERT( iLiveVideoPlayer->IsLcWindowEnabled() ) |
|
286 |
|
287 // Disable |
|
288 iLiveVideoPlayer->EnableLcWindowL( EFalse ); |
|
289 EUNIT_ASSERT( !iLiveVideoPlayer->IsLcWindowEnabled() ) |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void UT_CMusEngLiveVideoPlayer::UT_LcWindowRectL() |
|
297 { |
|
298 TRect rect( 12, 34, 56, 78 ); |
|
299 iLiveVideoPlayer->SetLcWindowRectL( rect ); |
|
300 EUNIT_ASSERT( iLiveVideoPlayer->LcWindowRect() == rect ) |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void UT_CMusEngLiveVideoPlayer::UT_LcWindowOrientationL() |
|
308 { |
|
309 iLiveVideoPlayer->SetLcWindowOrientationL( MLcWindow::EPortrait ); |
|
310 EUNIT_ASSERT_EQUALS( TInt( MLcWindow::EPortrait ), |
|
311 TInt( iLiveVideoPlayer->LcWindowOrientationL() ) ) |
|
312 |
|
313 iLiveVideoPlayer->SetLcWindowOrientationL( MLcWindow::ELandscape ); |
|
314 EUNIT_ASSERT_EQUALS( TInt( MLcWindow::ELandscape ), |
|
315 TInt( iLiveVideoPlayer->LcWindowOrientationL() ) ) |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 void UT_CMusEngLiveVideoPlayer::UT_SetLcFileNameL() |
|
323 { |
|
324 EUNIT_ASSERT_EQUALS( KNullDesC(), iLiveVideoPlayer->LcFileName() ) |
|
325 |
|
326 _LIT( KFileName, "my_clip.format"); |
|
327 TFileName fileName( KFileName ); |
|
328 iLiveVideoPlayer->SetLcFileNameL( fileName ); |
|
329 EUNIT_ASSERT_EQUALS( fileName, iLiveVideoPlayer->LcFileName() ) |
|
330 } |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void UT_CMusEngLiveVideoPlayer::UT_LcRecordL() |
|
337 { |
|
338 // No MCE session |
|
339 iLiveVideoPlayer->SetMceSession( NULL ); |
|
340 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
341 iLiveVideoPlayer->LcRecordL( ETrue ), KErrNotReady ) |
|
342 |
|
343 // No file sink in the session |
|
344 iLiveVideoPlayer->SetMceSession( iMceSession ); |
|
345 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
346 iLiveVideoPlayer->LcRecordL( ETrue ), KErrNotReady ) |
|
347 |
|
348 // Record, not yet recording |
|
349 EUNIT_ASSERT( !iLiveVideoPlayer->LcIsRecording() ) |
|
350 CMceVideoStream* streamForRecording = CMceVideoStream::NewLC(); |
|
351 CMceFileSink* fileSink = CMceFileSink::NewLC( KTestVideoFileName() ); |
|
352 fileSink->DisableL(); |
|
353 streamForRecording->AddSinkL( fileSink ); |
|
354 CleanupStack::Pop( fileSink ); |
|
355 iMceSession->AddStreamL( streamForRecording ); |
|
356 CleanupStack::Pop( streamForRecording ); |
|
357 iLiveVideoPlayer->LcRecordL( ETrue ); |
|
358 EUNIT_ASSERT( iLiveVideoPlayer->LcIsRecording() ) |
|
359 |
|
360 // Record, already recording |
|
361 iLiveVideoPlayer->LcRecordL( ETrue ); |
|
362 EUNIT_ASSERT( iLiveVideoPlayer->LcIsRecording() ) |
|
363 |
|
364 // Stop recording |
|
365 iLiveVideoPlayer->LcRecordL( EFalse ); |
|
366 EUNIT_ASSERT( !iLiveVideoPlayer->LcIsRecording() ) |
|
367 |
|
368 // Stop recording, not anymore recording |
|
369 iLiveVideoPlayer->LcRecordL( EFalse ); |
|
370 EUNIT_ASSERT( !iLiveVideoPlayer->LcIsRecording() ) |
|
371 } |
|
372 |
|
373 |
|
374 // TEST TABLE |
|
375 |
|
376 EUNIT_BEGIN_TEST_TABLE( |
|
377 UT_CMusEngLiveVideoPlayer, |
|
378 "UT_CMusEngLiveVideoPlayer", |
|
379 "UNIT" ) |
|
380 |
|
381 EUNIT_TEST( |
|
382 "NewL - test ", |
|
383 "CMusEngLiveVideoPlayer", |
|
384 "NewL", |
|
385 "FUNCTIONALITY", |
|
386 SetupL, UT_NewLL, Teardown) |
|
387 |
|
388 EUNIT_TEST( |
|
389 "LcVideoPlayerState - test ", |
|
390 "CMusEngLiveVideoPlayer", |
|
391 "LcVideoPlayerState", |
|
392 "FUNCTIONALITY", |
|
393 SetupL, UT_LcVideoPlayerStateL, Teardown) |
|
394 |
|
395 EUNIT_TEST( |
|
396 "LcPlayL - test ", |
|
397 "CMusEngLiveVideoPlayer", |
|
398 "LcPlayL", |
|
399 "FUNCTIONALITY", |
|
400 SetupL, UT_LcPlayL, Teardown) |
|
401 |
|
402 EUNIT_TEST( |
|
403 "LcWindow - test ", |
|
404 "CMusEngLiveVideoPlayer", |
|
405 "LcWindow", |
|
406 "FUNCTIONALITY", |
|
407 SetupL, UT_LcWindowL, Teardown) |
|
408 |
|
409 EUNIT_TEST( |
|
410 "LcCameraControl - test ", |
|
411 "CMusEngLiveVideoPlayer", |
|
412 "LcCameraControl", |
|
413 "FUNCTIONALITY", |
|
414 SetupL, UT_LcCameraControlL, Teardown) |
|
415 |
|
416 EUNIT_TEST( |
|
417 "LcSourceFileControl - test ", |
|
418 "CMusEngLiveVideoPlayer", |
|
419 "LcSourceFileControl", |
|
420 "FUNCTIONALITY", |
|
421 SetupL, UT_LcSourceFileControlL, Teardown) |
|
422 |
|
423 EUNIT_TEST( |
|
424 "LcDestinationFileControl - test ", |
|
425 "CMusEngLiveVideoPlayer", |
|
426 "LcDestinationFileControl", |
|
427 "FUNCTIONALITY", |
|
428 SetupL, UT_LcDestinationFileControlL, Teardown) |
|
429 |
|
430 EUNIT_TEST( |
|
431 "LcAudioControl - test ", |
|
432 "CMusEngLiveVideoPlayer", |
|
433 "LcAudioControl", |
|
434 "FUNCTIONALITY", |
|
435 SetupL, UT_LcAudioControlL, Teardown) |
|
436 |
|
437 EUNIT_TEST( |
|
438 "LcZoomControl - test ", |
|
439 "CMusEngLiveVideoPlayer", |
|
440 "LcZoomControl", |
|
441 "FUNCTIONALITY", |
|
442 SetupL, UT_LcZoomControlL, Teardown) |
|
443 |
|
444 EUNIT_TEST( |
|
445 "LcBrightnessControl - test ", |
|
446 "CMusEngLiveVideoPlayer", |
|
447 "LcBrightnessControl", |
|
448 "FUNCTIONALITY", |
|
449 SetupL, UT_LcBrightnessControlL, Teardown) |
|
450 |
|
451 EUNIT_TEST( |
|
452 "EnableLcWindowL - test ", |
|
453 "CMusEngLiveVideoPlayer", |
|
454 "EnableLcWindowL", |
|
455 "FUNCTIONALITY", |
|
456 SetupL, UT_EnableLcWindowL, Teardown) |
|
457 |
|
458 EUNIT_TEST( |
|
459 "LcWindowRect - test ", |
|
460 "CMusEngLiveVideoPlayer", |
|
461 "LcWindowRect", |
|
462 "FUNCTIONALITY", |
|
463 SetupL, UT_LcWindowRectL, Teardown) |
|
464 |
|
465 EUNIT_TEST( |
|
466 "LcWindowOrientation - test ", |
|
467 "CMusEngLiveVideoPlayer", |
|
468 "LcWindowOrientation", |
|
469 "FUNCTIONALITY", |
|
470 SetupL, UT_LcWindowOrientationL, Teardown) |
|
471 |
|
472 EUNIT_TEST( |
|
473 "SetLcFileNameL - test ", |
|
474 "CMusEngLiveVideoPlayer", |
|
475 "SetLcFileNameL", |
|
476 "FUNCTIONALITY", |
|
477 SetupL, UT_SetLcFileNameL, Teardown) |
|
478 |
|
479 EUNIT_TEST( |
|
480 "LcRecordL - test ", |
|
481 "CMusEngLiveVideoPlayer", |
|
482 "LcRecordL", |
|
483 "FUNCTIONALITY", |
|
484 SetupL, UT_LcRecordL, Teardown) |
|
485 |
|
486 EUNIT_END_TEST_TABLE |
|
487 |
|
488 // END OF FILE |
|
489 |
|
490 |
|