os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer2.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) 2007-2010 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 <e32math.h>
sl@0
    17
#include "testvideoplayer2.h"
sl@0
    18
sl@0
    19
#ifdef SYMBIAN_BUILD_GCE
sl@0
    20
#include <graphics/surfacemanager.h>
sl@0
    21
#endif
sl@0
    22
sl@0
    23
const TInt KSettingsAndAlignmentTest = 3;
sl@0
    24
sl@0
    25
//
sl@0
    26
// RTestVclntPlayAviFile
sl@0
    27
//
sl@0
    28
sl@0
    29
/**
sl@0
    30
 * RTestVclnt2PlayFile::Constructor
sl@0
    31
 */
sl@0
    32
RTestVclnt2PlayFile::RTestVclnt2PlayFile(const TDesC& aTestName, 
sl@0
    33
                                         const TDesC& aSectName, 
sl@0
    34
                                         const TDesC& aKeyName, 
sl@0
    35
                                         TInt aExpectedError)
sl@0
    36
    : RTestVclnt2AviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
    37
    {
sl@0
    38
    }
sl@0
    39
sl@0
    40
/**
sl@0
    41
 * RTestVclnt2PlayFile::NewL
sl@0
    42
 */
sl@0
    43
RTestVclnt2PlayFile* RTestVclnt2PlayFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
    44
    {
sl@0
    45
    RTestVclnt2PlayFile* self = new (ELeave) RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
    46
    return self;
sl@0
    47
    }
sl@0
    48
sl@0
    49
/**
sl@0
    50
 * RTestVclnt2PlayFile::DoTestStepPreambleL
sl@0
    51
 */
sl@0
    52
TVerdict RTestVclnt2PlayFile::DoTestStepPreambleL()
sl@0
    53
    {
sl@0
    54
    return RTestVclnt2AviPlayerStep::DoTestStepPreambleL();
sl@0
    55
    }
sl@0
    56
sl@0
    57
/**
sl@0
    58
 * RTestVclnt2PlayFile::DoTestStepPostambleL
sl@0
    59
 */
sl@0
    60
TVerdict RTestVclnt2PlayFile::DoTestStepPostambleL()
sl@0
    61
    {
sl@0
    62
    return RTestVclnt2AviPlayerStep::DoTestStepPostambleL();        
sl@0
    63
    }
sl@0
    64
sl@0
    65
/**
sl@0
    66
 * RTestVclnt2PlayFile::FsmL
sl@0
    67
 */
sl@0
    68
void RTestVclnt2PlayFile::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
    69
    {
sl@0
    70
    if (FsmCheck(aEventCode))
sl@0
    71
        {
sl@0
    72
        switch (aEventCode)
sl@0
    73
            {
sl@0
    74
            case EVPIdle:
sl@0
    75
                HandleIdleL();
sl@0
    76
                break;
sl@0
    77
                
sl@0
    78
            case EVPOpenComplete:
sl@0
    79
                HandleOpenCompleteL();
sl@0
    80
                break;
sl@0
    81
                
sl@0
    82
            case EVPPrepareComplete:                    
sl@0
    83
                HandlePrepareCompleteL();
sl@0
    84
                break;
sl@0
    85
                
sl@0
    86
            case EVPPlayComplete:
sl@0
    87
                HandlePlayCompleteL();
sl@0
    88
                break;
sl@0
    89
            }
sl@0
    90
        }
sl@0
    91
    }
sl@0
    92
    
sl@0
    93
void RTestVclnt2PlayFile::HandleIdleL()
sl@0
    94
	{
sl@0
    95
	// Open iVideoPlayer
sl@0
    96
    INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
sl@0
    97
    iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
sl@0
    98
    PrepareState(EVPOpenComplete, KErrNone);
sl@0
    99
	}
sl@0
   100
sl@0
   101
void RTestVclnt2PlayFile::HandleOpenCompleteL()
sl@0
   102
	{
sl@0
   103
	// Prepare iVideoPlayer2
sl@0
   104
    INFO_PRINTF1(_L("iVideoPlayer2->Prepare()"));
sl@0
   105
    iVideoPlayer2->Prepare();
sl@0
   106
    PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   107
	}
sl@0
   108
	
sl@0
   109
void RTestVclnt2PlayFile::HandlePrepareCompleteL()
sl@0
   110
	{
sl@0
   111
	// Add display window using default values - ie. video extent & window clipping 
sl@0
   112
	// defaulted to whole window
sl@0
   113
	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
sl@0
   114
	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
sl@0
   115
sl@0
   116
    // trigger the video to start playing                
sl@0
   117
    StartPlayback();
sl@0
   118
	}
sl@0
   119
sl@0
   120
void RTestVclnt2PlayFile::HandlePlayCompleteL()
sl@0
   121
	{
sl@0
   122
	iTestStepResult = EPass;
sl@0
   123
	CActiveScheduler::Stop();
sl@0
   124
	}
sl@0
   125
sl@0
   126
void RTestVclnt2PlayFile::StartPlayback()
sl@0
   127
	{
sl@0
   128
    iError = KErrTimedOut;
sl@0
   129
    INFO_PRINTF1(_L("iVideoPlayer2->Play()"));
sl@0
   130
    PrepareState(EVPPlayComplete, KErrNone);
sl@0
   131
    iVideoPlayer2->Play();
sl@0
   132
	}
sl@0
   133
	
sl@0
   134
#ifdef SYMBIAN_BUILD_GCE
sl@0
   135
//
sl@0
   136
// RTestMediaClientVideoDisplay
sl@0
   137
//
sl@0
   138
sl@0
   139
/**
sl@0
   140
 * RTestMediaClientVideoDisplay::Constructor
sl@0
   141
 */
sl@0
   142
sl@0
   143
sl@0
   144
RTestMediaClientVideoDisplay::RTestMediaClientVideoDisplay(const TDesC& aTestName, 
sl@0
   145
                                         const TDesC& aSectName, 
sl@0
   146
                                         const TDesC& aKeyName, 
sl@0
   147
                                         TInt aExpectedError)
sl@0
   148
    : RTestVclnt2AviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   149
    {
sl@0
   150
    }
sl@0
   151
sl@0
   152
/**
sl@0
   153
 * RTestMediaClientVideoDisplay::NewL
sl@0
   154
 */
sl@0
   155
sl@0
   156
RTestMediaClientVideoDisplay* RTestMediaClientVideoDisplay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
   157
    {
sl@0
   158
    RTestMediaClientVideoDisplay* self = new (ELeave) RTestMediaClientVideoDisplay(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   159
    return self;
sl@0
   160
    }
sl@0
   161
sl@0
   162
/**
sl@0
   163
 * RTestMediaClientVideoDisplay::DoTestStepPreambleL
sl@0
   164
 */
sl@0
   165
 
sl@0
   166
TVerdict RTestMediaClientVideoDisplay::DoTestStepPreambleL()
sl@0
   167
    {
sl@0
   168
    return RTestVclnt2AviPlayerStep::DoTestStepPreambleL();
sl@0
   169
    }
sl@0
   170
sl@0
   171
/**
sl@0
   172
 * RTestMediaClientVideoDisplay::DoTestStepPostambleL
sl@0
   173
 */
sl@0
   174
 
sl@0
   175
TVerdict RTestMediaClientVideoDisplay::DoTestStepPostambleL()
sl@0
   176
    {
sl@0
   177
    return RTestVclnt2AviPlayerStep::DoTestStepPostambleL();        
sl@0
   178
    }
sl@0
   179
sl@0
   180
/**
sl@0
   181
 * RTestMediaClientVideoDisplay::FsmL
sl@0
   182
 */
sl@0
   183
void RTestMediaClientVideoDisplay::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   184
    {
sl@0
   185
    if (FsmCheck(aEventCode))
sl@0
   186
        {
sl@0
   187
        switch (aEventCode)
sl@0
   188
            {
sl@0
   189
            case EVPIdle:
sl@0
   190
                HandleIdleL();
sl@0
   191
                break;
sl@0
   192
                
sl@0
   193
            case EVPOpenComplete:
sl@0
   194
                HandleOpenCompleteL();
sl@0
   195
                break;
sl@0
   196
                
sl@0
   197
            case EVPPrepareComplete:                    
sl@0
   198
                HandlePrepareCompleteL();
sl@0
   199
                break;
sl@0
   200
                
sl@0
   201
            case EVPPlayComplete:
sl@0
   202
                HandlePlayCompleteL();
sl@0
   203
                break;
sl@0
   204
            }
sl@0
   205
        }
sl@0
   206
    }
sl@0
   207
    
sl@0
   208
void RTestMediaClientVideoDisplay::HandleIdleL()
sl@0
   209
	{
sl@0
   210
	// Open iVideoPlayer
sl@0
   211
    INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
sl@0
   212
    iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
sl@0
   213
    PrepareState(EVPOpenComplete, KErrNone);
sl@0
   214
	}
sl@0
   215
sl@0
   216
void RTestMediaClientVideoDisplay::HandleOpenCompleteL()
sl@0
   217
	{
sl@0
   218
	// Prepare iVideoPlayer2
sl@0
   219
    INFO_PRINTF1(_L("iVideoPlayer2->Prepare()"));
sl@0
   220
    iVideoPlayer2->Prepare();
sl@0
   221
    PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   222
	}
sl@0
   223
	
sl@0
   224
void RTestMediaClientVideoDisplay::HandlePrepareCompleteL()
sl@0
   225
	{
sl@0
   226
	// trigger the video to start playing  
sl@0
   227
	StartPlayback();
sl@0
   228
	
sl@0
   229
	TInt displayId = iScreen->GetScreenNumber();
sl@0
   230
	TRect clipRect = TRect(iWindow->Size());
sl@0
   231
	TRect cropRegion = clipRect;
sl@0
   232
	
sl@0
   233
	// ==========================
sl@0
   234
	
sl@0
   235
    iMediaClientVideoDisplay = CMediaClientVideoDisplay::NewL(displayId);
sl@0
   236
    
sl@0
   237
 	RSurfaceManager surfaceManager;
sl@0
   238
 	User::LeaveIfError(surfaceManager.Open());
sl@0
   239
	
sl@0
   240
	RSurfaceManager::TSurfaceCreationAttributesBuf bf;
sl@0
   241
	RSurfaceManager::TSurfaceCreationAttributes& b=bf();
sl@0
   242
	b.iSize.iWidth = 320;
sl@0
   243
	b.iSize.iHeight = 240;
sl@0
   244
	b.iBuffers = 1;
sl@0
   245
	b.iPixelFormat = EUidPixelFormatXRGB_8888;	
sl@0
   246
	b.iStride = 320 * 4;
sl@0
   247
	b.iOffsetToFirstBuffer = 0;
sl@0
   248
	b.iAlignment=4;
sl@0
   249
	b.iContiguous=ETrue;
sl@0
   250
	
sl@0
   251
	TRect cropRect(0, 0, 320, 240);
sl@0
   252
	TVideoAspectRatio par(1,2);
sl@0
   253
	TSurfaceId surfaceId;
sl@0
   254
	
sl@0
   255
	User::LeaveIfError(surfaceManager.CreateSurface(bf, surfaceId));
sl@0
   256
 	
sl@0
   257
    iMediaClientVideoDisplay->SurfaceCreated(surfaceId, cropRect, par, cropRegion);
sl@0
   258
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SurfaceCreated()"));
sl@0
   259
    
sl@0
   260
    delete iMediaClientVideoDisplay;
sl@0
   261
    iMediaClientVideoDisplay = NULL;
sl@0
   262
    
sl@0
   263
    // ==================
sl@0
   264
    
sl@0
   265
    iMediaClientVideoDisplay = CMediaClientVideoDisplay::NewL(displayId);
sl@0
   266
    
sl@0
   267
	TRect videoExtent = clipRect;
sl@0
   268
	TReal32 scaleWidth(100.0f);
sl@0
   269
	TReal32 scaleHeight(100.0f);
sl@0
   270
	TInt horizPos(EHorizontalAlignCenter);
sl@0
   271
	TInt vertPos(EVerticalAlignCenter);	
sl@0
   272
	
sl@0
   273
	TReal32 widthPercentage(50.0f); 
sl@0
   274
	TReal32 heightPercentage(50.0f);
sl@0
   275
	TReal32 widthP; 
sl@0
   276
	TReal32 heightP;
sl@0
   277
	RWindow newWindow;
sl@0
   278
	
sl@0
   279
	// Check for invalid rotation when adding new window
sl@0
   280
	INFO_PRINTF1(_L("Testing invalid rotations for AddDisplayWindowL"));
sl@0
   281
	TInt err = KErrNone;
sl@0
   282
	TVideoRotation rotation = static_cast<TVideoRotation>(-1);
sl@0
   283
	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow));
sl@0
   284
	if (err != KErrArgument)
sl@0
   285
		{
sl@0
   286
		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for negative rotation"));
sl@0
   287
    	iTestStepResult = EFail;
sl@0
   288
    	CActiveScheduler::Stop();
sl@0
   289
    	return;
sl@0
   290
		}
sl@0
   291
sl@0
   292
	rotation = static_cast<TVideoRotation>(4);
sl@0
   293
	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow));
sl@0
   294
	if (err != KErrArgument)
sl@0
   295
		{
sl@0
   296
		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for out of range rotation"));
sl@0
   297
    	iTestStepResult = EFail;
sl@0
   298
    	CActiveScheduler::Stop();
sl@0
   299
    	return;
sl@0
   300
		}
sl@0
   301
sl@0
   302
	rotation = EVideoRotationNone;
sl@0
   303
sl@0
   304
	// Check for invalid autoScaleType when adding new window
sl@0
   305
	INFO_PRINTF1(_L("Testing invalid autoScaleType for AddDisplayWindowL"));
sl@0
   306
	TAutoScaleType autoScaleType = static_cast<TAutoScaleType>(-1);
sl@0
   307
	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, autoScaleType, horizPos, vertPos, iWindow));
sl@0
   308
	if (err != KErrArgument)
sl@0
   309
		{
sl@0
   310
		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for negative scale"));
sl@0
   311
    	iTestStepResult = EFail;
sl@0
   312
    	CActiveScheduler::Stop();
sl@0
   313
    	return;
sl@0
   314
		}
sl@0
   315
sl@0
   316
	autoScaleType = static_cast<TAutoScaleType>(4);
sl@0
   317
	TRAP(err, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, autoScaleType, horizPos, vertPos, iWindow));
sl@0
   318
	if (err != KErrArgument)
sl@0
   319
		{
sl@0
   320
		ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() did not leave with KErrArgument for out of range scale"));
sl@0
   321
    	iTestStepResult = EFail;
sl@0
   322
    	CActiveScheduler::Stop();
sl@0
   323
    	return;
sl@0
   324
		}
sl@0
   325
	
