os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer.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) 2005-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 "testvideoplayer.h"
sl@0
    17
sl@0
    18
#include <e32math.h>
sl@0
    19
#include <mmf/common/mmfvideo.h>
sl@0
    20
#include "u32hal.h"
sl@0
    21
sl@0
    22
#ifdef SYMBIAN_BUILD_GCE
sl@0
    23
#include <gceavailable.h>
sl@0
    24
#endif
sl@0
    25
sl@0
    26
const TInt KFrameWidth = 100;
sl@0
    27
const TInt KFrameHeight = 50;
sl@0
    28
sl@0
    29
const TInt KCropRegionRectTop = 1;
sl@0
    30
const TInt KCropRegionRectLeft = 3;
sl@0
    31
const TInt KCropRegionRectRight = 5;
sl@0
    32
const TInt KCropRegionRectBottom = 7;
sl@0
    33
const TUint KCacheSize = 1000000; //1MB
sl@0
    34
const TUint KMaxCacheSize = 30000000; //30MB
sl@0
    35
sl@0
    36
//
sl@0
    37
// RTestVclntPlayAviFile
sl@0
    38
//
sl@0
    39
sl@0
    40
/**
sl@0
    41
 * RTestVclntPlayAviFile::Constructor
sl@0
    42
 */
sl@0
    43
RTestVclntPlayAviFile::RTestVclntPlayAviFile(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError, const TBool aPlay)
sl@0
    44
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError), iPlay(aPlay)
sl@0
    45
    {
sl@0
    46
    iHeapSize = 2000000; //-2MB
sl@0
    47
    }
sl@0
    48
sl@0
    49
/**
sl@0
    50
 * RTestVclntPlayAviFile::NewL
sl@0
    51
 */
sl@0
    52
RTestVclntPlayAviFile* RTestVclntPlayAviFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
    53
    {
sl@0
    54
    RTestVclntPlayAviFile* self = new (ELeave) RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
    55
    return self;
sl@0
    56
    }
sl@0
    57
sl@0
    58
/**
sl@0
    59
 * RTestVclntPlayAviFile::NewLC
sl@0
    60
 */
sl@0
    61
RTestVclntPlayAviFile* RTestVclntPlayAviFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
    62
    {
sl@0
    63
    RTestVclntPlayAviFile* self = new (ELeave) RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
    64
    CleanupStack::PushL(self);
sl@0
    65
    return self;
sl@0
    66
    }
sl@0
    67
sl@0
    68
/**
sl@0
    69
 * RTestVclntPlayAviFile::DoTestStepL
sl@0
    70
 */
sl@0
    71
TVerdict RTestVclntPlayAviFile::DoTestStepL()
sl@0
    72
    {
sl@0
    73
	 // WDP:We are going to start the test now
sl@0
    74
	 // Ensure we set paging memory to appropriate cache size for tests which need it
sl@0
    75
	 //ignore other tests
sl@0
    76
    TVerdict verdict=SetCacheSize();
sl@0
    77
    if(verdict!=EPass)
sl@0
    78
    	{
sl@0
    79
    	return verdict;
sl@0
    80
    	}
sl@0
    81
     
sl@0
    82
    // Call the state handler from IDLE state
sl@0
    83
    FsmL(EVPIdle);
sl@0
    84
    User::LeaveIfError(iError);
sl@0
    85
    // Start the scheduler - Done only once !
sl@0
    86
    CActiveScheduler::Start();
sl@0
    87
    
sl@0
    88
    return iTestStepResult;
sl@0
    89
    }
sl@0
    90
sl@0
    91
//Default SetCache size
sl@0
    92
TVerdict RTestVclntPlayAviFile::SetCacheSize()
sl@0
    93
	{
sl@0
    94
	//Do not try to increase cache size for tests which dont need it
sl@0
    95
	return EPass;
sl@0
    96
		    
sl@0
    97
	}
sl@0
    98
sl@0
    99
/**
sl@0
   100
 * RTestVclntPlayAviFile::FsmL
sl@0
   101
 */
sl@0
   102
void RTestVclntPlayAviFile::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   103
    {
sl@0
   104
    if (FsmCheck(aEventCode))
sl@0
   105
        {
sl@0
   106
        //TInt err = KErrNone;
sl@0
   107
        switch (aEventCode)
sl@0
   108
            {
sl@0
   109
            case EVPIdle:
sl@0
   110
                // Open iVideoPlayer
sl@0
   111
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
   112
                TRAP(iError, iVideoPlayer->OpenFileL(iFilename, ControllerUid()));
sl@0
   113
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   114
                break;
sl@0
   115
            case EVPOpenComplete:
sl@0
   116
                // Prepare iVideoPlayer
sl@0
   117
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
   118
                iVideoPlayer->Prepare();
sl@0
   119
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   120
                break;
sl@0
   121
            case EVPPrepareComplete:
sl@0
   122
                iTestStepResult = DoTestL(iVideoPlayer);
sl@0
   123
                break;
sl@0
   124
            case EVPPlayComplete:
sl@0
   125
                iTestStepResult = EPass;
sl@0
   126
                CActiveScheduler::Stop();
sl@0
   127
                break;
sl@0
   128
            }
sl@0
   129
        }
sl@0
   130
    }
sl@0
   131
sl@0
   132
/**
sl@0
   133
 * RTestVclntPlayAviFile::DoTestL
sl@0
   134
 */
sl@0
   135
TVerdict RTestVclntPlayAviFile::DoTestL(CVideoPlayerUtility* /*aPlayer*/)
sl@0
   136
    {
sl@0
   137
    TVerdict ret = EFail;
sl@0
   138
sl@0
   139
    if(iPlay)
sl@0
   140
        {
sl@0
   141
        iError = KErrTimedOut;
sl@0
   142
        INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   143
        PrepareState(EVPPlayComplete, KErrNone);
sl@0
   144
        iVideoPlayer->Play();
sl@0
   145
        }
sl@0
   146
    else
sl@0
   147
        {
sl@0
   148
        CActiveScheduler::Stop();
sl@0
   149
        ret = EPass;
sl@0
   150
        }
sl@0
   151
        
sl@0
   152
    return ret;
sl@0
   153
    }
sl@0
   154
sl@0
   155
//
sl@0
   156
// RTestVclntPlayAviDes
sl@0
   157
//
sl@0
   158
sl@0
   159
/**
sl@0
   160
 * RTestVclntPlayAviDes::Constructor
sl@0
   161
 */
sl@0
   162
RTestVclntPlayAviDes::RTestVclntPlayAviDes(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TBool aPlay)
sl@0
   163
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError), iPlay(aPlay)
sl@0
   164
    {
sl@0
   165
    iHeapSize = 500000;
sl@0
   166
    }
sl@0
   167
sl@0
   168
/**
sl@0
   169
 * RTestVclntPlayAviDes::NewL
sl@0
   170
 */
sl@0
   171
RTestVclntPlayAviDes* RTestVclntPlayAviDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
   172
    {
sl@0
   173
    RTestVclntPlayAviDes* self = new (ELeave) RTestVclntPlayAviDes(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
   174
    return self;
sl@0
   175
    }
sl@0
   176
sl@0
   177
/**
sl@0
   178
 * RTestVclntPlayAviDes::NewLC
sl@0
   179
 */
sl@0
   180
RTestVclntPlayAviDes* RTestVclntPlayAviDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
   181
    {
sl@0
   182
    RTestVclntPlayAviDes* self = new (ELeave) RTestVclntPlayAviDes(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
   183
    CleanupStack::PushL(self);
sl@0
   184
    return self;
sl@0
   185
    }
sl@0
   186
sl@0
   187
/**
sl@0
   188
 * RTestVclntPlayAviDes::DoTestStepPreambleL
sl@0
   189
 */
sl@0
   190
TVerdict  RTestVclntPlayAviDes::DoTestStepPreambleL()
sl@0
   191
    {
sl@0
   192
    TVerdict preamRes;
sl@0
   193
    preamRes = EPass;
sl@0
   194
    
sl@0
   195
    // Base DoTestStepPreambleL
sl@0
   196
    preamRes = RTestVclntAviPlayerStep::DoTestStepPreambleL();
sl@0
   197
    if (preamRes != EPass)
sl@0
   198
        {
sl@0
   199
        return preamRes;
sl@0
   200
        }
sl@0
   201
    
sl@0
   202
    RFs fs;
sl@0
   203
    RFile file;
sl@0
   204
    TInt size = 0;
sl@0
   205
sl@0
   206
    // connect to file system and open file
sl@0
   207
    User::LeaveIfError(fs.Connect());
sl@0
   208
    CleanupClosePushL(fs);
sl@0
   209
    User::LeaveIfError(file.Open(fs,iFilename,EFileRead));
sl@0
   210
    CleanupClosePushL(file);
sl@0
   211
sl@0
   212
    // Set HBuf size
sl@0
   213
    User::LeaveIfError(file.Size(size));
sl@0
   214
    INFO_PRINTF2(_L("size of file = %d\n"),size);//Statement Changed under DEF105143
sl@0
   215
sl@0
   216
	iVideo = HBufC8::NewMaxL(size);
sl@0
   217
sl@0
   218
    // read data into Hbuf
sl@0
   219
    TPtr8 bufferDes(iVideo->Des());
sl@0
   220
    User::LeaveIfError(file.Read(bufferDes));
sl@0
   221
    
sl@0
   222
    CleanupStack::PopAndDestroy(2); //fs, file
sl@0
   223
    
sl@0
   224
    return preamRes;
sl@0
   225
    }
sl@0
   226
sl@0
   227
/**
sl@0
   228
 * RTestVclntPlayAviDes::DoTestStepPostambleL
sl@0
   229
 */
sl@0
   230
TVerdict RTestVclntPlayAviDes::DoTestStepPostambleL()
sl@0
   231
    {
sl@0
   232
    delete iVideo;
sl@0
   233
    iVideo = NULL;
sl@0
   234
    return RTestVclntAviPlayerStep::DoTestStepPostambleL();
sl@0
   235
    }
sl@0
   236
sl@0
   237
/**
sl@0
   238
 * Load and initialise an video descriptor.
sl@0
   239
 */
sl@0
   240
TVerdict RTestVclntPlayAviDes::DoTestStepL()
sl@0
   241
    {
sl@0
   242
    iTestStepResult = EFail;
sl@0
   243
    // Call the state handler from IDLE state
sl@0
   244
    TRAPD(err, FsmL(EVPIdle));
sl@0
   245
    if (err == KErrNone)
sl@0
   246
        {
sl@0
   247
        CActiveScheduler::Start();    
sl@0
   248
        }
sl@0
   249
    // Start the scheduler - Done only once !
sl@0
   250
    return iTestStepResult;
sl@0
   251
    }
sl@0
   252
sl@0
   253
/**
sl@0
   254
 * RTestVclntPlayAviDes::FsmL
sl@0
   255
 */
sl@0
   256
void RTestVclntPlayAviDes::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   257
    {
sl@0
   258
    if (FsmCheck(aEventCode))
sl@0
   259
        {
sl@0
   260
        //TInt err = KErrNone;
sl@0
   261
        switch (aEventCode)
sl@0
   262
            {
sl@0
   263
            case EVPIdle:
sl@0
   264
                // Open iVideoPlayer
sl@0
   265
                INFO_PRINTF2(_L("iVideoPlayer->OpenDesL() %S"), &iFilename);
sl@0
   266
                TRAP(iError, iVideoPlayer->OpenDesL(iVideo->Des(), ControllerUid()));
sl@0
   267
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   268
                break;
sl@0
   269
            case EVPOpenComplete:
sl@0
   270
                // Prepare iVideoPlayer
sl@0
   271
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
   272
                iVideoPlayer->Prepare();
sl@0
   273
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   274
                break;
sl@0
   275
            case EVPPrepareComplete:
sl@0
   276
                iTestStepResult = DoTestL(iVideoPlayer);
sl@0
   277
                break;
sl@0
   278
            case EVPPlayComplete:
sl@0
   279
                iTestStepResult = EPass;
sl@0
   280
                CActiveScheduler::Stop();
sl@0
   281
                break;
sl@0
   282
            }
sl@0
   283
        }
sl@0
   284
    }
sl@0
   285
sl@0
   286
/**
sl@0
   287
 * RTestVclntPlayAviDes::DoTestL
sl@0
   288
 */
sl@0
   289
TVerdict RTestVclntPlayAviDes::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   290
    {
sl@0
   291
    TVerdict ret = EFail;
sl@0
   292
sl@0
   293
    if(iPlay)
sl@0
   294
        {
sl@0
   295
        iError = KErrTimedOut;
sl@0
   296
        INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   297
        PrepareState(EVPPlayComplete, KErrNone);
sl@0
   298
        aPlayer->Play();
sl@0
   299
        }
sl@0
   300
    else
sl@0
   301
        {
sl@0
   302
        CActiveScheduler::Stop();
sl@0
   303
        ret = EPass;
sl@0
   304
        }
sl@0
   305
        
sl@0
   306
    return ret;
sl@0
   307
    }
sl@0
   308
sl@0
   309
sl@0
   310
//
sl@0
   311
// RTestVclntPlayAviUrl
sl@0
   312
//
sl@0
   313
sl@0
   314
/**
sl@0
   315
 * RTestVclntPlayAviUrl::Constructor
sl@0
   316
 */
sl@0
   317
 
sl@0
   318
RTestVclntPlayAviUrl::RTestVclntPlayAviUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
   319
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError), iPlay(aPlay)
sl@0
   320
    {
sl@0
   321
    }
sl@0
   322
sl@0
   323
/**
sl@0
   324
 * RTestVclntPlayAviUrl::NewL
sl@0
   325
 */
sl@0
   326
sl@0
   327
RTestVclntPlayAviUrl* RTestVclntPlayAviUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
   328
    {
sl@0
   329
    RTestVclntPlayAviUrl* self = RTestVclntPlayAviUrl::NewLC(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
   330
    CleanupStack::Pop();
sl@0
   331
    return self;
sl@0
   332
    }
sl@0
   333
sl@0
   334
/**
sl@0
   335
 * RTestVclntPlayAviUrl::NewLC
sl@0
   336
 */
sl@0
   337
sl@0
   338
RTestVclntPlayAviUrl* RTestVclntPlayAviUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TBool aPlay)
sl@0
   339
    {
sl@0
   340
    RTestVclntPlayAviUrl* self = new (ELeave) RTestVclntPlayAviUrl(aTestName, aSectName, aKeyName, aExpectedError, aPlay);
sl@0
   341
    CleanupStack::PushL(self);
sl@0
   342
    return self;
sl@0
   343
    }
sl@0
   344
sl@0
   345
/**
sl@0
   346
 * RTestVclntPlayAviUrl::Constructor
sl@0
   347
 */
sl@0
   348
sl@0
   349
TVerdict RTestVclntPlayAviUrl::DoTestStepL()
sl@0
   350
    {
sl@0
   351
    // Call the state handler from IDLE state
sl@0
   352
    FsmL(EVPIdle);
sl@0
   353
    
sl@0
   354
    // Start the scheduler - Done only once !
sl@0
   355
    CActiveScheduler::Start();
sl@0
   356
    
sl@0
   357
    return iTestStepResult;
sl@0
   358
    }
sl@0
   359
sl@0
   360
/**
sl@0
   361
 * RTestVclntPlayAviUrl::FsmL
sl@0
   362
 */
sl@0
   363
 
sl@0
   364
void RTestVclntPlayAviUrl::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   365
    {
sl@0
   366
    if (FsmCheck(aEventCode))
sl@0
   367
        {
sl@0
   368
        switch (aEventCode)
sl@0
   369
            {
sl@0
   370
            case EVPIdle:
sl@0
   371
                // Open iVideoPlayer
sl@0
   372
                
sl@0
   373
                INFO_PRINTF2(_L("iVideoPlayer->OpenUrlL() %S"), &iFilename);
sl@0
   374
                TRAP(iError,iVideoPlayer->OpenUrlL(iFilename, KUseDefaultIap, KNullDesC8, ControllerUid()));
sl@0
   375
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   376
                break;
sl@0
   377
            case EVPOpenComplete:
sl@0
   378
                // Prepare iVideoPlayer
sl@0
   379
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
   380
                iVideoPlayer->Prepare();
sl@0
   381
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   382
                break;
sl@0
   383
            case EVPPrepareComplete:
sl@0
   384
                iTestStepResult = DoTestL(iVideoPlayer);
sl@0
   385
                break;
sl@0
   386
            case EVPPlayComplete:
sl@0
   387
                CActiveScheduler::Stop();
sl@0
   388
                iTestStepResult = EPass;
sl@0
   389
                break;
sl@0
   390
            }
sl@0
   391
        }
sl@0
   392
    }
sl@0
   393
sl@0
   394
/**
sl@0
   395
 * RTestVclntPlayAviUrl::Constructor
sl@0
   396
 */
sl@0
   397
 
sl@0
   398
TVerdict RTestVclntPlayAviUrl::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   399
    {
sl@0
   400
    TVerdict ret = EFail;
sl@0
   401
sl@0
   402
    if(iPlay)
sl@0
   403
        {
sl@0
   404
        iError = KErrTimedOut;
sl@0
   405
        INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   406
        PrepareState(EVPPlayComplete, KErrNone);
sl@0
   407
        aPlayer->Play();
sl@0
   408
        }
sl@0
   409
    else
sl@0
   410
        {
sl@0
   411
        CActiveScheduler::Stop();
sl@0
   412
        ret = EPass;
sl@0
   413
        }
sl@0
   414
        
sl@0
   415
    return ret;
sl@0
   416
    }
sl@0
   417
sl@0
   418
sl@0
   419
//
sl@0
   420
// RTestVclntEnqFrameRate
sl@0
   421
//
sl@0
   422
sl@0
   423
/**
sl@0
   424
 * RTestVclntEnqFrameRate::Constructor
sl@0
   425
 */
sl@0
   426
RTestVclntEnqFrameRate::RTestVclntEnqFrameRate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aFrameRate)
sl@0
   427
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   428
    {
sl@0
   429
    iFrameRate = aFrameRate;
sl@0
   430
    }
sl@0
   431
sl@0
   432
/**
sl@0
   433
 * RTestVclntEnqFrameRate::Constructor
sl@0
   434
 */
sl@0
   435
RTestVclntEnqFrameRate* RTestVclntEnqFrameRate::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aFrameRate)
sl@0
   436
    {
sl@0
   437
    RTestVclntEnqFrameRate* self = new (ELeave) RTestVclntEnqFrameRate(aTestName, aSectName, aKeyName, aExpectedError, aFrameRate);
sl@0
   438
    return self;
sl@0
   439
    }
