os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/TestPlayer.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "TestPlayer.h"
sl@0
    17
sl@0
    18
#include <e32math.h>
sl@0
    19
sl@0
    20
/**
sl@0
    21
 * Constructor
sl@0
    22
 */
sl@0
    23
CTestVclntVideoFile::CTestVclntVideoFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
    24
	:iPlay (aPlay)
sl@0
    25
	{
sl@0
    26
	// store the name of this test case
sl@0
    27
	// this is the name that is used by the script file
sl@0
    28
	// Each test step initialises it's own name
sl@0
    29
	iTestStepName = aTestName;
sl@0
    30
	iSectName = aSectName;
sl@0
    31
	iKeyName = aKeyName;
sl@0
    32
sl@0
    33
	// expand heap, so we can load 80k video
sl@0
    34
	iHeapSize = 150000;
sl@0
    35
	}
sl@0
    36
sl@0
    37
CTestVclntVideoFile* CTestVclntVideoFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
    38
	{
sl@0
    39
	CTestVclntVideoFile* self = new (ELeave) CTestVclntVideoFile(aTestName,aSectName,aKeyName,aPlay);
sl@0
    40
	return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
sl@0
    41
	}
sl@0
    42
sl@0
    43
CTestVclntVideoFile* CTestVclntVideoFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
    44
	{
sl@0
    45
	CTestVclntVideoFile* self = CTestVclntVideoFile::NewLC(aTestName,aSectName,aKeyName,aPlay);
sl@0
    46
	CleanupStack::PushL(self);
sl@0
    47
	return self;
sl@0
    48
	}
sl@0
    49
sl@0
    50
void CTestVclntVideoFile::MvpuoOpenComplete(TInt aError)
sl@0
    51
	{
sl@0
    52
	iError = aError;
sl@0
    53
	INFO_PRINTF1(_L("Open Complete callback"));
sl@0
    54
	CActiveScheduler::Stop();
sl@0
    55
	}
sl@0
    56
sl@0
    57
void CTestVclntVideoFile::MvpuoPrepareComplete(TInt aError)
sl@0
    58
	{
sl@0
    59
	iError = aError;
sl@0
    60
	INFO_PRINTF1(_L("Open Complete callback"));
sl@0
    61
	CActiveScheduler::Stop();
sl@0
    62
	}
sl@0
    63
sl@0
    64
void CTestVclntVideoFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
sl@0
    65
	{
sl@0
    66
	iError = aError;
sl@0
    67
	INFO_PRINTF1(_L("Frame Ready callback"));
sl@0
    68
	}
sl@0
    69
sl@0
    70
void CTestVclntVideoFile::MvpuoPlayComplete(TInt aError)
sl@0
    71
	{
sl@0
    72
	iError = aError;
sl@0
    73
	INFO_PRINTF1(_L("Play Complete callback"));
sl@0
    74
	CActiveScheduler::Stop();
sl@0
    75
	}
sl@0
    76
	
sl@0
    77
void CTestVclntVideoFile::MvpuoEvent(const TMMFEvent& /*aEvent*/)
sl@0
    78
	{
sl@0
    79
	}
sl@0
    80
sl@0
    81
sl@0
    82
/**
sl@0
    83
 * Load and initialise an audio file.
sl@0
    84
 */
sl@0
    85
TVerdict CTestVclntVideoFile::DoTestStepL()
sl@0
    86
	{
sl@0
    87
	TVerdict ret = EFail;
sl@0
    88
	iError = KErrTimedOut;
sl@0
    89
sl@0
    90
	INFO_PRINTF1(_L("Test : Video Player - File"));
sl@0
    91
sl@0
    92
	TPtrC filename;
sl@0
    93
	if(!GetStringFromConfig(iSectName,iKeyName,filename))
sl@0
    94
		return EInconclusive;
sl@0
    95
sl@0
    96
	InitWservL();
sl@0
    97
sl@0
    98
	TRect rect, clipRect;
sl@0
    99
	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
sl@0
   100
															EMdaPriorityPreferenceTimeAndQuality,
sl@0
   101
															iWs, *iScreen, *iWindow, rect, clipRect);
sl@0
   102
	CleanupStack::PushL(player);
sl@0
   103
	TRAP(iError,player->OpenFileL(filename));
sl@0
   104
	
sl@0
   105
	if(iError == KErrNone)
sl@0
   106
		{
sl@0
   107
		// Wait for initialisation callback
sl@0
   108
		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
sl@0
   109
		CActiveScheduler::Start();
sl@0
   110
		}
sl@0
   111
sl@0
   112
	// Until JetStream
sl@0
   113
#ifndef JETSTREAM_TESTS
sl@0
   114
	if(iError == KErrNotSupported)
sl@0
   115
		ret = EPass;
sl@0
   116
#endif
sl@0
   117
sl@0
   118
	// Check for errors.
sl@0
   119
	if (iError == KErrNone && player != NULL)
sl@0
   120
		{
sl@0
   121
		player->Prepare();
sl@0
   122
		CActiveScheduler::Start();
sl@0
   123
		}
sl@0
   124
sl@0
   125
	// Check for errors.
sl@0
   126
	if (iError == KErrNone && player != NULL)
sl@0
   127
		ret = DoTestL(player);
sl@0
   128
		
sl@0
   129
	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
sl@0
   130
	CleanupStack::PopAndDestroy(player);
sl@0
   131
	if(iError != KErrNone)
sl@0
   132
		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
sl@0
   133
	return	ret;
sl@0
   134
	}
sl@0
   135
sl@0
   136
TVerdict CTestVclntVideoFile::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   137
	{
sl@0
   138
	TVerdict ret = EFail;
sl@0
   139
sl@0
   140
// #ifdef JETSTREAM_TESTS
sl@0
   141
	if(iPlay)
sl@0
   142
		{
sl@0
   143
		iError = KErrTimedOut;
sl@0
   144
		aPlayer->Play();
sl@0
   145
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file"));
sl@0
   146
		// Wait for init callback
sl@0
   147
		CActiveScheduler::Start();
sl@0
   148
		if(iError == KErrNone)
sl@0
   149
			ret = EPass;
sl@0
   150
		}
sl@0
   151
	else
sl@0
   152
		ret = EPass;
sl@0
   153
// #else
sl@0
   154
//	aPlayer->Stop();
sl@0
   155
// #endif
sl@0
   156
sl@0
   157
	return ret;
sl@0
   158
	}
sl@0
   159
sl@0
   160
//------------------------------------------------------------------
sl@0
   161
sl@0
   162
/**
sl@0
   163
 * Constructor
sl@0
   164
 */
sl@0
   165
CTestVclntVideoDes::CTestVclntVideoDes(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay)
sl@0
   166
	:iPlay (aPlay)
sl@0
   167