sl@0
   326
	iMediaClientVideoDisplay->AddDisplayWindowL(iWindow, clipRect, cropRegion, videoExtent, scaleWidth, scaleHeight, rotation, EAutoScaleBestFit, horizPos, vertPos, iWindow);
sl@0
   327
	INFO_PRINTF1(_L("iMediaClientVideoDisplay->AddDisplayWindowL()"));   
sl@0
   328
sl@0
   329
	// Check for invalid rotation when setting rotation for window
sl@0
   330
	INFO_PRINTF1(_L("Testing invalid rotation for SetRotationL"));
sl@0
   331
	TVideoRotation videoRotation = static_cast<TVideoRotation>(-1);
sl@0
   332
	TRAP(err, iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion));
sl@0
   333
	if (err != KErrArgument)
sl@0
   334
		{
sl@0
   335
		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL(window) did not leave with KErrArgument for negative value"));
sl@0
   336
    	iTestStepResult = EFail;
sl@0
   337
    	CActiveScheduler::Stop();
sl@0
   338
    	return;
sl@0
   339
		}
sl@0
   340
sl@0
   341
	videoRotation = static_cast<TVideoRotation>(4);
sl@0
   342
	TRAP(err, iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion));
sl@0
   343
	if (err != KErrArgument)
sl@0
   344
		{
sl@0
   345
		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL(window) did not leave with KErrArgument for out of range value"));
sl@0
   346
    	iTestStepResult = EFail;
sl@0
   347
    	CActiveScheduler::Stop();
sl@0
   348
    	return;
sl@0
   349
		}
sl@0
   350
sl@0
   351
	// Check for invalid rotation when setting rotation for all windows
sl@0
   352
	videoRotation = static_cast<TVideoRotation>(-1);
sl@0
   353
	TRAP(err, iMediaClientVideoDisplay->SetRotationL(videoRotation, cropRegion));
sl@0
   354
	if (err != KErrArgument)
sl@0
   355
		{
sl@0
   356
		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL() did not leave with KErrArgument for negative value"));
sl@0
   357
    	iTestStepResult = EFail;
sl@0
   358
    	CActiveScheduler::Stop();
sl@0
   359
    	return;
sl@0
   360
		}
sl@0
   361
sl@0
   362
	videoRotation = static_cast<TVideoRotation>(4);
sl@0
   363
	TRAP(err, iMediaClientVideoDisplay->SetRotationL(videoRotation, cropRegion));
sl@0
   364
	if (err != KErrArgument)
sl@0
   365
		{
sl@0
   366
		ERR_PRINTF1(_L("iVideoPlayer2->SetRotationL() did not leave with KErrArgument for out of range value"));
sl@0
   367
    	iTestStepResult = EFail;
sl@0
   368
    	CActiveScheduler::Stop();
sl@0
   369
    	return;
sl@0
   370
		}
sl@0
   371
sl@0
   372
	videoRotation = EVideoRotationClockwise180;
sl@0
   373
sl@0
   374
    iMediaClientVideoDisplay->SetRotationL(*iWindow, videoRotation, cropRegion);
sl@0
   375
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetRotationL()"));
sl@0
   376
    
sl@0
   377
    if (iMediaClientVideoDisplay->RotationL(*iWindow) != videoRotation)
sl@0
   378
        {
sl@0
   379
        ERR_PRINTF1(_L("iMediaClientVideoDisplay->RotationL() returns an unexpected value.  Test aborted."));
sl@0
   380
sl@0
   381
		iTestStepResult = EInconclusive;
sl@0
   382
		CActiveScheduler::Stop();
sl@0
   383
        }
sl@0
   384
	else
sl@0
   385
		{
sl@0
   386
		INFO_PRINTF1(_L("iMediaClientVideoDisplay->RotationL()"));	
sl@0
   387
		}
sl@0
   388
    
sl@0
   389
    iMediaClientVideoDisplay->SetScaleFactorL(*iWindow, widthPercentage, heightPercentage, cropRegion);
sl@0
   390
    iMediaClientVideoDisplay->SetScaleFactorL(widthPercentage, heightPercentage, cropRegion);
sl@0
   391
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetScaleFactorL()"));
sl@0
   392
    
sl@0
   393
    iMediaClientVideoDisplay->SetRotationL(EVideoRotationClockwise90, cropRegion);
sl@0
   394
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetRotationL()"));
sl@0
   395
    
sl@0
   396
    iMediaClientVideoDisplay->GetScaleFactorL(*iWindow, widthP, heightP);
sl@0
   397
    INFO_PRINTF3(_L("iMediaClientVideoDisplay->GetScaleFactorL() %df %df"), &widthP, &heightP);
sl@0
   398
sl@0
   399
    iMediaClientVideoDisplay->SetVideoExtentL(*iWindow, videoExtent, cropRegion);
sl@0
   400
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetVideoExtentL()"));
sl@0
   401
    
sl@0
   402
    iMediaClientVideoDisplay->SetWindowClipRectL(*iWindow, clipRect, cropRegion);
sl@0
   403
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetWindowClipRectL()"));
sl@0
   404
sl@0
   405
	// Check for invalid autoScaleType when setting autoScaleType for window
sl@0
   406
	INFO_PRINTF1(_L("Testing invalid autoScaleType for SetAutoScaleL"));
sl@0
   407
	autoScaleType = static_cast<TAutoScaleType>(-1);
sl@0
   408
	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(*iWindow, autoScaleType, horizPos, vertPos, cropRegion));
sl@0
   409
	if (err != KErrArgument)
sl@0
   410
		{
sl@0
   411
		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL(window) did not leave with KErrArgument for negative value"));
sl@0
   412
    	iTestStepResult = EFail;
sl@0
   413
    	CActiveScheduler::Stop();
sl@0
   414
    	return;
sl@0
   415
		}
sl@0
   416
sl@0
   417
	autoScaleType = static_cast<TAutoScaleType>(4);
sl@0
   418
	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(*iWindow, autoScaleType, horizPos, vertPos, cropRegion));
sl@0
   419
	if (err != KErrArgument)
sl@0
   420
		{
sl@0
   421
		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL(window) did not leave with KErrArgument for out of range value"));
sl@0
   422
    	iTestStepResult = EFail;
sl@0
   423
    	CActiveScheduler::Stop();
sl@0
   424
    	return;
sl@0
   425
		}
sl@0
   426
sl@0
   427
	// Check for invalid autoScaleType when setting autoScaleType for all windows
sl@0
   428
	autoScaleType = static_cast<TAutoScaleType>(-1);
sl@0
   429
	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(autoScaleType, horizPos, vertPos, cropRegion));
sl@0
   430
	if (err != KErrArgument)
sl@0
   431
		{
sl@0
   432
		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL() did not leave with KErrArgument for negative value"));
sl@0
   433
    	iTestStepResult = EFail;
sl@0
   434
    	CActiveScheduler::Stop();
sl@0
   435
    	return;
sl@0
   436
		}
sl@0
   437
sl@0
   438
	autoScaleType = static_cast<TAutoScaleType>(4);
sl@0
   439
	TRAP(err, iMediaClientVideoDisplay->SetAutoScaleL(autoScaleType, horizPos, vertPos, cropRegion));
sl@0
   440
	if (err != KErrArgument)
sl@0
   441
		{
sl@0
   442
		ERR_PRINTF1(_L("iVideoPlayer2->SetAutoScaleL() did not leave with KErrArgument for out of range value"));
sl@0
   443
    	iTestStepResult = EFail;
sl@0
   444
    	CActiveScheduler::Stop();
sl@0
   445
    	return;
sl@0
   446
		}
sl@0
   447
    
sl@0
   448
    iMediaClientVideoDisplay->SetAutoScaleL(EAutoScaleBestFit, horizPos, vertPos, cropRegion);
sl@0
   449
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->SetAutoScaleL()"));
sl@0
   450
    
sl@0
   451
    iMediaClientVideoDisplay->RedrawWindows(cropRegion);
sl@0
   452
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->RedrawWindows()"));   
sl@0
   453
    
sl@0
   454
	iMediaClientVideoDisplay->SurfaceParametersChanged(surfaceId, cropRect, par);
sl@0
   455
	INFO_PRINTF1(_L("iMediaClientVideoDisplay->SurfaceParametersChanged()"));
sl@0
   456
	
sl@0
   457
	iMediaClientVideoDisplay->RemoveSurface();
sl@0
   458
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->ReplaceSurface()"));
sl@0
   459
    
sl@0
   460
    iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
sl@0
   461
    INFO_PRINTF1(_L("iMediaClientVideoDisplay->RemoveDisplayWindow()"));
sl@0
   462
    
sl@0
   463
    surfaceManager.CloseSurface(surfaceId);
sl@0
   464
	surfaceId = TSurfaceId::CreateNullId();
sl@0
   465
	surfaceManager.Close();
sl@0
   466
    
sl@0
   467
    delete iMediaClientVideoDisplay;  
sl@0
   468
    iMediaClientVideoDisplay = NULL;              
sl@0
   469
   	}
sl@0
   470
sl@0
   471
void RTestMediaClientVideoDisplay::HandlePlayCompleteL()
sl@0
   472
	{
sl@0
   473
	iTestStepResult = EPass;
sl@0
   474
	CActiveScheduler::Stop();
sl@0
   475
	}
sl@0
   476
sl@0
   477
void RTestMediaClientVideoDisplay::StartPlayback()
sl@0
   478
	{
sl@0
   479
    iError = KErrTimedOut;
sl@0
   480
    INFO_PRINTF1(_L("iVideoPlayer2->Play()"));
sl@0
   481
    PrepareState(EVPPlayComplete, KErrNone);
sl@0
   482
    iVideoPlayer2->Play();
sl@0
   483
	}
sl@0
   484
	
sl@0
   485
#endif
sl@0
   486
sl@0
   487
//
sl@0
   488
// RTestVclnt2PerformActionDuringVideoPlayback
sl@0
   489
//
sl@0
   490
sl@0
   491
/**
sl@0
   492
 * RTestVclnt2PerformActionDuringVideoPlayback::Constructor
sl@0
   493
 */
sl@0
   494
RTestVclnt2PerformActionDuringVideoPlayback::RTestVclnt2PerformActionDuringVideoPlayback(
sl@0
   495
    const TDesC& aTestName, 
sl@0
   496
    const TDesC& aSectName, 
sl@0
   497
    const TDesC& aKeyName, 
sl@0
   498
    TInt aExpectedError)
sl@0
   499
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   500
    {
sl@0
   501
    }
sl@0
   502
sl@0
   503
/**
sl@0
   504
 * RTestVclnt2PerformActionDuringVideoPlayback::HandlePlayCompleteL
sl@0
   505
 */
sl@0
   506
void RTestVclnt2PerformActionDuringVideoPlayback::HandlePlayCompleteL()
sl@0
   507
    {
sl@0
   508
    if (iActionError != KErrNone)
sl@0
   509
        {
sl@0
   510
        ERR_PRINTF2(_L("Playback event left with error %d."), iActionError);
sl@0
   511
        iTestStepResult = EFail;
sl@0
   512
        }
sl@0
   513
    else 
sl@0
   514
        {
sl@0
   515
        iTestStepResult = EPass;
sl@0
   516
        }
sl@0
   517
sl@0
   518
	CActiveScheduler::Stop();        
sl@0
   519
    }
sl@0
   520
sl@0
   521
/**
sl@0
   522
 * RTestVclnt2PerformActionDuringVideoPlayback::StartPlayback
sl@0
   523
 */     
sl@0
   524
void RTestVclnt2PerformActionDuringVideoPlayback::StartPlayback()
sl@0
   525
	{
sl@0
   526
	RTestVclnt2PlayFile::StartPlayback();
sl@0
   527
	
sl@0
   528
	iActionError = KErrNone;
sl@0
   529
    TRAP(iActionError, DoThisActionDuringPlaybackL(*iVideoPlayer2));
sl@0
   530
	}
sl@0
   531
sl@0
   532
sl@0
   533
//
sl@0
   534
// RTestVclnt2AddWin
sl@0
   535
//
sl@0
   536
/**
sl@0
   537
 * RTestVclnt2AddWin::Constructor
sl@0
   538
 */
sl@0
   539
RTestVclnt2AddWin::RTestVclnt2AddWin(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   540
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   541
    {
sl@0
   542
    }
sl@0
   543
sl@0
   544
/**
sl@0
   545
 * RTestVclnt2AddWin::NewL
sl@0
   546
 */
sl@0
   547
RTestVclnt2AddWin* RTestVclnt2AddWin::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   548
    {
sl@0
   549
    RTestVclnt2AddWin* self = new (ELeave) RTestVclnt2AddWin(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   550
    return self;
sl@0
   551
    }
sl@0
   552
   
sl@0
   553
/**
sl@0
   554
 * RTestVclnt2AddWin::HandlePrepareCompleteL
sl@0
   555
 */
sl@0
   556
void RTestVclnt2AddWin::HandlePrepareCompleteL()
sl@0
   557
    {
sl@0
   558
    // retrieve video size
sl@0
   559
    TSize videoSize;
sl@0
   560
    iVideoPlayer2->VideoFrameSizeL(videoSize);                
sl@0
   561
sl@0
   562
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0505")) == 0)
sl@0
   563
        {
sl@0
   564
        // create a clipping rect partially out of screen
sl@0
   565
        TRect windowRect(iWindow->Size());
sl@0
   566
        windowRect.SetWidth(windowRect.Width() * 2);
sl@0
   567
        
sl@0
   568
        // Add the display window with a partially out of screen clipping rect
sl@0
   569
        TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, 
sl@0
   570
                                                    *iScreen, 
sl@0
   571
                                                    *iWindow, 
sl@0
   572
                                                    TRect(iWindow->Size()), 
sl@0
   573
                                                    windowRect));
sl@0
   574
        if (err != iTestExpectedError)
sl@0
   575
            {
sl@0
   576
            ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
sl@0
   577
sl@0
   578
    		iTestStepResult = EFail;
sl@0
   579
    		CActiveScheduler::Stop();
sl@0
   580
sl@0
   581
    		return;
sl@0
   582
            }
sl@0
   583
sl@0
   584
        // create a clipping rect completely out of screen
sl@0
   585
        windowRect.SetRect(TPoint(0, 0), iWindow->Size());
sl@0
   586
        windowRect.Move(windowRect.Width() + 10, 0);
sl@0
   587
        
sl@0
   588
        // Add the display window with a completely out of screen clipping rect
sl@0
   589
        TRAP(err, iVideoPlayer2->AddDisplayWindowL(iWs, 
sl@0
   590
                                                   *iScreen, 
sl@0
   591
                                                   *iWindow, 
sl@0
   592
                                                   TRect(iWindow->Size()), 
sl@0
   593
                                                   windowRect));
sl@0
   594
        if (err != iTestExpectedError)
sl@0
   595
            {
sl@0
   596
            ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
sl@0
   597
            
sl@0
   598
    		iTestStepResult = EFail;
sl@0
   599
    		CActiveScheduler::Stop();
sl@0
   600
sl@0
   601
    		return;
sl@0
   602
            }
sl@0
   603
        else 
sl@0
   604
            {
sl@0
   605
            // Reset the expected error to KErrNone as all expected failure tests have been completed.  
sl@0
   606
            // Any error that appears after this should fail the test
sl@0
   607
            iTestExpectedError = KErrNone;
sl@0
   608
            }
sl@0
   609
sl@0
   610
        // after failing to add window display with a partially & a completely out of screen
sl@0
   611
        // clipping rect, proceed to add a valid clipping rect below            
sl@0
   612
        }    
sl@0
   613
    
sl@0
   614
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0401")) == 0 ||
sl@0
   615
        iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0505")) == 0) 
sl@0
   616
        {
sl@0
   617
        // shrink both the video & window size by half
sl@0
   618
        TRect videoRect(videoSize);     
sl@0
   619
        videoRect.SetHeight(videoSize.iHeight / 2);
sl@0
   620
        videoRect.SetWidth(videoSize.iWidth / 2); 
sl@0
   621
        
sl@0
   622
        TRect windowRect(iWindow->Size());
sl@0
   623
        windowRect.SetHeight(iWindow->Size().iHeight / 2);
sl@0
   624
        windowRect.SetWidth(iWindow->Size().iWidth / 2); 
sl@0
   625
sl@0
   626
        // ensure the rect is within the boundary of the window        
sl@0
   627
        TRect finalRect(windowRect);
sl@0
   628
        finalRect.Intersection(videoRect);
sl@0
   629
sl@0
   630
        // add display window using this valid clipping rect 
sl@0
   631
        iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, finalRect, finalRect);
sl@0
   632
        }