sl@0
   440
sl@0
   441
/**
sl@0
   442
 * RTestVclntEnqFrameRate::Constructor
sl@0
   443
 */
sl@0
   444
TVerdict RTestVclntEnqFrameRate::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   445
    {
sl@0
   446
    INFO_PRINTF1(_L("Test : Video Player - Enquire Frame Rate"));
sl@0
   447
sl@0
   448
    TVerdict ret = EFail;
sl@0
   449
sl@0
   450
    TReal32 theFrameRate = 0.0;
sl@0
   451
    TRAPD(err, theFrameRate = aPlayer->VideoFrameRateL());
sl@0
   452
    INFO_PRINTF3(_L("iVideoPlayer->VideoFrameRateL() = %d...error =%d"), TInt(theFrameRate), err);
sl@0
   453
sl@0
   454
    // if we get here, we pass. The iVideoPlayer does not have a SetVideoFrameRate()
sl@0
   455
    INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   456
    PrepareState(EVPPlayComplete, KErrNone);
sl@0
   457
    aPlayer->Play();
sl@0
   458
sl@0
   459
    return ret;
sl@0
   460
    }
sl@0
   461
sl@0
   462
sl@0
   463
//
sl@0
   464
// RTestVclntPosition
sl@0
   465
//
sl@0
   466
sl@0
   467
/**
sl@0
   468
 * RTestVclntPosition::Constructor
sl@0
   469
 */
sl@0
   470
RTestVclntPosition::RTestVclntPosition(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aPosition)
sl@0
   471
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   472
    {
sl@0
   473
    iPosition = aPosition;
sl@0
   474
    }
sl@0
   475
sl@0
   476
/**
sl@0
   477
 * RTestVclntPosition::NewL
sl@0
   478
 */
sl@0
   479
RTestVclntPosition* RTestVclntPosition::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aPosition)
sl@0
   480
    {
sl@0
   481
    RTestVclntPosition* self = new (ELeave) RTestVclntPosition(aTestName, aSectName, aKeyName, aExpectedError, aPosition);
sl@0
   482
    return self;
sl@0
   483
    }
sl@0
   484
sl@0
   485
/**
sl@0
   486
 * RTestVclntPosition::DoTestL
sl@0
   487
 */
sl@0
   488
TVerdict RTestVclntPosition::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   489
    {
sl@0
   490
    // NB test video controller is stubbing certain functions. May have to rewrite this
sl@0
   491
    // for AVI Controller
sl@0
   492
sl@0
   493
    TVerdict ret = EFail;
sl@0
   494
    TInt err = KErrNone;
sl@0
   495
    TTimeIntervalMicroSeconds pos;
sl@0
   496
    
sl@0
   497
    INFO_PRINTF1(_L("Test : Video Player - Position"));
sl@0
   498
    INFO_PRINTF3(_L("Set Position = %d, Duration = %d"), I64INT(iPosition.Int64()), I64INT(aPlayer->DurationL().Int64()));
sl@0
   499
sl@0
   500
    //  Set position: middle of clip.
sl@0
   501
    if (I64INT(iPosition.Int64()) == 0)
sl@0
   502
        {
sl@0
   503
        iPosition = I64INT(aPlayer->DurationL().Int64()) / 2;
sl@0
   504
        }
sl@0
   505
        
sl@0
   506
    // Set position: end of clip.
sl@0
   507
    if (I64INT(iPosition.Int64()) == -1)
sl@0
   508
        {
sl@0
   509
        iPosition = aPlayer->DurationL();
sl@0
   510
        }
sl@0
   511
        
sl@0
   512
    // Position is beyond the end of the clips duration, so check that the value is clipped.
sl@0
   513
    if(aPlayer->DurationL() < iPosition)
sl@0
   514
        {
sl@0
   515
        INFO_PRINTF2(_L("Longer than duration : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   516
        TRAP(err, aPlayer->SetPositionL(iPosition));
sl@0
   517
        if (err == KErrNotSupported)
sl@0
   518
            {
sl@0
   519
            INFO_PRINTF1(_L("SetPositionL() left with Error - KErrNotSupported"));
sl@0
   520
            }
sl@0
   521
        TRAP(err, pos = aPlayer->PositionL());
sl@0
   522
        if (err == KErrNotReady)
sl@0
   523
            {
sl@0
   524
            INFO_PRINTF1(_L("PositionL() left with Error - KErrNotReady"));
sl@0
   525
            }
sl@0
   526
        INFO_PRINTF3(_L("Set Position = %d (if clipped : %d)"), I64INT(pos.Int64()), I64INT(aPlayer->DurationL().Int64()));
sl@0
   527
        }
sl@0
   528
    
sl@0
   529
    // Position is negative, so check that the value is clipped.
sl@0
   530
    else if (I64INT(iPosition.Int64()) < 0)
sl@0
   531
        {
sl@0
   532
        INFO_PRINTF2(_L("Negative value : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   533
        TRAP(err, aPlayer->SetPositionL(iPosition));
sl@0
   534
        if (err == KErrNotSupported)
sl@0
   535
            {
sl@0
   536
            INFO_PRINTF1(_L("SetPositionL() left with Error - KErrNotSupported"));
sl@0
   537
            }
sl@0
   538
        TRAP(err, pos = aPlayer->PositionL());
sl@0
   539
        if (err == KErrNotReady)
sl@0
   540
            {
sl@0
   541
            INFO_PRINTF1(_L("PositionL() left with Error - KErrNotReady"));
sl@0
   542
            }
sl@0
   543
        INFO_PRINTF2(_L("Set : position = %d (if clipped : 0)"), I64INT(pos.Int64()));
sl@0
   544
        }
sl@0
   545
    else
sl@0
   546
        {
sl@0
   547
        INFO_PRINTF2(_L("Normal : Setting position to %d"), I64INT(iPosition.Int64()));
sl@0
   548
        TRAP(err, aPlayer->SetPositionL(iPosition));
sl@0
   549
        if (err == KErrNotSupported)
sl@0
   550
            {
sl@0
   551
            INFO_PRINTF1(_L("SetPositionL() left with Error - KErrNotSupported"));
sl@0
   552
            }
sl@0
   553
        TRAP(err, pos = aPlayer->PositionL());
sl@0
   554
        if (err == KErrNotReady)
sl@0
   555
            {
sl@0
   556
            INFO_PRINTF1(_L("PositionL() left with Error - KErrNotReady"));
sl@0
   557
            }
sl@0
   558
        INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"), I64INT(pos.Int64()), I64INT(iPosition.Int64()));
sl@0
   559
        }
sl@0
   560
sl@0
   561
    INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   562
    PrepareState(EVPPlayComplete, KErrNone);
sl@0
   563
    aPlayer->Play();
sl@0
   564
    
sl@0
   565
    
sl@0
   566
    TRAP(err, pos = aPlayer->PositionL());
sl@0
   567
    if (err != KErrNone)
sl@0
   568
        {
sl@0
   569
        INFO_PRINTF2(_L("PositionL() left with Error - %d"), err);
sl@0
   570
        ret = EFail;
sl@0
   571
        }
sl@0
   572
    
sl@0
   573
    return ret;
sl@0
   574
    }
sl@0
   575
sl@0
   576
sl@0
   577
//
sl@0
   578
// RTestVclntPriority
sl@0
   579
//
sl@0
   580
sl@0
   581
/**
sl@0
   582
 * RTestVclntPriority::Constructor
sl@0
   583
 */
sl@0
   584
RTestVclntPriority::RTestVclntPriority(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aPriority)
sl@0
   585
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   586
    {
sl@0
   587
    iPriority = aPriority;
sl@0
   588
    }
sl@0
   589
sl@0
   590
/**
sl@0
   591
 * RTestVclntRecordAviFile::Constructor
sl@0
   592
 */
sl@0
   593
RTestVclntPriority* RTestVclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aPriority)
sl@0
   594
    {
sl@0
   595
    RTestVclntPriority* self = new (ELeave) RTestVclntPriority(aTestName, aSectName, aKeyName, aExpectedError, aPriority);
sl@0
   596
    return self;
sl@0
   597
    }
sl@0
   598
sl@0
   599
/**
sl@0
   600
 * RTestVclntRecordAviFile::Constructor
sl@0
   601
 */
sl@0
   602
TVerdict RTestVclntPriority::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   603
    {
sl@0
   604
    TVerdict ret = EFail;
sl@0
   605
sl@0
   606
    INFO_PRINTF1(_L("Test : Video Player - Priority"));
sl@0
   607
sl@0
   608
    aPlayer->SetPriorityL(iPriority, EMdaPriorityPreferenceNone);    
sl@0
   609
    TInt thePriority = 0;
sl@0
   610
    TMdaPriorityPreference thePref;
sl@0
   611
    aPlayer->PriorityL(thePriority, thePref);
sl@0
   612
    INFO_PRINTF3(_L("Priority = %d (expecting %d)"), thePriority, iPriority);
sl@0
   613
    INFO_PRINTF3(_L("Pref = %d (expecting %d)"), thePref, EMdaPriorityPreferenceNone);
sl@0
   614
    
sl@0
   615
    if( (thePriority == iPriority) && (thePref == EMdaPriorityPreferenceNone) )
sl@0
   616
        {
sl@0
   617
        ret = EPass;
sl@0
   618
        }
sl@0
   619
        
sl@0
   620
    CActiveScheduler::Stop();
sl@0
   621
    
sl@0
   622
    return ret;
sl@0
   623
    }
sl@0
   624
sl@0
   625
sl@0
   626
//
sl@0
   627
// RTestVclntDuration
sl@0
   628
//
sl@0
   629
sl@0
   630
/**
sl@0
   631
 * RTestVclntDuration::Constructor
sl@0
   632
 */
sl@0
   633
RTestVclntDuration::RTestVclntDuration(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aDuration)
sl@0
   634
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   635
    {
sl@0
   636
    iDuration = aDuration;
sl@0
   637
    }
sl@0
   638
sl@0
   639
/**
sl@0
   640
 * RTestVclntDuration::Constructor
sl@0
   641
 */
sl@0
   642
RTestVclntDuration* RTestVclntDuration::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aDuration)
sl@0
   643
    {
sl@0
   644
    RTestVclntDuration* self = new (ELeave) RTestVclntDuration(aTestName, aSectName, aKeyName, aExpectedError, aDuration);
sl@0
   645
    return self;
sl@0
   646
    }
sl@0
   647
sl@0
   648
/**
sl@0
   649
 * RTestVclntDuration::Constructor
sl@0
   650
 */
sl@0
   651
TVerdict RTestVclntDuration::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   652
    {
sl@0
   653
    TVerdict ret = EFail;
sl@0
   654
    
sl@0
   655
    INFO_PRINTF1(_L("Test : Video Player - Duration"));
sl@0
   656
sl@0
   657
    if (I64INT(iDuration.Int64()) == 0)
sl@0
   658
        {
sl@0
   659
        TInt duration = I64INT(aPlayer->DurationL().Int64());
sl@0
   660
        INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   661
        PrepareState(EVPPlayComplete, KErrNone);
sl@0
   662
        aPlayer->Play();
sl@0
   663
        TTime start;
sl@0
   664
        start.HomeTime();
sl@0
   665
        CActiveScheduler::Start();
sl@0
   666
        TTime stop;
sl@0
   667
        stop.HomeTime();
sl@0
   668
sl@0
   669
        TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
sl@0
   670
sl@0
   671
        INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
sl@0
   672
            iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
sl@0
   673
        if((iError == KErrNone) && (TimeComparison(actualDuration, duration, KExpectedDeviation)))
sl@0
   674
            {
sl@0
   675
            ret = EPass;
sl@0
   676
            }
sl@0
   677
        }
sl@0
   678
    else
sl@0
   679
        {
sl@0
   680
        if(aPlayer->DurationL() == iDuration)
sl@0
   681
            {
sl@0
   682
            ret = EPass;
sl@0
   683
            }
sl@0
   684
        }
sl@0
   685
    
sl@0
   686
    CActiveScheduler::Stop();
sl@0
   687
    TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)iCurrentCacheSize.iMinSize,(TAny*)iCurrentCacheSize.iMaxSize);
sl@0
   688
    if(CheckCacheError(error)==EInconclusive)
sl@0
   689
    	{
sl@0
   690
    	return EInconclusive;
sl@0
   691
    	}
sl@0
   692
    INFO_PRINTF3(_L("Setting Cache Min Size to %d,Setting Cache Max Size is %d"),iCurrentCacheSize.iMinSize,iCurrentCacheSize.iMaxSize);
sl@0
   693
    return ret;
sl@0
   694
    }
sl@0
   695
sl@0
   696
TVerdict RTestVclntDuration::SetCacheSize()
sl@0
   697
	{
sl@0
   698
	TVerdict ret=EPass;
sl@0
   699
	//save the default cache sizes, set the cache size back these values after the test
sl@0
   700
	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&iCurrentCacheSize,0);
sl@0
   701
	ret=CheckCacheError(error);
sl@0
   702
	if(ret==EPass)
sl@0
   703
		{
sl@0
   704
		error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)KCacheSize,(TAny*)KMaxCacheSize);
sl@0
   705
		ret=CheckCacheError(error);
sl@0
   706
		}
sl@0
   707
	return ret;
sl@0
   708
	}
sl@0
   709
sl@0
   710
TVerdict RTestVclntDuration::CheckCacheError(TInt aError)
sl@0
   711
	{
sl@0
   712
	TVerdict verdict=EPass;
sl@0
   713
	#ifdef __WINSCW__
sl@0
   714
	//Winscw does not support getting cache size. Ignoring -5 error
sl@0
   715
	if(aError!=KErrNone)
sl@0
   716
		{
sl@0
   717
		if(aError!=KErrNotSupported)
sl@0
   718
			{
sl@0
   719
			INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
sl@0
   720
			return EInconclusive;
sl@0
   721
			}
sl@0
   722
		}
sl@0
   723
	#else
sl@0
   724
	if(aError!=KErrNone)
sl@0
   725
		{//For ARMV5 we stop for all errors
sl@0
   726
		INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
sl@0
   727
		return EInconclusive;
sl@0
   728
		}
sl@0
   729
	#endif
sl@0
   730
	return verdict;
sl@0
   731
	}
sl@0
   732
sl@0
   733
//
sl@0
   734
// RTestVclntVolume
sl@0
   735
//
sl@0
   736
sl@0
   737
/**
sl@0
   738
 * RTestVclntVolume::Constructor
sl@0
   739
 */
sl@0
   740
RTestVclntVolume::RTestVclntVolume(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aVolume)
sl@0
   741
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   742
    {
sl@0
   743
    iVolume = aVolume;
sl@0
   744
    }
sl@0
   745
sl@0
   746
/**
sl@0
   747
 * RTestVclntVolume::Constructor
sl@0
   748
 */
sl@0
   749
RTestVclntVolume* RTestVclntVolume::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aVolume)
sl@0
   750
    {
sl@0
   751
    RTestVclntVolume* self = new (ELeave) RTestVclntVolume(aTestName, aSectName, aKeyName, aExpectedError, aVolume);
sl@0
   752
    return self;
sl@0
   753
    }
sl@0
   754
sl@0
   755
/**
sl@0
   756
 * RTestVclntVolume::Constructor
sl@0
   757
 */
sl@0
   758
TVerdict RTestVclntVolume::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
   759
    {
sl@0
   760
    TVerdict ret = EFail;
sl@0
   761
    TInt err;
sl@0
   762
    
sl@0
   763
    INFO_PRINTF1(_L("Test : Video Player - Volume"));
sl@0
   764
    
sl@0
   765
    // see if audio is enabled
sl@0
   766
    if (aPlayer->AudioEnabledL())
sl@0
   767
        {
sl@0
   768
        INFO_PRINTF1(_L("AudioEnabledL() returned True"));
sl@0
   769
        }
sl@0
   770
    else
sl@0
   771
        {
sl@0
   772
        INFO_PRINTF1(_L("AudioEnabledL() returned False"));   
sl@0
   773
        }
sl@0
   774
    
sl@0
   775
    // Check maxvolume function
sl@0
   776
    if(iVolume == -1)
sl@0
   777
        {
sl@0
   778
        iVolume = aPlayer->MaxVolume();
sl@0
   779
        TRAP(err, aPlayer->SetVolumeL(iVolume));
sl@0
   780
        INFO_PRINTF2(_L("Volume should be set to Max Volume. Returned with %d"), err);
sl@0
   781
        INFO_PRINTF3(_L("Volume = %d (expecting %d)"), aPlayer->Volume(), aPlayer->MaxVolume());
sl@0
   782
        if(aPlayer->Volume() == aPlayer->MaxVolume())
sl@0
   783
            {
sl@0
   784
            ret = EPass;
sl@0
   785
            }
sl@0
   786
        }
sl@0
   787
    // Volume should truncated to maxvolume
sl@0
   788
    else if(iVolume > aPlayer->MaxVolume())
sl@0
   789
        {
sl@0
   790
        TRAP(err, aPlayer->SetVolumeL(iVolume));
sl@0
   791
        INFO_PRINTF2(_L("Volume should be set to Max Volume. Returned with %d"), err);
sl@0
   792
        INFO_PRINTF3(_L("Volume = %d, MaxVolume = %d"), aPlayer->Volume(), aPlayer->MaxVolume());
sl@0
   793
        if(aPlayer->Volume() == aPlayer->MaxVolume())
sl@0
   794
            {
sl@0
   795
            ret = EPass;
sl@0
   796
            }
sl@0
   797
        }
sl@0
   798
    // Volume is truncated to 0
sl@0
   799
    else if(iVolume < 0)
sl@0
   800
        {
sl@0
   801
        TRAP(err, aPlayer->SetVolumeL(iVolume));
sl@0
   802
        INFO_PRINTF2(_L("Volume should be set to Min Volume.Returned with %d"), err);
sl@0
   803
        INFO_PRINTF2(_L("Volume = %d (expecting 0)"), aPlayer->Volume());
sl@0
   804
        if(aPlayer->Volume() == 0)
sl@0
   805
            {
sl@0
   806
            ret = EPass;
sl@0
   807
            }
sl@0
   808
        }
sl@0
   809
    // Set volume and check
sl@0
   810
    else
sl@0
   811
        {
sl@0
   812
        TRAP(err, aPlayer->SetVolumeL(iVolume));
sl@0
   813
        INFO_PRINTF2(_L("Volume should be set to the desired value. Retuned with %d"), err);
sl@0
   814
        INFO_PRINTF3(_L("Volume = %d (expecting %d)"), aPlayer->Volume(), iVolume);
sl@0
   815
        if(aPlayer->Volume() == iVolume)
sl@0
   816
            {
sl@0
   817
            ret = EPass;
sl@0
   818
            }
sl@0
   819
        }
sl@0
   820
    
sl@0
   821
    CActiveScheduler::Stop();
sl@0
   822
    
sl@0
   823
    return ret;
sl@0
   824
    }
