44
|
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 User Input Handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <e32err.h>
|
|
19 |
#include <w32std.h>
|
|
20 |
#include <eikenv.h>
|
|
21 |
|
|
22 |
#include <hbapplication.h>
|
|
23 |
#include <hbinstance.h>
|
|
24 |
#include <QDebug>
|
|
25 |
|
|
26 |
#include "testuserinputhandler.h"
|
|
27 |
#include "../stub/inc/mpxvideoviewwrapper.h"
|
|
28 |
#include "../stub/inc/videobaseplaybackview.h"
|
|
29 |
|
|
30 |
#define private public
|
55
|
31 |
#include "videoplaybackuserinputhandler.h"
|
44
|
32 |
#undef private
|
|
33 |
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// main
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
int main(int argc, char *argv[])
|
|
40 |
{
|
|
41 |
HbApplication app(argc, argv);
|
|
42 |
HbMainWindow window;
|
|
43 |
|
|
44 |
TestUserInputHandler tv;
|
|
45 |
|
|
46 |
char *pass[3];
|
|
47 |
pass[0] = argv[0];
|
|
48 |
pass[1] = "-o";
|
|
49 |
pass[2] = "c:\\data\\testuserinputhandler.txt";
|
|
50 |
|
|
51 |
int res = QTest::qExec(&tv, 3, pass);
|
|
52 |
|
|
53 |
return res;
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// init
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void TestUserInputHandler::init()
|
|
62 |
{
|
|
63 |
mBaseVideoView = new VideoBasePlaybackView();
|
|
64 |
mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView );
|
|
65 |
|
55
|
66 |
mUserInputHdlr = CVideoPlaybackUserInputHandler::NewL(mVideoViewWrapper, false);
|
44
|
67 |
}
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
// cleanup
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
void TestUserInputHandler::cleanup()
|
|
74 |
{
|
|
75 |
delete mUserInputHdlr;
|
|
76 |
mUserInputHdlr = NULL;
|
|
77 |
|
|
78 |
delete mVideoViewWrapper;
|
|
79 |
mVideoViewWrapper = NULL;
|
|
80 |
|
|
81 |
delete mBaseVideoView;
|
|
82 |
mBaseVideoView = NULL;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// setup
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void TestUserInputHandler::setup()
|
|
90 |
{
|
|
91 |
}
|
|
92 |
|
|
93 |
void TestUserInputHandler::testProcessMediaKeyPlay()
|
|
94 |
{
|
|
95 |
init();
|
|
96 |
|
|
97 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
98 |
|
|
99 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
100 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
101 |
|
|
102 |
// this event should be ignored as the 1st event is still being processed
|
|
103 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonPress);
|
|
104 |
|
|
105 |
// verify that "Play" is still being processed and not "Pause"
|
|
106 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiPlay );
|
|
107 |
|
|
108 |
// send the release event for "Play"
|
|
109 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
110 |
|
|
111 |
// verify that no input is now being processed
|
|
112 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
113 |
|
|
114 |
cleanup();
|
|
115 |
}
|
|
116 |
|
|
117 |
void TestUserInputHandler::testProcessMediaKeyPause()
|
|
118 |
{
|
|
119 |
init();
|
|
120 |
|
|
121 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
122 |
|
|
123 |
// Issue Play
|
|
124 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
125 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
126 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
127 |
|
|
128 |
// Initiate Pause
|
|
129 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonPress);
|
|
130 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
131 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiPause );
|
|
132 |
|
|
133 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPause, ERemConCoreApiButtonRelease);
|
|
134 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
135 |
|
|
136 |
cleanup();
|
|
137 |
|
|
138 |
}
|
|
139 |
|
|
140 |
void TestUserInputHandler::testProcessMediaKeyPlayPause()
|
|
141 |
{
|
|
142 |
init();
|
|
143 |
|
|
144 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
145 |
|
|
146 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPausePlayFunction, ERemConCoreApiButtonClick);
|
|
147 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
148 |
|
|
149 |
// set to background
|
|
150 |
mUserInputHdlr->iForeground = false;
|
|
151 |
|
|
152 |
mUserInputHdlr->iLastMediaKeyPressed = ENop;
|
|
153 |
// this event should be ignored as iForeground is false
|
|
154 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPausePlayFunction, ERemConCoreApiButtonPress);
|
|
155 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ENop );
|
|
156 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
157 |
|
|
158 |
cleanup();
|
|
159 |
}
|
|
160 |
|
|
161 |
void TestUserInputHandler::testProcessMediaKeyStop()
|
|
162 |
{
|
|
163 |
init();
|
|
164 |
|
|
165 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
166 |
|
|
167 |
// Issue Play
|
|
168 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
169 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
170 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
171 |
|
|
172 |
// Stop
|
|
173 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiStop, ERemConCoreApiButtonPress);
|
|
174 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
175 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiStop );
|
|
176 |
|
|
177 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiStop, ERemConCoreApiButtonRelease);
|
|
178 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
179 |
|
|
180 |
cleanup();
|
|
181 |
}
|
|
182 |
|
|
183 |
void TestUserInputHandler::testProcessMediaKeyForward()
|
|
184 |
{
|
|
185 |
init();
|
|
186 |
|
|
187 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
188 |
|
|
189 |
// Issue Play
|
|
190 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
191 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
192 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
193 |
|
|
194 |
// Forward
|
|
195 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonPress);
|
|
196 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
197 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward );
|
|
198 |
|
|
199 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease);
|
|
200 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
201 |
|
|
202 |
cleanup();
|
|
203 |
}
|
|
204 |
|
|
205 |
void TestUserInputHandler::testProcessMediaKeyRewind()
|
|
206 |
{
|
|
207 |
init();
|
|
208 |
|
|
209 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
210 |
|
|
211 |
// Issue Play
|
|
212 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
213 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
214 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
215 |
|
|
216 |
// Forward
|
|
217 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonPress);
|
|
218 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
219 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiFastForward );
|
|
220 |
|
|
221 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiFastForward, ERemConCoreApiButtonRelease);
|
|
222 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
223 |
|
|
224 |
// Rewind
|
|
225 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiRewind, ERemConCoreApiButtonPress);
|
|
226 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
227 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiRewind );
|
|
228 |
|
|
229 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiRewind, ERemConCoreApiButtonRelease);
|
|
230 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
231 |
|
|
232 |
cleanup();
|
|
233 |
}
|
|
234 |
|
|
235 |
void TestUserInputHandler::testProcessMediaKeyVolumeUp()
|
|
236 |
{
|
|
237 |
init();
|
|
238 |
|
|
239 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
240 |
|
|
241 |
// Issue Play
|
|
242 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
243 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
244 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
245 |
|
|
246 |
// Volume Up
|
|
247 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonPress);
|
|
248 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
249 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeUp );
|
|
250 |
QVERIFY( mUserInputHdlr->iVolumeRepeatTimer->IsActive() );
|
|
251 |
QVERIFY( mUserInputHdlr->iVolumeRepeatUp );
|
|
252 |
|
|
253 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeUp, ERemConCoreApiButtonRelease);
|
|
254 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
255 |
QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() );
|
|
256 |
|
|
257 |
cleanup();
|
|
258 |
}
|
|
259 |
|
|
260 |
void TestUserInputHandler::testProcessMediaKeyVolumeDown()
|
|
261 |
{
|
|
262 |
init();
|
|
263 |
|
|
264 |
mUserInputHdlr->iProcessingInputType = EVideoNone;
|
|
265 |
|
|
266 |
// Issue Play
|
|
267 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonPress);
|
|
268 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiPlay, ERemConCoreApiButtonRelease);
|
|
269 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
270 |
|
|
271 |
// Volume Down
|
|
272 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonPress);
|
|
273 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoMediaKeys );
|
|
274 |
QVERIFY( mUserInputHdlr->iLastMediaKeyPressed == ERemConCoreApiVolumeDown );
|
|
275 |
QVERIFY( mUserInputHdlr->iVolumeRepeatTimer->IsActive() );
|
|
276 |
QVERIFY( ! mUserInputHdlr->iVolumeRepeatUp );
|
|
277 |
|
|
278 |
mUserInputHdlr->ProcessMediaKey(ERemConCoreApiVolumeDown, ERemConCoreApiButtonRelease);
|
|
279 |
QVERIFY( mUserInputHdlr->iProcessingInputType == EVideoNone );
|
|
280 |
QVERIFY( ! mUserInputHdlr->iVolumeRepeatTimer->IsActive() );
|
|
281 |
|
|
282 |
cleanup();
|
|
283 |
}
|
|
284 |
|
|
285 |
void TestUserInputHandler::testHandleTVOutEventL()
|
|
286 |
{
|
|
287 |
|
|
288 |
///////////////////////////////
|
|
289 |
// 1. HandleTVOutEventL(true)
|
|
290 |
///////////////////////////////
|
|
291 |
init();
|
|
292 |
|
|
293 |
mUserInputHdlr->iDisplayTimeOut = 0;
|
|
294 |
|
|
295 |
mUserInputHdlr->HandleTVOutEventL(true);
|
|
296 |
|
|
297 |
QVERIFY( mUserInputHdlr->iDisplayTimeOut != 0 );
|
|
298 |
QVERIFY( mUserInputHdlr->iDisplayTimer->IsActive() );
|
|
299 |
|
|
300 |
cleanup();
|
|
301 |
|
|
302 |
|
|
303 |
///////////////////////////////
|
|
304 |
// 2. HandleTVOutEventL(false)
|
|
305 |
///////////////////////////////
|
|
306 |
init();
|
|
307 |
|
|
308 |
mUserInputHdlr->iDisplayTimeOut = 0;
|
|
309 |
|
|
310 |
mUserInputHdlr->HandleTVOutEventL(false);
|
|
311 |
QVERIFY( ! mUserInputHdlr->iDisplayTimer->IsActive() );
|
|
312 |
|
|
313 |
cleanup();
|
|
314 |
|
|
315 |
}
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
// End of file
|
|
321 |
|
|
322 |
|
|
323 |
|