sl@0
   168
	{
sl@0
   169
	// store the name of this test case
sl@0
   170
	// this is the name that is used by the script file
sl@0
   171
	// Each test step initialises it's own name
sl@0
   172
	iTestStepName = aTestName;
sl@0
   173
	iSectName = aSectName;
sl@0
   174
	iKeyName = aKeyName;
sl@0
   175
sl@0
   176
	// *** Jim : expand heap, so we can load 80k video
sl@0
   177
	iHeapSize = 150000;
sl@0
   178
	}
sl@0
   179
sl@0
   180
CTestVclntVideoDes* CTestVclntVideoDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
   181
	{
sl@0
   182
	CTestVclntVideoDes* self = new (ELeave) CTestVclntVideoDes(aTestName,aSectName,aKeyName,aPlay);
sl@0
   183
	return self;
sl@0
   184
	}
sl@0
   185
sl@0
   186
CTestVclntVideoDes* CTestVclntVideoDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
   187
	{
sl@0
   188
	CTestVclntVideoDes* self = CTestVclntVideoDes::NewLC(aTestName,aSectName,aKeyName,aPlay);
sl@0
   189
	CleanupStack::PushL(self);
sl@0
   190
	return self;
sl@0
   191
	}
sl@0
   192
sl@0
   193
void CTestVclntVideoDes::MvpuoOpenComplete(TInt aError)
sl@0
   194
	{
sl@0
   195
	iError = aError;
sl@0
   196
	CActiveScheduler::Stop();
sl@0
   197
	}
sl@0
   198
sl@0
   199
void CTestVclntVideoDes::MvpuoPrepareComplete(TInt aError)
sl@0
   200
	{
sl@0
   201
	iError = aError;
sl@0
   202
	CActiveScheduler::Stop();
sl@0
   203
	}
sl@0
   204
sl@0
   205
void CTestVclntVideoDes::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
sl@0
   206
	{
sl@0
   207
	iError = aError;
sl@0
   208
	// Will this function require a Active Scheduler Stop?
sl@0
   209
	}
sl@0
   210
sl@0
   211
void CTestVclntVideoDes::MvpuoPlayComplete(TInt aError)
sl@0
   212
	{
sl@0
   213
	iError = aError;
sl@0
   214
	CActiveScheduler::Stop();
sl@0
   215
	}
sl@0
   216
	
sl@0
   217
void CTestVclntVideoDes::MvpuoEvent(const TMMFEvent& /*aEvent*/)
sl@0
   218
	{
sl@0
   219
	}
sl@0
   220
sl@0
   221
sl@0
   222
TVerdict  CTestVclntVideoDes::DoTestStepPreambleL()
sl@0
   223
	{
sl@0
   224
	TPtrC filename; 
sl@0
   225
	if(!GetStringFromConfig(iSectName, iKeyName, filename))
sl@0
   226
		return EInconclusive;
sl@0
   227
sl@0
   228
	RFs fs;
sl@0
   229
	RFile file;
sl@0
   230
	TInt size = 0;
sl@0
   231
sl@0
   232
	// connect to file system and open file
sl@0
   233
	User::LeaveIfError(fs.Connect());
sl@0
   234
	User::LeaveIfError(file.Open(fs,filename,EFileRead));
sl@0
   235
	CleanupClosePushL(file);
sl@0
   236
sl@0
   237
	// Set HBuf size
sl@0
   238
	User::LeaveIfError(file.Size(size));
sl@0
   239
	INFO_PRINTF2(_L("size of file = %d\n"),size);//Statement Changed under DEF105143
sl@0
   240
sl@0
   241
	iVideo = HBufC8::NewMaxL(size);
sl@0
   242
sl@0
   243
	// read data into Hbuf
sl@0
   244
	TPtr8 bufferDes(iVideo->Des());
sl@0
   245
	User::LeaveIfError(file.Read(bufferDes));
sl@0
   246
	
sl@0
   247
	CleanupStack::PopAndDestroy(); //file
sl@0
   248
	return CTestMmfVclntStep::DoTestStepPreambleL();
sl@0
   249
	}
sl@0
   250
sl@0
   251
TVerdict CTestVclntVideoDes::DoTestStepPostambleL()
sl@0
   252
	{
sl@0
   253
	delete iVideo;
sl@0
   254
	iVideo = NULL;
sl@0
   255
	return CTestMmfVclntStep::DoTestStepPostambleL();
sl@0
   256
	}
sl@0
   257
sl@0
   258
/**
sl@0
   259
 * Load and initialise an audio descriptor.
sl@0
   260
 */
sl@0
   261
TVerdict CTestVclntVideoDes::DoTestStepL()
sl@0
   262
	{
sl@0
   263
	TVerdict ret = EFail;
sl@0
   264
sl@0
   265
	INFO_PRINTF1(_L("Test : Video Player - Descriptor"));
sl@0
   266
sl@0
   267
	iError = KErrTimedOut;
sl@0
   268
sl@0
   269
	InitWservL();
sl@0
   270
sl@0
   271
	TRect rect, clipRect;
sl@0
   272
	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
sl@0
   273
															EMdaPriorityPreferenceTimeAndQuality,
sl@0
   274
															iWs, *iScreen, *iWindow, rect, clipRect);
sl@0
   275
	CleanupStack::PushL(player);
sl@0
   276
	
sl@0
   277
sl@0
   278
	TRAP(iError, player->OpenDesL(iVideo->Des()));
sl@0
   279
	
sl@0
   280
	if(iError == KErrNone)
sl@0
   281
		{
sl@0
   282
		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening descriptor"));
sl@0
   283
		// Wait for init callback
sl@0
   284
		CActiveScheduler::Start();
sl@0
   285
		}
sl@0
   286
sl@0
   287
	// Until JetStream
sl@0
   288
#ifndef JETSTREAM_TESTS
sl@0
   289
	if(iError == KErrNotSupported)
sl@0
   290
		ret = EPass;
sl@0
   291
#endif
sl@0
   292
sl@0
   293
	if (iError == KErrNone && player != NULL)
sl@0
   294
		{
sl@0
   295
		player->Prepare();
sl@0
   296
		CActiveScheduler::Start();
sl@0
   297
		}
sl@0
   298
sl@0
   299
sl@0
   300
	if ((iError == KErrNone) && (player != NULL))
sl@0
   301
		ret = DoTestL(player);
sl@0
   302
	
sl@0
   303
	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
sl@0
   304
	CleanupStack::PopAndDestroy(player);
sl@0
   305
	if(iError != KErrNone)
sl@0
   306
		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
sl@0
   307
	return	ret;
sl@0
   308
	}
sl@0
   309
sl@0
   310
TVerdict CTestVclntVideoDes::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   311
	{
sl@0
   312
	TVerdict ret = EFail;
sl@0
   313
// #ifdef JETSTREAM_TESTS
sl@0
   314
sl@0
   315
	if(iPlay)
sl@0
   316
		{
sl@0
   317
		iError = KErrTimedOut;
sl@0
   318
		aPlayer->Play();
sl@0
   319
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing descriptor"));
sl@0
   320
		// Wait for init callback
sl@0
   321
		CActiveScheduler::Start();
sl@0
   322
		if(iError == KErrNone)
sl@0
   323
			ret = EPass;
sl@0
   324
		}
sl@0
   325
	else
sl@0
   326
		ret = EPass;	
sl@0
   327
//#else
sl@0
   328
//	aPlayer->Stop();
sl@0
   329
//#endif
sl@0
   330
	return ret;		
sl@0
   331
	}
