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