30
|
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 |
#include <e32err.h>
|
|
19 |
#include <w32std.h>
|
|
20 |
|
|
21 |
#include <mmf/common/mmferrors.h>
|
|
22 |
#include <caf/caferr.h>
|
|
23 |
|
|
24 |
#include <mpxvideoplaybackdefs.h>
|
|
25 |
|
|
26 |
#include <hbapplication.h>
|
|
27 |
#include <hbinstance.h>
|
|
28 |
#include <qgraphicssceneevent>
|
|
29 |
#include <QDebug>
|
|
30 |
|
|
31 |
#include "mpxvideoplaybackviewfiledetails.h"
|
|
32 |
|
|
33 |
#include "testvideoplaybackview.h"
|
|
34 |
#include "mpxvideoviewwrapper.h"
|
|
35 |
|
|
36 |
#define private public
|
|
37 |
#define protected public
|
|
38 |
#include "hbvideoplaybackview.h"
|
|
39 |
#include "hbvideobaseplaybackview.h"
|
|
40 |
#undef protected
|
|
41 |
#undef private
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// main
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
int main(int argc, char *argv[])
|
|
51 |
{
|
|
52 |
HbApplication app(argc, argv);
|
|
53 |
HbMainWindow window;
|
|
54 |
|
|
55 |
TestVideoPlaybackView tv;
|
|
56 |
|
|
57 |
char *pass[3];
|
|
58 |
pass[0] = argv[0];
|
|
59 |
pass[1] = "-o";
|
|
60 |
pass[2] = "c:\\data\\TestVideoPlaybackView.txt";
|
|
61 |
|
|
62 |
int res = QTest::qExec(&tv, 3, pass);
|
|
63 |
|
|
64 |
return res;
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// init
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void TestVideoPlaybackView::init()
|
|
73 |
{
|
|
74 |
mVideoView = new HbVideoPlaybackView();
|
|
75 |
}
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
// cleanup
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
void TestVideoPlaybackView::cleanup()
|
|
82 |
{
|
|
83 |
delete mVideoView;
|
|
84 |
mVideoView = NULL;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// setup
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void TestVideoPlaybackView::setup()
|
|
92 |
{
|
|
93 |
init();
|
|
94 |
mVideoView->handleActivateView();
|
|
95 |
}
|
|
96 |
|
|
97 |
|
|
98 |
void TestVideoPlaybackView::testHandleActivateView()
|
|
99 |
{
|
|
100 |
init();
|
|
101 |
mVideoView->handleActivateView();
|
|
102 |
|
|
103 |
QVERIFY( mVideoView->mVideoMpxWrapper->iMediaRequested == true );
|
|
104 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mBitRate, 16000 );
|
|
105 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mTitle, QString("Test Video Title") );
|
|
106 |
|
|
107 |
cleanup();
|
|
108 |
}
|
|
109 |
|
|
110 |
void TestVideoPlaybackView::testHandlePluginError()
|
|
111 |
{ /*
|
|
112 |
setup();
|
|
113 |
|
|
114 |
mVideoView->handlePluginError( KErrGeneral );
|
|
115 |
QVERIFY( mVideoView->isEnabled() );
|
|
116 |
QVERIFY( ! mVideoView->isObscured() );
|
|
117 |
|
|
118 |
mVideoView->handlePluginError( KErrNotSupported );
|
|
119 |
|
|
120 |
mVideoView->handlePluginError( KErrArgument );
|
|
121 |
|
|
122 |
mVideoView->handlePluginError( KErrSessionClosed );
|
|
123 |
|
|
124 |
mVideoView->handlePluginError( KErrTimedOut );
|
|
125 |
|
|
126 |
mVideoView->handlePluginError( KErrNotFound );
|
|
127 |
|
|
128 |
mVideoView->handlePluginError( KErrMMNotEnoughBandwidth );
|
|
129 |
|
|
130 |
mVideoView->handlePluginError( KErrDisconnected );
|
|
131 |
|
|
132 |
mVideoView->handlePluginError( KMPXVideoPlayOver2GDuringVoiceCallError );
|
|
133 |
|
|
134 |
mVideoView->handlePluginError( KErrTimedOut );
|
|
135 |
|
|
136 |
mVideoView->handlePluginError( KErrCancel );
|
|
137 |
|
|
138 |
mVideoView->handlePluginError( KErrCANoPermission );
|
|
139 |
|
|
140 |
mVideoView->handlePluginError( KMPXVideoCallOngoingError );
|
|
141 |
|
|
142 |
mVideoView->handlePluginError( KMPXVideoTvOutPlaybackNotAllowed );
|
|
143 |
|
|
144 |
mVideoView->handlePluginError( KMPXVideoTvOutPlaybackNotAllowedClose );
|
|
145 |
|
|
146 |
cleanup();*/
|
|
147 |
}
|
|
148 |
|
|
149 |
void TestVideoPlaybackView::testDisplayErrorMessage()
|
|
150 |
{
|
|
151 |
setup();
|
|
152 |
|
|
153 |
mVideoView->displayErrorMessage( "test error msg" );
|
|
154 |
|
|
155 |
QVERIFY( mVideoView->isEnabled() );
|
|
156 |
QVERIFY( ! mVideoView->isObscured() );
|
|
157 |
|
|
158 |
cleanup();
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
void TestVideoPlaybackView::testDisplayInfoMessage()
|
|
163 |
{
|
|
164 |
setup();
|
|
165 |
|
|
166 |
mVideoView->displayInfoMessage( "test info msg" );
|
|
167 |
|
|
168 |
QVERIFY( mVideoView->isEnabled() );
|
|
169 |
QVERIFY( ! mVideoView->isObscured() );
|
|
170 |
|
|
171 |
cleanup();
|
|
172 |
}
|
|
173 |
|
|
174 |
|
|
175 |
void TestVideoPlaybackView::testGetWindow()
|
|
176 |
{
|
|
177 |
setup();
|
|
178 |
|
|
179 |
QVERIFY( mVideoView->getWindow() != NULL );
|
|
180 |
|
|
181 |
cleanup();
|
|
182 |
}
|
|
183 |
|
|
184 |
|
|
185 |
void TestVideoPlaybackView::testIssuePlayCommand()
|
|
186 |
{
|
|
187 |
setup();
|
|
188 |
|
|
189 |
mVideoView->issuePlayCommand();
|
|
190 |
|
|
191 |
//JAM remove
|
|
192 |
QVERIFY( mVideoView->isEnabled() );
|
|
193 |
|
|
194 |
cleanup();
|
|
195 |
}
|
|
196 |
|
|
197 |
void TestVideoPlaybackView::testEvent()
|
|
198 |
{
|
|
199 |
setup();
|
|
200 |
|
|
201 |
//
|
|
202 |
// ensure default foreground is false
|
|
203 |
//
|
|
204 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 );
|
|
205 |
|
|
206 |
//
|
|
207 |
// declare foreground/background event
|
|
208 |
//
|
|
209 |
QEvent* windowActivate = new QEvent( QEvent::WindowActivate );
|
|
210 |
QEvent* windowDeactivate = new QEvent( QEvent::WindowDeactivate );
|
|
211 |
|
|
212 |
//
|
|
213 |
// verify the returned value (consumed) of HbVideoBasePlaybackView::event()
|
|
214 |
// for QEvent::WindowActivate is false
|
|
215 |
//
|
|
216 |
QVERIFY( ! mVideoView->event( windowActivate ) );
|
|
217 |
|
|
218 |
//
|
|
219 |
// verify view is in foreground
|
|
220 |
//
|
|
221 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 1 );
|
|
222 |
|
|
223 |
//
|
|
224 |
// verify the returned value (consumed) of HbVideoBasePlaybackView::event()
|
|
225 |
// for QEvent::WindowDeactivate is false
|
|
226 |
//
|
|
227 |
QVERIFY( ! mVideoView->event( windowDeactivate ) );
|
|
228 |
|
|
229 |
//
|
|
230 |
// verify view is in background
|
|
231 |
//
|
|
232 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iForeground, 0 );
|
|
233 |
|
|
234 |
//
|
|
235 |
// clean up
|
|
236 |
//
|
|
237 |
delete windowActivate;
|
|
238 |
windowActivate = NULL;
|
|
239 |
delete windowDeactivate;
|
|
240 |
windowDeactivate = NULL;
|
|
241 |
cleanup();
|
|
242 |
}
|
|
243 |
|
|
244 |
void TestVideoPlaybackView::testClosePlaybackView()
|
|
245 |
{
|
|
246 |
setup();
|
|
247 |
|
|
248 |
QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
|
|
249 |
|
|
250 |
mVideoView->closePlaybackView();
|
|
251 |
|
|
252 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
253 |
|
|
254 |
cleanup();
|
|
255 |
}
|
|
256 |
|
|
257 |
void TestVideoPlaybackView::testMousePressEvent()
|
|
258 |
{
|
|
259 |
setup();
|
|
260 |
|
|
261 |
//
|
|
262 |
// declare QEvent::GraphicsSceneMousePress
|
|
263 |
//
|
|
264 |
QGraphicsSceneMouseEvent* event = new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMousePress );
|
|
265 |
|
|
266 |
//
|
|
267 |
// set m_accept value to false
|
|
268 |
//
|
|
269 |
event->setAccepted( false );
|
|
270 |
|
|
271 |
//
|
|
272 |
// simulate QEvent::GraphicsSceneMousePress event
|
|
273 |
//
|
|
274 |
mVideoView->mousePressEvent( event );
|
|
275 |
|
|
276 |
//
|
|
277 |
// verify event has been accepted
|
|
278 |
//
|
|
279 |
QVERIFY( event->isAccepted() );
|
|
280 |
|
|
281 |
//
|
|
282 |
// clean up
|
|
283 |
//
|
|
284 |
delete event;
|
|
285 |
event = NULL;
|
|
286 |
cleanup();
|
|
287 |
}
|
|
288 |
|
|
289 |
void TestVideoPlaybackView::testMouseReleaseEvent()
|
|
290 |
{
|
|
291 |
setup();
|
|
292 |
|
|
293 |
//
|
|
294 |
// declare QEvent::GraphicsSceneMouseRelease
|
|
295 |
//
|
|
296 |
QGraphicsSceneMouseEvent* event = new QGraphicsSceneMouseEvent( QEvent::GraphicsSceneMouseRelease );
|
|
297 |
|
|
298 |
//
|
|
299 |
// connect to tappedOnScreen() signal and record its emission
|
|
300 |
//
|
|
301 |
QSignalSpy spy( mVideoView, SIGNAL(tappedOnScreen()) );
|
|
302 |
|
|
303 |
//
|
|
304 |
// ensure signal has not been emitted yet
|
|
305 |
//
|
|
306 |
QCOMPARE(spy.count(), 0);
|
|
307 |
|
|
308 |
//
|
|
309 |
// simulate QEvent::GraphicsSceneMousePress event
|
|
310 |
//
|
|
311 |
mVideoView->mouseReleaseEvent( event );
|
|
312 |
|
|
313 |
//
|
|
314 |
// ensure signal has been emitted and its emission count is incremented
|
|
315 |
//
|
|
316 |
QCOMPARE(spy.count(), 1);
|
|
317 |
|
|
318 |
//
|
|
319 |
// clean up
|
|
320 |
//
|
|
321 |
delete event;
|
|
322 |
event = NULL;
|
|
323 |
spy.clear();
|
|
324 |
cleanup();
|
|
325 |
}
|
|
326 |
|
|
327 |
|
|
328 |
void TestVideoPlaybackView::testHandlePdlStateChange()
|
|
329 |
{
|
|
330 |
setup();
|
|
331 |
|
|
332 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") );
|
|
333 |
|
|
334 |
mVideoView->handlePdlStateChange( 0 );
|
|
335 |
|
|
336 |
QCOMPARE( mVideoView->mVideoMpxWrapper->iFileDetails->mClipName, QString("testClip.3gp") );
|
|
337 |
|
|
338 |
cleanup();
|
|
339 |
}
|
|
340 |
|
|
341 |
void TestVideoPlaybackView::testHandleStoppedStateNoPrevView()
|
|
342 |
{
|
|
343 |
setup();
|
|
344 |
|
|
345 |
QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
|
|
346 |
mVideoView->handleStoppedState();
|
|
347 |
|
|
348 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
349 |
|
|
350 |
cleanup();
|
|
351 |
}
|
|
352 |
|
|
353 |
|
|
354 |
void TestVideoPlaybackView::testHandleStoppedStatePrevView()
|
|
355 |
{
|
|
356 |
setup();
|
|
357 |
|
|
358 |
mVideoView->handleStoppedState();
|
|
359 |
|
|
360 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
361 |
|
|
362 |
cleanup();
|
|
363 |
|
|
364 |
}
|
|
365 |
|
|
366 |
void TestVideoPlaybackView::testHandleBackNoPrevView()
|
|
367 |
{
|
|
368 |
setup();
|
|
369 |
|
|
370 |
QVERIFY( ! mVideoView->mTimerForClosingView->isActive() );
|
|
371 |
mVideoView->handleBack();
|
|
372 |
|
|
373 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
374 |
|
|
375 |
cleanup();
|
|
376 |
|
|
377 |
}
|
|
378 |
|
|
379 |
void TestVideoPlaybackView::testHandleBackPrevView()
|
|
380 |
{
|
|
381 |
setup();
|
|
382 |
|
|
383 |
mVideoView->handleBack();
|
|
384 |
|
|
385 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
386 |
|
|
387 |
cleanup();
|
|
388 |
}
|
|
389 |
|
|
390 |
void TestVideoPlaybackView::testHandleSoftkeyback()
|
|
391 |
{
|
|
392 |
setup();
|
|
393 |
|
|
394 |
mVideoView->handleSoftkeyBack();
|
|
395 |
|
|
396 |
QVERIFY( mVideoView->mTimerForClosingView->isActive() );
|
|
397 |
|
|
398 |
cleanup();
|
|
399 |
}
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
void TestVideoPlaybackView::testDoClosePlayer()
|
|
404 |
{
|
|
405 |
// quits app - which can be problematic for the qvptestrunner app
|
|
406 |
|
|
407 |
// setup();
|
|
408 |
//
|
|
409 |
// mVideoView->handleActivateView();
|
|
410 |
//
|
|
411 |
// mVideoView->doClosePlayer();
|
|
412 |
//
|
|
413 |
// cleanup();
|
|
414 |
|
|
415 |
}
|
|
416 |
|
|
417 |
void TestVideoPlaybackView::testHandleDeactivateView()
|
|
418 |
{
|
|
419 |
setup();
|
|
420 |
|
|
421 |
mVideoView->handleDeactivateView();
|
|
422 |
|
|
423 |
QVERIFY( mVideoView->mVideoMpxWrapper == NULL );
|
|
424 |
|
|
425 |
cleanup();
|
|
426 |
}
|
|
427 |
|
|
428 |
|
|
429 |
// End of file
|
|
430 |
|
|
431 |
|
|
432 |
|