sl@0
   633
    else
sl@0
   634
        {
sl@0
   635
        // Invalid test case
sl@0
   636
        User::Panic(_L("RTestVclnt2AddWin"), KErrArgument);        
sl@0
   637
        }
sl@0
   638
sl@0
   639
    // Start video playback
sl@0
   640
    StartPlayback();
sl@0
   641
    }
sl@0
   642
sl@0
   643
sl@0
   644
//
sl@0
   645
// RTestVclnt2RemoveWin
sl@0
   646
//
sl@0
   647
sl@0
   648
/**
sl@0
   649
 * RTestVclnt2RemoveWin::Constructor
sl@0
   650
 */ 
sl@0
   651
RTestVclnt2RemoveWin::RTestVclnt2RemoveWin(const TDesC& aTestName, 
sl@0
   652
                                           const TDesC& aSectName,
sl@0
   653
                                           const TDesC& aKeyName, 
sl@0
   654
                                           TInt aExpectedError,
sl@0
   655
                                           TBool aAddBack)
sl@0
   656
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError),
sl@0
   657
      iAddBack(aAddBack)
sl@0
   658
    {
sl@0
   659
    }
sl@0
   660
sl@0
   661
/**
sl@0
   662
 * RTestVclnt2RemoveWin::NewL
sl@0
   663
 */
sl@0
   664
RTestVclnt2RemoveWin* RTestVclnt2RemoveWin::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, TBool aAddBack)
sl@0
   665
    {
sl@0
   666
    RTestVclnt2RemoveWin* self = new (ELeave) RTestVclnt2RemoveWin(aTestName, aSectName, aKeyName, aExpectedError, aAddBack);
sl@0
   667
    return self;
sl@0
   668
    }
sl@0
   669
sl@0
   670
/**
sl@0
   671
 * RTestVclnt2RemoveWin::HandlePrepareCompleteL
sl@0
   672
 */
sl@0
   673
void RTestVclnt2RemoveWin::HandlePrepareCompleteL()
sl@0
   674
    {
sl@0
   675
    // retrieve video size
sl@0
   676
    TSize videoSize;
sl@0
   677
    iVideoPlayer2->VideoFrameSizeL(videoSize);
sl@0
   678
sl@0
   679
    // shrink both the video & window size by half
sl@0
   680
    TRect videoRect(videoSize);     
sl@0
   681
    videoRect.SetHeight(videoSize.iHeight / 2);
sl@0
   682
    videoRect.SetWidth(videoSize.iWidth / 2); 
sl@0
   683
sl@0
   684
    TRect windowRect(iWindow->Size());
sl@0
   685
    windowRect.SetHeight(iWindow->Size().iHeight / 2);
sl@0
   686
    windowRect.SetWidth(iWindow->Size().iWidth / 2); 
sl@0
   687
sl@0
   688
    // ensure the rect is within the boundary of the window        
sl@0
   689
    TRect finalRect(windowRect);
sl@0
   690
    finalRect.Intersection(videoRect);
sl@0
   691
sl@0
   692
    // add display window using this valid clipping rect 
sl@0
   693
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, finalRect, finalRect);
sl@0
   694
sl@0
   695
    // trigger the video to start playing
sl@0
   696
    StartPlayback();    
sl@0
   697
    }
sl@0
   698
sl@0
   699
/**
sl@0
   700
 * RTestVclnt2RemoveWin::DoThisActionDuringPlaybackL
sl@0
   701
 */ 
sl@0
   702
void RTestVclnt2RemoveWin::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
   703
    {
sl@0
   704
    // Play the video clip using a specific display window & video clipping setting 
sl@0
   705
    // first
sl@0
   706
    TTimeIntervalMicroSeconds duration = aPlayer.DurationL();        
sl@0
   707
sl@0
   708
    // After a quarter of the clip's duration
sl@0
   709
    User::After(duration.Int64() / 4);
sl@0
   710
sl@0
   711
    // remove the original display        
sl@0
   712
    aPlayer.RemoveDisplayWindow(*iWindow);
sl@0
   713
sl@0
   714
sl@0
   715
    if (iAddBack)
sl@0
   716
    	{
sl@0
   717
	    // Add the window using default values to continues
sl@0
   718
	    aPlayer.AddDisplayWindowL(iWs, *iScreen, *iWindow);
sl@0
   719
    	}
sl@0
   720
    }
sl@0
   721
sl@0
   722
sl@0
   723
//
sl@0
   724
// RTestVclnt2WinPos
sl@0
   725
//
sl@0
   726
sl@0
   727
/**
sl@0
   728
 * RTestVclnt2WinPos::Constructor
sl@0
   729
 */
sl@0
   730
