36
|
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: Videoplayerengine test class implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// Version : %version: %
|
|
19 |
|
|
20 |
// INCLUDES
|
|
21 |
#include <QtTest/QtTest>
|
|
22 |
#include <qdebug.h>
|
|
23 |
|
|
24 |
#include <hbapplication.h>
|
|
25 |
#include <f32file.h>
|
|
26 |
#include <bautils.h>
|
|
27 |
#include <mpxmessagegeneraldefs.h>
|
|
28 |
#include <mpxplaybackmessage.h>
|
|
29 |
|
|
30 |
#include "stub/inc/testutilities.h"
|
|
31 |
|
|
32 |
#include "mpxplaybackutilityimp_stub.h"
|
|
33 |
#include "mpxcollectionutilityimp_stub.h"
|
|
34 |
|
|
35 |
#include "stub/inc/hbinstance.h"
|
|
36 |
#include "mpxhbvideocommondefs.h"
|
|
37 |
#include "testvideoappuiengine.h"
|
|
38 |
#include "../stub/inc/mpxvideoplaybackwrapper.h"
|
|
39 |
#define private public
|
|
40 |
#include "mpxvideoplayerappuiengine.h"
|
|
41 |
#undef private
|
|
42 |
#include "mpxvideo_debug.h"
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// main
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
int main(int argc, char *argv[])
|
|
52 |
{
|
|
53 |
HbApplication app(argc, argv);
|
|
54 |
|
|
55 |
TestVideoAppUiEngine tc;
|
|
56 |
|
|
57 |
char *pass[3];
|
|
58 |
pass[0] = argv[0];
|
|
59 |
pass[1] = "-o";
|
|
60 |
pass[2] = "c:\\data\\TestVideoAppUiEngine.txt";
|
|
61 |
|
|
62 |
return QTest::qExec(&tc, 3, pass);
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
TestVideoAppUiEngine::TestVideoAppUiEngine()
|
|
67 |
: mTestObject(0)
|
|
68 |
{
|
|
69 |
MPX_DEBUG(_L("TestVideoAppUiEngine::TestVideoAppUiEngine()"));
|
|
70 |
}
|
|
71 |
|
|
72 |
TestVideoAppUiEngine::~TestVideoAppUiEngine()
|
|
73 |
{
|
|
74 |
MPX_ENTER_EXIT(_L("TestVideoAppUiEngine::~TestVideoAppUiEngine()"));
|
|
75 |
|
|
76 |
delete mTestObject;
|
|
77 |
mTestObject = 0;
|
|
78 |
|
|
79 |
delete mPlaybackWrapper;
|
|
80 |
mPlaybackWrapper = 0;
|
|
81 |
|
|
82 |
|
|
83 |
TestUtilities* utility = reinterpret_cast<TestUtilities*>( UserSvr::DllTls(12345678) );
|
|
84 |
utility->iPlaybackUtility->RemoveTestObserverL();
|
|
85 |
|
|
86 |
}
|
|
87 |
|
|
88 |
|
|
89 |
void TestVideoAppUiEngine::init()
|
|
90 |
{
|
|
91 |
MPX_ENTER_EXIT(_L("TestVideoAppUiEngine::init()"));
|
|
92 |
|
|
93 |
mTestResult = false;
|
|
94 |
|
|
95 |
mPlaybackWrapper = new QMpxVideoPlaybackWrapper();
|
|
96 |
|
|
97 |
TRAPD( createErr, mTestObject = CMpxVideoPlayerAppUiEngine::NewL( mPlaybackWrapper ) );
|
|
98 |
|
|
99 |
QVERIFY( !createErr );
|
|
100 |
|
|
101 |
QVERIFY( mTestObject->iCollectionUtility );
|
|
102 |
|
|
103 |
TRAPD( initErr, mTestObject->LateInitL() );
|
|
104 |
|
|
105 |
QVERIFY( !initErr );
|
|
106 |
|
|
107 |
TestUtilities* utility = reinterpret_cast<TestUtilities*>( UserSvr::DllTls(12345678) );
|
|
108 |
|
|
109 |
TRAP_IGNORE( utility->iPlaybackUtility->AddTestObserverL( this ) );
|
|
110 |
}
|
|
111 |
|
|
112 |
void TestVideoAppUiEngine::cleanup()
|
|
113 |
{
|
|
114 |
MPX_ENTER_EXIT(_L("TestVideoAppUiEngine::cleanup()"));
|
|
115 |
|
|
116 |
delete mTestObject;
|
|
117 |
mTestObject = 0;
|
|
118 |
|
|
119 |
delete mPlaybackWrapper;
|
|
120 |
mPlaybackWrapper = 0;
|
|
121 |
|
|
122 |
TestUtilities* utility = reinterpret_cast<TestUtilities*>( UserSvr::DllTls(12345678) );
|
|
123 |
if ( utility )
|
|
124 |
{
|
|
125 |
utility->iPlaybackUtility->RemoveTestObserverL();
|
|
126 |
}
|
|
127 |
|
|
128 |
}
|
|
129 |
|
|
130 |
void TestVideoAppUiEngine::cleanupTestCase()
|
|
131 |
{
|
|
132 |
MPX_DEBUG(_L("TestVideoAppUiEngine::cleanupTestCase()"));
|
|
133 |
// all common cleanup here
|
|
134 |
}
|
|
135 |
|
|
136 |
void TestVideoAppUiEngine::testPlaybackUtility()
|
|
137 |
{
|
|
138 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testPlaybackUtility()"));
|
|
139 |
|
|
140 |
init();
|
|
141 |
|
|
142 |
QVERIFY( mTestObject->PlaybackUtility() );
|
|
143 |
|
|
144 |
}
|
|
145 |
|
|
146 |
void TestVideoAppUiEngine::testOpenFile()
|
|
147 |
{
|
|
148 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testOpenFile()"));
|
|
149 |
|
|
150 |
// Test for local file
|
|
151 |
init();
|
|
152 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
153 |
mExpectedEvent->iEvent = EPlaybackUtilityInitFileName;
|
|
154 |
TRAPD( openFileErr, mTestObject->OpenFileL( KTestLocalFilename ) );
|
|
155 |
QVERIFY( !openFileErr );
|
|
156 |
QVERIFY( mTestResult );
|
|
157 |
|
|
158 |
// Test for streaming link
|
|
159 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
160 |
mExpectedEvent->iEvent = EPlaybackUtilityInitStreamingUrl;
|
|
161 |
TRAPD( openRamFileErr, mTestObject->OpenFileL( KTestRamFilename ) );
|
|
162 |
QVERIFY( !openRamFileErr );
|
|
163 |
QVERIFY( mTestResult );
|
|
164 |
|
|
165 |
// Test for a url
|
|
166 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
167 |
mExpectedEvent->iEvent = EPlaybackUtilityInitStreamingUrl;
|
|
168 |
TRAPD( openUrlErr, mTestObject->OpenFileL( KTestRtspUrl ) );
|
|
169 |
QVERIFY( !openUrlErr );
|
|
170 |
QVERIFY( mTestResult );
|
|
171 |
|
|
172 |
}
|
|
173 |
|
|
174 |
void TestVideoAppUiEngine::testOpenMedia()
|
|
175 |
{
|
|
176 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testOpenMedia()"));
|
|
177 |
|
|
178 |
init();
|
|
179 |
|
|
180 |
CMPXMedia* media = CMPXMedia::NewL();
|
|
181 |
CleanupStack::PushL( media );
|
|
182 |
media->SetTextValueL( KMPXMediaGeneralUri, KTestLocalFilename );
|
|
183 |
media->SetTObjectValueL( KMPXMediaGeneralId, TMPXItemId( 1, 2 ) );
|
|
184 |
|
|
185 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
186 |
mExpectedEvent->iEvent = EPlaybackUtilityInitPlaylist;
|
|
187 |
|
|
188 |
TRAPD( err, mTestObject->OpenMediaL( *media ) );
|
|
189 |
QVERIFY( !err );
|
|
190 |
QVERIFY( mTestResult );
|
|
191 |
|
|
192 |
}
|
|
193 |
|
|
194 |
void TestVideoAppUiEngine::testDoHandlePlaybackMessage()
|
|
195 |
{
|
|
196 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testDoHandlePlaybackMessage()"));
|
|
197 |
|
|
198 |
init();
|
|
199 |
|
|
200 |
QSignalSpy spy( mPlaybackWrapper, SIGNAL(handlePlaybackView(int)) );
|
|
201 |
QCOMPARE(spy.count(), 0);
|
|
202 |
|
|
203 |
CMPXMessage* msg = CreateMpxMessageLC(TMPXPlaybackMessage::EPlayerChanged, 0, 0);
|
|
204 |
TRAPD(err, mTestObject->DoHandlePlaybackMessageL( *msg ));
|
|
205 |
QVERIFY( !err );
|
|
206 |
|
|
207 |
QCOMPARE(spy.count(), 1);
|
|
208 |
spy.clear();
|
|
209 |
|
|
210 |
}
|
|
211 |
|
|
212 |
void TestVideoAppUiEngine::testPrepareCloseMpx()
|
|
213 |
{
|
|
214 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testPrepareCloseMpx()"));
|
|
215 |
|
|
216 |
init();
|
|
217 |
|
|
218 |
TRAPD( err, mTestObject->PrepareCloseMpxL() );
|
|
219 |
|
|
220 |
QVERIFY( !err );
|
|
221 |
|
|
222 |
}
|
|
223 |
|
|
224 |
void TestVideoAppUiEngine::testDoHandleCollectionMedia()
|
|
225 |
{
|
|
226 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testDoHandleCollectionMedia()"));
|
|
227 |
|
|
228 |
init();
|
|
229 |
|
|
230 |
CMPXMedia* media = CMPXMedia::NewL();
|
|
231 |
CleanupStack::PushL( media );
|
|
232 |
media->SetTextValueL( KMPXMediaGeneralUri, KTestLocalFilename );
|
|
233 |
media->SetTObjectValueL( KMPXMediaGeneralId, TMPXItemId( 1, 2 ) );
|
|
234 |
|
|
235 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
236 |
mExpectedEvent->iEvent = EPlaybackUtilityInitPlaylist;
|
|
237 |
|
|
238 |
TRAPD( err, mTestObject->DoHandelCollectionMediaL( *media ) );
|
|
239 |
QVERIFY( !err );
|
|
240 |
QVERIFY( mTestResult );
|
|
241 |
|
|
242 |
}
|
|
243 |
|
|
244 |
void TestVideoAppUiEngine::testHandlePlaybackMessage()
|
|
245 |
{
|
|
246 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testHandlePlaybackMessage()"));
|
|
247 |
|
|
248 |
init();
|
|
249 |
|
|
250 |
QSignalSpy spy( mPlaybackWrapper, SIGNAL(handlePlaybackView(int)) );
|
|
251 |
QCOMPARE(spy.count(), 0);
|
|
252 |
|
|
253 |
mTestObject->iUpdateSeekInfo = ETrue;
|
|
254 |
|
|
255 |
CMPXMessage* msg = CreateMpxMessageLC(TMPXPlaybackMessage::EPlayerChanged, 0, 0);
|
|
256 |
mTestObject->HandlePlaybackMessage( msg, KErrNone );
|
|
257 |
|
|
258 |
QCOMPARE(spy.count(), 1);
|
|
259 |
spy.clear();
|
|
260 |
|
|
261 |
QVERIFY( ! mTestObject->iUpdateSeekInfo );
|
|
262 |
}
|
|
263 |
|
|
264 |
void TestVideoAppUiEngine::testHandleCollectionMessage()
|
|
265 |
{
|
|
266 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testHandleCollectionMessage()"));
|
|
267 |
|
|
268 |
init();
|
|
269 |
|
|
270 |
// Test for EMcItemOpened
|
|
271 |
//
|
|
272 |
CMPXMessage* msg = CreateMpxMessageLC(4, EMcPathChangedByOpen, EMcItemOpened); // EPathChanged => 4
|
|
273 |
mTestObject->HandleCollectionMessage( msg, KErrNone );
|
|
274 |
QVERIFY( mTestObject->iCollectionUtility );
|
|
275 |
|
|
276 |
// Test for EMcContainerOpened
|
|
277 |
//
|
|
278 |
mTestObject->iMultilinkPlaylist = ETrue;
|
|
279 |
|
|
280 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
281 |
mExpectedEvent->iEvent = EPlaybackUtilityInitPlaylist;
|
|
282 |
|
|
283 |
delete msg;
|
|
284 |
msg = NULL;
|
|
285 |
msg = CreateMpxMessageLC(4, EMcPathChangedByOpen, EMcContainerOpened);
|
|
286 |
mTestObject->HandleCollectionMessage( msg, KErrNone );
|
|
287 |
|
|
288 |
QVERIFY( mTestResult );
|
|
289 |
|
|
290 |
}
|
|
291 |
|
|
292 |
void TestVideoAppUiEngine::testHandleCollectionMedia()
|
|
293 |
{
|
|
294 |
MPX_DEBUG(_L("TestVideoAppUiEngine::testHandleCollectionMedia()"));
|
|
295 |
|
|
296 |
init();
|
|
297 |
|
|
298 |
CMPXMedia* media = CMPXMedia::NewL();
|
|
299 |
CleanupStack::PushL( media );
|
|
300 |
media->SetTextValueL( KMPXMediaGeneralUri, KTestLocalFilename );
|
|
301 |
media->SetTObjectValueL( KMPXMediaGeneralId, TMPXItemId( 1, 2 ) );
|
|
302 |
|
|
303 |
mExpectedEvent = new (ELeave) TCallbackEvent;
|
|
304 |
mExpectedEvent->iEvent = EPlaybackUtilityInitPlaylist;
|
|
305 |
|
|
306 |
TRAPD( err, mTestObject->HandleCollectionMediaL( *media, KErrNone ) );
|
|
307 |
QVERIFY( !err );
|
|
308 |
QVERIFY( mTestResult );
|
|
309 |
|
|
310 |
}
|
|
311 |
|
|
312 |
void TestVideoAppUiEngine::HandleUtilityEvent( TCallbackEvent* aEvent )
|
|
313 |
{
|
|
314 |
MPX_DEBUG(_L("TestVideoAppUiEngine::HandleUtilityEvent()"));
|
|
315 |
|
|
316 |
if ( mExpectedEvent->iEvent == aEvent->iEvent )
|
|
317 |
{
|
|
318 |
switch ( aEvent->iEvent )
|
|
319 |
{
|
|
320 |
case EPlaybackUtilityInitFileName:
|
|
321 |
{
|
|
322 |
if ( aEvent->iFileName == KTestLocalFilename )
|
|
323 |
{
|
|
324 |
mTestResult = true;
|
|
325 |
}
|
|
326 |
break;
|
|
327 |
}
|
|
328 |
case EPlaybackUtilityInitStreamingUrl:
|
|
329 |
{
|
|
330 |
if ( aEvent->iFileName == KTestRamFilename )
|
|
331 |
{
|
|
332 |
mTestResult = true;
|
|
333 |
}
|
|
334 |
break;
|
|
335 |
}
|
|
336 |
case EPlaybackUtilityInitPlaylist:
|
|
337 |
{
|
|
338 |
mTestResult = true;
|
|
339 |
break;
|
|
340 |
}
|
|
341 |
case EAsxAttributeSeekUpdate:
|
|
342 |
{
|
|
343 |
mTestResult = true;
|
|
344 |
break;
|
|
345 |
}
|
|
346 |
|
|
347 |
}
|
|
348 |
|
|
349 |
}
|
|
350 |
|
|
351 |
delete aEvent;
|
|
352 |
}
|
|
353 |
|
|
354 |
// -------------------------------------------------------------------------------------------------
|
|
355 |
// CMpxVideoPlayer_AppUiEngineTester::CreateMpxMessageLC
|
|
356 |
// -------------------------------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
CMPXMessage*
|
|
359 |
TestVideoAppUiEngine::CreateMpxMessageLC( int aEvent, int aType, int aData )
|
|
360 |
{
|
|
361 |
MPX_ENTER_EXIT(_L("TestVideoAppUiEngine::CreateMpxMessageLC()"));
|
|
362 |
|
|
363 |
CMPXMessage* pbMessage = CMPXMessage::NewL();
|
|
364 |
CleanupStack::PushL( pbMessage );
|
|
365 |
|
|
366 |
pbMessage->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, KMPXMessageGeneral );
|
|
367 |
pbMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralEvent, aEvent );
|
|
368 |
pbMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralType, aType );
|
|
369 |
pbMessage->SetTObjectValueL<TInt>( KMPXMessageGeneralData, aData );
|
|
370 |
|
|
371 |
return pbMessage;
|
|
372 |
}
|
|
373 |
|
|
374 |
|
|
375 |
// End of file
|
|
376 |
|
|
377 |
|
|
378 |
|