29 #include <hbinstance.h> |
29 #include <hbinstance.h> |
30 #include <qgraphicssceneevent> |
30 #include <qgraphicssceneevent> |
31 #include <QDebug> |
31 #include <QDebug> |
32 |
32 |
33 #include "mpxvideoplaybackviewfiledetails.h" |
33 #include "mpxvideoplaybackviewfiledetails.h" |
|
34 #include "mpxcommonvideoplaybackview.hrh" |
34 |
35 |
35 #include "testvideoplaybackview.h" |
36 #include "testvideoplaybackview.h" |
36 #include "mpxvideoviewwrapper.h" |
37 #include "mpxvideoviewwrapper.h" |
|
38 #include "hbtapgesture.h" |
|
39 #include "hbpangesture.h" |
37 |
40 |
38 #define private public |
41 #define private public |
39 #define protected public |
42 #define protected public |
40 #include "hbvideoplaybackview.h" |
43 #include "hbvideoplaybackview.h" |
41 #include "hbvideobaseplaybackview.h" |
44 #include "hbvideobaseplaybackview.h" |
42 #undef protected |
45 #undef protected |
43 #undef private |
46 #undef private |
44 |
47 |
45 |
48 |
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
49 // --------------------------------------------------------------------------- |
49 // main |
50 // main |
50 // --------------------------------------------------------------------------- |
51 // --------------------------------------------------------------------------- |
51 // |
52 // |
52 int main(int argc, char *argv[]) |
53 int main(int argc, char *argv[]) |
53 { |
54 { |
54 HbApplication app(argc, argv); |
55 HbApplication app(argc, argv); |
55 HbMainWindow window; |
56 HbMainWindow window; |
56 |
57 |
57 TestVideoPlaybackView tv; |
58 TestVideoPlaybackView tv; |
58 |
59 |
59 char *pass[3]; |
60 char *pass[3]; |
60 pass[0] = argv[0]; |
61 pass[0] = argv[0]; |
61 pass[1] = "-o"; |
62 pass[1] = "-o"; |
62 pass[2] = "c:\\data\\TestVideoPlaybackView.txt"; |
63 pass[2] = "c:\\data\\TestVideoPlaybackView.txt"; |
63 |
64 |
64 int res = QTest::qExec(&tv, 3, pass); |
65 int res = QTest::qExec(&tv, 3, pass); |
65 |
66 |
66 return res; |
67 return res; |
67 } |
68 } |
68 |
69 |
69 |
|
70 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
71 // init |
71 // init |
72 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
73 // |
73 // |
74 void TestVideoPlaybackView::init() |
74 void TestVideoPlaybackView::init() |
75 { |
75 { |
76 mVideoView = new HbVideoPlaybackView(); |
76 mVideoView = new HbVideoPlaybackView(); |
77 } |
77 } |
78 |
78 |
79 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
80 // cleanup |
80 // cleanup |
81 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
120 verifyHandlePluginError( KErrCorrupt ); |
127 verifyHandlePluginError( KErrCorrupt ); |
121 verifyHandlePluginError( KErrTooBig ); |
128 verifyHandlePluginError( KErrTooBig ); |
122 verifyHandlePluginError( KErrMMInvalidProtocol ); |
129 verifyHandlePluginError( KErrMMInvalidProtocol ); |
123 verifyHandlePluginError( KErrMMInvalidURL ); |
130 verifyHandlePluginError( KErrMMInvalidURL ); |
124 verifyHandlePluginError( KErrArgument ); |
131 verifyHandlePluginError( KErrArgument ); |
125 verifyHandlePluginError( KErrSessionClosed ); |
132 verifyHandlePluginError( KErrSessionClosed ); |
126 verifyHandlePluginError( KErrTimedOut ); |
133 verifyHandlePluginError( KErrTimedOut ); |
127 verifyHandlePluginError( KErrNotFound ); |
134 verifyHandlePluginError( KErrNotFound ); |
128 verifyHandlePluginError( KErrMMNotEnoughBandwidth ); |
135 verifyHandlePluginError( KErrMMNotEnoughBandwidth ); |
129 verifyHandlePluginError( KErrDisconnected ); |
136 verifyHandlePluginError( KErrDisconnected ); |
130 verifyHandlePluginError( KErrMMProxyServer ); |
137 verifyHandlePluginError( KErrMMProxyServer ); |
131 verifyHandlePluginError( KErrCouldNotConnect ); |
138 verifyHandlePluginError( KErrCouldNotConnect ); |
132 verifyHandlePluginError( KErrAbort ); |
139 verifyHandlePluginError( KErrAbort ); |
133 verifyHandlePluginError( KErrCancel ); |
140 verifyHandlePluginError( KErrCancel ); |
134 verifyHandlePluginError( KErrMMDRMNotAuthorized ); |
141 verifyHandlePluginError( KErrMMDRMNotAuthorized ); |
135 verifyHandlePluginError( KErrCANoRights ); |
142 verifyHandlePluginError( KErrCANoRights ); |
136 verifyHandlePluginError( KErrCANoPermission ); |
143 verifyHandlePluginError( KErrCANoPermission ); |
137 |
144 |
138 // |
145 // |
139 // playback view remains open after displaying these error notes |
146 // playback view remains open after displaying these error notes |
140 // |
147 // |
141 verifyHandlePluginError( KMPXVideoCallOngoingError, false ); |
148 verifyHandlePluginError( KMPXVideoCallOngoingError, false ); |
142 verifyHandlePluginError( KMPXVideoPlayOver2GDuringVoiceCallError, false ); |
149 verifyHandlePluginError( KMPXVideoPlayOver2GDuringVoiceCallError, false ); |
143 |
150 |
144 // |
151 // |
145 // default error case, playback view is closed after displaying error note |
152 // default error case, playback view is closed after displaying error note |
146 // |
153 // |
147 verifyHandlePluginError( KErrGeneral ); |
154 verifyHandlePluginError( KErrGeneral ); |
148 } |
155 } |
149 |
156 |
|
157 // ------------------------------------------------------------------------------------------------- |
|
158 // TestVideoPlaybackView::testShowDialog() |
|
159 // ------------------------------------------------------------------------------------------------- |
|
160 // |
150 void TestVideoPlaybackView::testShowDialog() |
161 void TestVideoPlaybackView::testShowDialog() |
151 { |
162 { |
152 // |
163 // |
153 // construct and activate playback view |
164 // construct and activate playback view |
154 // |
165 // |
155 setup(); |
166 setup(); |
156 |
167 |
157 // |
168 // |
158 // ensure that playback view is currently activated |
169 // ensure that playback view is currently activated |
159 // |
170 // |
160 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
171 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
161 |
172 |
162 // |
173 // |
163 // test showDialog() method |
174 // test showDialog() method |
164 // |
175 // |
165 mVideoView->showDialog( "test error msg" ); |
176 mVideoView->showDialog( "test error msg" ); |
166 |
177 |
167 // |
178 // |
168 // connect and emit signal for handleClosePopupDialog() slot |
179 // connect and emit signal for handleClosePopupDialog() slot |
169 // |
180 // |
170 connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
181 connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
171 emit commandSignal(); |
182 emit commandSignal(); |
172 |
183 |
173 // |
184 // |
174 // verify that playback view is properly closed |
185 // verify that playback view is properly closed |
175 // |
186 // |
176 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
187 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
177 |
188 |
178 // |
189 // |
179 // disconnect signal for handleClosePopupDialog() slot |
190 // disconnect signal for handleClosePopupDialog() slot |
180 // |
191 // |
181 disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
192 disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
182 |
193 |
183 // |
194 // |
184 // destruct playback view |
195 // destruct playback view |
185 // |
196 // |
186 cleanup(); |
197 cleanup(); |
187 } |
198 } |
188 |
199 |
189 |
200 // ------------------------------------------------------------------------------------------------- |
|
201 // TestVideoPlaybackView::testGetWindow() |
|
202 // ------------------------------------------------------------------------------------------------- |
|
203 // |
190 void TestVideoPlaybackView::testGetWindow() |
204 void TestVideoPlaybackView::testGetWindow() |
191 { |
205 { |
192 setup(); |
206 setup(); |
193 |
207 |
194 QVERIFY( mVideoView->getWindow() != NULL ); |
208 QVERIFY( mVideoView->getWindow() != NULL ); |
195 |
209 |
196 cleanup(); |
210 cleanup(); |
197 } |
211 } |
198 |
212 |
199 |
213 // ------------------------------------------------------------------------------------------------- |
|
214 // TestVideoPlaybackView::testIssuePlayCommand() |
|
215 // ------------------------------------------------------------------------------------------------- |
|
216 // |
200 void TestVideoPlaybackView::testIssuePlayCommand() |
217 void TestVideoPlaybackView::testIssuePlayCommand() |
201 { |
218 { |
202 setup(); |
219 setup(); |
203 |
220 |
204 mVideoView->issuePlayCommand(); |
221 mVideoView->issuePlayCommand(); |
205 |
222 |
206 //JAM remove |
223 //JAM remove |
207 QVERIFY( mVideoView->isEnabled() ); |
224 QVERIFY( mVideoView->isEnabled() ); |
208 |
225 |
209 cleanup(); |
226 cleanup(); |
210 } |
227 } |
211 |
228 |
|
229 // ------------------------------------------------------------------------------------------------- |
|
230 // TestVideoPlaybackView::testEventFilter() |
|
231 // ------------------------------------------------------------------------------------------------- |
|
232 // |
212 void TestVideoPlaybackView::testEventFilter() |
233 void TestVideoPlaybackView::testEventFilter() |
213 { |
234 { |
214 setup(); |
235 setup(); |
215 |
236 |
216 // |
237 // |
217 // ensure default foreground is false |
238 // ensure default foreground is false |
218 // |
239 // |
219 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 ); |
240 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 ); |
220 |
241 |
221 // |
242 // |
222 // declare foreground/background event |
243 // declare foreground/background event |
223 // |
244 // |
224 QEvent* appActivate = new QEvent( QEvent::ApplicationActivate ); |
245 QEvent* appActivate = new QEvent( QEvent::ApplicationActivate ); |
225 QEvent* appDeactivate = new QEvent( QEvent::ApplicationDeactivate ); |
246 QEvent* appDeactivate = new QEvent( QEvent::ApplicationDeactivate ); |
226 |
247 |
227 // |
248 // |
228 // verify the returned value (consumed) of HbVideoBasePlaybackView::event() |
249 // verify the returned value (consumed) of HbVideoBasePlaybackView::event() |
229 // for QEvent::ApplicationActivate is false |
250 // for QEvent::ApplicationActivate is false |
230 // |
251 // |
231 QVERIFY( ! mVideoView->eventFilter( NULL, appActivate ) ); |
252 QVERIFY( ! mVideoView->eventFilter( NULL, appActivate ) ); |
232 |
253 |
233 // |
254 // |
234 // verify view is in foreground |
255 // verify view is in foreground |
235 // |
256 // |
236 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 1 ); |
257 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 1 ); |
237 |
258 |
238 // |
259 // |
239 // verify the returned value (consumed) of HbVideoBasePlaybackView::event() |
260 // verify the returned value (consumed) of HbVideoBasePlaybackView::event() |
240 // for QEvent::ApplicationDeactivate is false |
261 // for QEvent::ApplicationDeactivate is false |
241 // |
262 // |
242 QVERIFY( ! mVideoView->eventFilter( NULL, appDeactivate ) ); |
263 QVERIFY( ! mVideoView->eventFilter( NULL, appDeactivate ) ); |
243 |
264 |
244 // |
265 // |
245 // verify view is in background |
266 // verify view is in background |
246 // |
267 // |
247 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 ); |
268 QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 ); |
248 |
269 |
249 // |
270 // |
250 // clean up |
271 // clean up |
251 // |
272 // |
252 if ( appActivate ) |
273 if ( appActivate ) |
253 { |
274 { |
262 } |
283 } |
263 |
284 |
264 cleanup(); |
285 cleanup(); |
265 } |
286 } |
266 |
287 |
|
288 // ------------------------------------------------------------------------------------------------- |
|
289 // TestVideoPlaybackView::testClosePlaybackView() |
|
290 // ------------------------------------------------------------------------------------------------- |
|
291 // |
267 void TestVideoPlaybackView::testClosePlaybackView() |
292 void TestVideoPlaybackView::testClosePlaybackView() |
268 { |
293 { |
269 setup(); |
294 setup(); |
270 |
295 |
271 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
296 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
272 |
297 |
273 mVideoView->closePlaybackView(); |
298 mVideoView->closePlaybackView(); |
274 |
299 |
275 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
300 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
276 |
301 |
277 cleanup(); |
302 cleanup(); |
278 } |
303 } |
279 |
304 |
280 void TestVideoPlaybackView::testMousePressEvent() |
305 // ------------------------------------------------------------------------------------------------- |
281 { |
306 // TestVideoPlaybackView::testHandlePdlStateChange() |
282 setup(); |
307 // ------------------------------------------------------------------------------------------------- |
283 |
308 // |
284 // |
|
285 // declare QEvent::GraphicsSceneMousePress |
|
286 // |
|
287 QGraphicsSceneMouseEvent* event = new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMousePress ); |
|
288 |
|
289 // |
|
290 // set m_accept value to false |
|
291 // |
|
292 event->setAccepted( false ); |
|
293 |
|
294 // |
|
295 // simulate QEvent::GraphicsSceneMousePress event |
|
296 // |
|
297 mVideoView->mousePressEvent( event ); |
|
298 |
|
299 // |
|
300 // verify event has been accepted |
|
301 // |
|
302 QVERIFY( event->isAccepted() ); |
|
303 |
|
304 // |
|
305 // clean up |
|
306 // |
|
307 delete event; |
|
308 event = NULL; |
|
309 cleanup(); |
|
310 } |
|
311 |
|
312 void TestVideoPlaybackView::testMouseReleaseEvent() |
|
313 { |
|
314 setup(); |
|
315 |
|
316 // |
|
317 // declare QEvent::GraphicsSceneMouseRelease |
|
318 // |
|
319 QGraphicsSceneMouseEvent* event = new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMouseRelease ); |
|
320 |
|
321 // |
|
322 // connect to tappedOnScreen() signal and record its emission |
|
323 // |
|
324 QSignalSpy spy( mVideoView, SIGNAL(tappedOnScreen()) ); |
|
325 |
|
326 // |
|
327 // ensure signal has not been emitted yet |
|
328 // |
|
329 QCOMPARE(spy.count(), 0); |
|
330 |
|
331 // |
|
332 // simulate QEvent::GraphicsSceneMousePress event |
|
333 // |
|
334 mVideoView->mouseReleaseEvent( event ); |
|
335 |
|
336 // |
|
337 // ensure signal has been emitted and its emission count is incremented |
|
338 // |
|
339 QCOMPARE(spy.count(), 1); |
|
340 |
|
341 // |
|
342 // clean up |
|
343 // |
|
344 delete event; |
|
345 event = NULL; |
|
346 spy.clear(); |
|
347 cleanup(); |
|
348 } |
|
349 |
|
350 |
|
351 void TestVideoPlaybackView::testHandlePdlStateChange() |
309 void TestVideoPlaybackView::testHandlePdlStateChange() |
352 { |
310 { |
353 setup(); |
311 setup(); |
354 |
312 |
355 QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") ); |
313 QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") ); |
356 |
314 |
357 mVideoView->handlePdlStateChange( 0 ); |
315 mVideoView->handlePdlStateChange( 0 ); |
358 |
316 |
359 QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") ); |
317 QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") ); |
360 |
318 |
361 cleanup(); |
319 cleanup(); |
362 } |
320 } |
363 |
321 |
|
322 // ------------------------------------------------------------------------------------------------- |
|
323 // TestVideoPlaybackView::testHandleStoppedStateNoPrevView() |
|
324 // ------------------------------------------------------------------------------------------------- |
|
325 // |
364 void TestVideoPlaybackView::testHandleStoppedStateNoPrevView() |
326 void TestVideoPlaybackView::testHandleStoppedStateNoPrevView() |
365 { |
327 { |
366 setup(); |
328 setup(); |
367 |
329 |
368 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
330 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
369 mVideoView->handleStoppedState(); |
331 mVideoView->handleStoppedState(); |
370 |
332 |
371 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
333 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
372 |
334 |
373 cleanup(); |
335 cleanup(); |
374 } |
336 } |
375 |
337 |
376 |
338 // ------------------------------------------------------------------------------------------------- |
|
339 // TestVideoPlaybackView::testHandleStoppedStatePrevView() |
|
340 // ------------------------------------------------------------------------------------------------- |
|
341 // |
377 void TestVideoPlaybackView::testHandleStoppedStatePrevView() |
342 void TestVideoPlaybackView::testHandleStoppedStatePrevView() |
378 { |
343 { |
379 setup(); |
344 setup(); |
380 |
345 |
381 mVideoView->handleStoppedState(); |
346 mVideoView->handleStoppedState(); |
382 |
347 |
383 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
348 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
384 |
349 |
385 cleanup(); |
350 cleanup(); |
386 |
351 |
387 } |
352 } |
388 |
353 |
|
354 // ------------------------------------------------------------------------------------------------- |
|
355 // TestVideoPlaybackView::testHandleBackNoPrevView() |
|
356 // ------------------------------------------------------------------------------------------------- |
|
357 // |
389 void TestVideoPlaybackView::testHandleBackNoPrevView() |
358 void TestVideoPlaybackView::testHandleBackNoPrevView() |
390 { |
359 { |
391 setup(); |
360 setup(); |
392 |
361 |
393 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
362 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
394 mVideoView->handleBack(); |
363 mVideoView->handleBack(); |
395 |
364 |
396 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
365 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
397 |
366 |
398 cleanup(); |
367 cleanup(); |
399 |
368 |
400 } |
369 } |
401 |
370 |
|
371 // ------------------------------------------------------------------------------------------------- |
|
372 // TestVideoPlaybackView::testHandleBackPrevView() |
|
373 // ------------------------------------------------------------------------------------------------- |
|
374 // |
402 void TestVideoPlaybackView::testHandleBackPrevView() |
375 void TestVideoPlaybackView::testHandleBackPrevView() |
403 { |
376 { |
404 setup(); |
377 setup(); |
405 |
378 |
406 mVideoView->handleBack(); |
379 mVideoView->handleBack(); |
407 |
380 |
408 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
381 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
409 |
382 |
410 cleanup(); |
383 cleanup(); |
411 } |
384 } |
412 |
385 |
|
386 // ------------------------------------------------------------------------------------------------- |
|
387 // TestVideoPlaybackView::testHandleSoftkeyback() |
|
388 // ------------------------------------------------------------------------------------------------- |
|
389 // |
413 void TestVideoPlaybackView::testHandleSoftkeyback() |
390 void TestVideoPlaybackView::testHandleSoftkeyback() |
414 { |
391 { |
415 setup(); |
392 setup(); |
416 |
393 |
417 mVideoView->handleSoftkeyBack(); |
394 mVideoView->handleSoftkeyBack(); |
418 |
395 |
419 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
396 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
420 |
397 |
421 cleanup(); |
398 cleanup(); |
422 } |
399 } |
423 |
400 |
424 |
401 // ------------------------------------------------------------------------------------------------- |
425 |
402 // TestVideoPlaybackView::testDoClosePlayer() |
|
403 // ------------------------------------------------------------------------------------------------- |
|
404 // |
426 void TestVideoPlaybackView::testDoClosePlayer() |
405 void TestVideoPlaybackView::testDoClosePlayer() |
427 { |
406 { |
428 // quits app - which can be problematic for the qvptestrunner app |
407 // quits app - which can be problematic for the qvptestrunner app |
429 |
408 |
430 // setup(); |
409 // setup(); |
431 // |
410 // |
432 // mVideoView->handleActivateView(); |
411 // mVideoView->handleActivateView(); |
433 // |
412 // |
434 // mVideoView->doClosePlayer(); |
413 // mVideoView->doClosePlayer(); |
435 // |
414 // |
436 // cleanup(); |
415 // cleanup(); |
437 |
416 |
438 } |
417 } |
439 |
418 |
|
419 // ------------------------------------------------------------------------------------------------- |
|
420 // TestVideoPlaybackView::testHandleDeactivateView() |
|
421 // ------------------------------------------------------------------------------------------------- |
|
422 // |
440 void TestVideoPlaybackView::testHandleDeactivateView() |
423 void TestVideoPlaybackView::testHandleDeactivateView() |
441 { |
424 { |
442 setup(); |
425 setup(); |
443 |
426 |
444 mVideoView->handleDeactivateView(); |
427 mVideoView->handleDeactivateView(); |
445 |
428 |
446 QVERIFY( mVideoView->mVideoMpxWrapper == NULL ); |
429 QVERIFY( mVideoView->mVideoMpxWrapper == NULL ); |
447 |
430 |
448 cleanup(); |
431 cleanup(); |
449 } |
432 } |
450 |
433 |
|
434 // ------------------------------------------------------------------------------------------------- |
|
435 // TestVideoPlaybackView::verifyHandlePluginError() |
|
436 // ------------------------------------------------------------------------------------------------- |
|
437 // |
451 void TestVideoPlaybackView::verifyHandlePluginError( TInt error, bool closeView ) |
438 void TestVideoPlaybackView::verifyHandlePluginError( TInt error, bool closeView ) |
452 { |
439 { |
453 // |
440 // |
454 // construct and activate playback view |
441 // construct and activate playback view |
455 // |
442 // |
456 setup(); |
443 setup(); |
457 |
444 |
458 // |
445 // |
459 // ensure that playback view is currently open |
446 // ensure that playback view is currently open |
460 // |
447 // |
461 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
448 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
462 |
449 |
463 // |
450 // |
464 // test handlePluginError() method |
451 // test handlePluginError() method |
465 // |
452 // |
466 mVideoView->handlePluginError( error ); |
453 mVideoView->handlePluginError( error ); |
467 |
454 |
468 // |
455 // |
469 // close playback view after error note has been launched |
456 // close playback view after error note has been launched |
470 // |
457 // |
471 if ( closeView ) |
458 if ( closeView ) |
472 { |
459 { |
473 // |
460 // |
474 // connect and emit signal for handleClosePopupDialog() slot |
461 // connect and emit signal for handleClosePopupDialog() slot |
475 // |
462 // |
476 connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
463 connect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
477 emit commandSignal(); |
464 emit commandSignal(); |
478 |
465 |
479 // |
466 // |
480 // verify that playback view is properly closed |
467 // verify that playback view is properly closed |
481 // |
468 // |
482 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
469 QVERIFY( mVideoView->mTimerForClosingView->isActive() ); |
483 |
470 |
484 // |
471 // |
485 // disconnect signal for handleClosePopupDialog() slot |
472 // disconnect signal for handleClosePopupDialog() slot |
486 // |
473 // |
487 disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
474 disconnect( this, SIGNAL( commandSignal() ), mVideoView, SLOT( handleClosePopupDialog() ) ); |
488 } |
475 } |
489 else |
476 else |
490 { |
477 { |
491 // |
478 // |
492 // verify that playback view is still open after error note has been launched |
479 // verify that playback view is still open after error note has been launched |
493 // |
480 // |
494 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
481 QVERIFY( ! mVideoView->mTimerForClosingView->isActive() ); |
495 } |
482 } |
496 |
483 |
497 // |
484 // |
498 // destruct playback view |
485 // destruct playback view |
499 // |
486 // |
500 cleanup(); |
487 cleanup(); |
501 } |
488 } |
502 |
489 |
|
490 // ------------------------------------------------------------------------------------------------- |
|
491 // TestVideoPlaybackView::testGestureEvent() |
|
492 // ------------------------------------------------------------------------------------------------- |
|
493 // |
|
494 void TestVideoPlaybackView::testGestureEvent() |
|
495 { |
|
496 setup(); |
|
497 |
|
498 // |
|
499 // 1. Test tap gesture |
|
500 // |
|
501 QList<QGesture *> list; |
|
502 HbTapGesture *tapGesture = new HbTapGesture(); |
|
503 list.append( tapGesture ); |
|
504 QGestureEvent* event = new QGestureEvent( list ); |
|
505 |
|
506 // |
|
507 // connect to tappedOnScreen() signal and record its emission |
|
508 // |
|
509 QSignalSpy spy( mVideoView, SIGNAL( tappedOnScreen() ) ); |
|
510 |
|
511 // |
|
512 // ensure signal has not been emitted yet |
|
513 // |
|
514 QCOMPARE( spy.count(), 0 ); |
|
515 |
|
516 // |
|
517 // With GestureStarted |
|
518 // |
|
519 tapGesture->mState = Qt::GestureStarted; |
|
520 mVideoView->gestureEvent( event ); |
|
521 |
|
522 // |
|
523 // ensure signal hasn't been emitted and its emission count is not incremented |
|
524 // |
|
525 QCOMPARE( spy.count(), 0 ); |
|
526 |
|
527 // |
|
528 // With GestureFinished |
|
529 // |
|
530 tapGesture->mState = Qt::GestureFinished; |
|
531 mVideoView->gestureEvent( event ); |
|
532 |
|
533 // |
|
534 // ensure signal has been emitted and its emission count is incremented |
|
535 // |
|
536 QCOMPARE( spy.count(), 1 ); |
|
537 |
|
538 // |
|
539 // clean up |
|
540 // |
|
541 spy.clear(); |
|
542 |
|
543 list.clear(); |
|
544 |
|
545 if ( tapGesture ) |
|
546 { |
|
547 delete tapGesture; |
|
548 tapGesture = NULL; |
|
549 } |
|
550 |
|
551 if ( event ) |
|
552 { |
|
553 delete event; |
|
554 event = NULL; |
|
555 } |
|
556 |
|
557 // |
|
558 // 2. Test pan gesture |
|
559 // |
|
560 HbPanGesture *panGesture = new HbPanGesture(); |
|
561 list.append( panGesture ); |
|
562 event = new QGestureEvent( list ); |
|
563 |
|
564 // |
|
565 // connect to pannedToRight() signal and record its emission |
|
566 // |
|
567 QSignalSpy spy1( mVideoView, SIGNAL( pannedToRight() ) ); |
|
568 |
|
569 // |
|
570 // ensure signal has not been emitted yet |
|
571 // |
|
572 QCOMPARE( spy1.count(), 0 ); |
|
573 |
|
574 // |
|
575 // Test pan gesture With GestureStarted |
|
576 // |
|
577 panGesture->mState = Qt::GestureStarted; |
|
578 mVideoView->gestureEvent( event ); |
|
579 |
|
580 // |
|
581 // ensure signal has not been emitted yet |
|
582 // |
|
583 QCOMPARE( spy1.count(), 0 ); |
|
584 |
|
585 // |
|
586 // Test pan gesture with GestureFinished |
|
587 // |
|
588 panGesture->mState = Qt::GestureFinished; |
|
589 panGesture->mSceneDelta = QPointF( 5, 0 ); |
|
590 mVideoView->gestureEvent( event ); |
|
591 |
|
592 // |
|
593 // ensure signal has been emitted |
|
594 // |
|
595 QCOMPARE( spy1.count(), 1 ); |
|
596 spy1.clear(); |
|
597 |
|
598 // |
|
599 // Test pan gesture with GestureFinished |
|
600 // |
|
601 |
|
602 // |
|
603 // connect to pannedToRight() signal and record its emission |
|
604 // |
|
605 QSignalSpy spy2( mVideoView, SIGNAL( pannedToLeft() ) ); |
|
606 |
|
607 // |
|
608 // ensure signal has not been emitted yet |
|
609 // |
|
610 QCOMPARE( spy2.count(), 0 ); |
|
611 |
|
612 panGesture->mState = Qt::GestureFinished; |
|
613 panGesture->mSceneDelta = QPointF( -5, 0 ); |
|
614 mVideoView->gestureEvent( event ); |
|
615 |
|
616 // |
|
617 // ensure signal has not been emitted yet |
|
618 // |
|
619 QCOMPARE( spy2.count(), 1 ); |
|
620 |
|
621 // |
|
622 // clean up |
|
623 // |
|
624 spy2.clear(); |
|
625 list.clear(); |
|
626 |
|
627 if ( panGesture ) |
|
628 { |
|
629 delete panGesture; |
|
630 panGesture = NULL; |
|
631 } |
|
632 |
|
633 if ( event ) |
|
634 { |
|
635 delete event; |
|
636 event = NULL; |
|
637 } |
|
638 |
|
639 cleanup(); |
|
640 } |
|
641 |
503 // End of file |
642 // End of file |
504 |
|
505 |
|
506 |
|