RTestVclnt2WinPos::RTestVclnt2WinPos(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   731
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   732
    {
sl@0
   733
    }
sl@0
   734
sl@0
   735
/**
sl@0
   736
 * RTestVclnt2WinPos::NewL
sl@0
   737
 */
sl@0
   738
RTestVclnt2WinPos* RTestVclnt2WinPos::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   739
    {
sl@0
   740
    RTestVclnt2WinPos* self = new (ELeave) RTestVclnt2WinPos(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   741
    return self;
sl@0
   742
    }
sl@0
   743
sl@0
   744
/**
sl@0
   745
 * RTestVclnt2WinPos::DoThisActionDuringPlaybackL
sl@0
   746
 */
sl@0
   747
void RTestVclnt2WinPos::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
   748
    {
sl@0
   749
    TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
sl@0
   750
            
sl@0
   751
    // shrink the window clipping rect by half the height & width            
sl@0
   752
    aPlayer.SetWindowClipRectL(*iWindow, TRect(windowSize));    
sl@0
   753
    }
sl@0
   754
sl@0
   755
sl@0
   756
//
sl@0
   757
// RTestVclnt2VideoExt
sl@0
   758
//
sl@0
   759
sl@0
   760
/**
sl@0
   761
 * RTestVclnt2VideoExt::Constructor
sl@0
   762
 */
sl@0
   763
RTestVclnt2VideoExt::RTestVclnt2VideoExt(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   764
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   765
    {
sl@0
   766
    }
sl@0
   767
sl@0
   768
/**
sl@0
   769
 * RTestVclnt2VideoExt::NewL
sl@0
   770
 */
sl@0
   771
RTestVclnt2VideoExt* RTestVclnt2VideoExt::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   772
    {
sl@0
   773
    RTestVclnt2VideoExt* self = new (ELeave) RTestVclnt2VideoExt(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   774
    return self;
sl@0
   775
    }
sl@0
   776
sl@0
   777
/**
sl@0
   778
 * RTestVclnt2VideoExt::DoThisActionDuringPlaybackL
sl@0
   779
 */
sl@0
   780
void RTestVclnt2VideoExt::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
   781
    {
sl@0
   782
    TSize windowSize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);
sl@0
   783
            
sl@0
   784
    // shrink the video extent by half the height & width            
sl@0
   785
    aPlayer.SetVideoExtentL(*iWindow, TRect(windowSize));
sl@0
   786
    }
sl@0
   787
sl@0
   788
sl@0
   789
//
sl@0
   790
// RTestVclnt2ClipRect
sl@0
   791
//
sl@0
   792
sl@0
   793
/**
sl@0
   794
 * RTestVclnt2ClipRect::Constructor
sl@0
   795
 */
sl@0
   796
RTestVclnt2ClipRect::RTestVclnt2ClipRect(const TDesC& aTestName, 
sl@0
   797
                                         const TDesC& aSectName,
sl@0
   798
                                         const TDesC& aKeyName, 
sl@0
   799
                                         TInt aExpectedError)
sl@0
   800
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   801
    {
sl@0
   802
    }
sl@0
   803
sl@0
   804
/**
sl@0
   805
 * RTestVclnt2ClipRect::NewL
sl@0
   806
 */
sl@0
   807
RTestVclnt2ClipRect* RTestVclnt2ClipRect::NewL(const TDesC& aTestName, 
sl@0
   808
                                               const TDesC& aSectName,
sl@0
   809
                                               const TDesC& aKeyName, 
sl@0
   810
                                               TInt aExpectedError)
sl@0
   811
    {
sl@0
   812
    RTestVclnt2ClipRect* self 
sl@0
   813
        = new (ELeave) RTestVclnt2ClipRect(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   814
    return self;
sl@0
   815
    }
sl@0
   816
sl@0
   817
/**
sl@0
   818
 * RTestVclnt2ClipRect::DoThisActionDuringPlaybackL
sl@0
   819
 */
sl@0
   820
void RTestVclnt2ClipRect::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
   821
    {
sl@0
   822
    TRect clipRect;    
sl@0
   823
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0405")) == 0)
sl@0
   824
        {
sl@0
   825
        // shrink the current window clipping rect by half the height & width 
sl@0
   826
        clipRect.Resize(iWindow->Size().iWidth / 2, iWindow->Size().iHeight / 2);            
sl@0
   827
        }
sl@0
   828
    else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0503")) == 0)
sl@0
   829
        {
sl@0
   830
        // grow the current window clipping rect by double the width         
sl@0
   831
        clipRect.Resize(iWindow->Size().iWidth * 2, iWindow->Size().iHeight);
sl@0
   832
        }
sl@0
   833
    else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0504")) == 0)
sl@0
   834
        {
sl@0
   835
        // move the current window clipping rect to be out of the window
sl@0
   836
        clipRect.SetSize(iWindow->Size());
sl@0
   837
        clipRect.Move(TPoint(iWindow->Size().iWidth + 1, 0));
sl@0
   838
        }
sl@0
   839
    else
sl@0
   840
        {
sl@0
   841
        User::Panic(_L("RTestVclnt2ClipRect"), KErrArgument);
sl@0
   842
        }
sl@0
   843
    
sl@0
   844
    // change the window clipping of the display window
sl@0
   845
    TRAPD(err, aPlayer.SetWindowClipRectL(*iWindow, clipRect));
sl@0
   846
    if (err != iTestExpectedError)
sl@0
   847
        {
sl@0
   848
        if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0503")) == 0 || 
sl@0
   849
            iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0504")) == 0)
sl@0
   850
            {
sl@0
   851
            // for negative tests, stop the test if the failure is not expected
sl@0
   852
            ERR_PRINTF1(_L("iVideoPlayer2->SetWindowClipRectL() did not failed as expected.  Test failed."));
sl@0
   853
sl@0
   854
    		iTestStepResult = EInconclusive;
sl@0
   855
    		CActiveScheduler::Stop();
sl@0
   856
sl@0
   857
    		return;
sl@0
   858
            }
sl@0
   859
        else
sl@0
   860
            {
sl@0
   861
            // fail only if error is returned for positive tests
sl@0
   862
            User::LeaveIfError(err);
sl@0
   863
            }
sl@0
   864
        }
sl@0
   865
    else
sl@0
   866
        {        
sl@0
   867
        // Reset the expected error to KErrNone as all expected failure tests have been completed.  
sl@0
   868
        // Any error that appears after this should fail the test
sl@0
   869
        iTestExpectedError = KErrNone;
sl@0
   870
        }
sl@0
   871
    }
sl@0
   872
sl@0
   873
//
sl@0
   874
// RTestVclnt2Scale
sl@0
   875
//
sl@0
   876
sl@0
   877
/**
sl@0
   878
 * RTestVclnt2Scale::Constructor
sl@0
   879
 */
sl@0
   880
RTestVclnt2Scale::RTestVclnt2Scale(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   881
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
   882
    {
sl@0
   883
    }
sl@0
   884
sl@0
   885
/**
sl@0
   886
 * RTestVclnt2Scale::NewL
sl@0
   887
 */
sl@0
   888
RTestVclnt2Scale* RTestVclnt2Scale::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   889
    {
sl@0
   890
    RTestVclnt2Scale* self = new (ELeave) RTestVclnt2Scale(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   891
    return self;
sl@0
   892
    }
sl@0
   893
sl@0
   894
/**
sl@0
   895
 * RTestVclnt2Scale::DoThisActionDuringPlaybackL
sl@0
   896
 */
sl@0
   897
void RTestVclnt2Scale::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
   898
    {
sl@0
   899
    // Change the scale factor during playback
sl@0
   900
    aPlayer.SetScaleFactorL(*iWindow, 150, 150);
sl@0
   901
    }
sl@0
   902
sl@0
   903
/**
sl@0
   904
 * RTestVclnt2Scale::HandlePrepareCompleteL
sl@0
   905
 */ 
sl@0
   906
void RTestVclnt2Scale::HandlePrepareCompleteL()
sl@0
   907
    {
sl@0
   908
    // Continue to setup the video utility and then trigger playback
sl@0
   909
    RTestVclnt2PerformActionDuringVideoPlayback::HandlePrepareCompleteL();
sl@0
   910
    
sl@0
   911
    TReal32 scaleFactor = 50.0;
sl@0
   912
     
sl@0
   913
    // set scale factor to less than 100%
sl@0
   914
    iVideoPlayer2->SetScaleFactorL(*iWindow, scaleFactor, scaleFactor);
sl@0
   915
sl@0
   916
    // get scale factor 
sl@0
   917
    TReal32 widthScale;
sl@0
   918
    TReal32 heightScale;
sl@0
   919
    iVideoPlayer2->GetScaleFactorL(*iWindow, widthScale, heightScale);
sl@0
   920
sl@0
   921
    if (widthScale != scaleFactor || heightScale != scaleFactor)
sl@0
   922
        {
sl@0
   923
        ERR_PRINTF1(_L("iVideoPlayer2->GetScaleFactorL() returns unexpected values.  Test aborted."));
sl@0
   924
        
sl@0
   925
		iTestStepResult = EInconclusive;
sl@0
   926
		CActiveScheduler::Stop();
sl@0
   927
		
sl@0
   928
		return;
sl@0
   929
        }    
sl@0
   930
    }
sl@0
   931
sl@0
   932
sl@0
   933
//
sl@0
   934
// RTestVclnt2Viewport
sl@0
   935
//
sl@0
   936
sl@0
   937
/**
sl@0
   938
 * RTestVclnt2Viewport::Constructor
sl@0
   939
 */
sl@0
   940
RTestVclnt2Viewport::RTestVclnt2Viewport(const TDesC& aTestName,
sl@0
   941
                                         const TDesC& aSectName,
sl@0
   942
                                         const TDesC& aKeyName, 
sl@0
   943
                                         const TSize& aViewportSize,
sl@0
   944
                                         TInt aExpectedError)
sl@0
   945
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError),
sl@0
   946
      iViewportSize(aViewportSize)
sl@0
   947
    {
sl@0
   948
    }
sl@0
   949
sl@0
   950
/**
sl@0
   951
 * RTestVclnt2Viewport::NewL
sl@0
   952
 */
sl@0
   953
RTestVclnt2Viewport* RTestVclnt2Viewport::NewL(const TDesC& aTestName, 
sl@0
   954
                                               const TDesC& aSectName,
sl@0
   955
                                               const TDesC& aKeyName, 
sl@0
   956
                                               const TSize& aViewportSize,
sl@0
   957
                                               TInt aExpectedError)
sl@0
   958
    {
sl@0
   959
    RTestVclnt2Viewport* self = new (ELeave) RTestVclnt2Viewport(aTestName, 
sl@0
   960
                                                                 aSectName, 
sl@0
   961
                                                                 aKeyName, 
sl@0
   962
                                                                 aViewportSize,
sl@0
   963
                                                                 aExpectedError); 
sl@0
   964
    return self;
sl@0
   965
    }
sl@0
   966
sl@0
   967
void RTestVclnt2Viewport::HandlePrepareCompleteL()
sl@0
   968
	{
sl@0
   969
	// retrive original video size
sl@0
   970
    TSize videoSize;
sl@0
   971
    iVideoPlayer2->VideoFrameSizeL(videoSize);
sl@0
   972
        
sl@0
   973
    // crop the top left quarter of the video
sl@0
   974
    TRect cropRegion;
sl@0
   975
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
sl@0
   976
        {
sl@0
   977
        // Crop the right half of the video
sl@0
   978
        cropRegion.SetHeight(videoSize.iHeight);        
sl@0
   979
        cropRegion.SetWidth(videoSize.iWidth / 2);
sl@0
   980
        cropRegion.Move(cropRegion.Width(), 0);
sl@0
   981
        }
sl@0
   982
    else
sl@0
   983
        {
sl@0
   984
        cropRegion.SetWidth(iViewportSize.iWidth == -1 ? videoSize.iWidth : iViewportSize.iWidth);
sl@0
   985
        cropRegion.SetHeight(iViewportSize.iHeight == -1 ? videoSize.iHeight : iViewportSize.iHeight);
sl@0
   986
        }
sl@0
   987
    
sl@0
   988
    TRect videoExtentRect;
sl@0
   989
    TRect clipRegion;
sl@0
   990
    
sl@0
   991
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
sl@0
   992
        {
sl@0
   993
        videoExtentRect.SetRect(TPoint(0, 0), videoSize);
sl@0
   994
        clipRegion.SetRect(TPoint(0, 0), videoSize); 
sl@0
   995
        clipRegion.SetWidth(clipRegion.Width() / 2);
sl@0
   996
        clipRegion.Move(clipRegion.Width(), 0);
sl@0
   997
        }
sl@0
   998
    else 
sl@0
   999
        {
sl@0
  1000
        // Calculate the video extent to be exactly the same size as the cropped video picture, 
sl@0
  1001
        // placed at the center of the window
sl@0
  1002
        TInt offsetX = (iWindow->Size().iWidth - cropRegion.Width()) / 2;
sl@0
  1003
        TInt offsetY = (iWindow->Size().iHeight - cropRegion.Height()) / 2;
sl@0
  1004
        videoExtentRect.SetRect(TPoint(offsetX, offsetY), cropRegion.Size());                    
sl@0
  1005
sl@0
  1006
        // Set the window clipping region to the top vertical half of the cropped image, originating
sl@0
  1007
        // from the top left corner of the window                    
sl@0
  1008
        clipRegion = videoExtentRect;                    
sl@0
  1009
        clipRegion.SetHeight(videoExtentRect.Height() / 2);
sl@0
  1010
        }
sl@0
  1011
    
sl@0
  1012
    HandlePrepareCompleteL(cropRegion, videoExtentRect, clipRegion);
sl@0
  1013
    
sl@0
  1014
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0508")) == 0)
sl@0
  1015
    	{
sl@0
  1016
    	// Align the image to the left of the window
sl@0
  1017
        iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, 0);
sl@0
  1018
    	}
sl@0
  1019
    // trigger the video to start playing                
sl@0
  1020
    StartPlayback();
sl@0
  1021
	}
sl@0
  1022
sl@0
  1023
void RTestVclnt2Viewport::HandlePrepareCompleteL(const TRect& aCropRegion, 
sl@0
  1024
                                                 const TRect& aVideoExtent, 
sl@0
  1025
                                                 const TRect& aClipRect)
sl@0
  1026
    {
sl@0
  1027
    iVideoPlayer2->SetCropRegionL(aCropRegion);
sl@0
  1028
    
sl@0
  1029
    // get the video crop region to ensure the crop region is set
sl@0
  1030
    TRect currentCropRegion;
sl@0
  1031
    iVideoPlayer2->GetCropRegionL(currentCropRegion);
sl@0
  1032
    
sl@0
  1033
    if (currentCropRegion != aCropRegion)
sl@0
  1034
        {
sl@0
  1035
        ERR_PRINTF1(_L("iVideoPlayer2->GetCropRegionL() returns an unexpected value.  Test aborted."));
sl@0
  1036
        
sl@0
  1037
		iTestStepResult = EInconclusive;
sl@0
  1038
		CActiveScheduler::Stop();
sl@0
  1039
        }
sl@0
  1040
        
sl@0
  1041
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, aVideoExtent, aClipRect);                    
sl@0
  1042
    }
sl@0
  1043
sl@0
  1044
//
sl@0
  1045
// RTestVclnt2InvalidViewport
sl@0
  1046
//
sl@0
  1047
sl@0
  1048
/**
sl@0
  1049
 * RTestVclnt2InvalidViewport::Constructor
sl@0
  1050
 */
sl@0
  1051
RTestVclnt2InvalidViewport::RTestVclnt2InvalidViewport(const TDesC& aTestName,
sl@0
  1052
                                                       const TDesC& aSectName,
sl@0
  1053
                                                       const TDesC& aKeyName, 
sl@0
  1054
                                                       TInt aExpectedError)
sl@0
  1055
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1056
    {
sl@0
  1057
    }
sl@0
  1058
sl@0
  1059
/**
sl@0
  1060
 * RTestVclnt2InvalidViewport::NewL
sl@0
  1061
 */
sl@0
  1062
RTestVclnt2InvalidViewport* RTestVclnt2InvalidViewport::NewL(const TDesC& aTestName, 
sl@0
  1063
                                                             const TDesC& aSectName,
sl@0
  1064
                                                             const TDesC& aKeyName, 
sl@0
  1065
                                                             TInt aExpectedError)
sl@0
  1066
    {
sl@0
  1067
    RTestVclnt2InvalidViewport* self = new (ELeave) RTestVclnt2InvalidViewport(aTestName, 
sl@0
  1068
                                                                               aSectName, 
sl@0
  1069
                                                                               aKeyName, 
sl@0
  1070
                                                                               aExpectedError); 
sl@0
  1071
    return self;
sl@0
  1072
    }
sl@0
  1073
sl@0
  1074
/**
sl@0
  1075
 * RTestVclnt2InvalidViewport::HandlePrepareCompleteL
sl@0
  1076
 */
sl@0
  1077
void RTestVclnt2InvalidViewport::HandlePrepareCompleteL()
sl@0
  1078
    {
sl@0
  1079
	// retrive original video size
sl@0
  1080
    TSize videoSize;
sl@0
  1081
    iVideoPlayer2->VideoFrameSizeL(videoSize);
sl@0
  1082
sl@0
  1083
    // set the crop region to be completely out of the video image bound 
sl@0
  1084
    TRect cropRegion;
sl@0
  1085
    cropRegion.SetRect(TPoint(videoSize.iWidth, videoSize.iHeight), TSize(100, 100));
sl@0
  1086
sl@0
  1087
    // continue playback even if this fails
sl@0
  1088
    TRAPD(err, iVideoPlayer2->SetCropRegionL(cropRegion));
sl@0
  1089
    if (err == iTestExpectedError)
sl@0
  1090
        {
sl@0
  1091
        // the invalid crop area is not supposed to be set 
sl@0
  1092
        INFO_PRINTF1(_L("iVideoPlayer2->SetCropRegionL() returned expected.  Test continues."));
sl@0
  1093
sl@0
  1094
        // reset the expected error.  Any error that appears after this should fail the test
sl@0
  1095
        iTestExpectedError = KErrNone;
sl@0
  1096
        }
sl@0
  1097
    else 
sl@0
  1098
        {
sl@0
  1099
        // the invalid crop area is not supposed to be set 
sl@0
  1100
        ERR_PRINTF1(_L("iVideoPlayer2->SetCropRegionL() didn't leave with expected error.  Test cannot be continued."));
sl@0
  1101
sl@0
  1102
		iTestStepResult = EInconclusive;
sl@0
  1103
		CActiveScheduler::Stop();
sl@0
  1104
		return;
sl@0
  1105
        }
sl@0
  1106
sl@0
  1107
    // get the video crop region to ensure the crop region is set
sl@0
  1108
    TRect currentCropRegion;
sl@0
  1109
    iVideoPlayer2->GetCropRegionL(currentCropRegion);
sl@0
  1110
sl@0
  1111
    if (currentCropRegion != cropRegion)
sl@0
  1112
        {
sl@0
  1113
        // the invalid crop area is not supposed to be set 
sl@0
  1114
        ERR_PRINTF1(_L("iVideoPlayer2->GetCropRegionL() returns an unexpected value.  Test cannot be continued."));
sl@0
  1115
        
sl@0
  1116
		iTestStepResult = EInconclusive;
sl@0
  1117
		CActiveScheduler::Stop();
sl@0
  1118
		return;
sl@0
  1119
        }
sl@0
  1120
sl@0
  1121
    // setup the display then trigger the video to start playing
sl@0
  1122
    RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  1123
    }
sl@0
  1124
sl@0
  1125
sl@0
  1126
//
sl@0
  1127
// RTestVclnt2Rotation
sl@0
  1128
//
sl@0
  1129
/**
sl@0
  1130
 * RTestVclnt2Rotation::Constructor
sl@0
  1131
 */
sl@0
  1132
RTestVclnt2Rotation::RTestVclnt2Rotation(const TDesC& aTestName,
sl@0
  1133
                                         const TDesC& aSectName,
sl@0
  1134
                                         const TDesC& aKeyName, 
sl@0
  1135
                                         TInt aExpectedError)
sl@0
  1136
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1137
    {
sl@0
  1138
    }
sl@0
  1139
sl@0
  1140
/**
sl@0
  1141
 * RTestVclnt2Rotation::NewL
sl@0
  1142
 */
sl@0
  1143
RTestVclnt2Rotation* RTestVclnt2Rotation::NewL(const TDesC& aTestName, 
sl@0
  1144
                                               const TDesC& aSectName,
sl@0
  1145
                                               const TDesC& aKeyName, 
sl@0
  1146
                                               TInt aExpectedError)
sl@0
  1147
    {
sl@0
  1148
    RTestVclnt2Rotation* self = new (ELeave) RTestVclnt2Rotation(aTestName, 
sl@0
  1149
                                                                 aSectName, 
sl@0
  1150
                                                                 aKeyName, 
sl@0
  1151
                                                                 aExpectedError);
sl@0
  1152
    return self;
sl@0
  1153
    }
sl@0
  1154
sl@0
  1155
/**
sl@0
  1156
 * RTestVclnt2Rotation::HandlePrepareCompleteL
sl@0
  1157
 */
sl@0
  1158
void RTestVclnt2Rotation::HandlePrepareCompleteL()
sl@0
  1159
    {
sl@0
  1160
    // call parent's HandlePrepareCompleteL to finish off all preparation
sl@0
  1161
    RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  1162
    
sl@0
  1163
    // set the video to be displayed upside-down
sl@0
  1164
    TVideoRotation videoRotation(EVideoRotationClockwise180);
sl@0
  1165
    iVideoPlayer2->SetRotationL(*iWindow, videoRotation);
sl@0
  1166
sl@0
  1167
    // retrieve the rotation setting, and check if it's been properly updated
sl@0
  1168
    if (iVideoPlayer2->RotationL(*iWindow) != videoRotation)
sl@0
  1169
        {
sl@0
  1170
        ERR_PRINTF1(_L("iVideoPlayer2->RotationL() returns an unexpected value.  Test aborted."));
sl@0
  1171
sl@0
  1172
		iTestStepResult = EInconclusive;
sl@0
  1173
		CActiveScheduler::Stop();
sl@0
  1174
sl@0
  1175
		return;
sl@0
  1176
        }
sl@0
  1177
    }
sl@0
  1178
sl@0
  1179
//
sl@0
  1180
// RTestVclnt2Settings
sl@0
  1181
//
sl@0
  1182
/**
sl@0
  1183
 * RTestVclnt2Settings::Constructor
sl@0
  1184
 */
sl@0
  1185
RTestVclnt2Settings::RTestVclnt2Settings(const TDesC& aTestName,
sl@0
  1186
                                         const TDesC& aSectName,
sl@0
  1187
                                         const TDesC& aKeyName, 
sl@0
  1188
                                         TInt aExpectedError)
sl@0
  1189
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1190
    {
sl@0
  1191
    }
sl@0
  1192
sl@0
  1193
/**
sl@0
  1194
 * RTestVclnt2Settings::NewL
sl@0
  1195
 */
sl@0
  1196
RTestVclnt2Settings* RTestVclnt2Settings::NewL(const TDesC& aTestName, 
sl@0
  1197
                                               const TDesC& aSectName,
sl@0
  1198
                                               const TDesC& aKeyName, 
sl@0
  1199
                                               TInt aExpectedError)
sl@0
  1200
    {
sl@0
  1201
    RTestVclnt2Settings* self = new (ELeave) RTestVclnt2Settings(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1202
    return self;
sl@0
  1203
    }
sl@0
  1204
   
sl@0
  1205
/**
sl@0
  1206
 * RTestVclnt2Settings::HandlePrepareCompleteL
sl@0
  1207
 */
sl@0
  1208
void RTestVclnt2Settings::HandlePrepareCompleteL()
sl@0
  1209
    {
sl@0
  1210
    // retrieve the current frame size
sl@0
  1211
    TSize frameSize;
sl@0
  1212
    iVideoPlayer2->VideoFrameSizeL(frameSize);    
sl@0
  1213
    
sl@0
  1214
    TRect cropRegion(frameSize);
sl@0
  1215
    // shrink the crop region to half its original height
sl@0
  1216
    cropRegion.SetHeight(cropRegion.Height() / 2);
sl@0
  1217
    iVideoPlayer2->SetCropRegionL(cropRegion);
sl@0
  1218
    
sl@0
  1219
    TRect videoExtentRect;
sl@0
  1220
    videoExtentRect.SetWidth(cropRegion.Width());
sl@0
  1221
    videoExtentRect.SetHeight(cropRegion.Height());
sl@0
  1222
    
sl@0
  1223
    videoExtentRect.Move((iWindow->Size().iWidth - videoExtentRect.Width()) / 2,
sl@0
  1224
                         (iWindow->Size().iHeight - videoExtentRect.Height()) / 2); 
sl@0
  1225
    
sl@0
  1226
    TRect clippingRect(videoExtentRect);
sl@0
  1227
    clippingRect.SetWidth(clippingRect.Height() / 2);
sl@0
  1228
sl@0
  1229
    // add display window using this valid clipping rect 
sl@0
  1230
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtentRect, clippingRect);
sl@0
  1231
sl@0
  1232
 	// Scale the movie with best fit scaling, and vertically center the picture
sl@0
  1233
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleBestFit);
sl@0
  1234
    
sl@0
  1235
    // Start video playback
sl@0
  1236
    StartPlayback();
sl@0
  1237
    }
sl@0
  1238
sl@0
  1239
sl@0
  1240
sl@0
  1241
//
sl@0
  1242
// RTestVclnt2SettingsAndAlignments
sl@0
  1243
//
sl@0
  1244
/**
sl@0
  1245
 * RTestVclnt2SettingsAndAlignments::Constructor
sl@0
  1246
 */
sl@0
  1247
RTestVclnt2SettingsAndAlignments::RTestVclnt2SettingsAndAlignments(const TDesC& aTestName,
sl@0
  1248
                                                                   const TDesC& aSectName,
sl@0
  1249
                                                                   const TDesC& aKeyName, 
sl@0
  1250
                                                                   TInt aExpectedError)
sl@0
  1251
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1252
    {
sl@0
  1253
    }
sl@0
  1254
sl@0
  1255
/**
sl@0
  1256
 * RTestVclnt2SettingsAndAlignments::NewL
sl@0
  1257
 */
sl@0
  1258
RTestVclnt2SettingsAndAlignments* RTestVclnt2SettingsAndAlignments::NewL(const TDesC& aTestName, 
sl@0
  1259
                                                                         const TDesC& aSectName,
sl@0
  1260
                                                                         const TDesC& aKeyName, 
sl@0
  1261
                                                                         TInt aExpectedError)
sl@0
  1262
    {
sl@0
  1263
    RTestVclnt2SettingsAndAlignments* self = new (ELeave) RTestVclnt2SettingsAndAlignments(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1264
    return self;
sl@0
  1265
    }
sl@0
  1266
sl@0
  1267
TVerdict RTestVclnt2SettingsAndAlignments::DoTestStepPreambleL()
sl@0
  1268
	{
sl@0
  1269
	iCount = 0;
sl@0
  1270
	return RTestVclnt2PlayFile::DoTestStepPreambleL();
sl@0
  1271
	}
sl@0
  1272
sl@0
  1273
/**
sl@0
  1274
 * RTestVclnt2SettingsAndAlignments::HandlePrepareCompleteL
sl@0
  1275
 */
sl@0
  1276
void RTestVclnt2SettingsAndAlignments::HandlePrepareCompleteL()
sl@0
  1277
    {    
sl@0
  1278
    TRect cropRegion;
sl@0
  1279
    SetCropRegionL(cropRegion);
sl@0
  1280
sl@0
  1281
	AddDisplayWindowL(cropRegion);
sl@0
  1282
    
sl@0
  1283
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0418")) == 0)
sl@0
  1284
        {            
sl@0
  1285
        SetContentOffsetL();
sl@0
  1286
        }
sl@0
  1287
    else if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0419")) == 0)        
sl@0
  1288
        {
sl@0
  1289
        SetContentAlignmentL();            
sl@0
  1290
        }        
sl@0
  1291
sl@0
  1292
    SetScaleFactorL();
sl@0
  1293
       
sl@0
  1294
    // Start video playback
sl@0
  1295
    StartPlayback();
sl@0
  1296
    }
sl@0
  1297
sl@0
  1298
/**
sl@0
  1299
 * RTestVclnt2SettingsAndAlignments::HandlePlayCompleteL
sl@0
  1300
 */
sl@0
  1301
void RTestVclnt2SettingsAndAlignments::HandlePlayCompleteL()
sl@0
  1302
    {    
sl@0
  1303
    iCount++;
sl@0
  1304
    
sl@0
  1305
    if (iCount == KSettingsAndAlignmentTest)
sl@0
  1306
        {
sl@0
  1307
    	iTestStepResult = EPass;
sl@0
  1308
    	CActiveScheduler::Stop();
sl@0
  1309
        }
sl@0
  1310
    else
sl@0
  1311
        {
sl@0
  1312
        HandlePrepareCompleteL();                                
sl@0
  1313
        }
sl@0
  1314
    }
sl@0
  1315
sl@0
  1316
/**
sl@0
  1317
 * RTestVclnt2SettingsAndAlignments::SetCropRegionL
sl@0
  1318
 */
sl@0
  1319
void RTestVclnt2SettingsAndAlignments::SetCropRegionL(TRect& aCropRegion)
sl@0
  1320
    {
sl@0
  1321
    // retrieve the current frame size
sl@0
  1322
    TSize frameSize;
sl@0
  1323
    iVideoPlayer2->VideoFrameSizeL(frameSize);    
sl@0
  1324
    
sl@0
  1325
    // Framesize is used in this case as crop region is not returning default values
sl@0
  1326
    aCropRegion.SetRect(TPoint(0, 0), frameSize);
sl@0
  1327
    
sl@0
  1328
    // set the crop region 
sl@0
  1329
    switch (iCount % KSettingsAndAlignmentTest)
sl@0
  1330
        {
sl@0
  1331
        case 0:                
sl@0
  1332
            // set the crop region to the top half of the image
sl@0
  1333
            aCropRegion.SetHeight(aCropRegion.Height() / 2);
sl@0
  1334
            iVideoPlayer2->SetCropRegionL(aCropRegion);
sl@0
  1335
            break;
sl@0
  1336
sl@0
  1337
        case 1:
sl@0
  1338
            // set the crop region to the left half of the image
sl@0
  1339
            aCropRegion.SetWidth(aCropRegion.Width() / 2);
sl@0
  1340
            iVideoPlayer2->SetCropRegionL(aCropRegion);
sl@0
  1341
            break;
sl@0
  1342
sl@0
  1343
        default:
sl@0
  1344
            // set the crop region to the bottom, right quarter of the image
sl@0
  1345
            aCropRegion.SetHeight(aCropRegion.Height() / 2);
sl@0
  1346
            aCropRegion.SetWidth(aCropRegion.Width() / 2);
sl@0
  1347
            aCropRegion.Move(aCropRegion.Width(), aCropRegion.Height());                        
sl@0
  1348
            iVideoPlayer2->SetCropRegionL(aCropRegion);
sl@0
  1349
            break;
sl@0
  1350
        }
sl@0
  1351
    }
sl@0
  1352
sl@0
  1353
/**
sl@0
  1354
 * RTestVclnt2SettingsAndAlignments::SetContentOffsetL
sl@0
  1355
 */
sl@0
  1356
void RTestVclnt2SettingsAndAlignments::SetContentOffsetL()
sl@0
  1357
    {
sl@0
  1358
    switch (iCount % KSettingsAndAlignmentTest)
sl@0
  1359
        {
sl@0
  1360
        case 0:
sl@0
  1361
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 0, 100);
sl@0
  1362
            break;
sl@0
  1363
        
sl@0
  1364
        case 1:
sl@0
  1365
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 0);
sl@0
  1366
            break;
sl@0
  1367
        
sl@0
  1368
        default:
sl@0
  1369
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 100);
sl@0
  1370
            break;
sl@0
  1371
        }    
sl@0
  1372
    }
