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_musengclipvideoplayer.h" |
|
21 #include "musengtestdefs.h" |
|
22 #include "musengmceutils.h" |
|
23 #include "musengclipvideoplayer.h" |
|
24 #include "mceoutsession.h" |
|
25 #include "mcevideostream.h" |
|
26 #include "mcertpsink.h" |
|
27 #include "mcefilesource.h" |
|
28 #include "drmcommon.h" |
|
29 |
|
30 // SYSTEM INCLUDES |
|
31 #include <eunitmacros.h> |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 UT_CMusEngClipVideoPlayer* UT_CMusEngClipVideoPlayer::NewL() |
|
39 { |
|
40 UT_CMusEngClipVideoPlayer* self = UT_CMusEngClipVideoPlayer::NewLC(); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 UT_CMusEngClipVideoPlayer* UT_CMusEngClipVideoPlayer::NewLC() |
|
50 { |
|
51 UT_CMusEngClipVideoPlayer* self = new( ELeave ) UT_CMusEngClipVideoPlayer(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 UT_CMusEngClipVideoPlayer::~UT_CMusEngClipVideoPlayer() |
|
62 { |
|
63 // NOP |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Default constructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 UT_CMusEngClipVideoPlayer::UT_CMusEngClipVideoPlayer() |
|
71 { |
|
72 // NOP |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // Second phase construct |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void UT_CMusEngClipVideoPlayer::ConstructL() |
|
80 { |
|
81 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
82 // It generates the test case table. |
|
83 CEUnitTestSuiteClass::ConstructL(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void UT_CMusEngClipVideoPlayer::SetupL() |
|
91 { |
|
92 iMceSession = CMceOutSession::NewL(); |
|
93 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
94 CMceRtpSink* rtpsink = CMceRtpSink::NewLC(); |
|
95 videoStream->AddSinkL( rtpsink ); |
|
96 CleanupStack::Pop( rtpsink ); |
|
97 CMceFileSource* fileSource = |
|
98 CMceFileSource::NewLC( *iMceSession->iManager, KTestVideoFileName() ); |
|
99 fileSource->DisableL(); |
|
100 videoStream->SetSourceL( fileSource ); |
|
101 CleanupStack::Pop( fileSource ); |
|
102 iMceSession->AddStreamL( videoStream ); |
|
103 CleanupStack::Pop( videoStream ); |
|
104 iClipVideoPlayer = |
|
105 CMusEngClipVideoPlayer::NewL( |
|
106 iDisplayHandlerStub, |
|
107 iLcAudioControlStub ); |
|
108 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void UT_CMusEngClipVideoPlayer::Teardown() |
|
116 { |
|
117 delete iClipVideoPlayer; |
|
118 delete iMceSession; |
|
119 iLcAudioControlStub.Reset(); |
|
120 } |
|
121 |
|
122 |
|
123 // TEST CASES |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void UT_CMusEngClipVideoPlayer::UT_HasClipEndedL() |
|
130 { |
|
131 CMceSession* invalidMceSession = CMceOutSession::NewL(); |
|
132 CleanupStack::PushL( invalidMceSession ); |
|
133 |
|
134 // Try before establishing the session |
|
135 iClipVideoPlayer->SetMceSession( NULL ); |
|
136 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
137 |
|
138 // Try with session, but without video out stream |
|
139 iClipVideoPlayer->SetMceSession( invalidMceSession ); |
|
140 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
141 |
|
142 // Try with video out stream without source... |
|
143 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
144 videoStream->AddSinkL( CMceRtpSink::NewLC() ); |
|
145 CleanupStack::Pop(); |
|
146 invalidMceSession->AddStreamL( videoStream ); |
|
147 CleanupStack::Pop( videoStream ); |
|
148 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
149 |
|
150 // And with enabled source and stream |
|
151 CMceFileSource* fileSource = |
|
152 CMceFileSource::NewLC( |
|
153 *invalidMceSession->iManager, KTestVideoFileName() ); |
|
154 videoStream->SetSourceL( fileSource ); |
|
155 CleanupStack::Pop( fileSource ); |
|
156 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
157 |
|
158 // try with different position and duration |
|
159 fileSource->iPosition = 90; |
|
160 fileSource->iDuration = 111; |
|
161 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
162 |
|
163 // Disabled source |
|
164 fileSource->DisableL(); |
|
165 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
166 |
|
167 // Disabled stream |
|
168 videoStream->iState = CMceMediaStream::EDisabled; |
|
169 EUNIT_ASSERT( !iClipVideoPlayer->HasClipEnded() ) |
|
170 |
|
171 // and finaly try with "real" end of clip |
|
172 fileSource->iPosition = 0; |
|
173 fileSource->iDuration = 111; |
|
174 |
|
175 EUNIT_ASSERT( iClipVideoPlayer->HasClipEnded() ) |
|
176 |
|
177 CleanupStack::PopAndDestroy( invalidMceSession ); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 void UT_CMusEngClipVideoPlayer::UT_LcVideoPlayerStateL() |
|
185 { |
|
186 // iMceSession not set |
|
187 iClipVideoPlayer->SetMceSession( NULL ); |
|
188 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
189 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
190 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
191 |
|
192 // Establish Session and simulate media playing. |
|
193 iMceSession->iState = CMceSession::EEstablished; |
|
194 for ( TInt i = 0; i < iMceSession->Streams().Count(); i++ ) |
|
195 { |
|
196 iMceSession->Streams()[i]->iState = CMceMediaStream::EStreaming; |
|
197 } |
|
198 |
|
199 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPlaying ), |
|
200 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
201 |
|
202 // Media streams unavailable |
|
203 iMceSession->Streams()[0]->iState = CMceMediaStream::EUninitialized; |
|
204 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
205 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
206 |
|
207 // All other stream states |
|
208 iMceSession->Streams()[0]->iState = CMceMediaStream::EInitialized; |
|
209 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EInit ), |
|
210 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
211 |
|
212 iMceSession->Streams()[0]->iState = CMceMediaStream::EBuffering; |
|
213 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EBuffering ), |
|
214 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
215 |
|
216 iMceSession->Streams()[0]->iState = CMceMediaStream::EIdle; |
|
217 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPaused ), |
|
218 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
219 |
|
220 iMceSession->Streams()[0]->iState = CMceMediaStream::EDisabled; |
|
221 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPaused ), |
|
222 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
223 |
|
224 iMceSession->Streams()[0]->iState = CMceMediaStream::EStreaming; |
|
225 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EPlaying ), |
|
226 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
227 |
|
228 iMceSession->Streams()[0]->iState = CMceMediaStream::ENoResources; |
|
229 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
230 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
231 |
|
232 iMceSession->Streams()[0]->iState = CMceMediaStream::ETranscodingRequired; |
|
233 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
234 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
235 |
|
236 iMceSession->Streams()[0]->iState = CMceMediaStream::ETranscoding; |
|
237 EUNIT_ASSERT_EQUALS( TInt( MLcVideoPlayer::EUnavailable ), |
|
238 TInt( iClipVideoPlayer->LcVideoPlayerState() ) ) |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 void UT_CMusEngClipVideoPlayer::UT_LcPlayL() |
|
246 { |
|
247 // MCE session not set |
|
248 iClipVideoPlayer->SetMceSession( NULL ); |
|
249 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipVideoPlayer->LcPlayL(), KErrNotReady ) |
|
250 |
|
251 // File source does not exist |
|
252 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
253 iMceSession->Streams()[ 0 ]->SetSourceL( NULL ); |
|
254 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipVideoPlayer->LcPlayL(), KErrNotFound ) |
|
255 |
|
256 // Play |
|
257 CMceFileSource* fileSource = |
|
258 CMceFileSource::NewLC( *iMceSession->iManager, KTestVideoFileName() ); |
|
259 fileSource->DisableL(); |
|
260 iMceSession->Streams()[ 0 ]->SetSourceL( fileSource ); |
|
261 CleanupStack::Pop( fileSource ); |
|
262 EUNIT_ASSERT( !iClipVideoPlayer->LcIsPlayingL() ) |
|
263 iClipVideoPlayer->LcPlayL(); |
|
264 EUNIT_ASSERT( iClipVideoPlayer->LcIsPlayingL() ) |
|
265 |
|
266 // Try to play again |
|
267 iClipVideoPlayer->LcPlayL(); |
|
268 EUNIT_ASSERT( iClipVideoPlayer->LcIsPlayingL() ) |
|
269 } |
|
270 |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void UT_CMusEngClipVideoPlayer::UT_LcPauseL() |
|
277 { |
|
278 // MCE session not set |
|
279 iClipVideoPlayer->SetMceSession( NULL ); |
|
280 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipVideoPlayer->LcPauseL(), KErrNotReady ) |
|
281 |
|
282 // File source does not exist |
|
283 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
284 iMceSession->Streams()[ 0 ]->SetSourceL( NULL ); |
|
285 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipVideoPlayer->LcPauseL(), KErrNotFound ) |
|
286 |
|
287 // Pause |
|
288 CMceFileSource* fileSource = |
|
289 CMceFileSource::NewLC( *iMceSession->iManager, KTestVideoFileName() ); |
|
290 fileSource->EnableL(); |
|
291 iMceSession->Streams()[ 0 ]->SetSourceL( fileSource ); |
|
292 CleanupStack::Pop( fileSource ); |
|
293 EUNIT_ASSERT( iClipVideoPlayer->LcIsPlayingL() ) |
|
294 iClipVideoPlayer->LcPauseL(); |
|
295 EUNIT_ASSERT( !iClipVideoPlayer->LcIsPlayingL() ) |
|
296 |
|
297 // Try to pause already paused clip |
|
298 iClipVideoPlayer->LcPauseL(); |
|
299 EUNIT_ASSERT( !iClipVideoPlayer->LcIsPlayingL() ) |
|
300 } |
|
301 |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void UT_CMusEngClipVideoPlayer::UT_LcIsPlayingL() |
|
308 { |
|
309 // MCE session not set |
|
310 iClipVideoPlayer->SetMceSession( NULL ); |
|
311 EUNIT_ASSERT_SPECIFIC_LEAVE( iClipVideoPlayer->LcIsPlayingL(), KErrNotReady ) |
|
312 |
|
313 // Player is not playing when file source is disabled |
|
314 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
315 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
316 file->DisableL(); |
|
317 EUNIT_ASSERT( !iClipVideoPlayer->LcIsPlayingL() ) |
|
318 |
|
319 // Player is playing when file source is enabled |
|
320 file->EnableL(); |
|
321 EUNIT_ASSERT( iClipVideoPlayer->LcIsPlayingL() ) |
|
322 } |
|
323 |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 void UT_CMusEngClipVideoPlayer::UT_SetLcFileNameL() |
|
330 { |
|
331 // Set file before iMceSession is set |
|
332 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
333 iClipVideoPlayer->SetMceSession( NULL ); |
|
334 iClipVideoPlayer->SetLcFileNameL( KTestAvcVideoFileName() ); |
|
335 EUNIT_ASSERT_EQUALS( iClipVideoPlayer->LcFileName(), KTestAvcVideoFileName() ) |
|
336 EUNIT_ASSERT_EQUALS( file->iFileName, KTestVideoFileName() ) |
|
337 |
|
338 // Set file after session is set |
|
339 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
340 file->iFileName = KTestAvcVideoFileName(); |
|
341 iClipVideoPlayer->SetLcFileNameL( KTestVideoFileName() ); |
|
342 EUNIT_ASSERT_EQUALS( iClipVideoPlayer->LcFileName(), KTestVideoFileName() ) |
|
343 EUNIT_ASSERT_EQUALS( file->iFileName, KTestVideoFileName() ) |
|
344 |
|
345 // Set DRM protected file, file names not changed |
|
346 MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
347 iClipVideoPlayer->SetLcFileNameL( KMusDrmProtectedFileName() ), |
|
348 KErrPermissionDenied ) |
|
349 EUNIT_ASSERT_EQUALS( iClipVideoPlayer->LcFileName(), KTestVideoFileName() ) |
|
350 EUNIT_ASSERT_EQUALS( file->iFileName, KTestVideoFileName() ) |
|
351 } |
|
352 |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void UT_CMusEngClipVideoPlayer::UT_LcFastForwardL() |
|
359 { |
|
360 // Try before establishment |
|
361 iClipVideoPlayer->SetMceSession( NULL ); |
|
362 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
363 iClipVideoPlayer->LcFastForwardL( ETrue ), KErrNotReady ) |
|
364 |
|
365 // Establish session, simulate position and duration and try again |
|
366 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
367 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
368 file->iDuration = KMusEngTestFileDuration; |
|
369 file->iPosition = KMusEngTestFilePosition; |
|
370 iClipVideoPlayer->LcFastForwardL( ETrue ); |
|
371 EUNIT_ASSERT( !file->iIsEnabled ) |
|
372 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() > 0 ) |
|
373 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
374 |
|
375 // Simulate fastforwarding for a while |
|
376 User::After( 1000 ); |
|
377 |
|
378 // Try to fastforward when already fastforwarding, will be ignored |
|
379 iClipVideoPlayer->LcFastForwardL( ETrue ); |
|
380 EUNIT_ASSERT( !file->iIsEnabled ) |
|
381 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() > 0 ) |
|
382 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
383 |
|
384 // Stop fastforwarding |
|
385 iClipVideoPlayer->LcFastForwardL( EFalse ); |
|
386 EUNIT_ASSERT( file->iPosition > KMusEngTestFilePosition ) |
|
387 EUNIT_ASSERT( file->iPosition != file->iDuration ) |
|
388 EUNIT_ASSERT( !file->iIsEnabled ) |
|
389 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
390 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
391 |
|
392 // Try to stop fastforwarding again, leaves |
|
393 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
394 iClipVideoPlayer->LcFastForwardL( EFalse ), KErrAlreadyExists ) |
|
395 |
|
396 // Start fastrewinding |
|
397 iClipVideoPlayer->LcFastRewindL( ETrue ); |
|
398 EUNIT_ASSERT( !file->iIsEnabled ) |
|
399 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
400 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() > 0 ) |
|
401 |
|
402 // Start fastforwarding, rewinding should be stopped and FFWD started |
|
403 iClipVideoPlayer->LcFastForwardL( ETrue ); |
|
404 EUNIT_ASSERT( !file->iIsEnabled ) |
|
405 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() > 0 ) |
|
406 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
407 |
|
408 // Simulate fastforwarding for a while |
|
409 User::After( 1000 ); |
|
410 |
|
411 // Simulate that clip is almost in end and fastforwarding would have |
|
412 // continued over end, position should be set to duration. |
|
413 file->iPosition = TTimeIntervalMicroSeconds( file->iDuration.Int64() - 1 ); |
|
414 iClipVideoPlayer->LcFastForwardL( EFalse ); |
|
415 EUNIT_ASSERT( file->iPosition == file->iDuration ) |
|
416 EUNIT_ASSERT( !file->iIsEnabled ) |
|
417 EUNIT_ASSERT_EQUALS( 0, iClipVideoPlayer->iFFWDStartTime.Int64() ) |
|
418 EUNIT_ASSERT_EQUALS( 0, iClipVideoPlayer->iFRWDStartTime.Int64() ) |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 void UT_CMusEngClipVideoPlayer::UT_LcFastRewindL() |
|
426 { |
|
427 // Try before establishment |
|
428 iClipVideoPlayer->SetMceSession( NULL ); |
|
429 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
430 iClipVideoPlayer->LcFastRewindL( ETrue ), KErrNotReady ) |
|
431 |
|
432 // Establish session, simulate position and duration and try again |
|
433 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
434 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
435 file->iDuration = KMusEngTestFileDuration; |
|
436 file->iPosition = KMusEngTestFilePosition; |
|
437 iClipVideoPlayer->LcFastRewindL( ETrue ); |
|
438 EUNIT_ASSERT( !file->iIsEnabled ) |
|
439 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
440 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() > 0 ) |
|
441 |
|
442 // Simulate fastrewinding for a while |
|
443 User::After( 1000 ); |
|
444 |
|
445 // Try to fastrewind when already fastrewinding, will be ignored |
|
446 iClipVideoPlayer->LcFastRewindL( ETrue ); |
|
447 EUNIT_ASSERT( !file->iIsEnabled ) |
|
448 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
449 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() > 0 ) |
|
450 |
|
451 // Stop fastrewinding |
|
452 iClipVideoPlayer->LcFastRewindL( EFalse ); |
|
453 EUNIT_ASSERT( file->iPosition < KMusEngTestFilePosition ) |
|
454 EUNIT_ASSERT( file->iPosition != TTimeIntervalMicroSeconds( 0 ) ) |
|
455 EUNIT_ASSERT( !file->iIsEnabled ) |
|
456 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
457 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
458 |
|
459 // Try to stop fastrewinding again, leaves |
|
460 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
461 iClipVideoPlayer->LcFastRewindL( EFalse ), KErrAlreadyExists ) |
|
462 |
|
463 // Start fastforwarding |
|
464 iClipVideoPlayer->LcFastForwardL( ETrue ); |
|
465 EUNIT_ASSERT( !file->iIsEnabled ) |
|
466 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() >= 0 ) |
|
467 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
468 |
|
469 // Start fastrewinding, forwarding should be stopped and FFWD started |
|
470 iClipVideoPlayer->LcFastRewindL( ETrue ); |
|
471 EUNIT_ASSERT( !file->iIsEnabled ); |
|
472 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
473 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() >= 0 ) |
|
474 |
|
475 // Simulate that clip has just begun and fastrewinding would have |
|
476 // continued over beginning, position should be set to zero. |
|
477 |
|
478 file->iPosition = TTimeIntervalMicroSeconds( 1 ); |
|
479 |
|
480 // Simulate fastrewinding for a while |
|
481 User::After( 1000 ); |
|
482 |
|
483 iClipVideoPlayer->LcFastRewindL( EFalse ); |
|
484 EUNIT_ASSERT( file->iPosition == TTimeIntervalMicroSeconds( 0 ) ) |
|
485 EUNIT_ASSERT( !file->iIsEnabled ) |
|
486 EUNIT_ASSERT( iClipVideoPlayer->iFFWDStartTime.Int64() == 0 ) |
|
487 EUNIT_ASSERT( iClipVideoPlayer->iFRWDStartTime.Int64() == 0 ) |
|
488 } |
|
489 |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void UT_CMusEngClipVideoPlayer::UT_LcFilePositionL() |
|
496 { |
|
497 // Try before establishment |
|
498 iClipVideoPlayer->SetMceSession( NULL ); |
|
499 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
500 iClipVideoPlayer->LcFilePositionL(), KErrNotReady ) |
|
501 |
|
502 // Establish session and try again |
|
503 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
504 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
505 file->iPosition = 2000000; |
|
506 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 == |
|
507 file->iPosition.Int64() ) |
|
508 |
|
509 // Ask position while fastforwarding, it should be bigger than real position |
|
510 iClipVideoPlayer->LcFastForwardL( ETrue ); |
|
511 User::After( 1000000 ); // We have to wait since dividing in LcFilePositionL and |
|
512 // multiplying before comparison loses difference |
|
513 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 > |
|
514 file->iPosition.Int64() ) |
|
515 |
|
516 // Ask position while fastforwarding beyond end of clip, clip duration is |
|
517 // returned |
|
518 file->iPosition = file->iDuration; |
|
519 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 == |
|
520 file->iDuration.Int64() ) |
|
521 |
|
522 // Stop fastforwarding, start fastrewinding, position is set to the end clip |
|
523 iClipVideoPlayer->LcFastForwardL( EFalse ); |
|
524 iClipVideoPlayer->LcFastRewindL( ETrue ); |
|
525 User::After( 1000000 ); // We have to wait since dividing in LcFilePositionL and |
|
526 // multiplying before comparison loses difference |
|
527 |
|
528 // Ask position while fastrewinding, it should be smaller than real |
|
529 // position |
|
530 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 < |
|
531 file->iPosition.Int64() ) |
|
532 |
|
533 // Ask position while fastrewinding beyond the beginning of clip, zero |
|
534 // returned |
|
535 file->iPosition = 0; |
|
536 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 == 0 ) |
|
537 |
|
538 // Asking position when rewinded to beginning but rewinding has ended |
|
539 // and clip has not ended (position should not be altered in that case) |
|
540 iClipVideoPlayer->iRewindedToBeginning = ETrue; |
|
541 file->iPosition = 0; |
|
542 iClipVideoPlayer->iFRWDStartTime = TTime( 0 ); |
|
543 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 == 0 ) |
|
544 |
|
545 // Position has proceeded from beginning, rewinding to beginning info |
|
546 // is cleared. |
|
547 file->iPosition = 10000000; |
|
548 iClipVideoPlayer->iFRWDStartTime = TTime( 0 ); |
|
549 EUNIT_ASSERT( iClipVideoPlayer->LcFilePositionL().Int() * 1000000 == 10000000 ) |
|
550 EUNIT_ASSERT( iClipVideoPlayer->iRewindedToBeginning == EFalse ) |
|
551 } |
|
552 |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 void UT_CMusEngClipVideoPlayer::UT_LcFileDurationL() |
|
559 { |
|
560 // Try before establishment |
|
561 iClipVideoPlayer->SetMceSession( NULL ); |
|
562 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
563 iClipVideoPlayer->LcFileDurationL(), KErrNotReady ) |
|
564 |
|
565 // Establish session and try again |
|
566 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
567 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
568 file->iDuration = 2000000; |
|
569 EUNIT_ASSERT( iClipVideoPlayer->LcFileDurationL().Int() * 1000000 == |
|
570 file->iDuration.Int64() ) |
|
571 } |
|
572 |
|
573 |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 // ----------------------------------------------------------------------------- |
|
577 // |
|
578 void UT_CMusEngClipVideoPlayer::UT_SetLcFilePositionL() |
|
579 { |
|
580 TTimeIntervalSeconds time( 20 ); |
|
581 |
|
582 // Try before establishment |
|
583 iClipVideoPlayer->SetMceSession( NULL ); |
|
584 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
585 iClipVideoPlayer->SetLcFilePositionL( time ), KErrNotReady ) |
|
586 |
|
587 // Normal case with already disabled file source |
|
588 iClipVideoPlayer->SetMceSession( iMceSession ); |
|
589 CMceFileSource* file = MusEngMceUtils::GetFileSourceL( *iMceSession ); |
|
590 file->iIsEnabled = EFalse; |
|
591 iClipVideoPlayer->SetLcFilePositionL( time ); |
|
592 EUNIT_ASSERT( file->iPosition.Int64() == |
|
593 static_cast< TInt64 >( time.Int() ) * 1000000 ) |
|
594 EUNIT_ASSERT( !file->iIsEnabled ) |
|
595 |
|
596 // Normal case with enabled file source |
|
597 TTimeIntervalSeconds anotherTime( 30 ); |
|
598 file->iIsEnabled = ETrue; |
|
599 iClipVideoPlayer->SetLcFilePositionL( anotherTime ); |
|
600 EUNIT_ASSERT( file->iPosition.Int64() == |
|
601 static_cast< TInt64 >( anotherTime.Int() ) * 1000000 ) |
|
602 EUNIT_ASSERT( file->iIsEnabled ) |
|
603 } |
|
604 |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 void UT_CMusEngClipVideoPlayer::UT_LcWindowL() |
|
611 { |
|
612 EUNIT_ASSERT( iClipVideoPlayer->LcWindow() == iClipVideoPlayer ) |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 void UT_CMusEngClipVideoPlayer::UT_LcCameraControlL() |
|
620 { |
|
621 EUNIT_ASSERT( iClipVideoPlayer->LcCameraControl() == NULL ) |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void UT_CMusEngClipVideoPlayer::UT_LcSourceFileControlL() |
|
629 { |
|
630 EUNIT_ASSERT( iClipVideoPlayer->LcSourceFileControl() == iClipVideoPlayer ) |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 void UT_CMusEngClipVideoPlayer::UT_LcDestinationFileControlL() |
|
638 { |
|
639 EUNIT_ASSERT( iClipVideoPlayer->LcDestinationFileControl() == NULL ) |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 // ----------------------------------------------------------------------------- |
|
645 // |
|
646 void UT_CMusEngClipVideoPlayer::UT_LcAudioControlL() |
|
647 { |
|
648 EUNIT_ASSERT( iClipVideoPlayer->LcAudioControl() == &iLcAudioControlStub ) |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 void UT_CMusEngClipVideoPlayer::UT_LcZoomControlL() |
|
656 { |
|
657 EUNIT_ASSERT( iClipVideoPlayer->LcZoomControl() == NULL ) |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 void UT_CMusEngClipVideoPlayer::UT_LcBrightnessControlL() |
|
665 { |
|
666 EUNIT_ASSERT( iClipVideoPlayer->LcBrightnessControl() == NULL ) |
|
667 } |
|
668 |
|
669 // TEST TABLE |
|
670 |
|
671 EUNIT_BEGIN_TEST_TABLE( |
|
672 UT_CMusEngClipVideoPlayer, |
|
673 "UT_CMusEngClipVideoPlayer", |
|
674 "UNIT" ) |
|
675 |
|
676 EUNIT_TEST( |
|
677 "HasClipEnded - test ", |
|
678 "CMusEngClipVideoPlayer", |
|
679 "HasClipEnded", |
|
680 "FUNCTIONALITY", |
|
681 SetupL, UT_HasClipEndedL, Teardown) |
|
682 |
|
683 EUNIT_TEST( |
|
684 "LcVideoPlayerState - test ", |
|
685 "CMusEngClipVideoPlayer", |
|
686 "LcVideoPlayerState", |
|
687 "FUNCTIONALITY", |
|
688 SetupL, UT_LcVideoPlayerStateL, Teardown) |
|
689 |
|
690 EUNIT_TEST( |
|
691 "LcPlayL - test ", |
|
692 "CMusEngClipVideoPlayer", |
|
693 "LcPlayL", |
|
694 "FUNCTIONALITY", |
|
695 SetupL, UT_LcPlayL, Teardown) |
|
696 |
|
697 EUNIT_TEST( |
|
698 "LcPauseL - test ", |
|
699 "CMusEngClipVideoPlayer", |
|
700 "LcPauseL", |
|
701 "FUNCTIONALITY", |
|
702 SetupL, UT_LcPauseL, Teardown) |
|
703 |
|
704 EUNIT_TEST( |
|
705 "LcIsPlayingL - test ", |
|
706 "CMusEngClipVideoPlayer", |
|
707 "LcIsPlayingL", |
|
708 "FUNCTIONALITY", |
|
709 SetupL, UT_LcIsPlayingL, Teardown) |
|
710 |
|
711 EUNIT_TEST( |
|
712 "SetLcFileNameL - test ", |
|
713 "CMusEngClipVideoPlayer", |
|
714 "SetLcFileNameL", |
|
715 "FUNCTIONALITY", |
|
716 SetupL, UT_SetLcFileNameL, Teardown) |
|
717 |
|
718 EUNIT_TEST( |
|
719 "LcFastForwardL - test ", |
|
720 "CMusEngClipVideoPlayer", |
|
721 "LcFastForwardL", |
|
722 "FUNCTIONALITY", |
|
723 SetupL, UT_LcFastForwardL, Teardown) |
|
724 |
|
725 EUNIT_TEST( |
|
726 "LcFastRewindL - test ", |
|
727 "CMusEngClipVideoPlayer", |
|
728 "LcFastRewindL", |
|
729 "FUNCTIONALITY", |
|
730 SetupL, UT_LcFastRewindL, Teardown) |
|
731 |
|
732 EUNIT_TEST( |
|
733 "LcFilePositionL - test ", |
|
734 "CMusEngClipVideoPlayer", |
|
735 "LcFilePositionL", |
|
736 "FUNCTIONALITY", |
|
737 SetupL, UT_LcFilePositionL, Teardown) |
|
738 |
|
739 EUNIT_TEST( |
|
740 "LcFileDurationL - test ", |
|
741 "CMusEngClipVideoPlayer", |
|
742 "LcFileDurationL", |
|
743 "FUNCTIONALITY", |
|
744 SetupL, UT_LcFileDurationL, Teardown) |
|
745 |
|
746 EUNIT_TEST( |
|
747 "SetLcFilePositionL - test ", |
|
748 "CMusEngClipVideoPlayer", |
|
749 "SetLcFilePositionL", |
|
750 "FUNCTIONALITY", |
|
751 SetupL, UT_SetLcFilePositionL, Teardown) |
|
752 |
|
753 EUNIT_TEST( |
|
754 "LcWindow - test ", |
|
755 "CMusEngClipVideoPlayer", |
|
756 "LcWindow", |
|
757 "FUNCTIONALITY", |
|
758 SetupL, UT_LcWindowL, Teardown) |
|
759 |
|
760 EUNIT_TEST( |
|
761 "LcCameraControl - test ", |
|
762 "CMusEngClipVideoPlayer", |
|
763 "LcCameraControl", |
|
764 "FUNCTIONALITY", |
|
765 SetupL, UT_LcCameraControlL, Teardown) |
|
766 |
|
767 EUNIT_TEST( |
|
768 "LcSourceFileControl - test ", |
|
769 "CMusEngClipVideoPlayer", |
|
770 "LcSourceFileControl", |
|
771 "FUNCTIONALITY", |
|
772 SetupL, UT_LcSourceFileControlL, Teardown) |
|
773 |
|
774 EUNIT_TEST( |
|
775 "LcDestinationFileControl - test ", |
|
776 "CMusEngClipVideoPlayer", |
|
777 "LcDestinationFileControl", |
|
778 "FUNCTIONALITY", |
|
779 SetupL, UT_LcDestinationFileControlL, Teardown) |
|
780 |
|
781 EUNIT_TEST( |
|
782 "LcAudioControl - test ", |
|
783 "CMusEngClipVideoPlayer", |
|
784 "LcAudioControl", |
|
785 "FUNCTIONALITY", |
|
786 SetupL, UT_LcAudioControlL, Teardown) |
|
787 |
|
788 EUNIT_TEST( |
|
789 "LcZoomControl - test ", |
|
790 "CMusEngClipVideoPlayer", |
|
791 "LcZoomControl", |
|
792 "FUNCTIONALITY", |
|
793 SetupL, UT_LcZoomControlL, Teardown) |
|
794 |
|
795 EUNIT_TEST( |
|
796 "LcBrightnessControl - test ", |
|
797 "CMusEngClipVideoPlayer", |
|
798 "LcBrightnessControl", |
|
799 "FUNCTIONALITY", |
|
800 SetupL, UT_LcBrightnessControlL, Teardown) |
|
801 |
|
802 EUNIT_END_TEST_TABLE |
|
803 |
|
804 // END OF FILE |
|
805 |
|