sl@0
   825
sl@0
   826
//
sl@0
   827
// RTestVclntCloseOpen
sl@0
   828
//
sl@0
   829
sl@0
   830
/**
sl@0
   831
 * RTestVclntCloseOpen::Constructor
sl@0
   832
 */
sl@0
   833
RTestVclntCloseOpen::RTestVclntCloseOpen(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   834
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
   835
    {
sl@0
   836
    iOpenCount = 1;
sl@0
   837
    }
sl@0
   838
sl@0
   839
/**
sl@0
   840
 * RTestVclntCloseOpen::Constructor
sl@0
   841
 */
sl@0
   842
RTestVclntCloseOpen* RTestVclntCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   843
    {
sl@0
   844
    RTestVclntCloseOpen* self = new (ELeave) RTestVclntCloseOpen(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   845
    return self;
sl@0
   846
    }
sl@0
   847
sl@0
   848
/**
sl@0
   849
 * RTestVclntCloseOpen::DoTestStepL
sl@0
   850
 */
sl@0
   851
TVerdict RTestVclntCloseOpen::DoTestStepL()
sl@0
   852
    {
sl@0
   853
    // Call the state handler from IDLE state
sl@0
   854
    FsmL(EVPIdle);
sl@0
   855
    
sl@0
   856
    // Start the scheduler - Done only once !
sl@0
   857
    CActiveScheduler::Start();
sl@0
   858
    
sl@0
   859
    return iTestStepResult;
sl@0
   860
    }
sl@0
   861
sl@0
   862
/**
sl@0
   863
 * RTestVclntCloseOpen::FsmL
sl@0
   864
 */
sl@0
   865
void RTestVclntCloseOpen::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   866
    {
sl@0
   867
    if (FsmCheck(aEventCode))
sl@0
   868
        {
sl@0
   869
        switch (aEventCode)
sl@0
   870
            {
sl@0
   871
            case EVPIdle:
sl@0
   872
                // Open iVideoPlayer First time
sl@0
   873
                iOpenCount = 1;
sl@0
   874
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL(%S)"), &iFilename);
sl@0
   875
                TRAP(iError,iVideoPlayer->OpenFileL(iFilename, ControllerUid()));
sl@0
   876
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   877
                break;
sl@0
   878
            case EVPOpenComplete:
sl@0
   879
                if (iOpenCount == 1)
sl@0
   880
                    {
sl@0
   881
                    // Prepare iVideoPlayer
sl@0
   882
                    INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
   883
                    iVideoPlayer->Prepare();
sl@0
   884
                    PrepareState(EVPPrepareComplete, KErrNone);    
sl@0
   885
                    }
sl@0
   886
                else
sl@0
   887
                    {
sl@0
   888
                    CActiveScheduler::Stop();
sl@0
   889
                    iTestStepResult = EPass;
sl@0
   890
                    break;
sl@0
   891
                    }
sl@0
   892
                break;
sl@0
   893
            case EVPPrepareComplete:
sl@0
   894
                // Close iVideoPlayer
sl@0
   895
                CActiveScheduler::Stop();
sl@0
   896
                INFO_PRINTF1(_L("iVideoPlayer->Close()"));
sl@0
   897
                iVideoPlayer->Close();
sl@0
   898
                User::After(KOneSecond);
sl@0
   899
                // Open iVideoPlayer Second time
sl@0
   900
                iOpenCount = 2;
sl@0
   901
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL(%S)"), &iFilename);
sl@0
   902
                iVideoPlayer->OpenFileL(iFilename, ControllerUid());
sl@0
   903
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   904
                CActiveScheduler::Start();
sl@0
   905
                break;
sl@0
   906
            }
sl@0
   907
        }
sl@0
   908
    }
sl@0
   909
sl@0
   910
//
sl@0
   911
// RTestVclntPause
sl@0
   912
//
sl@0
   913
sl@0
   914
/**
sl@0
   915
 * RTestVclntPause::Constructor
sl@0
   916
 */
sl@0
   917
RTestVclntPause::RTestVclntPause(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   918
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
   919
    {}
sl@0
   920
sl@0
   921
/**
sl@0
   922
 * RTestVclntPause::NewL
sl@0
   923
 */
sl@0
   924
RTestVclntPause* RTestVclntPause::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
   925
    {
sl@0
   926
    RTestVclntPause* self = new (ELeave) RTestVclntPause(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
   927
    return self;
sl@0
   928
    }
sl@0
   929
sl@0
   930
/**
sl@0
   931
 * RTestVclntPause::DoTestStepL
sl@0
   932
 */
sl@0
   933
TVerdict RTestVclntPause::DoTestStepL()
sl@0
   934
    {
sl@0
   935
    // Call the state handler from IDLE state
sl@0
   936
    FsmL(EVPIdle);
sl@0
   937
    
sl@0
   938
    // Start the scheduler - Done only once !
sl@0
   939
    CActiveScheduler::Start();
sl@0
   940
    
sl@0
   941
    return iTestStepResult;
sl@0
   942
    }
sl@0
   943
sl@0
   944
/**
sl@0
   945
 * RTestVclntPause::FsmL
sl@0
   946
 */
sl@0
   947
void RTestVclntPause::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
   948
    {
sl@0
   949
    TTime stop;
sl@0
   950
    TTime start = NULL;
sl@0
   951
    
sl@0
   952
    if (FsmCheck(aEventCode))
sl@0
   953
        {
sl@0
   954
        switch (aEventCode)
sl@0
   955
            {
sl@0
   956
            case EVPIdle:
sl@0
   957
                // Open iVideoPlayer
sl@0
   958
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
   959
                TRAP(iError, iVideoPlayer->OpenFileL(iFilename, ControllerUid()));
sl@0
   960
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
   961
                break;
sl@0
   962
            case EVPOpenComplete:
sl@0
   963
                // Prepare iVideoPlayer
sl@0
   964
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
   965
                iVideoPlayer->Prepare();
sl@0
   966
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
   967
                break;
sl@0
   968
            case EVPPrepareComplete:
sl@0
   969
                // Play iVideoPlayer
sl@0
   970
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   971
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
   972
                iVideoPlayer->Play();
sl@0
   973
                // Pause iVideoPlayer
sl@0
   974
                INFO_PRINTF1(_L("iVideoPlayer->Pause()"));
sl@0
   975
                TRAPD(err,iVideoPlayer->PauseL());
sl@0
   976
                if (err == KErrNotSupported)
sl@0
   977
                    {
sl@0
   978
                    INFO_PRINTF1(_L("Pause not supported presently"));
sl@0
   979
                    }
sl@0
   980
                else
sl@0
   981
                    {
sl@0
   982
                    INFO_PRINTF2(_L("Pause() returns with error :  %d"),err);
sl@0
   983
                    iTestStepResult = EFail;
sl@0
   984
                    CActiveScheduler::Stop();
sl@0
   985
                    break;
sl@0
   986
                    }
sl@0
   987
                // Stop iVideoPlayer
sl@0
   988
                INFO_PRINTF1(_L("iVideoPlayer->Stop()"));
sl@0
   989
                iVideoPlayer->Stop();
sl@0
   990
                // Get the duration of the file.
sl@0
   991
                iPlayerDuration = I64INT(iVideoPlayer->DurationL().Int64());
sl@0
   992
                // Resume play iVideoPlayer
sl@0
   993
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
   994
                iVideoPlayer->Play();
sl@0
   995
                // Note the start time
sl@0
   996
                start.HomeTime();    
sl@0
   997
                break;
sl@0
   998
            case EVPPlayComplete:
sl@0
   999
                // Note the stop time
sl@0
  1000
                stop.HomeTime();
sl@0
  1001
                // Get the actual duration
sl@0
  1002
                iActualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
sl@0
  1003
                INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d PlayerDuration = %d ActualDuration = %d"),
sl@0
  1004
                    iError, I64INT(start.Int64()), I64INT(stop.Int64()), iPlayerDuration, iActualDuration);
sl@0
  1005
                // Check the results
sl@0
  1006
                if((iError == KErrNone) && (TimeComparison(iActualDuration, iPlayerDuration, KExpectedDeviation)))
sl@0
  1007
                    {
sl@0
  1008
                    iTestStepResult = EPass;
sl@0
  1009
                    }
sl@0
  1010
                CActiveScheduler::Stop();
sl@0
  1011
                break;
sl@0
  1012
            }
sl@0
  1013
        }
sl@0
  1014
    }
sl@0
  1015
sl@0
  1016
//
sl@0
  1017
// RTestVclntBalance
sl@0
  1018
//
sl@0
  1019
sl@0
  1020
/**
sl@0
  1021
 * RTestVclntBalance::Constructor
sl@0
  1022
 */
sl@0
  1023
RTestVclntBalance::RTestVclntBalance(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aBalance)
sl@0
  1024
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
  1025
    {
sl@0
  1026
    iBalance = aBalance;
sl@0
  1027
    }
sl@0
  1028
sl@0
  1029
/**
sl@0
  1030
 * RTestVclntBalance::NewL
sl@0
  1031
 */
sl@0
  1032
RTestVclntBalance* RTestVclntBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TInt aBalance)
sl@0
  1033
    {
sl@0
  1034
    RTestVclntBalance* self = new (ELeave) RTestVclntBalance(aTestName, aSectName, aKeyName, aExpectedError, aBalance);
sl@0
  1035
    return self;
sl@0
  1036
    }
sl@0
  1037
sl@0
  1038
/**
sl@0
  1039
 * RTestVclntBalance::DoTestL
sl@0
  1040
 */
sl@0
  1041
TVerdict RTestVclntBalance::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1042
    {
sl@0
  1043
    TVerdict ret = EFail;
sl@0
  1044
    TInt err = KErrNone;
sl@0
  1045
    
sl@0
  1046
    INFO_PRINTF1(_L("Test : Video Player - Balance"));
sl@0
  1047
    
sl@0
  1048
    // see if audio is enabled
sl@0
  1049
    if (aPlayer->AudioEnabledL())
sl@0
  1050
        {
sl@0
  1051
        INFO_PRINTF1(_L("AudioEnabledL() returned True"));
sl@0
  1052
        }
sl@0
  1053
    else
sl@0
  1054
        {
sl@0
  1055
        INFO_PRINTF1(_L("AudioEnabledL() returned False"));   
sl@0
  1056
        }
sl@0
  1057
    
sl@0
  1058
    // set the balance
sl@0
  1059
    TRAP(err, aPlayer->SetBalanceL(iBalance));
sl@0
  1060
    INFO_PRINTF2(_L("SetBalanceL() left with Error - %d"), err);
sl@0
  1061
    
sl@0
  1062
    // check for the valid balance    
sl@0
  1063
    if (iBalance < KMinBalance)
sl@0
  1064
        {
sl@0
  1065
        INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMinBalance);
sl@0
  1066
        if(aPlayer->Balance() == KMinBalance)
sl@0
  1067
            {
sl@0
  1068
            ret = EPass;
sl@0
  1069
            }
sl@0
  1070
        }
sl@0
  1071
    else if (iBalance > KMaxBalance)
sl@0
  1072
        {
sl@0
  1073
        INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), KMaxBalance);
sl@0
  1074
        if(aPlayer->Balance() == KMaxBalance)
sl@0
  1075
            {
sl@0
  1076
            ret = EPass;
sl@0
  1077
            }
sl@0
  1078
        }
sl@0
  1079
    else
sl@0
  1080
        {
sl@0
  1081
        INFO_PRINTF3(_L("Balance = %d (expecting %d)"), aPlayer->Balance(), iBalance);
sl@0
  1082
        if(aPlayer->Balance() == iBalance)
sl@0
  1083
            {
sl@0
  1084
            ret = EPass;
sl@0
  1085
            }
sl@0
  1086
        }
sl@0
  1087
    
sl@0
  1088
    CActiveScheduler::Stop();
sl@0
  1089
    
sl@0
  1090
    return ret;
sl@0
  1091
    }
sl@0
  1092
sl@0
  1093
sl@0
  1094
//
sl@0
  1095
// RTestVclntPlayWindow
sl@0
  1096
//
sl@0
  1097
sl@0
  1098
/**
sl@0
  1099
 * RTestVclntPlayWindow::Constructor
sl@0
  1100
 */
sl@0
  1101
RTestVclntPlayWindow::RTestVclntPlayWindow(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
sl@0
  1102
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
  1103
    {
sl@0
  1104
    iStart = aStart;
sl@0
  1105
    iEnd = aEnd;
sl@0
  1106
    }
sl@0
  1107
sl@0
  1108
/**
sl@0
  1109
 * RTestVclntPlayWindow::Constructor
sl@0
  1110
 */
sl@0
  1111
RTestVclntPlayWindow* RTestVclntPlayWindow::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TTimeIntervalMicroSeconds aStart, const TTimeIntervalMicroSeconds aEnd)
sl@0
  1112
    {
sl@0
  1113
    RTestVclntPlayWindow* self = new (ELeave) RTestVclntPlayWindow(aTestName, aSectName, aKeyName, aExpectedError, aStart, aEnd);
sl@0
  1114
    return self;
sl@0
  1115
    }
sl@0
  1116
sl@0
  1117
/**
sl@0
  1118
 * RTestVclntPlayWindow::Constructor
sl@0
  1119
 */
sl@0
  1120