sl@0
  1373
sl@0
  1374
/**
sl@0
  1375
 * RTestVclnt2SettingsAndAlignments::SetContentAlignmentL
sl@0
  1376
 */
sl@0
  1377
void RTestVclnt2SettingsAndAlignments::SetContentAlignmentL()
sl@0
  1378
    {
sl@0
  1379
    switch (iCount % KSettingsAndAlignmentTest)
sl@0
  1380
        {
sl@0
  1381
        case 0:
sl@0
  1382
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 0, EVerticalAlignCenter);
sl@0
  1383
            break;
sl@0
  1384
        
sl@0
  1385
        case 1:
sl@0
  1386
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, 0);
sl@0
  1387
            break;
sl@0
  1388
        
sl@0
  1389
        default:
sl@0
  1390
            iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignCenter);
sl@0
  1391
            break;
sl@0
  1392
        }    
sl@0
  1393
    }
sl@0
  1394
    
sl@0
  1395
/**
sl@0
  1396
 * RTestVclnt2SettingsAndAlignments::SetScaleFactorL
sl@0
  1397
 */
sl@0
  1398
void RTestVclnt2SettingsAndAlignments::SetScaleFactorL()
sl@0
  1399
    {
sl@0
  1400
    switch (iCount % KSettingsAndAlignmentTest)
sl@0
  1401
        {
sl@0
  1402
        case 0:
sl@0
  1403
            iVideoPlayer2->SetScaleFactorL(*iWindow, 1, 200);
sl@0
  1404
            break;
sl@0
  1405
        
sl@0
  1406
        case 1:
sl@0
  1407
            iVideoPlayer2->SetScaleFactorL(*iWindow, 200, 1);
sl@0
  1408
            break;
sl@0
  1409
        
sl@0
  1410
        default:
sl@0
  1411
            iVideoPlayer2->SetScaleFactorL(*iWindow, 200, 200);
sl@0
  1412
            break;
sl@0
  1413
        }    
sl@0
  1414
    }    
sl@0
  1415
sl@0
  1416
/**
sl@0
  1417
 * RTestVclnt2SettingsAndAlignments::AddDisplayWindowL
sl@0
  1418
 */
sl@0
  1419
void RTestVclnt2SettingsAndAlignments::AddDisplayWindowL(const TRect& aCropRegion)
sl@0
  1420
    {
sl@0
  1421
    TRect videoExtentRect(iWindow->Size());
sl@0
  1422
    TRect clippingRect(iWindow->Size());
sl@0
  1423
    
sl@0
  1424
    switch (iCount % KSettingsAndAlignmentTest)
sl@0
  1425
        {
sl@0
  1426
        case 0:
sl@0
  1427
            videoExtentRect.SetWidth(aCropRegion.Width());
sl@0
  1428
            if (iWindow->Size().iWidth > videoExtentRect.Width())
sl@0
  1429
                {                    
sl@0
  1430
                videoExtentRect.Move((iWindow->Size().iWidth - videoExtentRect.Width()) / 2, 0);
sl@0
  1431
                }
sl@0
  1432
            clippingRect = videoExtentRect;
sl@0
  1433
            break;
sl@0
  1434
            
sl@0
  1435
        case 1:
sl@0
  1436
            videoExtentRect.SetHeight(aCropRegion.Height());
sl@0
  1437
            if (iWindow->Size().iHeight > videoExtentRect.Height())
sl@0
  1438
                {                    
sl@0
  1439
                videoExtentRect.Move(0, (iWindow->Size().iHeight - videoExtentRect.Height()) / 2);
sl@0
  1440
                }
sl@0
  1441
            clippingRect = videoExtentRect;
sl@0
  1442
            break;
sl@0
  1443
            
sl@0
  1444
        default:
sl@0
  1445
            clippingRect.SetHeight(clippingRect.Height() / 2);
sl@0
  1446
            clippingRect.SetWidth(clippingRect.Width() / 2);            
sl@0
  1447
            clippingRect.Move(clippingRect.Width(), clippingRect.Height());            
sl@0
  1448
            break;                        
sl@0
  1449
        }
sl@0
  1450
    
sl@0
  1451
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);    
sl@0
  1452
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtentRect, clippingRect);    
sl@0
  1453
    }
sl@0
  1454
       
sl@0
  1455
    
sl@0
  1456
//
sl@0
  1457
// RTestVclnt2SecDisplay
sl@0
  1458
//
sl@0
  1459
/**
sl@0
  1460
 * RTestVclnt2SecDisplay::Constructor
sl@0
  1461
 */
sl@0
  1462
RTestVclnt2SecDisplay::RTestVclnt2SecDisplay(const TDesC& aTestName,
sl@0
  1463
                                             const TDesC& aSectName,
sl@0
  1464
                                             const TDesC& aKeyName, 
sl@0
  1465
                                             TInt aExpectedError)
sl@0
  1466
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1467
    {
sl@0
  1468
    }
sl@0
  1469
sl@0
  1470
/**
sl@0
  1471
 * RTestVclnt2SecDisplay::NewL
sl@0
  1472
 */
sl@0
  1473
RTestVclnt2SecDisplay* RTestVclnt2SecDisplay::NewL(const TDesC& aTestName, 
sl@0
  1474
                                                   const TDesC& aSectName,
sl@0
  1475
                                                   const TDesC& aKeyName, 
sl@0
  1476
                                                   TInt aExpectedError)
