|
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 Video Display 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 <mpxplaybackutility.h> |
|
27 |
|
28 #include "testvideodisplayhandler.h" |
|
29 #include "../stub/inc/videobaseplaybackview.h" |
|
30 #include "../stub/inc/videoplaybackviewfiledetails.h" |
|
31 #include "mpxvideoviewwrapper.h" |
|
32 |
|
33 #define private public |
|
34 #include "mpxvideoplaybackdisplayhandler.h" |
|
35 #undef private |
|
36 |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // main |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 int main(int argc, char *argv[]) |
|
43 { |
|
44 HbApplication app(argc, argv); |
|
45 HbMainWindow window; |
|
46 |
|
47 TestVideoDisplayHandler tv; |
|
48 |
|
49 char *pass[3]; |
|
50 pass[0] = argv[0]; |
|
51 pass[1] = "-o"; |
|
52 pass[2] = "c:\\data\\testvideodisplayhandler.txt"; |
|
53 |
|
54 int res = QTest::qExec(&tv, 3, pass); |
|
55 |
|
56 return res; |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // init |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void TestVideoDisplayHandler::init() |
|
65 { |
|
66 mPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault ); |
|
67 |
|
68 mBaseVideoView = new VideoBasePlaybackView(); |
|
69 mVideoViewWrapper = CMPXVideoViewWrapper::NewL( mBaseVideoView ); |
|
70 |
|
71 mDispHdlr = CMPXVideoPlaybackDisplayHandler::NewL(mPlaybackUtility, mVideoViewWrapper); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // cleanup |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void TestVideoDisplayHandler::cleanup() |
|
79 { |
|
80 if ( mPlaybackUtility ) |
|
81 { |
|
82 mPlaybackUtility->Close(); |
|
83 mPlaybackUtility = NULL; |
|
84 } |
|
85 |
|
86 delete mDispHdlr; |
|
87 mDispHdlr = NULL; |
|
88 |
|
89 delete mVideoViewWrapper; |
|
90 mVideoViewWrapper = NULL; |
|
91 |
|
92 delete mBaseVideoView; |
|
93 mBaseVideoView = NULL; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // setup |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 void TestVideoDisplayHandler::setup() |
|
101 { |
|
102 init(); |
|
103 |
|
104 RWindow *window = mBaseVideoView->getWindow(); |
|
105 |
|
106 TRect displayRect = TRect( window->Position().iX, |
|
107 window->Position().iY, |
|
108 window->Position().iX + window->Size().iWidth, |
|
109 window->Position().iY + window->Size().iHeight ); |
|
110 |
|
111 mDispHdlr->CreateDisplayWindowL( CCoeEnv::Static()->WsSession(), |
|
112 *(CCoeEnv::Static()->ScreenDevice()), |
|
113 *window, |
|
114 displayRect); |
|
115 |
|
116 QCOMPARE( mDispHdlr->iWindowRect, displayRect); |
|
117 |
|
118 } |
|
119 |
|
120 |
|
121 void TestVideoDisplayHandler::testCreateDisplayWindowL() |
|
122 { |
|
123 setup(); |
|
124 |
|
125 cleanup(); |
|
126 } |
|
127 |
|
128 void TestVideoDisplayHandler::testRemoveDisplayWindow() |
|
129 { |
|
130 setup(); |
|
131 |
|
132 mDispHdlr->RemoveDisplayWindow(); |
|
133 |
|
134 QVERIFY( mDispHdlr->iVideoContainer == NULL ); |
|
135 |
|
136 cleanup(); |
|
137 } |
|
138 |
|
139 void TestVideoDisplayHandler::testHandleSurfaceCreatedMessageL() |
|
140 { |
|
141 setup(); |
|
142 |
|
143 CMPXMessage* message = NULL; |
|
144 TRAP_IGNORE |
|
145 ( |
|
146 message = CMPXMessage::NewL(); |
|
147 message->SetTObjectValueL<TMPXVideoDisplayCommand> |
|
148 ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceCreated ); |
|
149 ); |
|
150 |
|
151 mDispHdlr->HandleVideoDisplayMessageL( message ); |
|
152 |
|
153 QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() ); |
|
154 QVERIFY( mDispHdlr->iViewWrapper->iAttatched ); |
|
155 |
|
156 mDispHdlr->RemoveDisplayWindow(); |
|
157 cleanup(); |
|
158 } |
|
159 |
|
160 void TestVideoDisplayHandler::testHandleSurfaceChangedMessageL() |
|
161 { |
|
162 setup(); |
|
163 |
|
164 CMPXMessage* message = NULL; |
|
165 TRAP_IGNORE |
|
166 ( |
|
167 message = CMPXMessage::NewL(); |
|
168 message->SetTObjectValueL<TMPXVideoDisplayCommand> |
|
169 ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceChanged ); |
|
170 ); |
|
171 |
|
172 mDispHdlr->HandleVideoDisplayMessageL( message ); |
|
173 |
|
174 QVERIFY( ! mDispHdlr->iSurfaceId.IsNull() ); |
|
175 |
|
176 mDispHdlr->RemoveDisplayWindow(); |
|
177 cleanup(); |
|
178 } |
|
179 |
|
180 void TestVideoDisplayHandler::testHandleVideoRemovedMessageL() |
|
181 { |
|
182 setup(); |
|
183 |
|
184 CMPXMessage* message = NULL; |
|
185 TRAP_IGNORE |
|
186 ( |
|
187 message = CMPXMessage::NewL(); |
|
188 message->SetTObjectValueL<TMPXVideoDisplayCommand> |
|
189 ( KMPXMediaVideoDisplayCommand, EPbMsgVideoSurfaceRemoved ); |
|
190 ); |
|
191 |
|
192 mDispHdlr->HandleVideoDisplayMessageL( message ); |
|
193 |
|
194 QVERIFY( mDispHdlr->iSurfaceId.IsNull() ); |
|
195 QVERIFY( ! mDispHdlr->iViewWrapper->iAttatched ); |
|
196 |
|
197 mDispHdlr->RemoveDisplayWindow(); |
|
198 cleanup(); |
|
199 } |
|
200 |
|
201 void TestVideoDisplayHandler::testSetAspectRatioL() |
|
202 { |
|
203 setup(); |
|
204 |
|
205 int aspectRatio = mDispHdlr->SetAspectRatioL( EPbCmdNaturalAspectRatio ); |
|
206 |
|
207 QVERIFY( aspectRatio == EMMFNatural ); |
|
208 |
|
209 mDispHdlr->RemoveDisplayWindow(); |
|
210 cleanup(); |
|
211 } |
|
212 |
|
213 void TestVideoDisplayHandler::testSetDefaultAspectRatioL() |
|
214 { |
|
215 setup(); |
|
216 |
|
217 // |
|
218 // get window size |
|
219 // |
|
220 RWindow *window = mBaseVideoView->getWindow(); |
|
221 TRect displayRect = TRect( TPoint( window->Position() ), TSize( window->Size() ) ); |
|
222 |
|
223 // |
|
224 // get window aspect ratio |
|
225 // if device is in landscape mode, width > height |
|
226 // if device is in portrait mode, width < height |
|
227 // |
|
228 TReal32 width = (TReal32) displayRect.Width(); |
|
229 TReal32 height = (TReal32) displayRect.Height(); |
|
230 TReal32 displayAspectRatio = (width > height)? (width / height) : (height / width); |
|
231 |
|
232 // |
|
233 // aspect ratio zoom |
|
234 // |
|
235 mFileDetails = new VideoPlaybackViewFileDetails(); |
|
236 mFileDetails->mVideoHeight = 280; |
|
237 mFileDetails->mVideoWidth = 600; |
|
238 |
|
239 int aspectRatio = mDispHdlr->SetDefaultAspectRatioL( mFileDetails, displayAspectRatio ); |
|
240 |
|
241 QVERIFY( aspectRatio == EMMFZoom ); |
|
242 |
|
243 // |
|
244 // aspect ratio stretch |
|
245 // |
|
246 mFileDetails->mVideoHeight = 144; |
|
247 mFileDetails->mVideoWidth = 220; |
|
248 |
|
249 aspectRatio = mDispHdlr->SetDefaultAspectRatioL( mFileDetails, displayAspectRatio ); |
|
250 |
|
251 QVERIFY( aspectRatio == EMMFStretch ); |
|
252 |
|
253 mDispHdlr->RemoveDisplayWindow(); |
|
254 |
|
255 cleanup(); |
|
256 } |
|
257 |
|
258 void TestVideoDisplayHandler::testUpdateVideoRectL() |
|
259 { |
|
260 setup(); |
|
261 |
|
262 RWindow *window = mBaseVideoView->getWindow(); |
|
263 |
|
264 TRect displayRect = TRect( 0, 0, 200, 300 ); |
|
265 |
|
266 mDispHdlr->UpdateVideoRectL( displayRect, false ); |
|
267 |
|
268 QCOMPARE( mDispHdlr->iWindowRect, displayRect); |
|
269 |
|
270 mDispHdlr->RemoveDisplayWindow(); |
|
271 cleanup(); |
|
272 } |
|
273 |
|
274 // End of file |
|
275 |