sl@0
   332
sl@0
   333
sl@0
   334
//------------------------------------------------------------------
sl@0
   335
sl@0
   336
/**
sl@0
   337
 * Constructor
sl@0
   338
 */
sl@0
   339
CTestVclntVideoUrl::CTestVclntVideoUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
   340
	:iPlay (aPlay)
sl@0
   341
	{
sl@0
   342
	// store the name of this test case
sl@0
   343
	// this is the name that is used by the script file
sl@0
   344
	// Each test step initialises it's own name
sl@0
   345
	iTestStepName = aTestName;
sl@0
   346
	iSectName = aSectName;
sl@0
   347
	iKeyName = aKeyName;
sl@0
   348
	}
sl@0
   349
sl@0
   350
CTestVclntVideoUrl* CTestVclntVideoUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
   351
	{
sl@0
   352
	CTestVclntVideoUrl* self = CTestVclntVideoUrl::NewLC(aTestName,aSectName,aKeyName,aPlay);
sl@0
   353
	CleanupStack::Pop();
sl@0
   354
	return self;
sl@0
   355
	}
sl@0
   356
sl@0
   357
CTestVclntVideoUrl* CTestVclntVideoUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
sl@0
   358
	{
sl@0
   359
	CTestVclntVideoUrl* self = new (ELeave) CTestVclntVideoUrl(aTestName,aSectName,aKeyName,aPlay);
sl@0
   360
	CleanupStack::PushL(self);
sl@0
   361
	return self;
sl@0
   362
	}
sl@0
   363
sl@0
   364
void CTestVclntVideoUrl::MvpuoOpenComplete(TInt aError)
sl@0
   365
	{
sl@0
   366
	iError = aError;
sl@0
   367
	INFO_PRINTF1(_L("Open complete callback"));
sl@0
   368
	CActiveScheduler::Stop();
sl@0
   369
	}
sl@0
   370
sl@0
   371
void CTestVclntVideoUrl::MvpuoPrepareComplete(TInt aError)
sl@0
   372
	{
sl@0
   373
	iError = aError;
sl@0
   374
	INFO_PRINTF1(_L("Open complete callback"));
sl@0
   375
	CActiveScheduler::Stop();
sl@0
   376
	}
sl@0
   377
sl@0
   378
void CTestVclntVideoUrl::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError)
sl@0
   379
	{
sl@0
   380
	iError = aError;
sl@0
   381
	// ???
sl@0
   382
	INFO_PRINTF1(_L("Frame Ready callback"));
sl@0
   383
	}
sl@0
   384
sl@0
   385
void CTestVclntVideoUrl::MvpuoPlayComplete(TInt aError)
sl@0
   386
	{
sl@0
   387
	iError = aError;
sl@0
   388
	INFO_PRINTF1(_L("Play complete callback"));
sl@0
   389
	CActiveScheduler::Stop();
sl@0
   390
	}
sl@0
   391
	
sl@0
   392
void CTestVclntVideoUrl::MvpuoEvent(const TMMFEvent& /*aEvent*/)
sl@0
   393
	{
sl@0
   394
	}
sl@0
   395
sl@0
   396
sl@0
   397
/**
sl@0
   398
 * Open audio from a URL and play.
sl@0
   399
 */
sl@0
   400
TVerdict CTestVclntVideoUrl::DoTestStepL()
sl@0
   401
	{
sl@0
   402
	TVerdict ret = EFail;
sl@0
   403
sl@0
   404
	INFO_PRINTF1(_L("Test : Video Player - URL"));
sl@0
   405
sl@0
   406
	iError = KErrTimedOut;	
sl@0
   407
sl@0
   408
	TPtrC urlname;
sl@0
   409
	if(!GetStringFromConfig(iSectName,iKeyName,urlname))
sl@0
   410
		return EInconclusive;
sl@0
   411
sl@0
   412
	InitWservL();
sl@0
   413
sl@0
   414
	TRect rect, clipRect;
sl@0
   415
	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
sl@0
   416
															EMdaPriorityPreferenceTimeAndQuality,
sl@0
   417
															iWs, *iScreen, *iWindow, rect, clipRect);
sl@0
   418
	// wait for init to complete
sl@0
   419
	CleanupStack::PushL(player);
sl@0
   420
	player->OpenUrlL(urlname);
sl@0
   421
	INFO_PRINTF1(_L("CVideoPlayerUtility: Opening URL"));
sl@0
   422
	CActiveScheduler::Start();
sl@0
   423
sl@0
   424
	// Until JetStream
sl@0
   425
#ifndef JETSTREAM_TESTS
sl@0
   426
	if(iError == KErrNotSupported)
sl@0
   427
		ret = EPass;
sl@0
   428
#endif
sl@0
   429
sl@0
   430
	if (iError == KErrNone)
sl@0
   431
		{
sl@0
   432
		player->Prepare();
sl@0
   433
		CActiveScheduler::Start();
sl@0
   434
		}
sl@0
   435
sl@0
   436
	if (iError == KErrNone)
sl@0
   437
		ret = DoTestL(player);
sl@0
   438
sl@0
   439
	INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying"));
sl@0
   440
	CleanupStack::PopAndDestroy(player);
sl@0
   441
	if(iError != KErrNone)
sl@0
   442
		ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
sl@0
   443
	return	ret;
sl@0
   444
	}
sl@0
   445
sl@0
   446
TVerdict CTestVclntVideoUrl::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   447
	{
sl@0
   448
	TVerdict ret = EFail;
sl@0
   449
sl@0
   450
//#ifdef JETSTREAM_TESTS
sl@0
   451
sl@0
   452
	iError = KErrTimedOut;	
sl@0
   453
sl@0
   454
	aPlayer->Play();
sl@0
   455
	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing URL"));
sl@0
   456
	// Wait for play to complete
sl@0
   457
	CActiveScheduler::Start();
sl@0
   458
sl@0
   459
	if(iError == KErrNone)
sl@0
   460
		ret = EPass;
sl@0
   461
//#else
sl@0
   462
//	aPlayer->Stop();
sl@0
   463
//#endif
sl@0
   464
sl@0
   465
	return ret;
sl@0
   466
	}
sl@0
   467
sl@0
   468
sl@0
   469
//------------------------------------------------------------------
sl@0
   470
sl@0
   471
sl@0
   472
CTestVclntEnqFrameRate::CTestVclntEnqFrameRate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
sl@0
   473
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   474
	{
sl@0
   475
	iFrameRate = aFrameRate;
sl@0
   476
	}
sl@0
   477
sl@0
   478