sl@0
  1477
    {
sl@0
  1478
    RTestVclnt2SecDisplay* self = new (ELeave) RTestVclnt2SecDisplay(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1479
    return self;
sl@0
  1480
    }
sl@0
  1481
   
sl@0
  1482
/**
sl@0
  1483
 * RTestVclnt2SecDisplay::DoTestStepPreambleL
sl@0
  1484
 */
sl@0
  1485
TVerdict RTestVclnt2SecDisplay::DoTestStepPreambleL()
sl@0
  1486
    {
sl@0
  1487
    TVerdict verdict = RTestVclnt2PlayFile::DoTestStepPreambleL();    
sl@0
  1488
    if (verdict == EPass)
sl@0
  1489
        {
sl@0
  1490
        // make a 2nd device for this session
sl@0
  1491
        iSecondScreen = new (ELeave) CWsScreenDevice(iWs); 
sl@0
  1492
        User::LeaveIfError(iSecondScreen->Construct()); 
sl@0
  1493
        }
sl@0
  1494
    
sl@0
  1495
    return verdict;
sl@0
  1496
    }
sl@0
  1497
sl@0
  1498
/**
sl@0
  1499
 * RTestVclnt2SecDisplay::DoTestStepPostambleL
sl@0
  1500
 */
sl@0
  1501
TVerdict RTestVclnt2SecDisplay::DoTestStepPostambleL()
sl@0
  1502
    {
sl@0
  1503
    delete iSecondScreen;
sl@0
  1504
    
sl@0
  1505
    return EPass;
sl@0
  1506
    }
sl@0
  1507
sl@0
  1508
/**
sl@0
  1509
 * RTestVclnt2SecDisplay::HandlePrepareCompleteL
sl@0
  1510
 */
sl@0
  1511
void RTestVclnt2SecDisplay::HandlePrepareCompleteL()
sl@0
  1512
	{
sl@0
  1513
	// Add display window using default values - ie. video extent & window clipping 
sl@0
  1514
	// defaulted to whole window
sl@0
  1515
	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
sl@0
  1516
	iVideoPlayer2->AddDisplayWindowL(iWs, *iSecondScreen, *iWindow);
sl@0
  1517
sl@0
  1518
    // trigger the video to start playing                
sl@0
  1519
    StartPlayback();
sl@0
  1520
	}
sl@0
  1521
sl@0
  1522
sl@0
  1523
//
sl@0
  1524
// RTestVclnt2CropRectPause
sl@0
  1525
//
sl@0
  1526
/**
sl@0
  1527
 * RTestVclnt2CropRectPause::Constructor
sl@0
  1528
 */
sl@0
  1529
RTestVclnt2CropRectPause::RTestVclnt2CropRectPause(const TDesC& aTestName, 
sl@0
  1530
                                                   const TDesC& aSectName, 
sl@0
  1531
                                                   const TDesC& aKeyName, 
sl@0
  1532
                                                   TInt aExpectedError)
sl@0
  1533
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1534
    {
sl@0
  1535
    }
sl@0
  1536
sl@0
  1537
/**
sl@0
  1538
 * RTestVclnt2CropRectPause::NewL
sl@0
  1539
 */
sl@0
  1540
RTestVclnt2CropRectPause* RTestVclnt2CropRectPause::NewL(const TDesC& aTestName, 
sl@0
  1541
                                                         const TDesC& aSectName,
sl@0
  1542
                                                         const TDesC& aKeyName, 
sl@0
  1543
                                                         TInt aExpectedError)
sl@0
  1544
    {
sl@0
  1545
    RTestVclnt2CropRectPause* self 
sl@0
  1546
        = new (ELeave) RTestVclnt2CropRectPause(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1547
    return self;
sl@0
  1548
    }
sl@0
  1549
	
sl@0
  1550
/**
sl@0
  1551
 * RTestVclnt2CropRectPause::DoThisActionDuringPlaybackL
sl@0
  1552
 */
sl@0
  1553
void RTestVclnt2CropRectPause::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
  1554
    {    
sl@0
  1555
    TRect cropRegion;
sl@0
  1556
	aPlayer.GetCropRegionL(cropRegion);
sl@0
  1557
	
sl@0
  1558
	// change the crop region and continue to play the clip
sl@0
  1559
	cropRegion.SetHeight(cropRegion.Height() / 2);
sl@0
  1560
    aPlayer.SetCropRegionL(cropRegion);    
sl@0
  1561
    }
sl@0
  1562
    
sl@0
  1563
    
sl@0
  1564
    
sl@0
  1565
//
sl@0
  1566
// RTestVclnt2Overlay
sl@0
  1567
//
sl@0
  1568
/**
sl@0
  1569
 * RTestVclnt2Overlay::Constructor
sl@0
  1570
 */
sl@0
  1571
RTestVclnt2Overlay::RTestVclnt2Overlay(const TDesC& aTestName,
sl@0
  1572
                                       const TDesC& aSectName,
sl@0
  1573
                                       const TDesC& aKeyName, 
sl@0
  1574
                                       TInt aExpectedError)
sl@0
  1575
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1576
    {
sl@0
  1577
    }
sl@0
  1578
sl@0
  1579
/**
sl@0
  1580
 * RTestVclnt2Overlay::NewL
sl@0
  1581
 */
sl@0
  1582
RTestVclnt2Overlay* RTestVclnt2Overlay::NewL(const TDesC& aTestName, 
sl@0
  1583
                                             const TDesC& aSectName,
sl@0
  1584
                                             const TDesC& aKeyName, 
sl@0
  1585
                                             TInt aExpectedError)
sl@0
  1586
    {
sl@0
  1587
    RTestVclnt2Overlay* self = new (ELeave) RTestVclnt2Overlay(aTestName, 
sl@0
  1588
                                                               aSectName, 
sl@0
  1589
                                                               aKeyName, 
sl@0
  1590
                                                               aExpectedError);
sl@0
  1591
    return self;
sl@0
  1592
    }
sl@0
  1593
sl@0
  1594
/**
sl@0
  1595
 * RTestVclnt2Overlay::DoTestStepPreambleL
sl@0
  1596
 */
sl@0
  1597
TVerdict RTestVclnt2Overlay::DoTestStepPreambleL()
sl@0
  1598
    {
sl@0
  1599
    TVerdict verdict = RTestVclnt2PlayFile::DoTestStepPreambleL();    
sl@0
  1600
    if (verdict == EPass)
sl@0
  1601
        {
sl@0
  1602
        TFontSpec fontSpec; // use default fonts
sl@0
  1603
        fontSpec.iHeight = 20;
sl@0
  1604
sl@0
  1605
        // Get a font to draw overlay text
sl@0
  1606
        if (iScreen->GetNearestFontToDesignHeightInPixels(iFont, fontSpec) != KErrNone)
sl@0
  1607
            {
sl@0
  1608
            // if no font can be retrieved, abort the test
sl@0
  1609
            ERR_PRINTF1(_L("Cannot retrieve font to perform test.  Test aborted."));
sl@0
  1610
            
sl@0
  1611
    		return EInconclusive;
sl@0
  1612
            }
sl@0
  1613
sl@0
  1614
        iGc->Activate(*iWindow);
sl@0
  1615
        iGc->UseFont(iFont);
sl@0
  1616
        }
sl@0
  1617
    
sl@0
  1618
    return verdict;
sl@0
  1619
    }
sl@0
  1620
sl@0
  1621
/**
sl@0
  1622
 * RTestVclnt2Overlay::DoTestStepPostambleL
sl@0
  1623
 */
sl@0
  1624
TVerdict RTestVclnt2Overlay::DoTestStepPostambleL()
sl@0
  1625
    {
sl@0
  1626
    iGc->DiscardFont();    
sl@0
  1627
    iGc->Deactivate();                    
sl@0
  1628
               
sl@0
  1629
    return RTestVclnt2PlayFile::DoTestStepPostambleL();        
sl@0
  1630
    }
sl@0
  1631
sl@0
  1632
/**
sl@0
  1633
 * RTestVclnt2Overlay::HandlePrepareCompleteL
sl@0
  1634
 */
sl@0
  1635
void RTestVclnt2Overlay::HandlePrepareCompleteL()
sl@0
  1636
	{
sl@0
  1637
    TRect rect(iWindow->Size());
sl@0
  1638
    TInt baseline = (rect.Height() + iFont->AscentInPixels()) >> 1;
sl@0
  1639
    
sl@0
  1640
    // Draw the overlay text if needed
sl@0
  1641
    iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
  1642
    iGc->SetBrushColor(KRgbRed);
sl@0
  1643
         
sl@0
  1644
    iGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1645
    iGc->SetPenColor(KRgbBlue);
sl@0
  1646
    
sl@0
  1647
    iGc->DrawText(_L("Overlay Testing"), rect, baseline, CGraphicsContext::ELeft);
sl@0
  1648
sl@0
  1649
    // setup the display window and trigger the video to start playing
sl@0
  1650
    RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  1651
	}
sl@0
  1652
	
sl@0
  1653
sl@0
  1654
//
sl@0
  1655
// RTestVclnt2AddWin2
sl@0
  1656
//
sl@0
  1657
sl@0
  1658
/**
sl@0
  1659
 * RTestVclnt2AddWin2::Constructor
sl@0
  1660
 */
sl@0
  1661
RTestVclnt2AddWin2::RTestVclnt2AddWin2(const TDesC& aTestName,
sl@0
  1662
                                       const TDesC& aSectName,
sl@0
  1663
                                       const TDesC& aKeyName, 
sl@0
  1664
                                       TInt aExpectedError)
sl@0
  1665
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1666
    {
sl@0
  1667
    }
sl@0
  1668
sl@0
  1669
/**
sl@0
  1670
 * RTestVclnt2AddWin2::NewL
sl@0
  1671
 */
sl@0
  1672
RTestVclnt2AddWin2* RTestVclnt2AddWin2::NewL(const TDesC& aTestName, 
sl@0
  1673
                                             const TDesC& aSectName,
sl@0
  1674
                                             const TDesC& aKeyName, 
sl@0
  1675
                                             TInt aExpectedError)
sl@0
  1676
    {
sl@0
  1677
    RTestVclnt2AddWin2* self = new (ELeave) RTestVclnt2AddWin2(aTestName, 
sl@0
  1678
                                                               aSectName, 
sl@0
  1679
                                                               aKeyName, 
sl@0
  1680
                                                               aExpectedError);
sl@0
  1681
    return self;
sl@0
  1682
    }
sl@0
  1683
sl@0
  1684
/**
sl@0
  1685
 * RTestVclnt2AddWin2::HandlePrepareCompleteL
sl@0
  1686
 */
sl@0
  1687
void RTestVclnt2AddWin2::HandlePrepareCompleteL()
sl@0
  1688
	{
sl@0
  1689
    // add the display window for the player to use for displaying the video
sl@0
  1690
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
sl@0
  1691
    
sl@0
  1692
    // Add the same display window again
sl@0
  1693
    TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
sl@0
  1694
    if (err != iTestExpectedError)
sl@0
  1695
        {
sl@0
  1696
        ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
sl@0
  1697
sl@0
  1698
		iTestStepResult = EFail;
sl@0
  1699
		CActiveScheduler::Stop();
sl@0
  1700
sl@0
  1701
		return;
sl@0
  1702
        }
sl@0
  1703
    else
sl@0
  1704
        {
sl@0
  1705
        INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an expected error.  Test continues."));
sl@0
  1706
sl@0
  1707
        // reset the expected error.  Any error that appears after this should fail the test
sl@0
  1708
        iTestExpectedError = KErrNone;        
sl@0
  1709
        }
sl@0
  1710
sl@0
  1711
    // trigger the video to start playing
sl@0
  1712
    StartPlayback();
sl@0
  1713
	}
sl@0
  1714
sl@0
  1715
//
sl@0
  1716
// RTestVclnt2AddWin2WithSettings
sl@0
  1717
//
sl@0
  1718
sl@0
  1719
/**
sl@0
  1720
 * RTestVclnt2AddWin2WithSettings::Constructor
sl@0
  1721
 */
sl@0
  1722
RTestVclnt2AddWin2WithSettings::RTestVclnt2AddWin2WithSettings(const TDesC& aTestName,
sl@0
  1723
                                                               const TDesC& aSectName,
sl@0
  1724
                                                               const TDesC& aKeyName, 
sl@0
  1725
                                                               TInt aExpectedError)
sl@0
  1726
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1727
    {
sl@0
  1728
    }
sl@0
  1729
sl@0
  1730
/**
sl@0
  1731
 * RTestVclnt2AddWin2WithSettings::NewL
sl@0
  1732
 */
sl@0
  1733
RTestVclnt2AddWin2WithSettings* RTestVclnt2AddWin2WithSettings::NewL(const TDesC& aTestName, 
sl@0
  1734
                                                                     const TDesC& aSectName,
sl@0
  1735
                                                                     const TDesC& aKeyName,     
sl@0
  1736
                                                                     TInt aExpectedError)
sl@0
  1737
    {
sl@0
  1738
    RTestVclnt2AddWin2WithSettings* self = new (ELeave) RTestVclnt2AddWin2WithSettings(aTestName, 
sl@0
  1739
                                                                                       aSectName, 
sl@0
  1740
                                                                                       aKeyName, 
sl@0
  1741
                                                                                       aExpectedError);
sl@0
  1742
    return self;
sl@0
  1743
    }
sl@0
  1744
sl@0
  1745
/**
sl@0
  1746
 * RTestVclnt2AddWin2WithSettings::HandlePrepareCompleteL
sl@0
  1747
 */
sl@0
  1748
void RTestVclnt2AddWin2WithSettings::HandlePrepareCompleteL()
sl@0
  1749
	{
sl@0
  1750
	TRect windowRect(iWindow->Size());
sl@0
  1751
	windowRect.SetHeight(windowRect.Height() / 2);
sl@0
  1752
sl@0
  1753
	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, windowRect, windowRect);
sl@0
  1754
sl@0
  1755
	// Add the same display window again with default values
sl@0
  1756
	TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
sl@0
  1757
	if (err != iTestExpectedError)
sl@0
  1758
	    {
sl@0
  1759
	    ERR_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an unexpected error.  Test failed."));
sl@0
  1760
sl@0
  1761
		iTestStepResult = EFail;
sl@0
  1762
		CActiveScheduler::Stop();
sl@0
  1763
sl@0
  1764
		return;
sl@0
  1765
	    }
sl@0
  1766
    else
sl@0
  1767
        {
sl@0
  1768
        INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL() leaves with an expected error.  Test continues."));
sl@0
  1769
sl@0
  1770
        // reset the expected error.  Any error that appears after this should fail the test
sl@0
  1771
        iTestExpectedError = KErrNone;
sl@0
  1772
	    }
sl@0
  1773
sl@0
  1774
	// trigger the video to start playing
sl@0
  1775
    StartPlayback();
sl@0
  1776
	}
sl@0
  1777
sl@0
  1778
//
sl@0
  1779
// RTestVclnt2ContOffset
sl@0
  1780
//
sl@0
  1781
sl@0
  1782
/**
sl@0
  1783
 * RTestVclnt2ContOffset::Constructor
sl@0
  1784
 */
sl@0
  1785
RTestVclnt2ContOffset::RTestVclnt2ContOffset(const TDesC& aTestName, 
sl@0
  1786
                                             const TDesC& aSectName, 
sl@0
  1787
                                             const TDesC& aKeyName, 
sl@0
  1788
                                             TInt aExpectedError)
sl@0
  1789
    : RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1790
    {
sl@0
  1791
    iHeapSize = 2000000; //~2MB
sl@0
  1792
    }
sl@0
  1793
sl@0
  1794
/**
sl@0
  1795
 * RTestVclnt2ContOffset::NewL
sl@0
  1796
 */
sl@0
  1797
RTestVclnt2ContOffset* RTestVclnt2ContOffset::NewL(const TDesC& aTestName, 
sl@0
  1798
                                                   const TDesC& aSectName,
sl@0
  1799
                                                   const TDesC& aKeyName, 
sl@0
  1800
                                                   TInt aExpectedError)
sl@0
  1801
    {
sl@0
  1802
    RTestVclnt2ContOffset* self = new (ELeave) RTestVclnt2ContOffset(aTestName, 
sl@0
  1803
                                                                     aSectName, 
sl@0
  1804
                                                                     aKeyName, 
sl@0
  1805
                                                                     aExpectedError);
sl@0
  1806
    return self;
sl@0
  1807
    }
sl@0
  1808
sl@0
  1809
/**
sl@0
  1810
 * RTestVclnt2ContOffset::HandlePrepareCompleteL
sl@0
  1811
 */
sl@0
  1812
void RTestVclnt2ContOffset::HandlePrepareCompleteL()
sl@0
  1813
	{
sl@0
  1814
    // call parent's HandlePrepareCompleteL to finish off all preparation    
sl@0
  1815
	RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  1816
    // Set the content offset before starting to play the video.
sl@0
  1817
    INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
sl@0
  1818
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 100, 100);
sl@0
  1819
    
sl@0
  1820
    if (iTestStepName.CompareF(_L("MM-MMF-VCLNTAVI-I-0409")) == 0)
sl@0
  1821
        {
sl@0
  1822
        // Set the content alignment after setting the content offset
sl@0
  1823
        iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignTop);
sl@0
  1824
        }