TVerdict RTestVclntPlayWindow::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1121
    {
sl@0
  1122
    TVerdict ret = EFail;
sl@0
  1123
sl@0
  1124
    INFO_PRINTF1(_L("Test : Video Player - Window"));
sl@0
  1125
sl@0
  1126
    TPoint rectOrigin(10, 10);
sl@0
  1127
    TSize rectSize(176, 144);
sl@0
  1128
    TRect rect(rectOrigin, rectSize);
sl@0
  1129
    
sl@0
  1130
    TPoint clipOrigin(10, 10);
sl@0
  1131
    TSize clipSize(176, 144);
sl@0
  1132
    TRect clipRect(clipOrigin, clipSize);
sl@0
  1133
    
sl@0
  1134
    // first call tests creation of display instance
sl@0
  1135
    TRAPD(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
sl@0
  1136
    INFO_PRINTF1(_L("Test : Made first call to SetDisplayWindowL()"));
sl@0
  1137
    if(err)
sl@0
  1138
        {
sl@0
  1139
        ERR_PRINTF2(_L("First call to SetDisplayWindowL() failed, error %d"), err);
sl@0
  1140
        CActiveScheduler::Stop();
sl@0
  1141
        return EFail;
sl@0
  1142
        }
sl@0
  1143
sl@0
  1144
    // second call tests update of display instance
sl@0
  1145
    TRAP(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
sl@0
  1146
    INFO_PRINTF1(_L("Test : Made second call to SetDisplayWindowL()"));
sl@0
  1147
    if(err)
sl@0
  1148
        {
sl@0
  1149
        ERR_PRINTF2(_L("Second call to SetDisplayWindowL() failed, error %d"), err);
sl@0
  1150
        ret = EFail;
sl@0
  1151
        }
sl@0
  1152
    else
sl@0
  1153
        {
sl@0
  1154
        ret = EPass;
sl@0
  1155
        }
sl@0
  1156
sl@0
  1157
    CActiveScheduler::Stop();
sl@0
  1158
    return ret;
sl@0
  1159
    }
sl@0
  1160
sl@0
  1161
sl@0
  1162
//
sl@0
  1163
// RTestVclntMeta
sl@0
  1164
//
sl@0
  1165
sl@0
  1166
/**
sl@0
  1167
 * RTestVclntMeta::Constructor
sl@0
  1168
 */
sl@0
  1169
RTestVclntMeta::RTestVclntMeta(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1170
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
  1171
    {}
sl@0
  1172
sl@0
  1173
/**
sl@0
  1174
 * RTestVclntMeta::Constructor
sl@0
  1175
 */
sl@0
  1176
RTestVclntMeta* RTestVclntMeta::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1177
    {
sl@0
  1178
    RTestVclntMeta* self = new (ELeave) RTestVclntMeta(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1179
    return self;
sl@0
  1180
    }
sl@0
  1181
sl@0
  1182
/**
sl@0
  1183
 * RTestVclntMeta::Constructor
sl@0
  1184
 */
sl@0
  1185
TVerdict RTestVclntMeta::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1186
    {
sl@0
  1187
    INFO_PRINTF1(_L("Test : Video Player - Metadata"));
sl@0
  1188
    
sl@0
  1189
    CActiveScheduler::Stop();
sl@0
  1190
    
sl@0
  1191
    // there are zero meta entries now.
sl@0
  1192
    TInt numOfMeta = -1;
sl@0
  1193
    TRAPD(err, numOfMeta = aPlayer->NumberOfMetaDataEntriesL() );
sl@0
  1194
    INFO_PRINTF3(_L("Error : %d Entries = %d"), err, numOfMeta);
sl@0
  1195
    if (err != KErrNotSupported || numOfMeta != -1)
sl@0
  1196
        {
sl@0
  1197
        return EFail;
sl@0
  1198
        }
sl@0
  1199
    
sl@0
  1200
    // attempt to get an entry when no entry exists.
sl@0
  1201
    CMMFMetaDataEntry* theEntry=NULL;
sl@0
  1202
    TRAP(err, theEntry = aPlayer->MetaDataEntryL(1));
sl@0
  1203
    INFO_PRINTF2(_L("Error : %d"), err);
sl@0
  1204
    if (err != KErrNotSupported)
sl@0
  1205
        {
sl@0
  1206
        return EFail;
sl@0
  1207
        }
sl@0
  1208
    else 
sl@0
  1209
        {
sl@0
  1210
        delete theEntry;
sl@0
  1211
        return EPass;
sl@0
  1212
        }
sl@0
  1213
    }
sl@0
  1214
sl@0
  1215
sl@0
  1216
//
sl@0
  1217
// RTestVclntFrameSize
sl@0
  1218
//
sl@0
  1219
sl@0
  1220
/**
sl@0
  1221
 * RTestVclntFrameSize::Constructor
sl@0
  1222
 */
sl@0
  1223
RTestVclntFrameSize::RTestVclntFrameSize(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1224
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse)
sl@0
  1225
    {
sl@0
  1226
    iFrameSize.iWidth = 0;
sl@0
  1227
    iFrameSize.iHeight = 0;
sl@0
  1228
    }
sl@0
  1229
sl@0
  1230
/**
sl@0
  1231
 * RTestVclntFrameSize::NewL
sl@0
  1232
 */
sl@0
  1233
RTestVclntFrameSize* RTestVclntFrameSize::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1234
    {
sl@0
  1235
    RTestVclntFrameSize* self = new (ELeave) RTestVclntFrameSize(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1236
    return self;
sl@0
  1237
    }
sl@0
  1238
sl@0
  1239
/**
sl@0
  1240
 * RTestVclntFrameSize::DoTestL
sl@0
  1241
 */
sl@0
  1242
TVerdict RTestVclntFrameSize::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1243
    {
sl@0
  1244
    TVerdict ret = EFail;
sl@0
  1245
sl@0
  1246
    INFO_PRINTF1(_L("Test : Video Player - Get Frame Size"));
sl@0
  1247
    TInt err;
sl@0
  1248
    TRAP(err, aPlayer->VideoFrameSizeL(iFrameSize));
sl@0
  1249
sl@0
  1250
    INFO_PRINTF4(_L("Error : %d, Frame size : (%d, %d)"), err, iFrameSize.iWidth, iFrameSize.iHeight);
sl@0
  1251
    if (err == KErrNone && iFrameSize.iWidth >= 0 && iFrameSize.iHeight >= 0 )
sl@0
  1252
        {
sl@0
  1253
        ret = EPass;
sl@0
  1254
        }
sl@0
  1255
    
sl@0
  1256
    CActiveScheduler::Stop();
sl@0
  1257
    
sl@0
  1258
    return ret;
sl@0
  1259
    }
sl@0
  1260
sl@0
  1261
//
sl@0
  1262
// RTestVclntMimeType
sl@0
  1263
//
sl@0
  1264
sl@0
  1265
/**
sl@0
  1266
 * RTestVclntMimeType::Constructor
sl@0
  1267
 */
sl@0
  1268
RTestVclntMimeType::RTestVclntMimeType(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1269
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1270
    {
sl@0
  1271
    }
sl@0
  1272
sl@0
  1273
/**
sl@0
  1274
 * RTestVclntMimeType::Constructor
sl@0
  1275
 */
sl@0
  1276
RTestVclntMimeType* RTestVclntMimeType::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1277
    {
sl@0
  1278
    RTestVclntMimeType* self = new (ELeave) RTestVclntMimeType(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1279
    return self;
sl@0
  1280
    }
sl@0
  1281
sl@0
  1282
/**
sl@0
  1283
 * RTestVclntMimeType::Constructor
sl@0
  1284
 */
sl@0
  1285
TVerdict RTestVclntMimeType::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1286
    {
sl@0
  1287
        
sl@0
  1288
    TVerdict ret = EFail;
sl@0
  1289
    
sl@0
  1290
    INFO_PRINTF1(_L("Test : Video Player - MimeType"));
sl@0
  1291
sl@0
  1292
    // Get the Video Mime type
sl@0
  1293
    TPtrC8 mimeType = aPlayer->VideoFormatMimeType();
sl@0
  1294
sl@0
  1295
    // take it to a 16-bit string
sl@0
  1296
    TBuf<64> mimeType16;
sl@0
  1297
    mimeType16.Copy(mimeType);
sl@0
  1298
    INFO_PRINTF2(_L("Mime type : \'%S\'"), &mimeType16);
sl@0
  1299
    
sl@0
  1300
    // Check if its valid
sl@0
  1301
    if (mimeType16.Compare(_L("XVID")) == 0)
sl@0
  1302
        {
sl@0
  1303
        INFO_PRINTF1(_L("MIME Types match"));
sl@0
  1304
        ret = EPass;
sl@0
  1305
        }
sl@0
  1306
    
sl@0
  1307
    CActiveScheduler::Stop();
sl@0
  1308
    
sl@0
  1309
    return ret;
sl@0
  1310
    }
sl@0
  1311
sl@0
  1312
//
sl@0
  1313
// RTestVclntScale
sl@0
  1314
//
sl@0
  1315
sl@0
  1316
/**
sl@0
  1317
 * RTestVclntScale::Constructor
sl@0
  1318
 */
sl@0
  1319
RTestVclntScale::RTestVclntScale(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1320
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1321
    {
sl@0
  1322
    }
sl@0
  1323
sl@0
  1324
/**
sl@0
  1325
 * RTestVclntScale::Constructor
sl@0
  1326
 */
sl@0
  1327
RTestVclntScale* RTestVclntScale::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1328
    {
sl@0
  1329
    RTestVclntScale* self = new (ELeave) RTestVclntScale(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1330
    return self;
sl@0
  1331
    }
sl@0
  1332
sl@0
  1333
/**
sl@0
  1334
 * RTestVclntScale::Constructor
sl@0
  1335
 */
sl@0
  1336
TVerdict RTestVclntScale::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1337
    {
sl@0
  1338
    INFO_PRINTF1(_L("Test : Video Player - Scale Values test"));
sl@0
  1339
    
sl@0
  1340
    CActiveScheduler::Stop();
sl@0
  1341
    
sl@0
  1342
    // Set the scale factor using values set #1
sl@0
  1343
    INFO_PRINTF1(_L("iVideoPlayer->SetScaleFactorL() #1"));
sl@0
  1344
    TRAPD(err, aPlayer->SetScaleFactorL(100, 100, ETrue));
sl@0
  1345
sl@0
  1346
#ifdef SYMBIAN_BUILD_GCE
sl@0
  1347
	TInt expected = iBinaryCompatibility || !GCEAvailable() ? KErrNotSupported : KErrNone;
sl@0
  1348
#else
sl@0
  1349
	TInt expected = KErrNotSupported;
sl@0
  1350
#endif
sl@0
  1351
sl@0
  1352
    if (err != expected)
sl@0
  1353
        {       
sl@0
  1354
        ERR_PRINTF2(_L("iVideoPlayer->SetScaleFactorL() encountered error : %d"), err);
sl@0
  1355
        return EFail;
sl@0
  1356
        }
sl@0
  1357
sl@0
  1358
    return EPass;
sl@0
  1359
    }
sl@0
  1360
sl@0
  1361
//
sl@0
  1362
// RTestVclntCrop
sl@0
  1363
//
sl@0
  1364
sl@0
  1365
/**
sl@0
  1366
 * RTestVclntCrop::Constructor
sl@0
  1367
 */
sl@0
  1368
RTestVclntCrop::RTestVclntCrop(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1369
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1370
    {
sl@0
  1371
    }
sl@0
  1372
sl@0
  1373
/**
sl@0
  1374
 * RTestVclntCrop::Constructor
sl@0
  1375
 */
sl@0
  1376
RTestVclntCrop* RTestVclntCrop::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1377
    {
sl@0
  1378
    RTestVclntCrop* self = new (ELeave) RTestVclntCrop(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1379
    return self;
sl@0
  1380
    }
sl@0
  1381
sl@0
  1382
/**
sl@0
  1383
 * RTestVclntCrop::Constructor
sl@0
  1384
 */
sl@0
  1385
TVerdict RTestVclntCrop::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1386
    {
sl@0
  1387
    TRect cropRegion(KCropRegionRectLeft, KCropRegionRectTop, KCropRegionRectRight, KCropRegionRectBottom);
sl@0
  1388
    TRect region;
sl@0
  1389
    
sl@0
  1390
    INFO_PRINTF1(_L("Test : Video Player - Crop Values"));
sl@0
  1391
    
sl@0
  1392
    CActiveScheduler::Stop();
sl@0
  1393
sl@0
  1394
    // Set the Crop Region
sl@0
  1395
    INFO_PRINTF1(_L("iVideoPlayer->SetCropRegionL()"));
sl@0
  1396
    TRAPD(err, aPlayer->SetCropRegionL(cropRegion));
sl@0
  1397
    
sl@0
  1398
#ifdef SYMBIAN_BUILD_GCE
sl@0
  1399
	TInt expected = iBinaryCompatibility || !GCEAvailable() ? KErrNotSupported : KErrNone;
sl@0
  1400
#else
sl@0
  1401
	TInt expected = KErrNotSupported;
sl@0
  1402
#endif
sl@0
  1403
sl@0
  1404
    if (err != expected)
sl@0
  1405
        {       
sl@0
  1406
        ERR_PRINTF2(_L("iVideoPlayer->SetCropRegionL() encountered error : %d"), err);
sl@0
  1407
        return EFail;
sl@0
  1408
        }
sl@0
  1409
sl@0
  1410
    return EPass;
sl@0
  1411
    }
sl@0
  1412
    
sl@0
  1413
#ifdef SYMBIAN_BUILD_GCE
sl@0
  1414
sl@0
  1415
RTestVclntAutoScale::RTestVclntAutoScale(const TDesC& aTestName)
sl@0
  1416
    : RTestVclntPlayAviFile(aTestName, KNullDesC, KNullDesC, KErrNone, EFalse)
sl@0
  1417
    {
sl@0
  1418
    }
sl@0
  1419
sl@0
  1420
/**
sl@0
  1421
 * RTestVclntCrop::Constructor
sl@0
  1422
 */
sl@0
  1423
RTestVclntAutoScale* RTestVclntAutoScale::NewL(const TDesC& aTestName)
sl@0
  1424
    {
sl@0
  1425
    RTestVclntAutoScale* self = new (ELeave) RTestVclntAutoScale(aTestName);
sl@0
  1426
    return self;
sl@0
  1427
    }
sl@0
  1428
sl@0
  1429
/**
sl@0
  1430
 * RTestVclntCrop::Constructor
sl@0
  1431
 */
sl@0
  1432
TVerdict RTestVclntAutoScale::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1433
    {
sl@0
  1434
    INFO_PRINTF1(_L("Test : Video Player - AutoScale Values"));
sl@0
  1435
    
sl@0
  1436
    CActiveScheduler::Stop();
sl@0
  1437
sl@0
  1438
    // Set auto scale
sl@0
  1439
    INFO_PRINTF1(_L("iVideoPlayer->SetAutoScaleL()"));
sl@0
  1440
    TRAPD(err, aPlayer->SetAutoScaleL(EAutoScaleBestFit));
sl@0
  1441
sl@0
  1442
    if (err != KErrNone)
sl@0
  1443
        {
sl@0
  1444
        ERR_PRINTF2(_L("iVideoPlayer->SetAutoScaleL() encountered error : %d"), err);
sl@0
  1445
        return EFail;
sl@0
  1446
        }
sl@0
  1447
sl@0
  1448
    TRAP(err, aPlayer->SetAutoScaleL(EAutoScaleNone));
sl@0
  1449
sl@0
  1450
    if (err != KErrNone)
sl@0
  1451
        {
sl@0
  1452
        ERR_PRINTF2(_L("iVideoPlayer->SetAutoScaleL() encountered error : %d"), err);
sl@0
  1453
        return EFail;
sl@0
  1454
        }
sl@0
  1455
sl@0
  1456
    TRAP(err, aPlayer->SetAutoScaleL(EAutoScaleClip));
sl@0
  1457
sl@0
  1458
    if (err != KErrNone)
sl@0
  1459
        {
sl@0
  1460
        ERR_PRINTF2(_L("iVideoPlayer->SetAutoScaleL() encountered error : %d"), err);
sl@0
  1461
        return EFail;
sl@0
  1462
        }
sl@0
  1463
sl@0
  1464
    TRAP(err, aPlayer->SetAutoScaleL(EAutoScaleStretch, EHorizontalAlignLeft, EVerticalAlignBottom));
sl@0
  1465
sl@0
  1466
    if (err != KErrNone)
sl@0
  1467
        {
sl@0
  1468
        ERR_PRINTF2(_L("iVideoPlayer->SetAutoScaleL() encountered error : %d"), err);
sl@0
  1469
        return EFail;
sl@0
  1470
        }
sl@0
  1471
sl@0
  1472
    return EPass;
sl@0
  1473
    }
sl@0
  1474
sl@0
  1475
#endif // SYMBIAN_BUILD_GCE
sl@0
  1476
sl@0
  1477
//
sl@0
  1478
// RTestVclntGetFrame
sl@0
  1479
//
sl@0
  1480
sl@0
  1481
/**
sl@0
  1482
 * RTestVclntGetFrame::Constructor
sl@0
  1483
 */
sl@0
  1484
RTestVclntGetFrame::RTestVclntGetFrame(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, TBool aUseIntentAPI)
sl@0
  1485
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError, EFalse), iUseIntentAPI(aUseIntentAPI)
sl@0
  1486
    {
sl@0
  1487
    }
sl@0
  1488
sl@0
  1489
/**
sl@0
  1490
 * RTestVclntGetFrame::Constructor
sl@0
  1491
 */
sl@0
  1492
RTestVclntGetFrame* RTestVclntGetFrame::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, TBool aUseIntentAPI)
sl@0
  1493
    {
sl@0
  1494
    RTestVclntGetFrame* self = new (ELeave) RTestVclntGetFrame(aTestName, aSectName, aKeyName, aExpectedError, aUseIntentAPI);
sl@0
  1495
    return self;
sl@0
  1496
    }
sl@0
  1497
sl@0
  1498
/**
sl@0
  1499
 * RTestVclntGetFrame::DoTestStepL
sl@0
  1500
 */
sl@0
  1501
TVerdict RTestVclntGetFrame::DoTestStepL()
sl@0
  1502
    {
sl@0
  1503
    // Call the state handler from IDLE state
sl@0
  1504
    FsmL(EVPIdle);
sl@0
  1505
    
sl@0
  1506
    // Start the scheduler - Done only once !
sl@0
  1507
    CActiveScheduler::Start();
sl@0
  1508
    
sl@0
  1509
    return iTestStepResult;
sl@0
  1510
    }
sl@0
  1511
sl@0
  1512
/**
sl@0
  1513
 * RTestVclntGetFrame::FsmL
sl@0
  1514
 */
sl@0
  1515
void RTestVclntGetFrame::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  1516
    {
sl@0
  1517
    if (FsmCheck(aEventCode))
sl@0
  1518
        {
sl@0
  1519
        switch (aEventCode)
sl@0
  1520
            {
sl@0
  1521
            case EVPIdle:
sl@0
  1522
                // Open iVideoPlayer
sl@0
  1523
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL(%S)"), &iFilename);
sl@0
  1524
                TRAP(iError,iVideoPlayer->OpenFileL(iFilename, ControllerUid()));
sl@0
  1525
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  1526
                break;
sl@0
  1527
            case EVPOpenComplete:
sl@0
  1528
                // Prepare iVideoPlayer
sl@0
  1529
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  1530
                iVideoPlayer->Prepare();
sl@0
  1531
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  1532
                break;
sl@0
  1533
            case EVPPrepareComplete:
sl@0
  1534
                // Play iVideoPlayer
sl@0
  1535
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  1536
                iVideoPlayer->Play();
sl@0
  1537
                // Call GetFrameL
sl@0
  1538
                if (iUseIntentAPI)
sl@0
  1539
                    {
sl@0
  1540
                    INFO_PRINTF1(_L("iVideoPlayer->GetFrameL() with EPeek Intent"));
sl@0
  1541
                    TRAP(iError, iVideoPlayer->GetFrameL(EColor16M, ContentAccess::EPeek));
sl@0
  1542
                    INFO_PRINTF2(_L("iVideoPlayer->GetFrameL() left with error - %d"), iError);
sl@0
  1543
                    }
sl@0
  1544
                else 
sl@0
  1545
                    {
sl@0
  1546
                    INFO_PRINTF1(_L("iVideoPlayer->GetFrameL()"));
sl@0
  1547
                    TRAP(iError, iVideoPlayer->GetFrameL(EColor16M));
sl@0
  1548
                    INFO_PRINTF2(_L("iVideoPlayer->GetFrameL() left with error - %d"), iError);
sl@0
  1549
                    }
sl@0
  1550
                PrepareState(EVPFrameReady, KErrNone);
sl@0
  1551
            case EVPFrameReady:
sl@0
  1552
                // Stop iVideoPlayer
sl@0
  1553
                iVideoPlayer->Stop();
sl@0
  1554
                CActiveScheduler::Stop();
sl@0
  1555
                iTestStepResult = EPass;
sl@0
  1556
                break;
sl@0
  1557
            }
sl@0
  1558
        }
sl@0
  1559
    }
sl@0
  1560
sl@0
  1561
/**
sl@0
  1562
 * RTestVclntGetFrame::MvpuoFrameReady
sl@0
  1563
 * Overriding the callback method here, to check the bitmap..
sl@0
  1564
 */
sl@0
  1565
void RTestVclntGetFrame::MvpuoFrameReady(CFbsBitmap& aFrame, TInt aError)
sl@0
  1566
    {
sl@0
  1567
    if (aError!=KErrNone)
sl@0
  1568
        {
sl@0
  1569
        iError = aError;
sl@0
  1570
        }
sl@0
  1571
    else if (aFrame.Handle() == NULL || aFrame.SizeInPixels() != TSize(KFrameWidth, KFrameHeight) )
sl@0
  1572
        {
sl@0
  1573
        iError = KErrArgument;
sl@0
  1574
        ERR_PRINTF1(_L("The Frame returned is either NULL or there is a mismatch in the size.."));
sl@0
  1575
        }
sl@0
  1576
    TRAP(iError, FsmL(EVPFrameReady));
sl@0
  1577
    INFO_PRINTF2(_L("Error code : %d"),iError);
sl@0
  1578
    }
sl@0
  1579
sl@0
  1580
    
sl@0
  1581
//
sl@0
  1582
// RTestVclntRebuffering
sl@0
  1583
//
sl@0
  1584
sl@0
  1585
/**
sl@0
  1586
 * RTestVclntRebuffering::Constructor
sl@0
  1587
 */
sl@0
  1588
RTestVclntRebuffering::RTestVclntRebuffering(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1589
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1590
    {
sl@0
  1591
    }
sl@0
  1592
sl@0
  1593
/**
sl@0
  1594
 * RTestVclntRebuffering::NewL
sl@0
  1595
 */
sl@0
  1596
RTestVclntRebuffering* RTestVclntRebuffering::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1597
    {
sl@0
  1598
    RTestVclntRebuffering* self = new (ELeave) RTestVclntRebuffering(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1599
    return self;
sl@0
  1600
    }
sl@0
  1601
sl@0
  1602
/**
sl@0
  1603
 * RTestVclntRebuffering::DoTestL
sl@0
  1604
 */
sl@0
  1605
TVerdict RTestVclntRebuffering::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1606
    {
sl@0
  1607
    INFO_PRINTF1(_L("Test : Video Player - Rebuffering"));
sl@0
  1608
sl@0
  1609
    aPlayer->RegisterForVideoLoadingNotification(*this);
sl@0
  1610
sl@0
  1611
    INFO_PRINTF1(_L("Rebuffering request completed"));
sl@0
  1612
    
sl@0
  1613
    CActiveScheduler::Stop();
sl@0
  1614
    
sl@0
  1615
    return EPass;
sl@0
  1616
    }
sl@0
  1617
sl@0
  1618
/**
sl@0
  1619
 * RTestVclntRebuffering::MvloLoadingStarted
sl@0
  1620
 */
sl@0
  1621
void RTestVclntRebuffering::MvloLoadingStarted()
sl@0
  1622
    {
sl@0
  1623
    INFO_PRINTF1(_L("RTestVclntRebuffering::MvloLoadingStarted"));
sl@0
  1624
    }
sl@0
  1625
sl@0
  1626
/**
sl@0
  1627
 * RTestVclntRebuffering::MvloLoadingComplete
sl@0
  1628
 */
sl@0
  1629
void RTestVclntRebuffering::MvloLoadingComplete()
sl@0
  1630
    {
sl@0
  1631
    INFO_PRINTF1(_L("RTestVclntRebuffering::MvloLoadingComplete"));
sl@0
  1632
    }
sl@0
  1633
sl@0
  1634
//
sl@0
  1635
// RTestVclntRepeat
sl@0
  1636
//
sl@0
  1637
sl@0
  1638
/**
sl@0
  1639
 * RTestVclntRepeat::Constructor
sl@0
  1640
 */
sl@0
  1641
RTestVclntRepeat::RTestVclntRepeat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TInt aRepeat)
sl@0
  1642
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1643
    {
sl@0
  1644
    iRepeat = aRepeat;
sl@0
  1645
    }
sl@0
  1646
sl@0
  1647
/**
sl@0
  1648
 * RTestVclntRepeat::NewL
sl@0
  1649
 */
sl@0
  1650
RTestVclntRepeat* RTestVclntRepeat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError,const TInt aRepeat)
sl@0
  1651
    {
sl@0
  1652
    RTestVclntRepeat* self = new (ELeave) RTestVclntRepeat(aTestName, aSectName, aKeyName, aExpectedError, aRepeat);
sl@0
  1653
    return self;
sl@0
  1654
    }
sl@0
  1655
sl@0
  1656
/**
sl@0
  1657
 * RTestVclntRepeat::DoTestL
sl@0
  1658
  */
sl@0
  1659
  //The commented lines are kept for future implementation
sl@0
  1660
  
sl@0
  1661
TVerdict RTestVclntRepeat::DoTestL(CVideoPlayerUtility* aPlayer)
sl@0
  1662
    {
sl@0
  1663
    TVerdict ret = EFail;
sl@0
  1664
sl@0
  1665
    INFO_PRINTF1(_L("Test : Video Player - Repeats"));
sl@0
  1666
    iRepeat = 1;
sl@0
  1667
    INFO_PRINTF1(_L("Warning : SetRepeats() does not exist in iVideoPlayer API. Repeat count set to 1"));
sl@0
  1668
    
sl@0
  1669
    INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  1670
    PrepareState(EVPPlayComplete, KErrNone);
sl@0
  1671
    aPlayer->Play();
sl@0
  1672
    
sl@0
  1673
    CActiveScheduler::Start();
sl@0
  1674
    
sl@0
  1675
    if(iError == KErrNotSupported || iRepeat == 1) 
sl@0
  1676
        {
sl@0
  1677
        ret = EPass;    
sl@0
  1678
        INFO_PRINTF2(_L("Repeat not supported currently : err : %d"),iError);   
sl@0
  1679
        }
sl@0
  1680
    else
sl@0
  1681
        {
sl@0
  1682
        ret = EFail;
sl@0
  1683
        INFO_PRINTF2(_L("Returned with : err : %d"),iError);   
sl@0
  1684
        }    
sl@0
  1685
        
sl@0
  1686
    CActiveScheduler::Stop();
sl@0
  1687
    
sl@0
  1688
    return ret;
sl@0
  1689
    }
sl@0
  1690
sl@0
  1691
//
sl@0
  1692
// RTestVclntDelete
sl@0
  1693
//
sl@0
  1694
sl@0
  1695
/**
sl@0
  1696
 * RTestVclntDelete::Constructor
sl@0
  1697
 */
sl@0
  1698
RTestVclntDelete::RTestVclntDelete(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1699
    : RTestVclntPlayAviFile(aTestName, aSectName, aKeyName, aExpectedError,EFalse)
sl@0
  1700
    {}
sl@0
  1701
sl@0
  1702
/**
sl@0
  1703
 * RTestVclntDelete::NewL
sl@0
  1704
 */
sl@0
  1705
RTestVclntDelete* RTestVclntDelete::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  1706
    {
sl@0
  1707
    RTestVclntDelete* self = new (ELeave) RTestVclntDelete(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  1708
    return self;
sl@0
  1709
    }
sl@0
  1710
sl@0
  1711
/**
sl@0
  1712
 * RTestVclntDelete::DoTestStepL
sl@0
  1713
 */
sl@0
  1714
TVerdict RTestVclntDelete::DoTestStepL()
sl@0
  1715
    {
sl@0
  1716
    // Call the state handler from IDLE state
sl@0
  1717
    FsmL(EVPIdle);
sl@0
  1718
    
sl@0
  1719
    // Start the scheduler - Done only once !
sl@0
  1720
    CActiveScheduler::Start();
sl@0
  1721
    
sl@0
  1722
    return iTestStepResult;
sl@0
  1723
    }
sl@0
  1724
sl@0
  1725
/**
sl@0
  1726
 * RTestVclntDelete::FsmL
sl@0
  1727
 */
sl@0
  1728
void RTestVclntDelete::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  1729
    {
sl@0
  1730
    if (FsmCheck(aEventCode))
sl@0
  1731
        {
sl@0
  1732
        switch (aEventCode)
sl@0
  1733
            {
sl@0
  1734
            case EVPIdle:
sl@0
  1735
                // Open iVideoPlayer
sl@0
  1736
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL(%S)"), &iFilename);
sl@0
  1737
                TRAP(iError,iVideoPlayer->OpenFileL(iFilename, ControllerUid()));
sl@0
  1738
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  1739
                break;
sl@0
  1740
            case EVPOpenComplete:
sl@0
  1741
                // Prepare iVideoPlayer
sl@0
  1742
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  1743
                iVideoPlayer->Prepare();
sl@0
  1744
                PrepareState(EVPPrepareComplete, KErrNone);    
sl@0
  1745
                break;
sl@0
  1746
            case EVPPrepareComplete:
sl@0
  1747
                // Play iVideoPlayer
sl@0
  1748
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  1749
                iVideoPlayer->Play();
sl@0
  1750
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
  1751
                INFO_PRINTF1(_L("delete iVideoPlayer before Play completes"));
sl@0
  1752
                
sl@0
  1753
                iVideoPlayer = NULL;
sl@0
  1754
                delete iVideoPlayer; // destroy iVideoPlayer before play has completed
sl@0
  1755
                
sl@0
  1756
                CActiveScheduler::Stop();
sl@0
  1757
                iTestStepResult = EPass;
sl@0
  1758
                break;
sl@0
  1759
            }
sl@0
  1760
        }
sl@0
  1761
    }
sl@0
  1762
sl@0
  1763
//
sl@0
  1764
// RTestVclntPlayAviFileHandle
sl@0
  1765
//
sl@0
  1766
sl@0
  1767
/**
sl@0
  1768
 * RTestVclntPlayAviFileHandle::Constructor
sl@0
  1769
 */
sl@0
  1770
RTestVclntPlayAviFileHandle::RTestVclntPlayAviFileHandle(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError, const TBool aAlloc)
sl@0
  1771
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError), iAlloc(aAlloc)
sl@0
  1772
    {
sl@0
  1773
    iIsOpen = EFalse;
sl@0
  1774
    }
sl@0
  1775
sl@0
  1776
/**
sl@0
  1777
 * RTestVclntPlayAviFileHandle::NewL
sl@0
  1778
 */
sl@0
  1779
RTestVclntPlayAviFileHandle* RTestVclntPlayAviFileHandle::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TBool aAlloc)
sl@0
  1780
    {
sl@0
  1781
    RTestVclntPlayAviFileHandle* self = new (ELeave) RTestVclntPlayAviFileHandle(aTestName, aSectName, aKeyName, aExpectedError, aAlloc);
sl@0
  1782
    return self;
sl@0
  1783
    }
sl@0
  1784
sl@0
  1785
/**
sl@0
  1786
 * RTestVclntPlayAviFileHandle::NewLC
sl@0
  1787
 */
sl@0
  1788
RTestVclntPlayAviFileHandle* RTestVclntPlayAviFileHandle::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError, const TBool aAlloc)
sl@0
  1789
    {
sl@0
  1790
    RTestVclntPlayAviFileHandle* self = new (ELeave) RTestVclntPlayAviFileHandle(aTestName, aSectName, aKeyName, aExpectedError, aAlloc);
sl@0
  1791
    CleanupStack::PushL(self);
sl@0
  1792
    return self;
sl@0
  1793
    }
sl@0
  1794
sl@0
  1795
/**
sl@0
  1796
 * RTestVclntPlayAviFileHandle::DoTestStepL()
sl@0
  1797
 */
sl@0
  1798
TVerdict RTestVclntPlayAviFileHandle::DoTestStepL()
sl@0
  1799
    {
sl@0
  1800
	if(SetCacheSize()!=KErrNone)
sl@0
  1801
    	{
sl@0
  1802
    	return EInconclusive;
sl@0
  1803
    	}
sl@0
  1804
sl@0
  1805
    if (iAlloc)
sl@0
  1806
        {
sl@0
  1807
        TVerdict iAllocTestStepResult=EPass;
sl@0
  1808
        TInt err = KErrNone;
sl@0
  1809
        TBool result = EFalse;
sl@0
  1810
        
sl@0
  1811
        //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
sl@0
  1812
        if( PerformTestStepL() != EPass )
sl@0
  1813
            {
sl@0
  1814
            err = iError;
sl@0
  1815
            }
sl@0
  1816
sl@0
  1817
        if (err != KErrNone)
sl@0
  1818
            {
sl@0
  1819
            INFO_PRINTF2(_L("Test error, returned error code =  %d"), err);
sl@0
  1820
            User::Leave(err);
sl@0
  1821
            }
sl@0
  1822
        else
sl@0
  1823
            {
sl@0
  1824
            //Check the iAllocTestStepResult
sl@0
  1825
            if (iAllocTestStepResult != EPass)
sl@0
  1826
                {
sl@0
  1827
                result = ETrue;
sl@0
  1828
                }
sl@0
  1829
            }    
sl@0
  1830
        
sl@0
  1831
        TInt failCount = 1;
sl@0
  1832
        TBool completed = EFalse;
sl@0
  1833
        iAllocTestStepResult = EPass; // XXX check?? assume pass
sl@0
  1834
        TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
sl@0
  1835
        for(;;)    
sl@0
  1836
            {
sl@0
  1837
            __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
sl@0
  1838
            __MM_HEAP_MARK;
sl@0
  1839
            
sl@0
  1840
             //INFO_PRINTF2(_L("CVideoPlayerUtility: Alloc Test Loop: %d"), failCount);
sl@0
  1841
            //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
sl@0
  1842
            TVerdict verdict = EFail;
sl@0
  1843
            TRAP(err, verdict = PerformTestStepL());
sl@0
  1844
            if (err == KErrNone && verdict != EPass)
sl@0
  1845
                {
sl@0
  1846
                err = iError;
sl@0
  1847
                }
sl@0
  1848
sl@0
  1849
            completed = EFalse;
sl@0
  1850
            if (err == KErrNone)
sl@0
  1851
                {
sl@0
  1852
                TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
sl@0
  1853
                if (testAlloc == NULL)
sl@0
  1854
                    {
sl@0
  1855
                    reachedEnd = ETrue;
sl@0
  1856
                    failCount -= 1;
sl@0
  1857
                    }
sl@0
  1858
                else
sl@0
  1859
                    {
sl@0
  1860
                    User::Free(testAlloc);    
sl@0
  1861
                    }            
sl@0
  1862
                
sl@0
  1863
                //Check the iAllocTestStepResult
sl@0
  1864
                if (iAllocTestStepResult != EPass)
sl@0
  1865
                    {
sl@0
  1866
                    result = ETrue;
sl@0
  1867
                    }
sl@0
  1868
                
sl@0
  1869
                completed = reachedEnd || result;
sl@0
  1870
                }
sl@0
  1871
            else if (err != KErrNoMemory) // bad error code
sl@0
  1872
                {
sl@0
  1873
                completed = ETrue;
sl@0
  1874
                result = EFail;
sl@0
  1875
                }            
sl@0
  1876
sl@0
  1877
            __MM_HEAP_MARKEND;
sl@0
  1878
            __UHEAP_SETFAIL(RHeap::ENone, 0);
sl@0
  1879
sl@0
  1880
            if (completed)
sl@0
  1881
                {
sl@0
  1882
                break; // exit loop
sl@0
  1883
                }
sl@0
  1884
sl@0
  1885
            failCount++;
sl@0
  1886
            }
sl@0
  1887
sl@0
  1888
        failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
sl@0
  1889
sl@0
  1890
        if (err != KErrNone || result)
sl@0
  1891
            {
sl@0
  1892
            iAllocTestStepResult = EFail;
sl@0
  1893
            TBuf<80> format;
sl@0
  1894
            if (result)
sl@0
  1895
                {
sl@0
  1896
                format.Format(_L("  Bad result with %d memory allocations tested\n"), failCount);
sl@0
  1897
                }
sl@0
  1898
            else
sl@0
  1899
                {
sl@0
  1900
                format.Format(_L("  Error(%d) with %d memory allocations tested\n"), err, failCount);
sl@0
  1901
                }
sl@0
  1902
            Log(format);
sl@0
  1903
            }
sl@0
  1904
        else 
sl@0
  1905
            {
sl@0
  1906
            TBuf<80> format;
sl@0
  1907
            format.Format(_L("  Completed OK with %d memory allocations tested\n"), failCount);
sl@0
  1908
            Log(format);
sl@0
  1909
            }
sl@0
  1910
    	TUint defaultCacheSize = 0; 
sl@0
  1911
    	//Done with the test. Setting 0 makes the cache size revert back to boot up values
sl@0
  1912
    	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)defaultCacheSize,(TAny*)defaultCacheSize);
sl@0
  1913
        if(CheckCacheError(error)!=KErrNone)
sl@0
  1914
        	{
sl@0
  1915
        	INFO_PRINTF1(_L("Could not revert the cache size to default"));
sl@0
  1916
        	iAllocTestStepResult=EInconclusive;
sl@0
  1917
        	}
sl@0
  1918
        return iAllocTestStepResult;
sl@0
  1919
        }
sl@0
  1920
    else
sl@0
  1921
        {
sl@0
  1922
        return( PerformTestStepL() );    
sl@0
  1923
        }
sl@0
  1924
    }
sl@0
  1925
sl@0
  1926
/**
sl@0
  1927
 * RTestVclntPlayAviFileHandle::PerformTestStepL()
sl@0
  1928
 */
sl@0
  1929
TVerdict RTestVclntPlayAviFileHandle::PerformTestStepL()
sl@0
  1930
    {
sl@0
  1931
    INFO_PRINTF1(_L("Test : Video Player - OpenFileL(RFile&)"));
sl@0
  1932
    
sl@0
  1933
    // Connect to RFs
sl@0
  1934
    User::LeaveIfError(iFs.Connect());
sl@0
  1935
    User::LeaveIfError(iFs.ShareProtected());
sl@0
  1936
    CleanupClosePushL(iFs);
sl@0
  1937
    
sl@0
  1938
    // Open RFile
sl@0
  1939
    User::LeaveIfError(iFile.Open(iFs, iFilename, EFileRead));
sl@0
  1940
    CleanupClosePushL(iFile);
sl@0
  1941
    
sl@0
  1942
    // Call the state handler from IDLE state
sl@0
  1943
    iError = KErrNone;
sl@0
  1944
    PrepareState(EVPIdle, KErrNone);
sl@0
  1945
    FsmL(EVPIdle);
sl@0
  1946
    
sl@0
  1947
    // Start the scheduler - Done only once !
sl@0
  1948
    CActiveScheduler::Start();
sl@0
  1949
    
sl@0
  1950
    CleanupStack::PopAndDestroy(2);
sl@0
  1951
    
sl@0
  1952
    // Leave if the Expected error is KErrNone    
sl@0
  1953
    if (iTestExpectedError == KErrNone)
sl@0
  1954
        {
sl@0
  1955
        User::LeaveIfError(iError);
sl@0
  1956
        }
sl@0
  1957
sl@0
  1958
    return iTestStepResult;
sl@0
  1959
    }
sl@0
  1960
sl@0
  1961
sl@0
  1962
/**
sl@0
  1963
 * RTestVclntPlayAviFileHandle::FsmL()
sl@0
  1964
 */
sl@0
  1965
void RTestVclntPlayAviFileHandle::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  1966
    {
sl@0
  1967
    if (FsmCheck(aEventCode))
sl@0
  1968
        {
sl@0
  1969
        switch (aEventCode)
sl@0
  1970
            {
sl@0
  1971
            case EVPIdle:
sl@0
  1972
                // Open iVideoPlayer
sl@0
  1973
                if ((iTestStepName.Compare(_L("MM-MMF-VCLNTAVI-I-1013-HP")) == 0) ||
sl@0
  1974
                	(iTestStepName.Compare(_L("MM-MMF-VCLNTAVI-I-9113-HP")) == 0))
sl@0
  1975
                    {
sl@0
  1976
                    INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S with Invalid Controller UID"), &iFilename);
sl@0
  1977
                    TRAP(iError, iVideoPlayer->OpenFileL(iFile, KVideoInvalidControllerUid));
sl@0
  1978
                    INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() returned error - %d"), iError);
sl@0
  1979
                    PrepareState(EVPOpenComplete, KErrNone);
sl@0
  1980
                    }
sl@0
  1981
                else
sl@0
  1982
                    {
sl@0
  1983
                    INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
  1984
                	iVideoPlayer->OpenFileL(iFile, ControllerUid());
sl@0
  1985
                    PrepareState(EVPOpenComplete, KErrNone);
sl@0
  1986
                    }
sl@0
  1987
                break;
sl@0
  1988
            case EVPOpenComplete:
sl@0
  1989
                iIsOpen = ETrue; //-set iIsOpen flag (for closing Player, in case of Underflow)...
sl@0
  1990
                // Prepare iVideoPlayer
sl@0
  1991
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  1992
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  1993
                iVideoPlayer->Prepare();
sl@0
  1994
                break;
sl@0
  1995
            case EVPPrepareComplete:
sl@0
  1996
                // Play iVideoPlayer
sl@0
  1997
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  1998
                iVideoPlayer->Play();
sl@0
  1999
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2000
                break;
sl@0
  2001
            case EVPPlayComplete:
sl@0
  2002
                iVideoPlayer->Stop();
sl@0
  2003
                iVideoPlayer->Close();
sl@0
  2004
                CActiveScheduler::Stop();
sl@0
  2005
                iTestStepResult = EPass;
sl@0
  2006
                break;
sl@0
  2007
            }
sl@0
  2008
        }
sl@0
  2009
    else if(iIsOpen)
sl@0
  2010
        {
sl@0
  2011
        iVideoPlayer->Close();
sl@0
  2012
        }
sl@0
  2013
    }
sl@0
  2014
sl@0
  2015
TInt RTestVclntPlayAviFileHandle::SetCacheSize()
sl@0
  2016
	{
sl@0
  2017
	TInt error=UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)KCacheSize,(TAny*)KMaxCacheSize);
sl@0
  2018
	TInt ret=CheckCacheError(error);
sl@0
  2019
		
sl@0
  2020
	return ret;
sl@0
  2021
	}
sl@0
  2022
sl@0
  2023
TInt RTestVclntPlayAviFileHandle::CheckCacheError(TInt aError)
sl@0
  2024
	{
sl@0
  2025
	TInt ret=KErrNone;
sl@0
  2026
	#ifdef __WINSCW__
sl@0
  2027
	//Winscw does not support getting cache size. Ignoring -5 error
sl@0
  2028
	if(aError!=KErrNone)
sl@0
  2029
		{
sl@0
  2030
		if(aError!=KErrNotSupported)
sl@0
  2031
			{
sl@0
  2032
			INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
sl@0
  2033
			ret=aError;
sl@0
  2034
			}
sl@0
  2035
		}
sl@0
  2036
	#else
sl@0
  2037
	if(aError!=KErrNone)
sl@0
  2038
		{//For ARMV5 we stop for all errors
sl@0
  2039
		INFO_PRINTF2(_L("Could not get the cache size  %d"),aError);
sl@0
  2040
		ret=aError;
sl@0
  2041
		}
sl@0
  2042
	#endif
sl@0
  2043
	return ret;
sl@0
  2044
	}
sl@0
  2045
sl@0
  2046
sl@0
  2047
//
sl@0
  2048
// RTestVideoPlayCapabilityVelocity
sl@0
  2049
//
sl@0
  2050
sl@0
  2051
/**
sl@0
  2052
RTestVideoPlayCapabilityVelocity::Constructor
sl@0
  2053
*/
sl@0
  2054
RTestVideoPlayCapabilityVelocity::RTestVideoPlayCapabilityVelocity(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2055
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2056
    { ;
sl@0
  2057
    }
sl@0
  2058
sl@0
  2059
/**
sl@0
  2060
RTestVideoPlayCapabilityVelocity::NewL
sl@0
  2061
*/
sl@0
  2062
RTestVideoPlayCapabilityVelocity* RTestVideoPlayCapabilityVelocity::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2063
	{
sl@0
  2064
    RTestVideoPlayCapabilityVelocity* self = new (ELeave) RTestVideoPlayCapabilityVelocity(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2065
    return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
sl@0
  2066
    }
sl@0
  2067
sl@0
  2068
/**
sl@0
  2069
RTestVideoPlayCapabilityVelocity::DoTestStepL()
sl@0
  2070
*/
sl@0
  2071
TVerdict RTestVideoPlayCapabilityVelocity::DoTestStepL()
sl@0
  2072
    {
sl@0
  2073
    // Call the state handler from IDLE state
sl@0
  2074
    TRAPD(err, FsmL(EVPIdle));
sl@0
  2075
    if (err == KErrNone)
sl@0
  2076
        {
sl@0
  2077
        // Start the scheduler - Done only once !
sl@0
  2078
        CActiveScheduler::Start();    
sl@0
  2079
        }
sl@0
  2080
    return iTestStepResult;  
sl@0
  2081
    }
sl@0
  2082
/**
sl@0
  2083
RTestVideoPlayCapabilityVelocity::FsmL()
sl@0
  2084
*/
sl@0
  2085
void RTestVideoPlayCapabilityVelocity::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  2086
    {
sl@0
  2087
    const TUint KVelocityDefault = 100;
sl@0
  2088
    const TUint KVelocityMinPositive = 1;
sl@0
  2089
    const TInt KVelocityMinNegative = -1;
sl@0
  2090
    const TUint KVelocityPositive = 200;
sl@0
  2091
    const TUint KVelocityBigPositive = 500;
sl@0
  2092
    const TInt KVelocityNegative = -200;
sl@0
  2093
    const TInt KVelocityBigNegative= -500;
sl@0
  2094
    //Set default value for PlayRateCapability
sl@0
  2095
    iVideoPlayRateCapabilities.iStepForward = 1;
sl@0
  2096
    iVideoPlayRateCapabilities.iPlayBackward = 0;
sl@0
  2097
    if (FsmCheck(aEventCode))
sl@0
  2098
        {
sl@0
  2099
        TInt err;
sl@0
  2100
        switch (aEventCode)
sl@0
  2101
            {
sl@0
  2102
            case EVPIdle:
sl@0
  2103
	        	//Calling GetPlayRateCapabilitiesL() before opening should return KErrNotReady.
sl@0
  2104
	        	INFO_PRINTF1(_L("iVideoPlayer->GetPlayRateCapabilitiesL()"));            	
sl@0
  2105
	            TRAP(err,iVideoPlayer->GetPlayRateCapabilitiesL(iVideoPlayRateCapabilities));
sl@0
  2106
	            if( err != KErrNotReady)
sl@0
  2107
	            	{
sl@0
  2108
	            	INFO_PRINTF2(_L("GetPlayRateCapabilitiesL returned wrong err= %d"), err);
sl@0
  2109
	                iTestStepResult = EFail;
sl@0
  2110
	                CActiveScheduler::Stop();
sl@0
  2111
	                return;                	
sl@0
  2112
	            	}
sl@0
  2113
	            iPlayVelocity = KVelocityDefault;
sl@0
  2114
	        	//Calling SetPlayVelocityL() before opening should return KErrNotReady.
sl@0
  2115
	        	INFO_PRINTF2(_L("iVideoPlayer->SetPlayVelocityL(%d)"),iPlayVelocity);
sl@0
  2116
                TRAP(err, iVideoPlayer->SetPlayVelocityL(iPlayVelocity));
sl@0
  2117
                if(KErrNotReady != err)
sl@0
  2118
                	{
sl@0
  2119
                	INFO_PRINTF2(_L("SetPlayVelocityL returned wrong err= %d"), err);
sl@0
  2120
                    iTestStepResult = EFail;
sl@0
  2121
                    CActiveScheduler::Stop();
sl@0
  2122
                    return;
sl@0
  2123
                	}
sl@0
  2124
sl@0
  2125
                //calling PlayVelocityL before opening should result in error KErrNotReady
sl@0
  2126
            	INFO_PRINTF1(_L("iVideoPlayer->PlayVelocityL()"));            	
sl@0
  2127
                TRAP(err, iPlayVelocity = iVideoPlayer->PlayVelocityL());
sl@0
  2128
                if( err != KErrNotReady)
sl@0
  2129
                	{
sl@0
  2130
                	INFO_PRINTF2(_L("PlayVelocityL returned wrong err= %d"), err);
sl@0
  2131
                    iTestStepResult = EFail;
sl@0
  2132
                    CActiveScheduler::Stop();
sl@0
  2133
                    return;
sl@0
  2134
                	}
sl@0
  2135
                
sl@0
  2136
                // Open iVideoPlayer
sl@0
  2137
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
  2138
                iVideoPlayer->OpenFileL(iFilename);
sl@0
  2139
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  2140
                break;
sl@0
  2141
            case EVPOpenComplete:
sl@0
  2142
            	//Get playrate capabilities
sl@0
  2143
            	INFO_PRINTF1(_L("iVideoPlayer->GetPlayRateCapabilitiesL()"));            	
sl@0
  2144
                TRAP(err,iVideoPlayer->GetPlayRateCapabilitiesL(iVideoPlayRateCapabilities));
sl@0
  2145
                if( err != KErrNone)
sl@0
  2146
                	{
sl@0
  2147
                	INFO_PRINTF2(_L("GetPlayRateCapabilitiesL returned err= %d"), err);
sl@0
  2148
                	INFO_PRINTF1(_L("invalid TPlayRateCapabilities"));
sl@0
  2149
                    iTestStepResult = EFail;
sl@0
  2150
                    CActiveScheduler::Stop();
sl@0
  2151
                    return;                	
sl@0
  2152
                	}
sl@0
  2153
            	INFO_PRINTF2(_L("iVideoPlayRateCapabilities.iPlayForward= %d"), iVideoPlayRateCapabilities.iPlayForward);
sl@0
  2154
                INFO_PRINTF2(_L("iVideoPlayRateCapabilities.iPlayBackward= %d"), iVideoPlayRateCapabilities.iPlayBackward);
sl@0
  2155
                INFO_PRINTF2(_L("iVideoPlayRateCapabilities.iStepForward= %d"), iVideoPlayRateCapabilities.iStepForward);
sl@0
  2156
                INFO_PRINTF2(_L("iVideoPlayRateCapabilities.iStepBackward= %d"), iVideoPlayRateCapabilities.iStepBackward);                
sl@0
  2157
                if ((iVideoPlayRateCapabilities.iPlayForward != 0) && (iVideoPlayRateCapabilities.iPlayForward != 1)||
sl@0
  2158
                	(iVideoPlayRateCapabilities.iPlayBackward != 0) && (iVideoPlayRateCapabilities.iPlayBackward != 1)||
sl@0
  2159
                	(iVideoPlayRateCapabilities.iStepForward != 0) && (iVideoPlayRateCapabilities.iStepForward != 1)||
sl@0
  2160
                	(iVideoPlayRateCapabilities.iStepBackward != 0) && (iVideoPlayRateCapabilities.iStepBackward != 1) )
sl@0
  2161
                	{
sl@0
  2162
                	INFO_PRINTF1(_L("invalid TPlayRateCapabilities"));
sl@0
  2163
                    iTestStepResult = EFail;
sl@0
  2164
                    CActiveScheduler::Stop();
sl@0
  2165
                    return;
sl@0
  2166
                	}
sl@0
  2167
                
sl@0
  2168
                //Get default play velocity, it shall be 100.
sl@0
  2169
            	INFO_PRINTF1(_L("iVideoPlayer->PlayVelocityL()"));            	
sl@0
  2170
                TRAP(err, iPlayVelocity = iVideoPlayer->PlayVelocityL());
sl@0
  2171
                if( err != KErrNone)
sl@0
  2172
                	{
sl@0
  2173
                	INFO_PRINTF2(_L("PlayVelocityL returned err= %d"), err);
sl@0
  2174
                	INFO_PRINTF1(_L("invalid TPlayRateCapabilities"));
sl@0
  2175
                    iTestStepResult = EFail;
sl@0
  2176
                    CActiveScheduler::Stop();
sl@0
  2177
                    return;                	
sl@0
  2178
                	}
sl@0
  2179
            	
sl@0
  2180
            	if( iPlayVelocity != KVelocityDefault )
sl@0
  2181
            		{
sl@0
  2182
                	INFO_PRINTF2(_L("invalid default play velocity =%d"), iPlayVelocity);
sl@0
  2183
                    iTestStepResult = EFail;
sl@0
  2184
                    CActiveScheduler::Stop();
sl@0
  2185
                    return;
sl@0
  2186
            		}
sl@0
  2187
            	
sl@0
  2188
                // Prepare iVideoPlayer
sl@0
  2189
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  2190
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  2191
                iVideoPlayer->Prepare();
sl@0
  2192
                break;
sl@0
  2193
            case EVPPrepareComplete:
sl@0
  2194
            	//Try to set different play velocities and play.
sl@0
  2195
	        	INFO_PRINTF2(_L("iVideoPlayer->SetPlayVelocityL(%d)"),iPlayVelocity);
sl@0
  2196
                TRAP(err, iVideoPlayer->SetPlayVelocityL(iPlayVelocity));
sl@0
  2197
                if(KErrNotSupported == err)
sl@0
  2198
                	{
sl@0
  2199
                	if(iVideoPlayRateCapabilities.iPlayForward || iVideoPlayRateCapabilities.iPlayBackward)
sl@0
  2200
                		{
sl@0
  2201
	                	INFO_PRINTF2(_L("SetPlayVelocityL returned err= %d"), err);
sl@0
  2202
	                    iTestStepResult = EFail;
sl@0
  2203
	                    CActiveScheduler::Stop();
sl@0
  2204
	                    return;                	
sl@0
  2205
                		}
sl@0
  2206
                	INFO_PRINTF1(_L("SetPlayVelocityL returned err KErrNotSupported"));
sl@0
  2207
                	}
sl@0
  2208
                else if( err != KErrNone)
sl@0
  2209
                	{
sl@0
  2210
                	INFO_PRINTF2(_L("SetPlayVelocityL returned err= %d"), err);
sl@0
  2211
                    iTestStepResult = EFail;
sl@0
  2212
                    CActiveScheduler::Stop();
sl@0
  2213
                    return;                	
sl@0
  2214
                	}	        	
sl@0
  2215
                // Play iVideoPlayer
sl@0
  2216
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2217
                iVideoPlayer->Play();
sl@0
  2218
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2219
                break;
sl@0
  2220
            case EVPPlayComplete:
sl@0
  2221
                //Try to set different play velocities and play.
sl@0
  2222
                if (iVideoPlayRateCapabilities.iPlayForward )
sl@0
  2223
                	{
sl@0
  2224
	                if (iPlayVelocity == KVelocityDefault)
sl@0
  2225
	                	{
sl@0
  2226
	                	iPlayVelocity = KVelocityMinPositive;
sl@0
  2227
	                	}
sl@0
  2228
	                else if(iPlayVelocity == KVelocityMinPositive)
sl@0
  2229
	                	{
sl@0
  2230
	                	iPlayVelocity = KVelocityPositive;
sl@0
  2231
	                	}
sl@0
  2232
	                else if(iPlayVelocity == KVelocityPositive)
sl@0
  2233
	                	{
sl@0
  2234
	                	iPlayVelocity = KVelocityBigPositive;
sl@0
  2235
	                	}
sl@0
  2236
                	}
sl@0
  2237
                if (iVideoPlayRateCapabilities.iPlayBackward )
sl@0
  2238
                	{
sl@0
  2239
	                if (iPlayVelocity == KVelocityBigPositive)
sl@0
  2240
	                	{
sl@0
  2241
	                	iPlayVelocity = KVelocityMinNegative;
sl@0
  2242
	                	}
sl@0
  2243
	                else if(iPlayVelocity == KVelocityMinNegative)
sl@0
  2244
	                	{
sl@0
  2245
	                	iPlayVelocity = KVelocityNegative;
sl@0
  2246
	                	}
sl@0
  2247
	                else if(iPlayVelocity == KVelocityNegative)
sl@0
  2248
	                	{
sl@0
  2249
	                	iPlayVelocity = KVelocityBigNegative;
sl@0
  2250
	                	}
sl@0
  2251
	                else if(iPlayVelocity == KVelocityBigNegative)
sl@0
  2252
	                	{
sl@0
  2253
		                iVideoPlayer->Close();
sl@0
  2254
		                CActiveScheduler::Stop();
sl@0
  2255
		                iTestStepResult = EPass;
sl@0
  2256
		                return;
sl@0
  2257
	                	}
sl@0
  2258
                	}
sl@0
  2259
sl@0
  2260
                //Set next velocity
sl@0
  2261
                INFO_PRINTF2(_L("iVideoPlayer->SetPlayVelocityL(%d)"),iPlayVelocity);
sl@0
  2262
                TRAP(err,iVideoPlayer->SetPlayVelocityL(iPlayVelocity));
sl@0
  2263
                if ( err == KErrNotSupported )
sl@0
  2264
                	{
sl@0
  2265
                		INFO_PRINTF1(_L("iVideoPlayer->SetPlayVelocityL returned KErrNotSupported"));
sl@0
  2266
                		if( (iPlayVelocity >0) && iVideoPlayRateCapabilities.iPlayForward)
sl@0
  2267
                			{
sl@0
  2268
                    		INFO_PRINTF1(_L("PlayVelocity and capabilities are valid, still returned KErrNotSupported!!"));
sl@0
  2269
                        	User::Leave(err);
sl@0
  2270
                			}
sl@0
  2271
                		else if( (iPlayVelocity <0) && iVideoPlayRateCapabilities.iPlayBackward)
sl@0
  2272
                			{
sl@0
  2273
                    		INFO_PRINTF1(_L("PlayVelocity and capabilities are valid still returned KErrNotSupported!!"));                			
sl@0
  2274
                        	User::Leave(err);                			
sl@0
  2275
                			}
sl@0
  2276
                		else
sl@0
  2277
                			{
sl@0
  2278
                            // Play The file once again to test with different play velocity.
sl@0
  2279
                            INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2280
                            iVideoPlayer->Play();
sl@0
  2281
                            PrepareState(EVPPlayComplete, KErrNone);             			
sl@0
  2282
                			}
sl@0
  2283
                	}
sl@0
  2284
                else if (err != KErrNone)
sl@0
  2285
                	{
sl@0
  2286
                    INFO_PRINTF2(_L("iVideoPlayer->SetPlayVelocityL returned (%d)"),err);                	
sl@0
  2287
                	User::Leave(err);
sl@0
  2288
                	}
sl@0
  2289
                else //Success case
sl@0
  2290
                	{
sl@0
  2291
                    // Play The file once again to test with different play velocity.
sl@0
  2292
                    INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2293
                    iVideoPlayer->Play();
sl@0
  2294
                    PrepareState(EVPPlayComplete, KErrNone);                	
sl@0
  2295
                	}
sl@0
  2296
                
sl@0
  2297
                if ((!iVideoPlayRateCapabilities.iPlayForward ) && (!iVideoPlayRateCapabilities.iPlayBackward ))
sl@0
  2298
                	{
sl@0
  2299
                    INFO_PRINTF1(_L("Both forward and backward is not supported"));
sl@0
  2300
                    INFO_PRINTF1(_L("Pass the test, error checking for API SetPlayVelocity is already done."));
sl@0
  2301
	                iVideoPlayer->Close();
sl@0
  2302
	                CActiveScheduler::Stop();
sl@0
  2303
	                iTestStepResult = EPass;
sl@0
  2304
	                return;                	
sl@0
  2305
                	}
sl@0
  2306
                break;
sl@0
  2307
            }
sl@0
  2308
        }
sl@0
  2309
    }
sl@0
  2310
sl@0
  2311
sl@0
  2312
//
sl@0
  2313
// RTestVideoPlayStepFrame
sl@0
  2314
//
sl@0
  2315
sl@0
  2316
/**
sl@0
  2317
RTestVideoPlayStepFrame::Constructor
sl@0
  2318
*/
sl@0
  2319
RTestVideoPlayStepFrame::RTestVideoPlayStepFrame(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2320
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError), iTimer(NULL)
sl@0
  2321
    {
sl@0
  2322
    }
sl@0
  2323
sl@0
  2324
/**
sl@0
  2325
RTestVideoPlayStepFrame::NewL
sl@0
  2326
*/
sl@0
  2327
RTestVideoPlayStepFrame* RTestVideoPlayStepFrame::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2328
	{
sl@0
  2329
    RTestVideoPlayStepFrame* self = new (ELeave) RTestVideoPlayStepFrame(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2330
    return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
sl@0
  2331
    }
sl@0
  2332
sl@0
  2333
/**
sl@0
  2334
RTestVideoPlayStepFrame::DoTestStepL()
sl@0
  2335
*/
sl@0
  2336
TVerdict RTestVideoPlayStepFrame::DoTestStepL()
sl@0
  2337
    {
sl@0
  2338
	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0
  2339
    // Call the state handler from IDLE state
sl@0
  2340
    TRAPD(err, FsmL(EVPIdle));
sl@0
  2341
    if (err == KErrNone)
sl@0
  2342
        {
sl@0
  2343
        // Start the scheduler - Done only once !
sl@0
  2344
        CActiveScheduler::Start();    
sl@0
  2345
        }
sl@0
  2346
	delete iTimer;    
sl@0
  2347
    return iTestStepResult;
sl@0
  2348
    }
sl@0
  2349
sl@0
  2350
/**
sl@0
  2351
RTestVideoPlayStepFrame::FsmL()
sl@0
  2352
*/
sl@0
  2353
void RTestVideoPlayStepFrame::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  2354
    {
sl@0
  2355
    if (FsmCheck(aEventCode))
sl@0
  2356
        {
sl@0
  2357
        TInt err = KErrNone;
sl@0
  2358
    	TInt frame = 0xff;
sl@0
  2359
    	TBool pauseSupported = ETrue;    	
sl@0
  2360
        const TUint KStepForwardZeroFrame = 0;            	
sl@0
  2361
        const TUint KStepForwardOneFrame = 1;
sl@0
  2362
        const TInt KStepBackwardOneFrame = -1;
sl@0
  2363
        const TUint KStepForwardFourFrames = 4;
sl@0
  2364
        const TInt KStepBackwardFourFrames = -4;  
sl@0
  2365
        
sl@0
  2366
        switch (aEventCode)
sl@0
  2367
            {
sl@0
  2368
            case EVPIdle:
sl@0
  2369
	            // Calling StepFrameL() before Opeing file should result KErrNotReady.
sl@0
  2370
	            INFO_PRINTF2(_L("iVideoPlayer->StepFrameL(%d)"),1);
sl@0
  2371
	            TRAP(err,iVideoPlayer->StepFrameL(1));
sl@0
  2372
	            if(err != KErrNotReady)
sl@0
  2373
	            	{
sl@0
  2374
	            	INFO_PRINTF2(_L("StepFrameL returned wrong err= %d"), KErrNotReady);
sl@0
  2375
	                iTestStepResult = EFail;
sl@0
  2376
	                CActiveScheduler::Stop();
sl@0
  2377
	                return;	            	
sl@0
  2378
	            	}
sl@0
  2379
            
sl@0
  2380
                // Open iVideoPlayer
sl@0
  2381
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
  2382
                iVideoPlayer->OpenFileL(iFilename);
sl@0
  2383
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  2384
                break;
sl@0
  2385
            case EVPOpenComplete:
sl@0
  2386
            	//Get playrate capabilities
sl@0
  2387
            	INFO_PRINTF1(_L("iVideoPlayer->GetPlayRateCapabilitiesL()"));            	
sl@0
  2388
                TRAP(err,iVideoPlayer->GetPlayRateCapabilitiesL(iVideoPlayRateCapabilities));
sl@0
  2389
                if( err != KErrNone)
sl@0
  2390
                	{
sl@0
  2391
                	INFO_PRINTF2(_L("GetPlayRateCapabilitiesL returned err= %d"), err);
sl@0
  2392
                    iTestStepResult = EFail;
sl@0
  2393
                    CActiveScheduler::Stop();
sl@0
  2394
                    return;
sl@0
  2395
                	}
sl@0
  2396
                // Calling StepFrameL() in non-pause state should result KErrNotReady.
sl@0
  2397
                INFO_PRINTF2(_L("iVideoPlayer->StepFrameL(%d)"),1);
sl@0
  2398
	            TRAP(err,iVideoPlayer->StepFrameL(1));
sl@0
  2399
	            if(err != KErrNotReady)
sl@0
  2400
	            	{
sl@0
  2401
                	INFO_PRINTF2(_L("StepFrameL returned wrong err= %d"), KErrNotReady);	            	
sl@0
  2402
                    iTestStepResult = EFail;
sl@0
  2403
                    CActiveScheduler::Stop();
sl@0
  2404
                    return;	            	
sl@0
  2405
	            	}
sl@0
  2406
	            	
sl@0
  2407
                // Prepare iVideoPlayer
sl@0
  2408
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  2409
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  2410
                iVideoPlayer->Prepare();
sl@0
  2411
                break;
sl@0
  2412
            case EVPPrepareComplete:
sl@0
  2413
	            // Play iVideoPlayer
sl@0
  2414
	            INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2415
	            iVideoPlayer->Play();
sl@0
  2416
sl@0
  2417
                //wait for 1Second to pause the playback.
sl@0
  2418
                INFO_PRINTF1(_L("calling User::After(KOneSecond);"));
sl@0
  2419
                User::After(KOneSecond);
sl@0
  2420
                
sl@0
  2421
            	/* 
sl@0
  2422
				Pause the playback, if pause is not supported wait for play to complete.
sl@0
  2423
				In case of any other err fail the test with appropriate error code.
sl@0
  2424
				*/
sl@0
  2425
			    TRAP(err, iVideoPlayer->PauseL());
sl@0
  2426
sl@0
  2427
			    if( err == KErrNotSupported)
sl@0
  2428
			    	{
sl@0
  2429
			    	pauseSupported = EFalse;			    	
sl@0
  2430
			    	PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2431
			    	}
sl@0
  2432
			    else if( err != KErrNone)
sl@0
  2433
			    	{
sl@0
  2434
				    INFO_PRINTF2(_L("PauseL has returned error =%d"), err);
sl@0
  2435
		            iVideoPlayer->Stop();
sl@0
  2436
		            iVideoPlayer->Close();
sl@0
  2437
		            CActiveScheduler::Stop();
sl@0
  2438
		            iTestStepResult = EFail;			    	
sl@0
  2439
		            return;
sl@0
  2440
			    	}                
sl@0
  2441
			    
sl@0
  2442
			    INFO_PRINTF1(_L("Playback paused"));
sl@0
  2443
         	
sl@0
  2444
            	//Call StepFrameL with different step values.
sl@0
  2445
            	while(1)
sl@0
  2446
            		{
sl@0
  2447
            		if( frame == 0xff)
sl@0
  2448
            			frame = KStepForwardZeroFrame;
sl@0
  2449
            		else if (frame == KStepForwardZeroFrame)
sl@0
  2450
            			frame = KStepForwardOneFrame;
sl@0
  2451
            		else if (frame == KStepForwardOneFrame)
sl@0
  2452
            			frame = KStepForwardFourFrames;
sl@0
  2453
            		else if (frame == KStepForwardFourFrames)
sl@0
  2454
            			frame = KStepBackwardOneFrame;
sl@0
  2455
            		else if (frame == KStepBackwardOneFrame)
sl@0
  2456
            			frame = KStepBackwardFourFrames;
sl@0
  2457
            		else if (frame == KStepBackwardFourFrames)
sl@0
  2458
            			{
sl@0
  2459
                        INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2460
                        iVideoPlayer->Stop();
sl@0
  2461
                        iVideoPlayer->Close();
sl@0
  2462
                        CActiveScheduler::Stop();
sl@0
  2463
                        iTestStepResult = EPass;
sl@0
  2464
            			return; //Break the while loop
sl@0
  2465
            			}
sl@0
  2466
	            	INFO_PRINTF2(_L("iVideoPlayer->StepFrameL(%d)"),frame);
sl@0
  2467
		            TRAP(err,iVideoPlayer->StepFrameL(frame));
sl@0
  2468
		            if(err == KErrNotSupported)
sl@0
  2469
		            	{
sl@0
  2470
		            	if( ((iVideoPlayRateCapabilities.iStepForward) && (frame>0)) ||
sl@0
  2471
	            			((iVideoPlayRateCapabilities.iStepBackward) && (frame<0))   )
sl@0
  2472
		            		{
sl@0
  2473
			            	INFO_PRINTF2(_L("StepFrameL returned wrong err= %d"), err);
sl@0
  2474
			                iTestStepResult = EFail;
sl@0
  2475
			                CActiveScheduler::Stop();
sl@0
  2476
			                return;
sl@0
  2477
		            		}
sl@0
  2478
		            	INFO_PRINTF1(_L("StepFrameL returned KErrNotSupported"));
sl@0
  2479
		            	continue;
sl@0
  2480
		            	}
sl@0
  2481
		            else if( (err == KErrNotReady) && (!pauseSupported) )
sl@0
  2482
		            	{
sl@0
  2483
		            	INFO_PRINTF1(_L("pause is not supported in controller plugin. Returned correct err(KErrNotReady)"));
sl@0
  2484
		            	continue;
sl@0
  2485
		            	}
sl@0
  2486
		            else if( err != KErrNone)
sl@0
  2487
                    	{
sl@0
  2488
                    	INFO_PRINTF2(_L("StepFrameL returned err= %d"), err);
sl@0
  2489
                        iTestStepResult = EFail;
sl@0
  2490
                        CActiveScheduler::Stop();
sl@0
  2491
                        break;
sl@0
  2492
                    	}            		
sl@0
  2493
            		}
sl@0
  2494
                break;
sl@0
  2495
            case EVPPlayComplete:
sl@0
  2496
            	INFO_PRINTF1(_L("Plyback completed before pausing!!"));
sl@0
  2497
            	INFO_PRINTF1(_L("Video clip is too small to run this test step"));
sl@0
  2498
	            INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2499
	            iVideoPlayer->Stop();
sl@0
  2500
	            iVideoPlayer->Close();
sl@0
  2501
	            CActiveScheduler::Stop();
sl@0
  2502
	            iTestStepResult = EInconclusive;
sl@0
  2503
	            return;
sl@0
  2504
            }
sl@0
  2505
        }
sl@0
  2506
    }
sl@0
  2507
sl@0
  2508
//
sl@0
  2509
// RTestVideoPlayAudVidEnable.
sl@0
  2510
//
sl@0
  2511
sl@0
  2512
/**
sl@0
  2513
 * RTestVideoPlayAudVidEnable::Constructor
sl@0
  2514
 */
sl@0
  2515
RTestVideoPlayAudVidEnable::RTestVideoPlayAudVidEnable(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2516
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2517
    {
sl@0
  2518
    }
sl@0
  2519
sl@0
  2520
/**
sl@0
  2521
 * RTestVideoPlayAudVidEnable::NewL
sl@0
  2522
 */
sl@0
  2523
RTestVideoPlayAudVidEnable* RTestVideoPlayAudVidEnable::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2524
	{
sl@0
  2525
    RTestVideoPlayAudVidEnable* self = new (ELeave) RTestVideoPlayAudVidEnable(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2526
    return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
sl@0
  2527
    }
sl@0
  2528
sl@0
  2529
/**
sl@0
  2530
 * RTestVideoPlayAudVidEnable::DoTestStepL()
sl@0
  2531
 */
sl@0
  2532
TVerdict RTestVideoPlayAudVidEnable::DoTestStepL()
sl@0
  2533
    {
sl@0
  2534
    // Call the state handler from IDLE state
sl@0
  2535
    TRAPD(err, FsmL(EVPIdle));
sl@0
  2536
    if (err == KErrNone)
sl@0
  2537
        {
sl@0
  2538
        // Start the scheduler - Done only once !
sl@0
  2539
        CActiveScheduler::Start();    
sl@0
  2540
        }
sl@0
  2541
    return iTestStepResult;  
sl@0
  2542
    }
sl@0
  2543
/**
sl@0
  2544
 * RTestVideoPlayAudVidEnable::FsmL()
sl@0
  2545
 */
sl@0
  2546
void RTestVideoPlayAudVidEnable::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  2547
    {
sl@0
  2548
    if (FsmCheck(aEventCode))
sl@0
  2549
        {
sl@0
  2550
        TInt err = KErrNone;
sl@0
  2551
    	TBool enableFlag = EFalse;
sl@0
  2552
    	
sl@0
  2553
        switch (aEventCode)
sl@0
  2554
            {
sl@0
  2555
            case EVPIdle:
sl@0
  2556
	            //Calling SetAudioEnabledL() before opening file should return KErrNotReady
sl@0
  2557
	        	INFO_PRINTF1(_L("iVideoPlayer->SetAudioEnabledL()"));            	
sl@0
  2558
	            TRAP(err, iVideoPlayer->SetAudioEnabledL(ETrue));
sl@0
  2559
	            if (err != KErrNotReady)
sl@0
  2560
	            	{
sl@0
  2561
	            	INFO_PRINTF2(_L("SetAudioEnabledL returned wrong error code= %d"), err);
sl@0
  2562
	                iTestStepResult = EFail;
sl@0
  2563
	                CActiveScheduler::Stop();
sl@0
  2564
	                return;
sl@0
  2565
	            	}
sl@0
  2566
	            //Calling SetVideoEnabledL() before opening file should return KErrNotReady
sl@0
  2567
	        	INFO_PRINTF1(_L("iVideoPlayer->SetVideoEnabledL()"));            	
sl@0
  2568
	            TRAP(err, iVideoPlayer->SetVideoEnabledL(ETrue));
sl@0
  2569
	            if (err != KErrNotReady)
sl@0
  2570
	            	{
sl@0
  2571
	            	INFO_PRINTF2(_L("SetVideoEnabledL returned wrong error code= %d"), err);
sl@0
  2572
	                iTestStepResult = EFail;
sl@0
  2573
	                CActiveScheduler::Stop();
sl@0
  2574
	                return;
sl@0
  2575
	            	}
sl@0
  2576
	            //Calling VideoEnabledL() before opening file should return KErrNotReady
sl@0
  2577
	        	INFO_PRINTF1(_L("iVideoPlayer->VideoEnabledL()"));            	
sl@0
  2578
	            TRAP(err, iVideoPlayer->VideoEnabledL());
sl@0
  2579
	            if(err != KErrNotReady)
sl@0
  2580
	            	{
sl@0
  2581
	            	INFO_PRINTF2(_L("VideoEnabledL returned wrong error code= %d"), err);
sl@0
  2582
	                iTestStepResult = EFail;
sl@0
  2583
	                CActiveScheduler::Stop();
sl@0
  2584
	                return;
sl@0
  2585
	            	}
sl@0
  2586
                // Open iVideoPlayer
sl@0
  2587
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
  2588
                iVideoPlayer->OpenFileL(iFilename);
sl@0
  2589
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  2590
                break;
sl@0
  2591
            case EVPOpenComplete:
sl@0
  2592
            	//Check that by default audio is enabled.
sl@0
  2593
	        	INFO_PRINTF1(_L("iVideoPlayer->AudioEnabledL()"));            	
sl@0
  2594
	            TRAP(err,enableFlag = iVideoPlayer->AudioEnabledL());
sl@0
  2595
	            if( (err != KErrNone) || (enableFlag != (TBool)ETrue) )
sl@0
  2596
	            	{
sl@0
  2597
                	INFO_PRINTF3(_L("AudioEnabledL Leave err= %d, returned:%d"), err,enableFlag);
sl@0
  2598
                    iTestStepResult = EFail;
sl@0
  2599
                    CActiveScheduler::Stop();
sl@0
  2600
                    return;
sl@0
  2601
	            	}
sl@0
  2602
sl@0
  2603
            	//Check that by default video is enabled.
sl@0
  2604
	        	INFO_PRINTF1(_L("iVideoPlayer->VideoEnabledL()"));            	
sl@0
  2605
	            TRAP(err,enableFlag = iVideoPlayer->VideoEnabledL());
sl@0
  2606
	            if( (err != KErrNone) || (enableFlag != (TBool)ETrue) )
sl@0
  2607
	            	{
sl@0
  2608
                	INFO_PRINTF3(_L("VideoEnabledL Leave err= %d, returned:%d"), err,enableFlag);
sl@0
  2609
                    iTestStepResult = EFail;
sl@0
  2610
                    CActiveScheduler::Stop();
sl@0
  2611
                    return;
sl@0
  2612
	            	}
sl@0
  2613
            	
sl@0
  2614
	            //Try to disable audio, It shall leave with notsupported error.
sl@0
  2615
	        	INFO_PRINTF1(_L("iVideoPlayer->SetAudioEnabledL()"));            	
sl@0
  2616
	            TRAP(err, iVideoPlayer->SetAudioEnabledL(ETrue));
sl@0
  2617
	            if (err != KErrNotSupported)
sl@0
  2618
	            	{
sl@0
  2619
                	INFO_PRINTF2(_L("SetAudioEnabledL returned wrong error code= %d"), err);
sl@0
  2620
                    iTestStepResult = EFail;
sl@0
  2621
                    CActiveScheduler::Stop();
sl@0
  2622
                    return;
sl@0
  2623
	            	}
sl@0
  2624
sl@0
  2625
	            //Try to disable video, It shall leave with notsupported error.
sl@0
  2626
	        	INFO_PRINTF1(_L("iVideoPlayer->SetVideoEnabledL()"));            	
sl@0
  2627
	            TRAP(err, iVideoPlayer->SetVideoEnabledL(ETrue));
sl@0
  2628
	            if (err != KErrNotSupported)
sl@0
  2629
	            	{
sl@0
  2630
                	INFO_PRINTF2(_L("SetVideoEnabledL returned wrong error code= %d"), err);
sl@0
  2631
                    iTestStepResult = EFail;
sl@0
  2632
                    CActiveScheduler::Stop();
sl@0
  2633
                    return;
sl@0
  2634
	            	}
sl@0
  2635
	            
sl@0
  2636
                // Prepare iVideoPlayer
sl@0
  2637
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  2638
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  2639
                iVideoPlayer->Prepare();
sl@0
  2640
                break;
sl@0
  2641
            case EVPPrepareComplete:
sl@0
  2642
	            //Enabling/disabling audio after prepare() shall return KErrNotSupported error.
sl@0
  2643
	        	INFO_PRINTF1(_L("iVideoPlayer->SetAudioEnabledL()"));            	
sl@0
  2644
	            TRAP(err, iVideoPlayer->SetAudioEnabledL(ETrue));
sl@0
  2645
	            if(err != KErrNotSupported)
sl@0
  2646
	            	{
sl@0
  2647
	            	INFO_PRINTF2(_L("SetAudioEnabledL returned wrong error code= %d"), err);
sl@0
  2648
	                iTestStepResult = EFail;
sl@0
  2649
	                CActiveScheduler::Stop();
sl@0
  2650
	                return;
sl@0
  2651
	            	}
sl@0
  2652
sl@0
  2653
	            //Enabling/disabling video after prepare() shll return KErrNotSupported error.
sl@0
  2654
	        	INFO_PRINTF1(_L("iVideoPlayer->SetVideoEnabledL()"));            	
sl@0
  2655
	            TRAP(err, iVideoPlayer->SetVideoEnabledL(ETrue));
sl@0
  2656
	            if(err != KErrNotSupported)
sl@0
  2657
	            	{
sl@0
  2658
	            	INFO_PRINTF2(_L("SetVideoEnabledL returned wrong error code= %d"), err);
sl@0
  2659
	                iTestStepResult = EFail;
sl@0
  2660
	                CActiveScheduler::Stop();
sl@0
  2661
	                return;
sl@0
  2662
	            	}
sl@0
  2663
sl@0
  2664
                // Play iVideoPlayer
sl@0
  2665
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2666
                iVideoPlayer->Play();
sl@0
  2667
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2668
sl@0
  2669
                //calling SetAudioEnabledL while playing should return KErrNotReady
sl@0
  2670
	        	INFO_PRINTF1(_L("iVideoPlayer->SetAudioEnabledL()"));            	
sl@0
  2671
	            TRAP(err, iVideoPlayer->SetAudioEnabledL(ETrue));
sl@0
  2672
	            if (err != KErrNotReady)
sl@0
  2673
	            	{
sl@0
  2674
                	INFO_PRINTF2(_L("SetAudioEnabledL returned wrong error code= %d"), err);
sl@0
  2675
                    iTestStepResult = EFail;
sl@0
  2676
                    iVideoPlayer->Stop();
sl@0
  2677
                    iVideoPlayer->Close();                    
sl@0
  2678
                    CActiveScheduler::Stop();
sl@0
  2679
                    return;
sl@0
  2680
	            	}
sl@0
  2681
sl@0
  2682
	            //calling SetVideoEnabledL while playing should return KErrNotReady
sl@0
  2683
	        	INFO_PRINTF1(_L("iVideoPlayer->SetVideoEnabledL()"));            	
sl@0
  2684
	            TRAP(err, iVideoPlayer->SetVideoEnabledL(ETrue));
sl@0
  2685
	            if (err != KErrNotReady)
sl@0
  2686
	            	{
sl@0
  2687
                	INFO_PRINTF2(_L("SetVideoEnabledL returned wrong error code= %d"), err);
sl@0
  2688
                    iTestStepResult = EFail;
sl@0
  2689
                    iVideoPlayer->Stop();
sl@0
  2690
                    iVideoPlayer->Close();                    
sl@0
  2691
                    CActiveScheduler::Stop();
sl@0
  2692
                    return;
sl@0
  2693
	            	}
sl@0
  2694
sl@0
  2695
	            break;
sl@0
  2696
            case EVPPlayComplete:
sl@0
  2697
                INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2698
                iVideoPlayer->Stop();
sl@0
  2699
                iVideoPlayer->Close();
sl@0
  2700
                CActiveScheduler::Stop();
sl@0
  2701
                iTestStepResult = EPass;
sl@0
  2702
                break;
sl@0
  2703
            }
sl@0
  2704
        }
sl@0
  2705
    }
sl@0
  2706
sl@0
  2707
sl@0
  2708
//
sl@0
  2709
// RTestVideoPlayAutoScale.
sl@0
  2710
//
sl@0
  2711
sl@0
  2712
/**
sl@0
  2713
 * RTestVideoPlayAutoScale::Constructor
sl@0
  2714
 */
sl@0
  2715
RTestVideoPlayAutoScale::RTestVideoPlayAutoScale(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2716
    : RTestVclntAviPlayerStep(aTestName, aSectName, aKeyName, aExpectedError)
sl@0
  2717
    {
sl@0
  2718
    }
sl@0
  2719
sl@0
  2720
/**
sl@0
  2721
 * RTestVideoPlayAutoScale::NewL
sl@0
  2722
 */
sl@0
  2723
RTestVideoPlayAutoScale* RTestVideoPlayAutoScale::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TInt aExpectedError)
sl@0
  2724
	{
sl@0
  2725
    RTestVideoPlayAutoScale* self = new (ELeave) RTestVideoPlayAutoScale(aTestName, aSectName, aKeyName, aExpectedError);
sl@0
  2726
    return self;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
sl@0
  2727
    }
sl@0
  2728
sl@0
  2729
/**
sl@0
  2730
 * RTestVideoPlayAutoScale::DoTestStepL()
sl@0
  2731
 */
sl@0
  2732
TVerdict RTestVideoPlayAutoScale::DoTestStepL()
sl@0
  2733
    {
sl@0
  2734
    // Call the state handler from IDLE state
sl@0
  2735
    TRAPD(err, FsmL(EVPIdle));
sl@0
  2736
    if (err == KErrNone)
sl@0
  2737
        {
sl@0
  2738
        // Start the scheduler - Done only once !
sl@0
  2739
        CActiveScheduler::Start();    
sl@0
  2740
        }
sl@0
  2741
    return iTestStepResult;  
sl@0
  2742
    }
sl@0
  2743
/**
sl@0
  2744
 * RTestVideoPlayAutoScale::FsmL()
sl@0
  2745
 */
sl@0
  2746
void RTestVideoPlayAutoScale::FsmL(TVclntTestPlayEvents aEventCode)
sl@0
  2747
    {
sl@0
  2748
    if (FsmCheck(aEventCode))
sl@0
  2749
        {
sl@0
  2750
        TInt err = KErrNone;
sl@0
  2751
        TAutoScaleType scaleType = EAutoScaleNone;
sl@0
  2752
        THorizontalAlign horizontalAlign = EHorizontalAlignCenter;
sl@0
  2753
        TVerticalAlign verticalAlign = EVerticalAlignCenter;
sl@0
  2754
        
sl@0
  2755
        switch (aEventCode)
sl@0
  2756
            {
sl@0
  2757
            case EVPIdle:
sl@0
  2758
            	//Calling SetAutoScaleL() before opening file should return KErrNotReady error.
sl@0
  2759
	            INFO_PRINTF1(_L("Calling SetAutoScaleL(EAutoScaleNone);"));
sl@0
  2760
	            TRAP(err, iVideoPlayer->SetAutoScaleL(EAutoScaleNone));
sl@0
  2761
	            if( err != KErrNotReady)
sl@0
  2762
	            	{
sl@0
  2763
	                INFO_PRINTF2(_L("SetAutoScaleL() returned wrong error=%d"),err);
sl@0
  2764
                    CActiveScheduler::Stop();
sl@0
  2765
                    iTestStepResult = EFail;	    	                        
sl@0
  2766
                    return;	                
sl@0
  2767
	            	}
sl@0
  2768
	            
sl@0
  2769
                // Open iVideoPlayer
sl@0
  2770
                INFO_PRINTF2(_L("iVideoPlayer->OpenFileL() %S"), &iFilename);
sl@0
  2771
                iVideoPlayer->OpenFileL(iFilename);
sl@0
  2772
                PrepareState(EVPOpenComplete, KErrNone);
sl@0
  2773
                break;
sl@0
  2774
            case EVPOpenComplete:
sl@0
  2775
                // Prepare iVideoPlayer
sl@0
  2776
                INFO_PRINTF1(_L("iVideoPlayer->Prepare()"));
sl@0
  2777
                PrepareState(EVPPrepareComplete, KErrNone);
sl@0
  2778
                iVideoPlayer->Prepare();
sl@0
  2779
                break;
sl@0
  2780
            case EVPPrepareComplete:
sl@0
  2781
                // Play iVideoPlayer
sl@0
  2782
                INFO_PRINTF1(_L("iVideoPlayer->Play()"));
sl@0
  2783
                iVideoPlayer->Play();
sl@0
  2784
                PrepareState(EVPPlayComplete, KErrNone);
sl@0
  2785
sl@0
  2786
                /*
sl@0
  2787
                Wait for 1/4th of a second each time and call SetAutoScaleL multiple times
sl@0
  2788
                with different scale parameters.
sl@0
  2789
                This loop tests only "void SetAutoScaleL(TAutoScaleType aScaleType);"
sl@0
  2790
                */
sl@0
  2791
               
sl@0
  2792
                while(1)
sl@0
  2793
                	{
sl@0
  2794
    	            switch(scaleType)
sl@0
  2795
		            	{
sl@0
  2796
		            	case EAutoScaleNone:
sl@0
  2797
		            		scaleType = EAutoScaleBestFit;
sl@0
  2798
		            		break;
sl@0
  2799
		            	case EAutoScaleBestFit:
sl@0
  2800
		            		scaleType = EAutoScaleClip;
sl@0
  2801
		            		break;
sl@0
  2802
		            	case EAutoScaleClip:
sl@0
  2803
		            		scaleType = EAutoScaleStretch;
sl@0
  2804
		            		break;
sl@0
  2805
		            	case EAutoScaleStretch:
sl@0
  2806
		            		scaleType = EAutoScaleNone;		            		
sl@0
  2807
		            		break;
sl@0
  2808
		            	}
sl@0
  2809
                    INFO_PRINTF1(_L("calling User::After(KOneSecond/4);"));
sl@0
  2810
                    User::After(KOneSecond/4);
sl@0
  2811
                    
sl@0
  2812
                    INFO_PRINTF1(_L("Calling SetAutoScaleL();"));
sl@0
  2813
    	            TRAP(err, iVideoPlayer->SetAutoScaleL(scaleType));
sl@0
  2814
    	            
sl@0
  2815
#ifdef SYMBIAN_BUILD_GCE
sl@0
  2816
    	            const TInt KExpected = GCEAvailable() ? KErrNone : KErrNotSupported;
sl@0
  2817
#else
sl@0
  2818
					const TInt KExpected = KErrNotSupported;
sl@0
  2819
#endif
sl@0
  2820
    	            
sl@0
  2821
    	            if( err == KExpected)
sl@0
  2822
    	            	{
sl@0
  2823
                        INFO_PRINTF3(_L("SetAutoScaleL(%d) successfully returned %d"), scaleType, err);
sl@0
  2824
    	            	}
sl@0
  2825
    	            else
sl@0
  2826
    	            	{
sl@0
  2827
                        INFO_PRINTF4(_L("SetAutoScaleL(%d) returned error= %d.  Expected %d"),scaleType, err, KExpected);
sl@0
  2828
                        INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2829
                        iVideoPlayer->Stop();
sl@0
  2830
                        iVideoPlayer->Close();
sl@0
  2831
                        CActiveScheduler::Stop();
sl@0
  2832
                        iTestStepResult = EFail;	    	                        
sl@0
  2833
                        return;
sl@0
  2834
    	            	}
sl@0
  2835
    	            if( scaleType == EAutoScaleNone )
sl@0
  2836
    	            	{
sl@0
  2837
    	            	break;//Break the forever while loop;
sl@0
  2838
    	            	}
sl@0
  2839
                	}
sl@0
  2840
sl@0
  2841
                /*
sl@0
  2842
                Wait for half second each time and call SetAutoScaleL multiple times
sl@0
  2843
                with all combinations of TAutoScaleType, THorizontalAlign, and TVerticalAlign.
sl@0
  2844
                */
sl@0
  2845
                
sl@0
  2846
                while(1)
sl@0
  2847
                	{
sl@0
  2848
    	            switch(scaleType)
sl@0
  2849
		            	{
sl@0
  2850
		            	case EAutoScaleNone:
sl@0
  2851
		            		scaleType = EAutoScaleBestFit;
sl@0
  2852
		            		break;
sl@0
  2853
		            	case EAutoScaleBestFit:
sl@0
  2854
		            		scaleType = EAutoScaleClip;
sl@0
  2855
		            		break;
sl@0
  2856
		            	case EAutoScaleClip:
sl@0
  2857
		            		scaleType = EAutoScaleStretch;
sl@0
  2858
		            		break;
sl@0
  2859
		            	case EAutoScaleStretch:
sl@0
  2860
		            		scaleType = EAutoScaleNone;		            		
sl@0
  2861
		            		break;
sl@0
  2862
		            	}
sl@0
  2863
                    while(1)
sl@0
  2864
                    	{
sl@0
  2865
		            	if( horizontalAlign == EHorizontalAlignCenter)
sl@0
  2866
		            		{
sl@0
  2867
		            		horizontalAlign = EHorizontalAlignLeft;
sl@0
  2868
		            		}
sl@0
  2869
		            	else if( horizontalAlign == EHorizontalAlignLeft)
sl@0
  2870
		            		{
sl@0
  2871
		            		horizontalAlign = EHorizontalAlignRight;
sl@0
  2872
		            		}
sl@0
  2873
		            	else if( horizontalAlign == EHorizontalAlignRight)
sl@0
  2874
		            		{
sl@0
  2875
		            		horizontalAlign = EHorizontalAlignCenter;
sl@0
  2876
		            		}
sl@0
  2877
		                while(1)
sl@0
  2878
	                    	{
sl@0
  2879
    		            	if( verticalAlign == EVerticalAlignCenter)
sl@0
  2880
    		            		{
sl@0
  2881
    		            		verticalAlign = EVerticalAlignTop;
sl@0
  2882
    		            		}
sl@0
  2883
    		            	else if( verticalAlign == EVerticalAlignTop)
sl@0
  2884
    		            		{
sl@0
  2885
    		            		verticalAlign = EVerticalAlignBottom;
sl@0
  2886
    		            		}
sl@0
  2887
    		            	else if( verticalAlign == EVerticalAlignBottom)
sl@0
  2888
    		            		{
sl@0
  2889
    		            		verticalAlign = EVerticalAlignCenter;
sl@0
  2890
    		            		}
sl@0
  2891
    		            	
sl@0
  2892
	    		            	INFO_PRINTF1(_L("calling User::After(KOneSecond/4);"));
sl@0
  2893
	    	                    User::After(KOneSecond/4);
sl@0
  2894
								err = KErrNone;
sl@0
  2895
	    	                    
sl@0
  2896
	    	                    INFO_PRINTF1(_L("Calling SetAutoScaleL();"));
sl@0
  2897
	    	    	            TRAP(err, iVideoPlayer->SetAutoScaleL(scaleType,horizontalAlign,verticalAlign));
sl@0
  2898
	    	    	            if( err == KErrNotSupported)
sl@0
  2899
	    	    	            	{
sl@0
  2900
	    	                        INFO_PRINTF4(_L("SetAutoScaleL(%d,%d, %d) returned KErrNotSupported"),scaleType, horizontalAlign,verticalAlign);
sl@0
  2901
	    	    	            	}
sl@0
  2902
    							else if( err == KErrNone)
sl@0
  2903
    	            				{
sl@0
  2904
									INFO_PRINTF1(_L("Success calling SetAutoScaleL()"));
sl@0
  2905
	    	    	            	}
sl@0
  2906
	    	    	            else
sl@0
  2907
	    	    	            	{
sl@0
  2908
	    	                        INFO_PRINTF3(_L("SetAutoScaleL(%d) returned error= %d"),scaleType, err);
sl@0
  2909
	    	                        INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2910
	    	                        iVideoPlayer->Stop();
sl@0
  2911
	    	                        iVideoPlayer->Close();
sl@0
  2912
	    	                        CActiveScheduler::Stop();
sl@0
  2913
	    	                        iTestStepResult = EFail;	    	                        
sl@0
  2914
	    	                        return;	    	                        
sl@0
  2915
	    	    	            	}
sl@0
  2916
    	    	            
sl@0
  2917
    		            	if( verticalAlign == EVerticalAlignCenter )
sl@0
  2918
    	    	            	{
sl@0
  2919
    	    	            	break;//Break the forever while loop;
sl@0
  2920
    	    	            	}
sl@0
  2921
	    		            }    		            	
sl@0
  2922
		            	if( horizontalAlign == EHorizontalAlignCenter )
sl@0
  2923
	    	            	{
sl@0
  2924
	    	            	break;//Break the forever while loop;
sl@0
  2925
	    	            	}    		            	
sl@0
  2926
    		            }
sl@0
  2927
      	            if( scaleType == EAutoScaleNone )
sl@0
  2928
    	            	{
sl@0
  2929
    	            	break;//Break the forever while loop;
sl@0
  2930
    	            	}
sl@0
  2931
                	}
sl@0
  2932
                
sl@0
  2933
                INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2934
                iVideoPlayer->Stop();
sl@0
  2935
                iVideoPlayer->Close();
sl@0
  2936
                CActiveScheduler::Stop();
sl@0
  2937
                iTestStepResult = EPass;
sl@0
  2938
                break;
sl@0
  2939
            case EVPPlayComplete:
sl@0
  2940
            	INFO_PRINTF1(_L("Clip is too small to run the test"));
sl@0
  2941
                INFO_PRINTF1(_L("iVideoPlayer->Stop"));
sl@0
  2942
                iVideoPlayer->Stop();
sl@0
  2943
                iVideoPlayer->Close();
sl@0
  2944
                CActiveScheduler::Stop();
sl@0
  2945
                iTestStepResult = EInconclusive;
sl@0
  2946
                break;
sl@0
  2947
            }
sl@0
  2948
        }
sl@0
  2949
    }