CTestVclntEnqFrameRate* CTestVclntEnqFrameRate::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aFrameRate)
sl@0
   479
	{
sl@0
   480
	CTestVclntEnqFrameRate* self = new (ELeave) CTestVclntEnqFrameRate(aTestName,aSectName,aKeyName,aFrameRate);
sl@0
   481
	return self;
sl@0
   482
	}
sl@0
   483
sl@0
   484
TVerdict CTestVclntEnqFrameRate::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   485
	{
sl@0
   486
	INFO_PRINTF1(_L("Test : Video Player - Enquire Frame Rate"));
sl@0
   487
sl@0
   488
	TVerdict ret = EFail;
sl@0
   489
sl@0
   490
	TInt32 theFrameRate;
sl@0
   491
	Math::Int(theFrameRate, aPlayer->VideoFrameRateL());
sl@0
   492
	INFO_PRINTF2(_L("(Frame rate : %d)"), theFrameRate); 
sl@0
   493
sl@0
   494
	// if we get here, we pass. The player does not have a SetVideoFrameRate()
sl@0
   495
	ret = EPass;
sl@0
   496
sl@0
   497
	return ret;
sl@0
   498
	}
sl@0
   499
sl@0
   500
sl@0
   501
//------------------------------------------------------------------
sl@0
   502
sl@0
   503