sl@0
  1825
	}
sl@0
  1826
sl@0
  1827
//
sl@0
  1828
// RTestVclnt2ContOffsetAtPlay
sl@0
  1829
//
sl@0
  1830
/**
sl@0
  1831
 * RTestVclnt2ContOffsetAtPlay::Constructor
sl@0
  1832
 */
sl@0
  1833
RTestVclnt2ContOffsetAtPlay::RTestVclnt2ContOffsetAtPlay(const TDesC& aTestName, 
sl@0
  1834
                                                         const TDesC& aSectName, 
sl@0
  1835
                                                         const TDesC& aKeyName, 
sl@0
  1836
                                                         TInt aExpectedError)
sl@0
  1837
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1838
    {
sl@0
  1839
    iHeapSize = 2000000; //~2MB
sl@0
  1840
    }
sl@0
  1841
sl@0
  1842
/**
sl@0
  1843
 * RTestVclnt2ContOffsetAtPlay::NewL
sl@0
  1844
 */
sl@0
  1845
RTestVclnt2ContOffsetAtPlay* RTestVclnt2ContOffsetAtPlay::NewL(const TDesC& aTestName, 
sl@0
  1846
                                                               const TDesC& aSectName,
sl@0
  1847
                                                               const TDesC& aKeyName, 
sl@0
  1848
                                                               TInt aExpectedError)
sl@0
  1849
    {
sl@0
  1850
    RTestVclnt2ContOffsetAtPlay* self = new (ELeave) RTestVclnt2ContOffsetAtPlay(aTestName, 
sl@0
  1851
                                                                                 aSectName, 
sl@0
  1852
                                                                                 aKeyName, 
sl@0
  1853
                                                                                 aExpectedError);
sl@0
  1854
    return self;
sl@0
  1855
    }
sl@0
  1856
        
sl@0
  1857
/**
sl@0
  1858
 * RTestVclnt2ContOffsetAtPlay::DoThisActionDuringPlaybackL
sl@0
  1859
 */
sl@0
  1860
void RTestVclnt2ContOffsetAtPlay::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& /* aPlayer */)
sl@0
  1861
    {
sl@0
  1862
    // Change the scale factor during playback
sl@0
  1863
	INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
sl@0
  1864
	iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, 10, 10);    
sl@0
  1865
    }
sl@0
  1866
sl@0
  1867
sl@0
  1868
//
sl@0
  1869
// RTestVclnt2Align
sl@0
  1870
//
sl@0
  1871
/**
sl@0
  1872
 * RTestVclnt2Align::Constructor
sl@0
  1873
 */
sl@0
  1874
RTestVclnt2Align::RTestVclnt2Align(const TDesC& aTestName, 
sl@0
  1875
                                   const TDesC& aSectName, 
sl@0
  1876
                                   const TDesC& aKeyName, 
sl@0
  1877
                                   TInt aExpectedError)
sl@0
  1878
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1879
    {
sl@0
  1880
    iHeapSize = 2000000; //~2MB
sl@0
  1881
    }
sl@0
  1882
sl@0
  1883
/**
sl@0
  1884
 * RTestVclnt2Align::NewL
sl@0
  1885
 */
sl@0
  1886
RTestVclnt2Align* RTestVclnt2Align::NewL(const TDesC& aTestName, 
sl@0
  1887
                                         const TDesC& aSectName,
sl@0
  1888
                                         const TDesC& aKeyName, 
sl@0
  1889
                                         TInt aExpectedError)
sl@0
  1890
    {
sl@0
  1891
    RTestVclnt2Align* self = new (ELeave) RTestVclnt2Align(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1892
    return self;
sl@0
  1893
    }
sl@0
  1894
sl@0
  1895
/**
sl@0
  1896
 * RTestVclnt2Align::HandlePrepareCompleteL
sl@0
  1897
 */ 
sl@0
  1898
void RTestVclnt2Align::HandlePrepareCompleteL()
sl@0
  1899
    {
sl@0
  1900
    // Continue to setup the video utility and then trigger playback
sl@0
  1901
    RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  1902
	// Set the content offset before starting to play the video.
sl@0
  1903
    INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
sl@0
  1904
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignCenter);
sl@0
  1905
    }
sl@0
  1906
    
sl@0
  1907
/**
sl@0
  1908
 * RTestVclnt2Align::DoThisActionDuringPlaybackL
sl@0
  1909
 */
sl@0
  1910
void RTestVclnt2Align::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& /* aPlayer */)
sl@0
  1911
    {    
sl@0
  1912
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignCenter);    
sl@0
  1913
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1914
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(10, 10, 100, 100), TRect(0, 3, 4, 220));        
sl@0
  1915
    
sl@0
  1916
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignCenter);    
sl@0
  1917
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1918
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
sl@0
  1919
        
sl@0
  1920
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignTop);    
sl@0
  1921
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1922
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(10, 10, 100, 100), TRect(0, 5, 5, 200));        
sl@0
  1923
    
sl@0
  1924
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignTop);
sl@0
  1925
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1926
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
sl@0
  1927
    
sl@0
  1928
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignTop);
sl@0
  1929
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1930
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(0, 0, 100, 100), TRect(0, 5, 5, 200));        
sl@0
  1931
        
sl@0
  1932
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignCenter, EVerticalAlignBottom);
sl@0
  1933
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1934
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
sl@0
  1935
    
sl@0
  1936
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignLeft, EVerticalAlignBottom);
sl@0
  1937
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1938
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, TRect(0, 0, 100, 100), TRect(0, 5, 300, 230));        
sl@0
  1939
    
sl@0
  1940
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleNone, EHorizontalAlignRight, EVerticalAlignBottom);
sl@0
  1941
    iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  1942
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);        
sl@0
  1943
    }
sl@0
  1944
sl@0
  1945
sl@0
  1946
//
sl@0
  1947
// RTestVclnt2AutoScale
sl@0
  1948
//
sl@0
  1949
/**
sl@0
  1950
 * RTestVclnt2AutoScale::Constructor
sl@0
  1951
 */
sl@0
  1952
RTestVclnt2AutoScale::RTestVclnt2AutoScale(const TDesC& aTestName, 
sl@0
  1953
                                           const TDesC& aSectName, 
sl@0
  1954
                                           const TDesC& aKeyName, 
sl@0
  1955
                                           TInt aExpectedError)
sl@0
  1956
    : RTestVclnt2PerformActionDuringVideoPlayback(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  1957
    {
sl@0
  1958
    iHeapSize = 2000000; //~2MB
sl@0
  1959
    }
sl@0
  1960
sl@0
  1961
/**
sl@0
  1962
 * RTestVclnt2AutoScale::NewL
sl@0
  1963
 */
sl@0
  1964
RTestVclnt2AutoScale* RTestVclnt2AutoScale::NewL(const TDesC& aTestName, 
sl@0
  1965
                                                 const TDesC& aSectName,
sl@0
  1966
                                                 const TDesC& aKeyName, 
sl@0
  1967
                                                 TInt aExpectedError)
sl@0
  1968
    {
sl@0
  1969
    RTestVclnt2AutoScale* self = new (ELeave) RTestVclnt2AutoScale(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1970
    return self;
sl@0
  1971
    }
sl@0
  1972
sl@0
  1973
/**
sl@0
  1974
 * RTestVclnt2AutoScale::HandlePrepareCompleteL
sl@0
  1975
 */ 
sl@0
  1976
void RTestVclnt2AutoScale::HandlePrepareCompleteL()
sl@0
  1977
    {
sl@0
  1978
    iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
sl@0
  1979
	// Set the content offset before starting to play the video.
sl@0
  1980
    INFO_PRINTF1(_L("iVideoPlayer2->SetAutoScale()"));
sl@0
  1981
    iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleClip);
sl@0
  1982
    
sl@0
  1983
    // trigger the video to start playing                
sl@0
  1984
    StartPlayback();
sl@0
  1985
    }
sl@0
  1986
	
sl@0
  1987
/**
sl@0
  1988
 * RTestVclnt2AutoScale::DoThisActionDuringPlaybackL
sl@0
  1989
 */
sl@0
  1990
void RTestVclnt2AutoScale::DoThisActionDuringPlaybackL(CVideoPlayerUtility2& aPlayer)
sl@0
  1991
    {    
sl@0
  1992
	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleBestFit);
sl@0
  1993
	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleNone);
sl@0
  1994
	aPlayer.SetAutoScaleL(*iWindow, EAutoScaleStretch);
sl@0
  1995
    }
sl@0
  1996
sl@0
  1997
//
sl@0
  1998
// RTestVclnt2OldController
sl@0
  1999
//
sl@0
  2000
sl@0
  2001
RTestVclnt2OldController::RTestVclnt2OldController(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2002
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2003
	{
sl@0
  2004
	}
sl@0
  2005
sl@0
  2006
/**
sl@0
  2007
 * RTestVclnt2OldController::NewL
sl@0
  2008
 */
sl@0
  2009
RTestVclnt2OldController* RTestVclnt2OldController::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2010
    {
sl@0
  2011
    RTestVclnt2OldController* self = new (ELeave) RTestVclnt2OldController(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2012
    return self;
sl@0
  2013
    }
sl@0
  2014
sl@0
  2015
void RTestVclnt2OldController::HandleIdleL()
sl@0
  2016
	{
sl@0
  2017
	// Open iVideoPlayer using a controller that does not support surfaces. 
sl@0
  2018
    INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
sl@0
  2019
    iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviNonGcePlayControllerUid);
sl@0
  2020
    PrepareState(EVPOpenComplete, KErrNone);
sl@0
  2021
	}
sl@0
  2022
sl@0
  2023
void RTestVclnt2OldController::HandlePrepareCompleteL()
sl@0
  2024
	{
sl@0
  2025
	TRAPD(err, RTestVclnt2PlayFile::HandlePrepareCompleteL());
sl@0
  2026
	
sl@0
  2027
	if (err != KErrNotSupported)
sl@0
  2028
		{
sl@0
  2029
		ERR_PRINTF1(_L("AddDisplay did not leave with KErrNotSupported."));
sl@0
  2030
		iTestStepResult = EFail;
sl@0
  2031
		}
sl@0
  2032
	else
sl@0
  2033
		{
sl@0
  2034
		iTestStepResult = EPass;
sl@0
  2035
		}
sl@0
  2036
	
sl@0
  2037
	// Stop the test.
sl@0
  2038
	CActiveScheduler::Stop();
sl@0
  2039
	}
sl@0
  2040
//
sl@0
  2041
// RTestVclnt2NoFile
sl@0
  2042
//
sl@0
  2043
sl@0
  2044
RTestVclnt2NoFile::RTestVclnt2NoFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2045
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2046
	{
sl@0
  2047
	}
sl@0
  2048
sl@0
  2049
/**
sl@0
  2050
 * RTestVclnt2NoFile::NewL
sl@0
  2051
 */
sl@0
  2052
RTestVclnt2NoFile* RTestVclnt2NoFile::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2053
    {
sl@0
  2054
    RTestVclnt2NoFile* self = new (ELeave) RTestVclnt2NoFile(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2055
    return self;
sl@0
  2056
    }
sl@0
  2057
sl@0
  2058
void RTestVclnt2NoFile::HandleIdleL()
sl@0
  2059
	{
sl@0
  2060
	iTestStepResult = EFail;
sl@0
  2061
	TRAPD(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow));
sl@0
  2062
	
sl@0
  2063
	if (err != iTestExpectedError)
sl@0
  2064
		{
sl@0
  2065
		ERR_PRINTF1(_L("AddDisplayWindowL did not leave with KErrNotReady."));
sl@0
  2066
		User::Leave(KErrGeneral);
sl@0
  2067
		}
sl@0
  2068
	
sl@0
  2069
	TSize windowSize = iWindow->Size();
sl@0
  2070
	TRect videoExtent(-5, -5, windowSize.iWidth + 5, windowSize.iHeight + 5);
sl@0
  2071
	TRect windowClipRect(5, 5, windowSize.iWidth - 5, windowSize.iHeight - 5);
sl@0
  2072
	TRAP(err, iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtent, windowClipRect));
sl@0
  2073
	
sl@0
  2074
	if (err != iTestExpectedError)
sl@0
  2075
		{
sl@0
  2076
		ERR_PRINTF1(_L("AddDisplayWindowL did not leave with KErrNotReady."));
sl@0
  2077
		User::Leave(KErrGeneral);
sl@0
  2078
		}
sl@0
  2079
	
sl@0
  2080
	TRAP(err, iVideoPlayer2->SetWindowClipRectL(*iWindow, windowClipRect));
sl@0
  2081
	
sl@0
  2082
	if (err != iTestExpectedError)
sl@0
  2083
		{
sl@0
  2084
		ERR_PRINTF1(_L("SetWindowClipRectL did not leave with KErrNotReady."));
sl@0
  2085
		User::Leave(KErrGeneral);
sl@0
  2086
		}
sl@0
  2087
	
sl@0
  2088
	TRAP(err, iVideoPlayer2->SetVideoExtentL(*iWindow, videoExtent));
sl@0
  2089
	
sl@0
  2090
	if (err != iTestExpectedError)
sl@0
  2091
		{
sl@0
  2092
		ERR_PRINTF1(_L("SetVideoExtentL did not leave with KErrNotReady."));
sl@0
  2093
		User::Leave(KErrGeneral);
sl@0
  2094
		}
sl@0
  2095
	
sl@0
  2096
	// reset the expected error to KErrNone as any error happens after this is unexpected
sl@0
  2097
    iTestExpectedError = KErrNone;	
sl@0
  2098
	
sl@0
  2099
	// The video should still play when we try to play the video.  Perform 
sl@0
  2100
	// the basic play test now.
sl@0
  2101
	RTestVclnt2PlayFile::HandleIdleL();
sl@0
  2102
	}
