|
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: tester for methods in VideoSortFilterProxyModel |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: % |
|
19 |
|
20 #include <e32err.h> |
|
21 #include <w32std.h> |
|
22 |
|
23 #include <hbapplication.h> |
|
24 #include <hbinstance.h> |
|
25 #include <QDebug> |
|
26 |
|
27 #include <mpxplaybackframeworkdefs.h> |
|
28 #include <mpxplaybackutility.h> |
|
29 #include <mpxcommonvideoplaybackview.hrh> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxplaybackmessage.h> |
|
32 #include <mpxmediageneraldefs.h> |
|
33 #include <mpxmediavideodefs.h> |
|
34 |
|
35 #include "testmpxvideoviewwrapper.h" |
|
36 |
|
37 #include "../stub/inc/hbvideobaseplaybackview.h" |
|
38 #include "../stub/inc/mpxvideoplaybackviewfiledetails.h" |
|
39 #include "../stub/inc/mpxplaybackutilityimpl.h" |
|
40 #include "../stub/inc/mpxvideoplaybackdisplayhandler.h" |
|
41 #include "../stub/inc/mpxvideoplaybackcontrolscontroller.h" |
|
42 |
|
43 |
|
44 |
|
45 #define protected public |
|
46 #include "mpxvideoviewwrapper.h" |
|
47 #undef protected |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // main |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 int main(int argc, char *argv[]) |
|
55 { |
|
56 HbApplication app(argc, argv); |
|
57 HbMainWindow window; |
|
58 |
|
59 TestMPXVideoViewWrapper tv; |
|
60 |
|
61 char *pass[3]; |
|
62 pass[0] = argv[0]; |
|
63 pass[1] = "-o"; |
|
64 pass[2] = "c:\\data\\TestMPXVideoViewWrapper.txt"; |
|
65 |
|
66 int res = QTest::qExec(&tv, 3, pass); |
|
67 |
|
68 return res; |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // init |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void TestMPXVideoViewWrapper::init() |
|
77 { |
|
78 mBaseVideoView = new HbVideoBasePlaybackView(); |
|
79 TRAPD( err, mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView ) ); |
|
80 QVERIFY( err == KErrNone ); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // cleanup |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void TestMPXVideoViewWrapper::cleanup() |
|
88 { |
|
89 delete mVideoViewWrapper; |
|
90 mVideoViewWrapper = NULL; |
|
91 |
|
92 delete mBaseVideoView; |
|
93 mBaseVideoView = NULL; |
|
94 } |
|
95 |
|
96 |
|
97 void TestMPXVideoViewWrapper::testRequestMedia() |
|
98 { |
|
99 init(); |
|
100 |
|
101 TRAPD(err, mVideoViewWrapper->RequestMediaL()); |
|
102 QVERIFY( err == KErrNone ); |
|
103 |
|
104 QVERIFY( mVideoViewWrapper->iMediaRequested == true ); |
|
105 |
|
106 cleanup(); |
|
107 |
|
108 } |
|
109 |
|
110 void TestMPXVideoViewWrapper::testIsLive() |
|
111 { |
|
112 init(); |
|
113 |
|
114 TRAPD(err, mVideoViewWrapper->RequestMediaL()); |
|
115 QVERIFY( err == KErrNone ); |
|
116 |
|
117 mVideoViewWrapper->IsLive(); |
|
118 |
|
119 mVideoViewWrapper->iFileDetails->clearFileDetails(); |
|
120 |
|
121 QVERIFY( ! mVideoViewWrapper->IsLive() ); |
|
122 |
|
123 cleanup(); |
|
124 } |
|
125 |
|
126 |
|
127 void TestMPXVideoViewWrapper::testIsPlaylist() |
|
128 { |
|
129 init(); |
|
130 |
|
131 mVideoViewWrapper->IsPlaylist(); |
|
132 |
|
133 QVERIFY( mVideoViewWrapper->IsPlaylist() == false ); |
|
134 |
|
135 cleanup(); |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 void TestMPXVideoViewWrapper::testHandleCommand() |
|
141 { |
|
142 init(); |
|
143 |
|
144 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
145 QVERIFY( errReqMedia == KErrNone ); |
|
146 |
|
147 TRAPD(errHdlCmd, mVideoViewWrapper->HandleCommandL( EMPXPbvCmdPlay )); |
|
148 QVERIFY( errHdlCmd == KErrNone ); |
|
149 |
|
150 int state; |
|
151 TRAPD(errState, state = mVideoViewWrapper->iPlaybackUtility->StateL()); |
|
152 QVERIFY( errState == KErrNone ); |
|
153 |
|
154 QVERIFY( state == EPbStatePlaying ); |
|
155 |
|
156 cleanup(); |
|
157 |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 void TestMPXVideoViewWrapper::testHandlePluginError() |
|
163 { |
|
164 init(); |
|
165 |
|
166 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
167 QVERIFY( errReqMedia == KErrNone ); |
|
168 |
|
169 mVideoViewWrapper->HandlePluginError( KErrNotSupported ); |
|
170 |
|
171 QVERIFY( mVideoViewWrapper->iView->mCurrentError == KErrNotSupported ); |
|
172 |
|
173 cleanup(); |
|
174 |
|
175 } |
|
176 |
|
177 |
|
178 void TestMPXVideoViewWrapper::testHandlePlaybackMessage() |
|
179 { |
|
180 init(); |
|
181 |
|
182 //*************************** |
|
183 // Test Video Msg |
|
184 //*************************** |
|
185 CMPXMessage* message = NULL; |
|
186 TRAP_IGNORE( |
|
187 message = CMPXMessage::NewL(); |
|
188 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); |
|
189 message->SetTObjectValueL<TMPXVideoPlaybackCommand> |
|
190 ( KMPXMediaVideoPlaybackCommand, EPbCmdTvOutEvent ); |
|
191 message->SetTObjectValueL<TInt>( KMPXMediaVideoTvOutConnected, ETrue ); |
|
192 ); |
|
193 mVideoViewWrapper->HandlePlaybackMessage( message, KErrNone ); |
|
194 QVERIFY( mVideoViewWrapper->iFileDetails->mTvOutConnected ); |
|
195 if ( message ) |
|
196 { |
|
197 delete message; |
|
198 message = NULL; |
|
199 } |
|
200 |
|
201 |
|
202 |
|
203 //*************************** |
|
204 // Test General Msg |
|
205 //*************************** |
|
206 TRAP_IGNORE( |
|
207 message = CMPXMessage::NewL(); |
|
208 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral ); |
|
209 message->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, 28 ); // EReachedEndOfPlaylist = 28 |
|
210 message->SetTObjectValueL<TInt>( KMPXMessageGeneralType, 0 ); |
|
211 message->SetTObjectValueL<TInt>( KMPXMessageGeneralData, 0 ); |
|
212 ); |
|
213 mVideoViewWrapper->HandlePlaybackMessage( message, KErrNone ); |
|
214 QVERIFY( ! mVideoViewWrapper->iView->mViewActive ); |
|
215 if ( message ) |
|
216 { |
|
217 delete message; |
|
218 message = NULL; |
|
219 } |
|
220 |
|
221 |
|
222 //*************************** |
|
223 // Test Video Msg with err |
|
224 //*************************** |
|
225 TRAP_IGNORE( message = CMPXMessage::NewL() ); |
|
226 mVideoViewWrapper->HandlePlaybackMessage( message, KErrNotFound ); |
|
227 QVERIFY( mVideoViewWrapper->iView->mCurrentError == KErrNotFound ); |
|
228 if ( message ) |
|
229 { |
|
230 delete message; |
|
231 message = NULL; |
|
232 } |
|
233 |
|
234 cleanup(); |
|
235 } |
|
236 |
|
237 |
|
238 void TestMPXVideoViewWrapper::testSetProperty() |
|
239 { |
|
240 init(); |
|
241 |
|
242 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
243 QVERIFY( errReqMedia == KErrNone ); |
|
244 |
|
245 TRAPD(errSetProp, mVideoViewWrapper->SetPropertyL( EPbPropertyMute, 1 ) ); // 0=>noraml 1=>muted |
|
246 QVERIFY( errSetProp == KErrNone ); |
|
247 |
|
248 QVERIFY( ! mVideoViewWrapper->iFileDetails->mAudioEnabled ); |
|
249 |
|
250 cleanup(); |
|
251 } |
|
252 |
|
253 |
|
254 void TestMPXVideoViewWrapper::testHandleProperty() |
|
255 { |
|
256 init(); |
|
257 |
|
258 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
259 QVERIFY( errReqMedia == KErrNone ); |
|
260 |
|
261 TRAPD(errHdlProp, mVideoViewWrapper->HandlePropertyL( EPbPropertyDuration, 5000, KErrNone )); |
|
262 QVERIFY( errHdlProp == KErrNone ); |
|
263 |
|
264 QVERIFY( mVideoViewWrapper->iFileDetails->mDuration == 5000 ); |
|
265 |
|
266 cleanup(); |
|
267 } |
|
268 |
|
269 |
|
270 void TestMPXVideoViewWrapper::testRetrieveFileNameAndMode() |
|
271 { |
|
272 init(); |
|
273 |
|
274 mVideoViewWrapper->iFileDetails->clearFileDetails(); |
|
275 |
|
276 CMPXCommand* cmd = NULL; |
|
277 |
|
278 TRAP_IGNORE( cmd = CMPXCommand::NewL() ); |
|
279 |
|
280 TRAPD(errRetFileName, mVideoViewWrapper->RetrieveFileNameAndModeL( cmd ) ); |
|
281 QVERIFY( errRetFileName == KErrNone ); |
|
282 |
|
283 int state; |
|
284 TRAPD(errState, state = mVideoViewWrapper->iPlaybackUtility->StateL()); |
|
285 QVERIFY( errState == KErrNone ); |
|
286 |
|
287 QVERIFY( state == EPbStateInitialised ); |
|
288 |
|
289 QCOMPARE( mVideoViewWrapper->iFileDetails->mClipName, QString("testClip.3gp")); |
|
290 |
|
291 delete cmd; |
|
292 cmd = NULL; |
|
293 |
|
294 cleanup(); |
|
295 } |
|
296 |
|
297 |
|
298 void TestMPXVideoViewWrapper::testActivateClosePlayerActiveObject() |
|
299 { |
|
300 init(); |
|
301 |
|
302 mVideoViewWrapper->ActivateClosePlayerActiveObject(); |
|
303 |
|
304 QVERIFY( mVideoViewWrapper->iCloseAO->IsActive() ); |
|
305 |
|
306 cleanup(); |
|
307 } |
|
308 |
|
309 |
|
310 void TestMPXVideoViewWrapper::testDoClosePlayer() |
|
311 { |
|
312 init(); |
|
313 |
|
314 TRAPD(err, mVideoViewWrapper->DoClosePlayerL()); |
|
315 QVERIFY( err == KErrNone ); |
|
316 |
|
317 QVERIFY( ! mVideoViewWrapper->iView->mViewActive ); |
|
318 |
|
319 cleanup(); |
|
320 } |
|
321 |
|
322 |
|
323 void TestMPXVideoViewWrapper::testIssuePlayCommand() |
|
324 { |
|
325 init(); |
|
326 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
327 QVERIFY( errReqMedia == KErrNone ); |
|
328 |
|
329 TRAPD(errIssuePlay, mVideoViewWrapper->IssuePlayCommandL()); |
|
330 QVERIFY( errIssuePlay == KErrNone ); |
|
331 |
|
332 |
|
333 int state; |
|
334 TRAPD(errState, state = mVideoViewWrapper->iPlaybackUtility->StateL()); |
|
335 QVERIFY( errState == KErrNone ); |
|
336 |
|
337 QVERIFY( state == EPbStatePlaying ); |
|
338 |
|
339 cleanup(); |
|
340 } |
|
341 |
|
342 |
|
343 void TestMPXVideoViewWrapper::testSetAspectRatio() |
|
344 { |
|
345 init(); |
|
346 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
347 QVERIFY( errReqMedia == KErrNone ); |
|
348 |
|
349 TRAPD(errHdlCmd, mVideoViewWrapper->HandleCommandL(EMPXPbvCmdStretchAspectRatio)); |
|
350 QVERIFY( errHdlCmd == KErrNone ); |
|
351 |
|
352 QVERIFY( mVideoViewWrapper->iDisplayHandler->iCurrentIndexForAspectRatio == 1 ); |
|
353 |
|
354 cleanup(); |
|
355 } |
|
356 |
|
357 |
|
358 void TestMPXVideoViewWrapper::testIsAppInFront() |
|
359 { |
|
360 init(); |
|
361 |
|
362 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
363 QVERIFY( errReqMedia == KErrNone ); |
|
364 |
|
365 bool front = false; |
|
366 TRAPD(errIsAppInFrnt, front = mVideoViewWrapper->IsAppInFrontL()); |
|
367 |
|
368 QVERIFY( errIsAppInFrnt == KErrNone ); |
|
369 |
|
370 cleanup(); |
|
371 } |
|
372 |
|
373 |
|
374 void TestMPXVideoViewWrapper::testClosePlaybackView() |
|
375 { |
|
376 init(); |
|
377 |
|
378 TRAPD(err, mVideoViewWrapper->ClosePlaybackViewL()); |
|
379 QVERIFY( err == KErrNone ); |
|
380 |
|
381 QVERIFY( ! mVideoViewWrapper->iView->mViewActive ); |
|
382 |
|
383 cleanup(); |
|
384 } |
|
385 |
|
386 |
|
387 void TestMPXVideoViewWrapper::testHandleVolumeCmd() |
|
388 { |
|
389 init(); |
|
390 |
|
391 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
392 QVERIFY( errReqMedia == KErrNone ); |
|
393 |
|
394 TRAPD(errIssuePlay, mVideoViewWrapper->IssuePlayCommandL()); |
|
395 QVERIFY( errIssuePlay == KErrNone ); |
|
396 |
|
397 TRAPD(errHdlCmd, mVideoViewWrapper->HandleCommandL(EMPXPbvCmdDecreaseVolume)); |
|
398 QVERIFY( errHdlCmd == KErrNone ); |
|
399 |
|
400 QVERIFY( mVideoViewWrapper->iFileDetails->mAudioEnabled ); |
|
401 |
|
402 cleanup(); |
|
403 } |
|
404 |
|
405 |
|
406 void TestMPXVideoViewWrapper::testHandleShortPressBackward() |
|
407 { |
|
408 init(); |
|
409 |
|
410 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
411 QVERIFY( errReqMedia == KErrNone ); |
|
412 |
|
413 TRAPD(errIssuePlay, mVideoViewWrapper->IssuePlayCommandL()); |
|
414 QVERIFY( errIssuePlay == KErrNone ); |
|
415 |
|
416 TRAPD(errHdlCmd, mVideoViewWrapper->HandleCommandL(EMPXPbvCmdShortPressBackward)); |
|
417 QVERIFY( errHdlCmd == KErrNone ); |
|
418 |
|
419 cleanup(); |
|
420 } |
|
421 |
|
422 |
|
423 void TestMPXVideoViewWrapper::testIssueVideoAppForegroundCmd() |
|
424 { |
|
425 init(); |
|
426 |
|
427 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
428 QVERIFY( errReqMedia == KErrNone ); |
|
429 |
|
430 TRAPD(errIssuePlay, mVideoViewWrapper->IssuePlayCommandL()); |
|
431 QVERIFY( errIssuePlay == KErrNone ); |
|
432 |
|
433 TRAPD(errIssueVidAppFGCmd, mVideoViewWrapper->IssueVideoAppForegroundCmdL( ETrue )); |
|
434 QVERIFY( errIssueVidAppFGCmd == KErrNone ); |
|
435 |
|
436 cleanup(); |
|
437 } |
|
438 |
|
439 |
|
440 void TestMPXVideoViewWrapper::testCreateControls() |
|
441 { |
|
442 init(); |
|
443 |
|
444 TRAPD(err, mVideoViewWrapper->CreateControlsL()); |
|
445 QVERIFY( err == KErrNone ); |
|
446 |
|
447 QVERIFY( mVideoViewWrapper->iControlsController ); |
|
448 |
|
449 cleanup(); |
|
450 } |
|
451 |
|
452 |
|
453 void TestMPXVideoViewWrapper::testIsMultiItemPlaylist() |
|
454 { |
|
455 init(); |
|
456 |
|
457 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
458 QVERIFY( errReqMedia == KErrNone ); |
|
459 |
|
460 QVERIFY( ! mVideoViewWrapper->IsMultiItemPlaylist() ); |
|
461 |
|
462 cleanup(); |
|
463 } |
|
464 |
|
465 |
|
466 void TestMPXVideoViewWrapper::testUpdateVideoRect() |
|
467 { |
|
468 init(); |
|
469 |
|
470 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
471 QVERIFY( errReqMedia == KErrNone ); |
|
472 |
|
473 mVideoViewWrapper->UpdateVideoRect(0,0,50,50,false); |
|
474 |
|
475 float brY = 50; |
|
476 |
|
477 QCOMPARE(mVideoViewWrapper->iDisplayHandler->iBrYDiff, brY); |
|
478 |
|
479 cleanup(); |
|
480 } |
|
481 |
|
482 void TestMPXVideoViewWrapper::testUpdateVideoRectDone() |
|
483 { |
|
484 init(); |
|
485 |
|
486 TRAPD(errReqMedia, mVideoViewWrapper->RequestMediaL()); |
|
487 QVERIFY( errReqMedia == KErrNone ); |
|
488 |
|
489 mVideoViewWrapper->UpdateVideoRectDone(); |
|
490 |
|
491 cleanup(); |
|
492 } |
|
493 |
|
494 |
|
495 |
|
496 void TestMPXVideoViewWrapper::testHandleBufferingState() |
|
497 { |
|
498 init(); |
|
499 |
|
500 TRAPD(err, mVideoViewWrapper->HandleBufferingStateL()); |
|
501 QVERIFY( err == KErrNone ); |
|
502 |
|
503 cleanup(); |
|
504 } |
|
505 |
|
506 |
|
507 void TestMPXVideoViewWrapper::testHandleVideoPlaybackMessage() |
|
508 { |
|
509 init(); |
|
510 |
|
511 CMPXMessage* message = NULL; |
|
512 TRAP_IGNORE( |
|
513 message = CMPXMessage::NewL(); |
|
514 message->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMediaIdVideoPlayback ); |
|
515 message->SetTObjectValueL<TMPXVideoPlaybackCommand> |
|
516 ( KMPXMediaVideoPlaybackCommand, EPbCmdPluginError ); |
|
517 message->SetTObjectValueL<TInt>( KMPXMediaVideoError, KErrNotSupported ); |
|
518 ); |
|
519 |
|
520 mVideoViewWrapper->HandleVideoPlaybackMessage( message ); |
|
521 |
|
522 QCOMPARE( mVideoViewWrapper->iView->mCurrentError, KErrNotSupported ); |
|
523 if ( message ) |
|
524 { |
|
525 delete message; |
|
526 message = NULL; |
|
527 } |
|
528 |
|
529 cleanup(); |
|
530 } |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 void TestMPXVideoViewWrapper::testCreateGeneralPlaybackCommand() |
|
536 { |
|
537 init(); |
|
538 |
|
539 TRAPD(err, mVideoViewWrapper->CreateGeneralPlaybackCommandL( EPbCmdDecreaseVolume )); |
|
540 QVERIFY( err == KErrNone ); |
|
541 |
|
542 QVERIFY( ! mVideoViewWrapper->iFileDetails->mAudioEnabled ); |
|
543 |
|
544 cleanup(); |
|
545 } |
|
546 |
|
547 |
|
548 void TestMPXVideoViewWrapper::testHandlePlaybackCommandComplete() |
|
549 { |
|
550 init(); |
|
551 |
|
552 CMPXCommand* cmd = NULL; |
|
553 |
|
554 TRAP_IGNORE( cmd = CMPXCommand::NewL() ); |
|
555 |
|
556 mVideoViewWrapper->HandlePlaybackCommandComplete( cmd, KErrNone ); |
|
557 |
|
558 QVERIFY( mVideoViewWrapper ); |
|
559 |
|
560 delete cmd; |
|
561 cmd = NULL; |
|
562 |
|
563 cleanup(); |
|
564 } |
|
565 |
|
566 |
|
567 void TestMPXVideoViewWrapper::testHandleMedia() |
|
568 { |
|
569 init(); |
|
570 |
|
571 CMPXMedia* media = NULL; |
|
572 |
|
573 TRAP_IGNORE( |
|
574 RArray<TInt> suppIds; |
|
575 CleanupClosePushL( suppIds ); |
|
576 suppIds.AppendL( KMPXMediaIdGeneral ); |
|
577 suppIds.AppendL( KMPXMediaIdVideo ); |
|
578 |
|
579 media = CMPXMedia::NewL( suppIds.Array() ); |
|
580 CleanupStack::PopAndDestroy( &suppIds ); |
|
581 |
|
582 media->SetTObjectValueL<TInt>( TMPXAttribute( KMPXMediaVideoError ), |
|
583 KErrCancel ); |
|
584 ); |
|
585 |
|
586 TRAPD(err, mVideoViewWrapper->HandleMediaL( *media, KErrNone ) ); |
|
587 QVERIFY( err == KErrNone ); |
|
588 |
|
589 QCOMPARE( mVideoViewWrapper->iView->mCurrentError, KErrCancel ); |
|
590 |
|
591 if ( media ) |
|
592 { |
|
593 delete media; |
|
594 media = NULL; |
|
595 } |
|
596 |
|
597 |
|
598 cleanup(); |
|
599 } |
|
600 |
|
601 |
|
602 // End of file |
|
603 |
|
604 |
|
605 |