CTestVclntPosition::CTestVclntPosition(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
sl@0
   504
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   505
	{
sl@0
   506
	iPosition = aPosition;
sl@0
   507
	}
sl@0
   508
sl@0
   509
CTestVclntPosition* CTestVclntPosition::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
sl@0
   510
	{
sl@0
   511
	CTestVclntPosition* self = new (ELeave) CTestVclntPosition(aTestName,aSectName,aKeyName,aPosition);
sl@0
   512
	return self;
sl@0
   513
	}
sl@0
   514
sl@0
   515
TVerdict CTestVclntPosition::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   516
	{
sl@0
   517
	// NB test video controller is stubbing certain functions. May have to rewrite this
sl@0
   518
	// for Jet Stream
sl@0
   519
sl@0
   520
	TVerdict ret = EFail;
sl@0
   521
sl@0
   522
	INFO_PRINTF1(_L("Test : Video Player - Position"));
sl@0
   523
sl@0
   524
	TBool validPosition = EFalse;
sl@0
   525
sl@0
   526
	INFO_PRINTF3(_L("Set Position %d Duration = %d"), 
sl@0
   527
		I64INT(iPosition.Int64()), I64INT(aPlayer->DurationL().Int64()));
sl@0
   528
sl@0
   529
	//  Set position: middle of clip.
sl@0
   530
	if (I64INT(iPosition.Int64()) == 0)
sl@0
   531
		iPosition = I64INT(aPlayer->DurationL().Int64()) / 2;
sl@0
   532
	// Set position: end of clip.
sl@0
   533
	if (I64INT(iPosition.Int64()) == -1)
sl@0
   534
		iPosition = aPlayer->DurationL();
sl@0
   535
sl@0
   536
	// Position is beyond the end of the clips duration
sl@0
   537
	// so check that the value is clipped.
sl@0
   538
	if(aPlayer->DurationL() < iPosition)
sl@0
   539
		{
sl@0
   540
		INFO_PRINTF2(_L("Longer than duration : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   541
		aPlayer->SetPositionL(iPosition);
sl@0
   542
		INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"), 
sl@0
   543
			I64INT(aPlayer->PositionL().Int64()), I64INT(aPlayer->DurationL().Int64()));
sl@0
   544
		if(aPlayer->PositionL() == aPlayer->DurationL())
sl@0
   545
			validPosition = ETrue;
sl@0
   546
		}
sl@0
   547
	// Position is negative
sl@0
   548
	// so check that the value is clipped.
sl@0
   549
	else if (I64INT(iPosition.Int64()) < 0)
sl@0
   550
		{
sl@0
   551
		INFO_PRINTF2(_L("Negative value : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   552
		aPlayer->SetPositionL(iPosition);
sl@0
   553
		INFO_PRINTF2(_L("Set : position = %d (if clipped : 0)"), I64INT(aPlayer->PositionL().Int64()));
sl@0
   554
		if (I64INT(aPlayer->PositionL().Int64()) == 0)
sl@0
   555
			validPosition = ETrue;
sl@0
   556
		}
sl@0
   557
	else
sl@0
   558
		{
sl@0
   559
		INFO_PRINTF2(_L("Normal : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   560
		aPlayer->SetPositionL(iPosition);
sl@0
   561
		INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"), 
sl@0
   562
			I64INT(aPlayer->PositionL().Int64()), I64INT(iPosition.Int64()));
sl@0
   563
		if(aPlayer->PositionL() == iPosition)
sl@0
   564
			validPosition = ETrue;
sl@0
   565
		}
sl@0
   566
sl@0
   567
	// Position was set to a valid value.
sl@0
   568
	if(validPosition)
sl@0
   569
		{
sl@0
   570
		aPlayer->Play();
sl@0
   571
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
   572
		// wait for play to complete
sl@0
   573
		CActiveScheduler::Start();
sl@0
   574
sl@0
   575
		INFO_PRINTF2(_L("Error : %d"), iError);
sl@0
   576
		if (iError == KErrNone)
sl@0
   577
			ret = EPass;
sl@0
   578
		}
sl@0
   579
	else
sl@0
   580
		{
sl@0
   581
		// We've got an invalid position, attempt to play anyway...
sl@0
   582
		// the test controller should handle it
sl@0
   583
		aPlayer->Play();
sl@0
   584
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing from invalid position"));
sl@0
   585
		// wait for play to complete
sl@0
   586
		CActiveScheduler::Start();
sl@0
   587
sl@0
   588
		INFO_PRINTF2(_L("Error : %d"), iError);
sl@0
   589
		if (iError == KErrNone)
sl@0
   590
			ret = EPass;
sl@0
   591
sl@0
   592
		}
sl@0
   593
sl@0
   594
	return ret;
sl@0
   595
	}
sl@0
   596
sl@0
   597
sl@0
   598
//------------------------------------------------------------------
sl@0
   599
sl@0
   600
CTestVclntPriority::CTestVclntPriority(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
sl@0
   601
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   602
	{
sl@0
   603
	iPriority = aPriority;
sl@0
   604
	}
sl@0
   605
sl@0
   606
CTestVclntPriority* CTestVclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aPriority)
sl@0
   607
	{
sl@0
   608
	CTestVclntPriority* self = new (ELeave) CTestVclntPriority(aTestName,aSectName,aKeyName,aPriority);
sl@0
   609
	return self;
sl@0
   610
	}
sl@0
   611
sl@0
   612
TVerdict CTestVclntPriority::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   613
	{
sl@0
   614
	TVerdict ret = EFail;
sl@0
   615
sl@0
   616
	INFO_PRINTF1(_L("Test : Video Player - Priority"));
sl@0
   617
sl@0
   618
	aPlayer->SetPriorityL(iPriority, EMdaPriorityPreferenceNone);	
sl@0
   619
	TInt thePriority;
sl@0
   620
	TMdaPriorityPreference thePref;
sl@0
   621
	aPlayer->PriorityL(thePriority, thePref);
sl@0
   622
	INFO_PRINTF3(_L("Priority = %d (expecting %d)"), thePriority, iPriority);
sl@0
   623
	INFO_PRINTF3(_L("Pref = %d (expecting %d)"), thePref, EMdaPriorityPreferenceNone);
sl@0
   624
	if( (thePriority == iPriority) && (thePref == EMdaPriorityPreferenceNone) )
sl@0
   625
		return EPass;
sl@0
   626
	return ret;
sl@0
   627
	}
sl@0
   628
sl@0
   629
sl@0
   630
//------------------------------------------------------------------
sl@0
   631
sl@0
   632
CTestVclntDuration::CTestVclntDuration(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
sl@0
   633
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   634
	{
sl@0
   635
	iDuration = aDuration;
sl@0
   636
	}
sl@0
   637
sl@0
   638
CTestVclntDuration* CTestVclntDuration::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aDuration)
sl@0
   639
	{
sl@0
   640
	CTestVclntDuration* self = new (ELeave) CTestVclntDuration(aTestName,aSectName,aKeyName,aDuration);
sl@0
   641
	return self;
sl@0
   642
	}
sl@0
   643
sl@0
   644
TVerdict CTestVclntDuration::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   645
	{
sl@0
   646
	TVerdict ret = EFail;
sl@0
   647
sl@0
   648
	INFO_PRINTF1(_L("Test : Video Player - Duration"));
sl@0
   649
sl@0
   650
	if (I64INT(iDuration.Int64()) == 0)
sl@0
   651
		{
sl@0
   652
		TInt duration = I64INT(aPlayer->DurationL().Int64());
sl@0
   653
		aPlayer->Play();
sl@0
   654
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
   655
		TTime start;
sl@0
   656
		start.HomeTime();
sl@0
   657
		CActiveScheduler::Start();
sl@0
   658
		TTime stop;
sl@0
   659
		stop.HomeTime();
sl@0
   660
sl@0
   661
		TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
sl@0
   662
sl@0
   663
		INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
sl@0
   664
			iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
sl@0
   665
		if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
sl@0
   666
			ret = EPass;
sl@0
   667
		}
sl@0
   668
	else
sl@0
   669
		{
sl@0
   670
		if(aPlayer->DurationL() == iDuration)
sl@0
   671
			ret = EPass;
sl@0
   672
		}
sl@0
   673
	return ret;
sl@0
   674
	}
sl@0
   675
sl@0
   676
//------------------------------------------------------------------
sl@0
   677
sl@0
   678
CTestVclntVolume::CTestVclntVolume(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
sl@0
   679
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   680
	{
sl@0
   681
	iVolume = aVolume;
sl@0
   682
	}
sl@0
   683
sl@0
   684
CTestVclntVolume* CTestVclntVolume::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aVolume)
sl@0
   685
	{
sl@0
   686
	CTestVclntVolume* self = new (ELeave) CTestVclntVolume(aTestName,aSectName,aKeyName,aVolume);
sl@0
   687
	return self;
sl@0
   688
	}
sl@0
   689
sl@0
   690
TVerdict CTestVclntVolume::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   691
	{
sl@0
   692
	TVerdict ret = EFail;
sl@0
   693
sl@0
   694
	// NB : test video controller does not adjust invalid volumes
sl@0
   695
	// comment the checks back in for JS
sl@0
   696
sl@0
   697
	INFO_PRINTF1(_L("Test : Video Player - Volume"));
sl@0
   698
sl@0
   699
	INFO_PRINTF1(_L("Warning : test video controller does not adjust invalid volumes"));
sl@0
   700
sl@0
   701
	// Check maxvolume function
sl@0
   702
	if(iVolume == -1)
sl@0
   703
		{
sl@0
   704
		iVolume = aPlayer->MaxVolume();
sl@0
   705
		INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), iVolume, KMaxVolume);
sl@0
   706
		//if(iVolume == KMaxVolume) 
sl@0
   707
			ret = EPass;
sl@0
   708
		}
sl@0
   709
	// Volume is truncated to maxvolume
sl@0
   710
	else if(iVolume > aPlayer->MaxVolume())
sl@0
   711
		{
sl@0
   712
		aPlayer->SetVolumeL(iVolume);
sl@0
   713
		INFO_PRINTF3(_L("Volume = %d MaxVolume = %d"), aPlayer->Volume(), aPlayer->MaxVolume());
sl@0
   714
		//if(aPlayer->Volume() == aPlayer->MaxVolume())
sl@0
   715
			ret = EPass;
sl@0
   716
		}
sl@0
   717
	// Volume is truncated to 0
sl@0
   718
	else if(iVolume < 0)
sl@0
   719
		{
sl@0
   720
		aPlayer->SetVolumeL(iVolume);
sl@0
   721
		INFO_PRINTF2(_L("Volume = %d (expecting 0)"), aPlayer->Volume());
sl@0
   722
		//if(aPlayer->Volume() == 0)
sl@0
   723
			ret = EPass;
sl@0
   724
		}
sl@0
   725
	// Set volume and check
sl@0
   726
	else
sl@0
   727
		{
sl@0
   728
		aPlayer->SetVolumeL(iVolume);
sl@0
   729
		INFO_PRINTF3(_L("Volume = %d (expecting %d)"), aPlayer->Volume(), iVolume);
sl@0
   730
		if(aPlayer->Volume() == iVolume)
sl@0
   731
			ret = EPass;
sl@0
   732
		}
sl@0
   733
sl@0
   734
	return ret;
sl@0
   735
	}
sl@0
   736
sl@0
   737
//------------------------------------------------------------------
sl@0
   738
sl@0
   739
CTestVclntCloseOpen::CTestVclntCloseOpen(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   740
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   741
	{}
sl@0
   742
sl@0
   743
CTestVclntCloseOpen* CTestVclntCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   744
	{
sl@0
   745
	CTestVclntCloseOpen* self = new (ELeave) CTestVclntCloseOpen(aTestName,aSectName,aKeyName);
sl@0
   746
	return self;
sl@0
   747
	}
sl@0
   748
sl@0
   749
TVerdict CTestVclntCloseOpen::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   750
	{
sl@0
   751
	TVerdict ret = EFail;
sl@0
   752
sl@0
   753
	INFO_PRINTF1(_L("Test : Video Player - Close/Open"));
sl@0
   754
sl@0
   755
//#ifdef JETSTREAM_TESTS
sl@0
   756
sl@0
   757
	TPtrC filename;
sl@0
   758
	if(!GetStringFromConfig(iSectName,iKeyName,filename))
sl@0
   759
		return EInconclusive;
sl@0
   760
sl@0
   761
	aPlayer->Close();
sl@0
   762
	User::After(KOneSecond);
sl@0
   763
sl@0
   764
	TRAP(iError,aPlayer->OpenFileL(filename));
sl@0
   765
	if(iError == KErrNone)
sl@0
   766
		{
sl@0
   767
		// Wait for initialisation callback
sl@0
   768
		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
sl@0
   769
		ret = EPass;
sl@0
   770
		}
sl@0
   771
sl@0
   772
//#else
sl@0
   773
//	aPlayer->Stop();
sl@0
   774
//#endif
sl@0
   775
sl@0
   776
	return ret;
sl@0
   777
	}
sl@0
   778
sl@0
   779
//------------------------------------------------------------------
sl@0
   780
sl@0
   781
CTestVclntPause::CTestVclntPause(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   782
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   783
	{}
sl@0
   784
sl@0
   785
CTestVclntPause* CTestVclntPause::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   786
	{
sl@0
   787
	CTestVclntPause* self = new (ELeave) CTestVclntPause(aTestName,aSectName,aKeyName);
sl@0
   788
	return self;
sl@0
   789
	}
sl@0
   790
sl@0
   791
TVerdict CTestVclntPause::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   792
	{
sl@0
   793
	TVerdict ret = EFail;
sl@0
   794
sl@0
   795
	INFO_PRINTF1(_L("Test : Video Player - Pause"));
sl@0
   796
sl@0
   797
	// Tests pause functionality
sl@0
   798
	// NB : not implemented in test controller
sl@0
   799
	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
   800
	aPlayer->Play();
sl@0
   801
	CActiveScheduler::Start();
sl@0
   802
	aPlayer->PauseL();
sl@0
   803
sl@0
   804
#ifdef JETSTREAM_TESTS
sl@0
   805
	TInt duration = I64INT(aPlayer->DurationL().Int64());
sl@0
   806
sl@0
   807
	iError = KErrTimedOut;
sl@0
   808
	aPlayer->Play();
sl@0
   809
	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
   810
	TTime start;
sl@0
   811
	start.HomeTime();
sl@0
   812
	CActiveScheduler::Start();
sl@0
   813
	TTime stop;
sl@0
   814
	stop.HomeTime();
sl@0
   815
sl@0
   816
	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
sl@0
   817
sl@0
   818
	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
sl@0
   819
		iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
sl@0
   820
	if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
sl@0
   821
		ret = EPass;
sl@0
   822
#else
sl@0
   823
	INFO_PRINTF1(_L("Warning : PauseL() functionality not supported in test controller"));
sl@0
   824
	aPlayer->Stop();
sl@0
   825
	ret = EPass;
sl@0
   826
#endif
sl@0
   827
sl@0
   828
	return ret;
sl@0
   829
	}
sl@0
   830
sl@0
   831
//------------------------------------------------------------------
sl@0
   832
sl@0
   833
CTestVclntBalance::CTestVclntBalance(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
sl@0
   834
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   835
	{
sl@0
   836
	iBalance = aBalance;
sl@0
   837
	}
sl@0
   838
sl@0
   839
CTestVclntBalance* CTestVclntBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aBalance)
sl@0
   840
	{
sl@0
   841
	CTestVclntBalance* self = new (ELeave) CTestVclntBalance(aTestName,aSectName,aKeyName,aBalance);
sl@0
   842
	return self;
sl@0
   843
	}
sl@0
   844
sl@0
   845
TVerdict CTestVclntBalance::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   846
	{
sl@0
   847
	INFO_PRINTF1(_L("Test : Video Player - Balance"));
sl@0
   848
sl@0
   849
#ifdef JETSTREAM_TESTS
sl@0
   850
	if (iBalance < KMinBalance)
sl@0
   851
		{
sl@0
   852
		aPlayer->SetBalanceL(iBalance);		
sl@0
   853
		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMinBalance);
sl@0
   854
		if(aPlayer->Balance() == KMinBalance)
sl@0
   855
			return EPass;
sl@0
   856
		}
sl@0
   857
	else if (iBalance > KMaxBalance)
sl@0
   858
		{
sl@0
   859
		aPlayer->SetBalanceL(iBalance);		
sl@0
   860
		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMaxBalance);
sl@0
   861
		if(aPlayer->Balance() == KMaxBalance)
sl@0
   862
			return EPass;
sl@0
   863
		}
sl@0
   864
	else
sl@0
   865
		{
sl@0
   866
		aPlayer->SetBalanceL(iBalance);		
sl@0
   867
		INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), iBalance);
sl@0
   868
		if(aPlayer->Balance() == iBalance)
sl@0
   869
			return EPass;
sl@0
   870
		}
sl@0
   871
#else
sl@0
   872
	// the test video controller returns 1 for all calls of Balance()
sl@0
   873
	// call SetBalanceL() to show it doesn't leave
sl@0
   874
	aPlayer->SetBalanceL(iBalance);		
sl@0
   875
	INFO_PRINTF1(_L("Test controller should return 1 for all calls of Balance()"));
sl@0
   876
	INFO_PRINTF2(_L("Balance = %d (expecting 1)"), aPlayer->Balance());
sl@0
   877
	if(aPlayer->Balance() == 1)
sl@0
   878
		return EPass;
sl@0
   879
#endif
sl@0
   880
sl@0
   881
	return EFail;
sl@0
   882
	}
sl@0
   883
sl@0
   884
sl@0
   885
//------------------------------------------------------------------
sl@0
   886
sl@0
   887
CTestVclntPlayWindow::CTestVclntPlayWindow(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
sl@0
   888
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   889
	{
sl@0
   890
	iStart = aStart;
sl@0
   891
	iEnd = aEnd;
sl@0
   892
	}
sl@0
   893
sl@0
   894
CTestVclntPlayWindow* CTestVclntPlayWindow::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
sl@0
   895
	{
sl@0
   896
	CTestVclntPlayWindow* self = new (ELeave) CTestVclntPlayWindow(aTestName,aSectName,aKeyName,aStart,aEnd);
sl@0
   897
	return self;
sl@0
   898
	}
sl@0
   899
sl@0
   900
TVerdict CTestVclntPlayWindow::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   901
	{
sl@0
   902
	TVerdict ret = EFail;
sl@0
   903
sl@0
   904
	INFO_PRINTF1(_L("Test : Video Player - Window"));
sl@0
   905
sl@0
   906
//	InitWservL();
sl@0
   907
sl@0
   908
	TRect rect, clipRect;
sl@0
   909
	TRAPD(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
sl@0
   910
	if(err)
sl@0
   911
		{
sl@0
   912
		ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
sl@0
   913
		ret = EFail;
sl@0
   914
		}
sl@0
   915
	else
sl@0
   916
		{
sl@0
   917
		ret = EPass;
sl@0
   918
		}
sl@0
   919
sl@0
   920
	// removed an attempt at opening a window server manually - it seemed to work, but a RWsSession
sl@0
   921
	// couldn't Connect(), connectL() claimed no asynchronous operation...
sl@0
   922
	
sl@0
   923
	// we have no window server, so the test can't run - 
sl@0
   924
	// so call it with dummy parameters and add explanatory note to the test
sl@0
   925
sl@0
   926
	// NB ws.Connect() will panic on the target, hence don't run it
sl@0
   927
/*
sl@0
   928
#if defined (__WINS__)
sl@0
   929
	TBool testInvalid = EFalse;
sl@0
   930
 	RWsSession ws;
sl@0
   931
	if(ws.Connect() != KErrNone)
sl@0
   932
		testInvalid = ETrue;
sl@0
   933
sl@0
   934
	// we can't call it at all - SetDisplayWindowL() will cause an access violation if ws is null
sl@0
   935
	if(testInvalid)
sl@0
   936
		{
sl@0
   937
		INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested, no window server available"));
sl@0
   938
		ret = EPass;
sl@0
   939
		}
sl@0
   940
	else
sl@0
   941
		{
sl@0
   942
		// TBD - arguments to be correctly set
sl@0
   943
		CWsScreenDevice sd;
sl@0
   944
		RBlankWindow window;
sl@0
   945
		TRect rect, clipRect;
sl@0
   946
sl@0
   947
		TRAPD(err, aPlayer->SetDisplayWindowL(ws, sd, window, rect, clipRect));
sl@0
   948
		if(err)
sl@0
   949
			{
sl@0
   950
				ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
sl@0
   951
				ret = EFail;
sl@0
   952
			}
sl@0
   953
		else
sl@0
   954
			ret = EPass;
sl@0
   955
		
sl@0
   956
		}
sl@0
   957
#else
sl@0
   958
	INFO_PRINTF1(_L("Warning : SetDisplayWindowL() cannot be tested on target"));
sl@0
   959
	ret = EPass;
sl@0
   960
#endif
sl@0
   961
*/
sl@0
   962
	aPlayer->Stop();
sl@0
   963
	return ret;
sl@0
   964
	}
sl@0
   965
sl@0
   966
sl@0
   967
//------------------------------------------------------------------
sl@0
   968
sl@0
   969
CTestVclntMeta::CTestVclntMeta(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   970
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
   971
	{}
sl@0
   972
sl@0
   973
CTestVclntMeta* CTestVclntMeta::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
   974
	{
sl@0
   975
	CTestVclntMeta* self = new (ELeave) CTestVclntMeta(aTestName,aSectName,aKeyName);
sl@0
   976
	return self;
sl@0
   977
	}
sl@0
   978
sl@0
   979
TVerdict CTestVclntMeta::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   980
	{
sl@0
   981
	INFO_PRINTF1(_L("Test : Video Player - Metadata"));
sl@0
   982
sl@0
   983
	TInt numOfMeta = -1;
sl@0
   984
	TRAPD(err, numOfMeta = aPlayer->NumberOfMetaDataEntriesL() );
sl@0
   985
	INFO_PRINTF3(_L("Error : %d Entries = %d"), err, numOfMeta);
sl@0
   986
	if (err != KErrNone || numOfMeta != 0)
sl@0
   987
		return EFail;
sl@0
   988
	// call that goes to the dummy controller
sl@0
   989
	// NB we expect zero metadata entries
sl@0
   990
	CMMFMetaDataEntry* theEntry=NULL;
sl@0
   991
	TRAP(err, theEntry = aPlayer->MetaDataEntryL(1));
sl@0
   992
	INFO_PRINTF2(_L("Error : %d"), err);
sl@0
   993
	if (err != KErrNone)
sl@0
   994
		return EFail;
sl@0
   995
	else 
sl@0
   996
		{
sl@0
   997
		delete theEntry;
sl@0
   998
		return EPass;
sl@0
   999
		}
sl@0
  1000
	}
sl@0
  1001
sl@0
  1002
sl@0
  1003
//------------------------------------------------------------------
sl@0
  1004
sl@0
  1005
CTestVclntFrameSize::CTestVclntFrameSize(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
sl@0
  1006
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
  1007
	{
sl@0
  1008
	iFrameSize = aFrameSize;
sl@0
  1009
	}
sl@0
  1010
sl@0
  1011
CTestVclntFrameSize* CTestVclntFrameSize::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aFrameSize)
sl@0
  1012
	{
sl@0
  1013
	CTestVclntFrameSize* self = new (ELeave) CTestVclntFrameSize(aTestName,aSectName,aKeyName,aFrameSize);
sl@0
  1014
	return self;
sl@0
  1015
	}
sl@0
  1016
sl@0
  1017
TVerdict CTestVclntFrameSize::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1018
	{
sl@0
  1019
	TVerdict ret = EFail;
sl@0
  1020
sl@0
  1021
	INFO_PRINTF1(_L("Test : Video Player - Frame Size"));
sl@0
  1022
sl@0
  1023
	TSize	frameSize;
sl@0
  1024
	TRAPD(err, aPlayer->VideoFrameSizeL(frameSize) );
sl@0
  1025
sl@0
  1026
	INFO_PRINTF4(_L("Error : %d, Frame size : (%d, %d)"), err, frameSize.iWidth, frameSize.iHeight);
sl@0
  1027
	if (err == KErrNone &&
sl@0
  1028
		frameSize.iWidth >= 0 && frameSize.iHeight >= 0 )  
sl@0
  1029
		return EPass;
sl@0
  1030
sl@0
  1031
	return ret;
sl@0
  1032
	}
sl@0
  1033
sl@0
  1034
//------------------------------------------------------------------
sl@0
  1035
sl@0
  1036
CTestVclntMimeType::CTestVclntMimeType(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1037
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
  1038
	{
sl@0
  1039
	}
sl@0
  1040
sl@0
  1041
CTestVclntMimeType* CTestVclntMimeType::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1042
	{
sl@0
  1043
	CTestVclntMimeType* self = new (ELeave) CTestVclntMimeType(aTestName,aSectName,aKeyName);
sl@0
  1044
	return self;
sl@0
  1045
	}
sl@0
  1046
sl@0
  1047
TVerdict CTestVclntMimeType::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1048
	{
sl@0
  1049
	INFO_PRINTF1(_L("Test : Video Player - MimeType"));
sl@0
  1050
sl@0
  1051
	// NB we cannot check whether the mime type returned is valid, or even exists.
sl@0
  1052
	TPtrC8 mimeType = aPlayer->VideoFormatMimeType();
sl@0
  1053
sl@0
  1054
	// take it to a 16-bit string
sl@0
  1055
	TBuf<64> mimeType16;
sl@0
  1056
	mimeType16.Copy(mimeType);
sl@0
  1057
	INFO_PRINTF2(_L("Mime type : \'%S\'"), &mimeType16);
sl@0
  1058
	return EPass;
sl@0
  1059
	}
sl@0
  1060
sl@0
  1061
//------------------------------------------------------------------
sl@0
  1062
sl@0
  1063
CTestVclntRebuffering::CTestVclntRebuffering(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1064
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
  1065
	{
sl@0
  1066
	}
sl@0
  1067
sl@0
  1068
CTestVclntRebuffering* CTestVclntRebuffering::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1069
	{
sl@0
  1070
	CTestVclntRebuffering* self = new (ELeave) CTestVclntRebuffering(aTestName,aSectName,aKeyName);
sl@0
  1071
	return self;
sl@0
  1072
	}
sl@0
  1073
sl@0
  1074
TVerdict CTestVclntRebuffering::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1075
	{
sl@0
  1076
	INFO_PRINTF1(_L("Test : Video Player - Rebuffering"));
sl@0
  1077
sl@0
  1078
	aPlayer->RegisterForVideoLoadingNotification(*this);
sl@0
  1079
sl@0
  1080
	INFO_PRINTF1(_L("Rebuffering request completed"));
sl@0
  1081
	return EPass;
sl@0
  1082
	}
sl@0
  1083
sl@0
  1084
// from MRebufferCallback
sl@0
  1085
void CTestVclntRebuffering::MvloLoadingStarted()
sl@0
  1086
	{
sl@0
  1087
	INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingStarted"));
sl@0
  1088
	}
sl@0
  1089
sl@0
  1090
void CTestVclntRebuffering::MvloLoadingComplete()
sl@0
  1091
	{
sl@0
  1092
	INFO_PRINTF1(_L("CTestVclntRebuffering::MvloLoadingComplete"));
sl@0
  1093
	}
sl@0
  1094
sl@0
  1095
//------------------------------------------------------------------
sl@0
  1096
sl@0
  1097
CTestVclntRepeat::CTestVclntRepeat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
sl@0
  1098
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
  1099
	{
sl@0
  1100
	iRepeat = aRepeat;
sl@0
  1101
	}
sl@0
  1102
sl@0
  1103
CTestVclntRepeat* CTestVclntRepeat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TInt aRepeat)
sl@0
  1104
	{
sl@0
  1105
	CTestVclntRepeat* self = new (ELeave) CTestVclntRepeat(aTestName,aSectName,aKeyName,aRepeat);
sl@0
  1106
	return self;
sl@0
  1107
	}
sl@0
  1108
sl@0
  1109
TVerdict CTestVclntRepeat::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1110
	{
sl@0
  1111
	TVerdict ret = EFail;
sl@0
  1112
sl@0
  1113
	INFO_PRINTF1(_L("Test : Video Player - Repeats"));
sl@0
  1114
sl@0
  1115
	TInt duration = I64INT(aPlayer->DurationL().Int64());
sl@0
  1116
sl@0
  1117
	// SetRepeats() doesn't exist in the video controller, so set iRepeat to 1
sl@0
  1118
	iRepeat = 1;
sl@0
  1119
	INFO_PRINTF1(_L("Warning : SetRepeats() does not exist in player API. Repeat count set to 1"));
sl@0
  1120
	
sl@0
  1121
	aPlayer->Play();
sl@0
  1122
	INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
  1123
	TTime start;
sl@0
  1124
	start.HomeTime();
sl@0
  1125
	CActiveScheduler::Start();
sl@0
  1126
	TTime stop;
sl@0
  1127
	stop.HomeTime();
sl@0
  1128
sl@0
  1129
	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
sl@0
  1130
sl@0
  1131
	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
sl@0
  1132
		iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
sl@0
  1133
	if((iError == KErrNone) && (TimeComparison(actualDuration, duration * (iRepeat + 1), 
sl@0
  1134
											   KExpectedDeviation * iRepeat)))
sl@0
  1135
		ret = EPass;
sl@0
  1136
sl@0
  1137
	return ret;
sl@0
  1138
	}
sl@0
  1139
sl@0
  1140
//------------------------------------------------------------------
sl@0
  1141
sl@0
  1142
CTestVclntDelete::CTestVclntDelete(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1143
	: CTestVclntVideoFile(aTestName,aSectName,aKeyName,EFalse)
sl@0
  1144
	{}
sl@0
  1145
sl@0
  1146
CTestVclntDelete* CTestVclntDelete::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
sl@0
  1147
	{
sl@0
  1148
	CTestVclntDelete* self = new (ELeave) CTestVclntDelete(aTestName,aSectName,aKeyName);
sl@0
  1149
	return self;
sl@0
  1150
	}
sl@0
  1151
sl@0
  1152
TVerdict CTestVclntDelete::DoTestL(CVideoPlayerUtility* /* aPlayer */)
sl@0
  1153
	{
sl@0
  1154
	// this is never called
sl@0
  1155
	return EFail;
sl@0
  1156
	}
sl@0
  1157
sl@0
  1158
TVerdict CTestVclntDelete::DoTestStepL()
sl@0
  1159
	{
sl@0
  1160
	TVerdict ret = EFail;
sl@0
  1161
sl@0
  1162
	INFO_PRINTF1(_L("Test : Video Player - Delete"));
sl@0
  1163
sl@0
  1164
	TPtrC filename;
sl@0
  1165
	if(!GetStringFromConfig(iSectName,iKeyName,filename))
sl@0
  1166
		return EInconclusive;
sl@0
  1167
sl@0
  1168
	InitWservL();
sl@0
  1169
sl@0
  1170
	TRect rect, clipRect;
sl@0
  1171
	CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal,
sl@0
  1172
															EMdaPriorityPreferenceTimeAndQuality,
sl@0
  1173
															iWs, *iScreen, *iWindow, rect, clipRect);
sl@0
  1174
	CleanupStack::PushL(player);
sl@0
  1175
sl@0
  1176
	iError = KErrTimedOut;
sl@0
  1177
	INFO_PRINTF2(_L("Attempting to open file %S"), &filename);
sl@0
  1178
	TRAP(iError,player->OpenFileL(filename));
sl@0
  1179
	
sl@0
  1180
	if(iError == KErrNone)
sl@0
  1181
		{
sl@0
  1182
		// Wait for initialisation callback
sl@0
  1183
		INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file"));
sl@0
  1184
		CActiveScheduler::Start();
sl@0
  1185
		}
sl@0
  1186
sl@0
  1187
	if (iError == KErrNone)
sl@0
  1188
		{
sl@0
  1189
		player->Prepare();
sl@0
  1190
		CActiveScheduler::Start();
sl@0
  1191
		}
sl@0
  1192
sl@0
  1193
	if(iError == KErrNone)
sl@0
  1194
		{
sl@0
  1195
		player->Play();
sl@0
  1196
		INFO_PRINTF1(_L("CVideoPlayerUtility: Playing"));
sl@0
  1197
		INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying before play complete"));
sl@0
  1198
		CleanupStack::Pop(player); // destroy player before play has completed
sl@0
  1199
sl@0
  1200
		User::Heap().Check();
sl@0
  1201
		return EPass;
sl@0
  1202
		}
sl@0
  1203
sl@0
  1204
	CleanupStack::Pop(player);
sl@0
  1205
	ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError );
sl@0
  1206
	return ret;
sl@0
  1207
	}
sl@0
  1208