sl@0
  2103
sl@0
  2104
//
sl@0
  2105
// RTestVclnt2PlayAfterRemoveWin
sl@0
  2106
//
sl@0
  2107
sl@0
  2108
RTestVclnt2PlayAfterRemoveWin::RTestVclnt2PlayAfterRemoveWin(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2109
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2110
	{
sl@0
  2111
	}
sl@0
  2112
sl@0
  2113
/**
sl@0
  2114
 * RTestVclnt2PlayAfterRemoveWin::NewL
sl@0
  2115
 */
sl@0
  2116
RTestVclnt2PlayAfterRemoveWin* RTestVclnt2PlayAfterRemoveWin::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2117
    {
sl@0
  2118
    RTestVclnt2PlayAfterRemoveWin* self = new (ELeave) RTestVclnt2PlayAfterRemoveWin(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2119
    return self;
sl@0
  2120
    }
sl@0
  2121
sl@0
  2122
void RTestVclnt2PlayAfterRemoveWin::HandlePrepareCompleteL()
sl@0
  2123
	{
sl@0
  2124
	// Don't add a window. Just play the video.
sl@0
  2125
	StartPlayback();
sl@0
  2126
	}
sl@0
  2127
sl@0
  2128
void RTestVclnt2PlayAfterRemoveWin::HandlePlayCompleteL()
sl@0
  2129
	{
sl@0
  2130
	switch(iPlayAttempt)
sl@0
  2131
		{
sl@0
  2132
	case 0:
sl@0
  2133
		{
sl@0
  2134
		TSize windowSize = iWindow->Size();
sl@0
  2135
		TRect videoExtent(-5, -5, windowSize.iWidth + 5, windowSize.iHeight + 5);
sl@0
  2136
		TRect windowClipRect(5, 5, windowSize.iWidth - 5, windowSize.iHeight - 5);
sl@0
  2137
		iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow, videoExtent, windowClipRect);
sl@0
  2138
		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  2139
		iVideoPlayer2->Play();
sl@0
  2140
		PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2141
		break;
sl@0
  2142
		}
sl@0
  2143
	case 1:
sl@0
  2144
		// Removing the window again should have no effect.
sl@0
  2145
		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
sl@0
  2146
		iVideoPlayer2->Play();
sl@0
  2147
		PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2148
		break;
sl@0
  2149
	case 2:
sl@0
  2150
		// The previous play commands should have no effect when we try to add a 
sl@0
  2151
		// display window and render to surfaces. Use the base class to do this.
sl@0
  2152
		RTestVclnt2PlayFile::HandlePrepareCompleteL();
sl@0
  2153
		break;
sl@0
  2154
	default:
sl@0
  2155
		// Use the parent handler after we have tried the above play commands.
sl@0
  2156
		RTestVclnt2PlayFile::HandlePlayCompleteL();
sl@0
  2157
		break;
sl@0
  2158
		}
sl@0
  2159
	
sl@0
  2160
	iPlayAttempt++;
sl@0
  2161
	}
sl@0
  2162
sl@0
  2163
//
sl@0
  2164
// RTestVclnt2NoGce
sl@0
  2165
//
sl@0
  2166
sl@0
  2167
RTestVclnt2NoGce::RTestVclnt2NoGce(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2168
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2169
	{
sl@0
  2170
	}
sl@0
  2171
sl@0
  2172
/**
sl@0
  2173
 * RTestVclnt2NoGce::NewL
sl@0
  2174
 */
sl@0
  2175
RTestVclnt2NoGce* RTestVclnt2NoGce::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2176
    {
sl@0
  2177
    RTestVclnt2NoGce* self = new (ELeave) RTestVclnt2NoGce(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2178
    return self;
sl@0
  2179
    }
sl@0
  2180
sl@0
  2181
void RTestVclnt2NoGce::HandleIdleL()
sl@0
  2182
	{
sl@0
  2183
	// Open iVideoPlayer
sl@0
  2184
    INFO_PRINTF2(_L("iVideoPlayer2->OpenFileL() %S"), &iFilename);
sl@0
  2185
    iVideoPlayer2->OpenFileL(iFilename, KMmfTestAviPlayControllerUid);
sl@0
  2186
    PrepareState(EVPOpenComplete, KErrNotSupported);
sl@0
  2187
	}
sl@0
  2188
sl@0
  2189
void RTestVclnt2NoGce::HandleOpenCompleteL()
sl@0
  2190
	{
sl@0
  2191
	iTestStepResult = EPass;
sl@0
  2192
	CActiveScheduler::Stop();
sl@0
  2193
	}
sl@0
  2194
	
sl@0
  2195
//
sl@0
  2196
// RTestVclnt2Alloc
sl@0
  2197
//
sl@0
  2198
sl@0
  2199
RTestVclnt2Alloc::RTestVclnt2Alloc(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2200
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2201
	{
sl@0
  2202
	}
sl@0
  2203
sl@0
  2204
/**
sl@0
  2205
 * RTestVclnt2Alloc::NewL
sl@0
  2206
 */
sl@0
  2207
RTestVclnt2Alloc* RTestVclnt2Alloc::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2208
    {
sl@0
  2209
    RTestVclnt2Alloc* self = new (ELeave) RTestVclnt2Alloc(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2210
    return self;
sl@0
  2211
    }
sl@0
  2212
sl@0
  2213
TVerdict RTestVclnt2Alloc::DoTestStepPreambleL()
sl@0
  2214
	{
sl@0
  2215
    INFO_PRINTF1(_L("RTestVclnt2Alloc::DoTestStepPreambleL()"));
sl@0
  2216
        
sl@0
  2217
    // Call RTestMmfVclntAviStep::DoTestStepPreambleL instead of the immediate parent's 
sl@0
  2218
    // DoTestStepPreambleL as there is no need for CVideoPlayerUtility setup.
sl@0
  2219
    // Similarly, there is no need to initialize CVideoPlayerUtility2, as it will be
sl@0
  2220
    // created in each alloc iteration.
sl@0
  2221
    return RTestMmfVclntAviStep::DoTestStepPreambleL();
sl@0
  2222
	}
sl@0
  2223
sl@0
  2224
TVerdict RTestVclnt2Alloc::PerformTestL()
sl@0
  2225
	{
sl@0
  2226
	iVideoPlayer2 = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
sl@0
  2227
	ResetState();
sl@0
  2228
	iError = KErrNone;
sl@0
  2229
	TVerdict result = RTestVclnt2AviPlayerStep::DoTestStepL();
sl@0
  2230
	delete iVideoPlayer2;
sl@0
  2231
	iVideoPlayer2 = NULL;
sl@0
  2232
	return result;
sl@0
  2233
	}
sl@0
  2234
sl@0
  2235
/**
sl@0
  2236
 * RTestVclnt2Alloc::DoTestStepL()
sl@0
  2237
 */
sl@0
  2238
TVerdict RTestVclnt2Alloc::DoTestStepL()
sl@0
  2239
    {
sl@0
  2240
    TVerdict allocTestStepResult = EPass;
sl@0
  2241
    TInt err = KErrNone;
sl@0
  2242
    TBool result = EFalse;
sl@0
  2243
    
sl@0
  2244
    //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
sl@0
  2245
    if (PerformTestL() != EPass)
sl@0
  2246
        {
sl@0
  2247
        err = iError;
sl@0
  2248
        }
sl@0
  2249
sl@0
  2250
    if (err != KErrNone)
sl@0
  2251
        {
sl@0
  2252
        INFO_PRINTF2(_L("Test error, returned error code =  %d"), err);
sl@0
  2253
        User::Leave(err);
sl@0
  2254
        }
sl@0
  2255
    else
sl@0
  2256
        {
sl@0
  2257
        //Check the iAllocTestStepResult
sl@0
  2258
        if (allocTestStepResult != EPass)
sl@0
  2259
            {
sl@0
  2260
            result = ETrue;
sl@0
  2261
            }
sl@0
  2262
        }    
sl@0
  2263
    
sl@0
  2264
    TInt failCount = 1;
sl@0
  2265
    TBool completed = EFalse;
sl@0
  2266
    allocTestStepResult = EPass;
sl@0
  2267
    TBool reachedEnd = EFalse;
sl@0
  2268
    for(;;)    
sl@0
  2269
        {
sl@0
  2270
        __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
sl@0
  2271
        __MM_HEAP_MARK;
sl@0
  2272
sl@0
  2273
        //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
sl@0
  2274
        TVerdict verdict = EFail;
sl@0
  2275
        TRAP(err, verdict = PerformTestL());
sl@0
  2276
        if (err == KErrNone && verdict != EPass)
sl@0
  2277
            {
sl@0
  2278
            err = iError;
sl@0
  2279
            }
sl@0
  2280
sl@0
  2281
        completed = EFalse;
sl@0
  2282
        if (err == KErrNone)
sl@0
  2283
            {
sl@0
  2284
            TAny* testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
sl@0
  2285
            if (testAlloc == NULL)
sl@0
  2286
                {
sl@0
  2287
                reachedEnd = ETrue;
sl@0
  2288
                failCount -= 1;
sl@0
  2289
                }
sl@0
  2290
            else
sl@0
  2291
                {
sl@0
  2292
                User::Free(testAlloc);    
sl@0
  2293
                }            
sl@0
  2294
            
sl@0
  2295
            //Check the iAllocTestStepResult
sl@0
  2296
            if (allocTestStepResult != EPass)
sl@0
  2297
                {
sl@0
  2298
                result = ETrue;
sl@0
  2299
                }
sl@0
  2300
            
sl@0
  2301
            completed = reachedEnd || result;
sl@0
  2302
            }
sl@0
  2303
        else if (err != KErrNoMemory) // bad error code
sl@0
  2304
            {
sl@0
  2305
            completed = ETrue;
sl@0
  2306
            result = EFail;
sl@0
  2307
            }            
sl@0
  2308
sl@0
  2309
        __MM_HEAP_MARKEND;
sl@0
  2310
        __UHEAP_SETFAIL(RHeap::ENone, 0);
sl@0
  2311
sl@0
  2312
        if (completed)
sl@0
  2313
            {
sl@0
  2314
            break; // exit loop
sl@0
  2315
            }
sl@0
  2316
sl@0
  2317
        failCount++;
sl@0
  2318
        }
sl@0
  2319
sl@0
  2320
    failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
sl@0
  2321
sl@0
  2322
    if (err != KErrNone || result)
sl@0
  2323
        {
sl@0
  2324
        allocTestStepResult = EFail;
sl@0
  2325
        TBuf<80> format;
sl@0
  2326
        if (result)
sl@0
  2327
            {
sl@0
  2328
            format.Format(_L("  Bad result with %d memory allocations tested\n"), failCount);
sl@0
  2329
            }
sl@0
  2330
        else
sl@0
  2331
            {
sl@0
  2332
            format.Format(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
sl@0
  2333
            }
sl@0
  2334
        Log(format);
sl@0
  2335
        }
sl@0
  2336
    else 
sl@0
  2337
        {
sl@0
  2338
        TBuf<80> format;
sl@0
  2339
        format.Format(_L("  Completed OK with %d memory allocations tested\n"), failCount);
sl@0
  2340
        Log(format);
sl@0
  2341
        }
sl@0
  2342
sl@0
  2343
    return allocTestStepResult;
sl@0
  2344
    }
sl@0
  2345
sl@0
  2346
//
sl@0
  2347
// RTestVclnt2InvalidScaleFactor
sl@0
  2348
//
sl@0
  2349
RTestVclnt2InvalidScaleFactor::RTestVclnt2InvalidScaleFactor(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2350
	: RTestVclnt2PlayFile(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2351
	{
sl@0
  2352
	}
sl@0
  2353
sl@0
  2354
/**
sl@0
  2355
 * RTestVclnt2InvalidScaleFactor::NewL
sl@0
  2356
 */
sl@0
  2357
RTestVclnt2InvalidScaleFactor* RTestVclnt2InvalidScaleFactor::NewL(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2358
    {
sl@0
  2359
    RTestVclnt2InvalidScaleFactor* self = new (ELeave) RTestVclnt2InvalidScaleFactor(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2360
    return self;
sl@0
  2361
    }
sl@0
  2362
sl@0
  2363
void RTestVclnt2InvalidScaleFactor::HandlePrepareCompleteL()
sl@0
  2364
	{
sl@0
  2365
	INFO_PRINTF1(_L("iVideoPlayer2->AddDisplayWindowL()"));
sl@0
  2366
	iVideoPlayer2->AddDisplayWindowL(iWs, *iScreen, *iWindow);
sl@0
  2367
sl@0
  2368
	// Try to scale the video to an invalid values
sl@0
  2369
	TRAPD(err, iVideoPlayer2->SetScaleFactorL(*iWindow, 0, 100));
sl@0
  2370
	if (err != KErrArgument)
sl@0
  2371
		{
sl@0
  2372
		User::Leave(err == KErrNone ? KErrGeneral : err); 
sl@0
  2373
		}
sl@0
  2374
	
sl@0
  2375
	TRAP(err, iVideoPlayer2->SetScaleFactorL(*iWindow, 100, -100));
sl@0
  2376
	if (err != KErrArgument)
sl@0
  2377
		{
sl@0
  2378
		User::Leave(err == KErrNone ? KErrGeneral : err); 
sl@0
  2379
		}
sl@0
  2380
	
sl@0
  2381
	// trigger the video to start playing                
sl@0
  2382
    StartPlayback();
sl@0
  2383
	}