os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/testDRM.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) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "rightsdatabase.h"
sl@0
    17
#include "TestDRM.h"
sl@0
    18
#include <caf/caf.h>
sl@0
    19
sl@0
    20
const TInt KDefaultRightsID = 1;
sl@0
    21
const TInt KDefaultRightsCount = 2;
sl@0
    22
sl@0
    23
const TInt KMaxMimeLength = 256;
sl@0
    24
/**
sl@0
    25
 * Constructor
sl@0
    26
 */
sl@0
    27
CTestMmfAclntDRMPlayerNoRights::CTestMmfAclntDRMPlayerNoRights()
sl@0
    28
	{
sl@0
    29
	// store the name of this test case
sl@0
    30
	// this is the name that is used by the script file
sl@0
    31
	// Each test step initialises it's own name
sl@0
    32
	iTestStepName = _L("MM-MMF-ACLNT-I-9000-LP");
sl@0
    33
sl@0
    34
	}
sl@0
    35
sl@0
    36
CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewL()
sl@0
    37
	{
sl@0
    38
	CTestMmfAclntDRMPlayerNoRights* self = new (ELeave) CTestMmfAclntDRMPlayerNoRights();
sl@0
    39
	return self;
sl@0
    40
	}
sl@0
    41
sl@0
    42
CTestMmfAclntDRMPlayerNoRights* CTestMmfAclntDRMPlayerNoRights::NewLC()
sl@0
    43
	{
sl@0
    44
	CTestMmfAclntDRMPlayerNoRights* self = CTestMmfAclntDRMPlayerNoRights::NewL();
sl@0
    45
	CleanupStack::PushL(self);
sl@0
    46
	return self;
sl@0
    47
	}
sl@0
    48
sl@0
    49
void CTestMmfAclntDRMPlayerNoRights::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
sl@0
    50
	{
sl@0
    51
	iError = aError;
sl@0
    52
	iDuration = aDuration;
sl@0
    53
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
sl@0
    54
	CActiveScheduler::Stop();
sl@0
    55
	}
sl@0
    56
sl@0
    57
void CTestMmfAclntDRMPlayerNoRights::MapcPlayComplete(TInt aError)
sl@0
    58
	{
sl@0
    59
	iError = aError;
sl@0
    60
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
sl@0
    61
	CActiveScheduler::Stop();
sl@0
    62
	}
sl@0
    63
sl@0
    64
sl@0
    65
sl@0
    66
/** Load and initialise an audio file.
sl@0
    67
 */
sl@0
    68
TVerdict CTestMmfAclntDRMPlayerNoRights::DoTestStepL( void )
sl@0
    69
	{
sl@0
    70
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
sl@0
    71
	TVerdict ret = EFail;
sl@0
    72
sl@0
    73
	iError = KErrTimedOut;
sl@0
    74
sl@0
    75
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
    76
	delete rights; // the database will now be reset and have no entries in it
sl@0
    77
sl@0
    78
	TBuf<KSizeBuf>	filename;
sl@0
    79
	TPtrC			filename1; 
sl@0
    80
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
    81
		return EInconclusive;
sl@0
    82
	GetDriveName(filename);
sl@0
    83
	filename.Append(filename1);
sl@0
    84
sl@0
    85
	CMdaAudioPlayerUtility* player = NULL;
sl@0
    86
	player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
sl@0
    87
sl@0
    88
sl@0
    89
	// Wait for initialisation callback
sl@0
    90
	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
sl@0
    91
	CActiveScheduler::Start();
sl@0
    92
sl@0
    93
	if (iError == KErrCANoRights)
sl@0
    94
		ret = EPass;			
sl@0
    95
	else
sl@0
    96
		ret = EFail;
sl@0
    97
	
sl@0
    98
	delete player;
sl@0
    99
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   100
	return	ret;
sl@0
   101
	}
sl@0
   102
//--------------------------------------------------------------------------------
sl@0
   103
sl@0
   104
/**
sl@0
   105
 * Constructor
sl@0
   106
 */
sl@0
   107
CTestMmfAclntDRMPlayerRightsCount::CTestMmfAclntDRMPlayerRightsCount()
sl@0
   108
	{
sl@0
   109
	// store the name of this test case
sl@0
   110
	// this is the name that is used by the script file
sl@0
   111
	// Each test step initialises it's own name
sl@0
   112
	iTestStepName = _L("MM-MMF-ACLNT-I-9001-LP");
sl@0
   113
sl@0
   114
	}
sl@0
   115
sl@0
   116
CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewL()
sl@0
   117
	{
sl@0
   118
	CTestMmfAclntDRMPlayerRightsCount* self = new (ELeave) CTestMmfAclntDRMPlayerRightsCount();
sl@0
   119
	return self;
sl@0
   120
	}
sl@0
   121
sl@0
   122
CTestMmfAclntDRMPlayerRightsCount* CTestMmfAclntDRMPlayerRightsCount::NewLC()
sl@0
   123
	{
sl@0
   124
	CTestMmfAclntDRMPlayerRightsCount* self = CTestMmfAclntDRMPlayerRightsCount::NewL();
sl@0
   125
	CleanupStack::PushL(self);
sl@0
   126
	return self;
sl@0
   127
	}
sl@0
   128
sl@0
   129
void CTestMmfAclntDRMPlayerRightsCount::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
sl@0
   130
	{
sl@0
   131
	iError = aError;
sl@0
   132
	iDuration = aDuration;
sl@0
   133
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
sl@0
   134
	CActiveScheduler::Stop();
sl@0
   135
	}
sl@0
   136
sl@0
   137
void CTestMmfAclntDRMPlayerRightsCount::MapcPlayComplete(TInt aError)
sl@0
   138
	{
sl@0
   139
	iError = aError;
sl@0
   140
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
sl@0
   141
	CActiveScheduler::Stop();
sl@0
   142
	}
sl@0
   143
sl@0
   144
sl@0
   145
sl@0
   146
/** Load and initialise an audio file.
sl@0
   147
 */
sl@0
   148
TVerdict CTestMmfAclntDRMPlayerRightsCount::DoTestStepL( void )
sl@0
   149
	{
sl@0
   150
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
sl@0
   151
	TVerdict ret = EFail;
sl@0
   152
sl@0
   153
	iError = KErrTimedOut;
sl@0
   154
sl@0
   155
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   156
	CleanupStack::PushL(rights);
sl@0
   157
	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count 
sl@0
   158
	CleanupStack::PopAndDestroy(rights); // cleanup rights object
sl@0
   159
sl@0
   160
	TBuf<KSizeBuf>	filename;
sl@0
   161
	TPtrC			filename1; 
sl@0
   162
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   163
		return EInconclusive;
sl@0
   164
	GetDriveName(filename);
sl@0
   165
	filename.Append(filename1);
sl@0
   166
sl@0
   167
	CMdaAudioPlayerUtility* player = NULL;
sl@0
   168
	player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
sl@0
   169
sl@0
   170
sl@0
   171
	// Wait for initialisation callback
sl@0
   172
	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
sl@0
   173
	CActiveScheduler::Start();
sl@0
   174
sl@0
   175
	// Check for errors.
sl@0
   176
	if (iError == KErrNone && player != NULL)
sl@0
   177
		{
sl@0
   178
		iError = KErrTimedOut;
sl@0
   179
sl@0
   180
		for (TInt i=0;i<KDefaultRightsCount;i++)
sl@0
   181
			{
sl@0
   182
			player->Play();
sl@0
   183
			
sl@0
   184
			// Wait for play callback
sl@0
   185
			INFO_PRINTF2( _L("Play CMdaAudioPlayerUtility: DRM play number %d"),i);
sl@0
   186
			CActiveScheduler::Start();
sl@0
   187
sl@0
   188
			if (iError != KErrNone)
sl@0
   189
				{
sl@0
   190
				INFO_PRINTF2(_L("Unexpected error %d"),iError);
sl@0
   191
				break;
sl@0
   192
				}
sl@0
   193
			}
sl@0
   194
sl@0
   195
		if (iError == KErrNone)
sl@0
   196
			{
sl@0
   197
			player->Play();
sl@0
   198
			
sl@0
   199
			// Wait for play callback
sl@0
   200
			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility with expired rights"));
sl@0
   201
			CActiveScheduler::Start();
sl@0
   202
sl@0
   203
			if (iError != KErrCANoPermission)
sl@0
   204
				{
sl@0
   205
				INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
sl@0
   206
				}
sl@0
   207
			else
sl@0
   208
				{
sl@0
   209
				INFO_PRINTF1(_L("Expected failure: rights denied"));
sl@0
   210
				ret = EPass;
sl@0
   211
				}
sl@0
   212
sl@0
   213
			}
sl@0
   214
		}
sl@0
   215
	
sl@0
   216
	delete player;
sl@0
   217
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   218
	return	ret;
sl@0
   219
	}
sl@0
   220
sl@0
   221
//----------------------------------------------------------------------------------------
sl@0
   222
sl@0
   223
/**
sl@0
   224
 * Constructor
sl@0
   225
 */
sl@0
   226
CTestMmfAclntDRMRecorderNoRights::CTestMmfAclntDRMRecorderNoRights()
sl@0
   227
	{
sl@0
   228
	// store the name of this test case
sl@0
   229
	// this is the name that is used by the script file
sl@0
   230
	// Each test step initialises it's own name
sl@0
   231
	iTestStepName = _L("MM-MMF-ACLNT-I-9002-LP");
sl@0
   232
sl@0
   233
	}
sl@0
   234
sl@0
   235
CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewL()
sl@0
   236
	{
sl@0
   237
	CTestMmfAclntDRMRecorderNoRights* self = new (ELeave) CTestMmfAclntDRMRecorderNoRights();
sl@0
   238
	return self;
sl@0
   239
	}
sl@0
   240
sl@0
   241
CTestMmfAclntDRMRecorderNoRights* CTestMmfAclntDRMRecorderNoRights::NewLC()
sl@0
   242
	{
sl@0
   243
	CTestMmfAclntDRMRecorderNoRights* self = CTestMmfAclntDRMRecorderNoRights::NewL();
sl@0
   244
	CleanupStack::PushL(self);
sl@0
   245
	return self;
sl@0
   246
	}
sl@0
   247
sl@0
   248
sl@0
   249
/** Load and initialise an audio file.
sl@0
   250
 */
sl@0
   251
TVerdict CTestMmfAclntDRMRecorderNoRights::DoTestStepL( void )
sl@0
   252
	{
sl@0
   253
	INFO_PRINTF1( _L("TestRecorderUtils : File"));
sl@0
   254
	TVerdict ret = EFail;
sl@0
   255
sl@0
   256
	iError = KErrTimedOut;
sl@0
   257
sl@0
   258
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   259
	delete rights; // the database will now be reset and have no entries in it
sl@0
   260
sl@0
   261
	TBuf<KSizeBuf>	filename;
sl@0
   262
	TPtrC			filename1; 
sl@0
   263
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   264
		return EInconclusive;
sl@0
   265
	GetDriveName(filename);
sl@0
   266
	filename.Append(filename1);
sl@0
   267
sl@0
   268
	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
sl@0
   269
	CleanupStack::PushL(recorder);
sl@0
   270
sl@0
   271
	recorder->OpenFileL(filename);
sl@0
   272
sl@0
   273
	// Wait for initialisation callback
sl@0
   274
	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
sl@0
   275
	CActiveScheduler::Start();
sl@0
   276
sl@0
   277
	if (iError == KErrCANoRights)
sl@0
   278
		ret = EPass;			
sl@0
   279
	else
sl@0
   280
		ret = EFail;
sl@0
   281
	
sl@0
   282
	CleanupStack::PopAndDestroy(recorder);
sl@0
   283
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   284
	return	ret;
sl@0
   285
	}
sl@0
   286
sl@0
   287
sl@0
   288
void CTestMmfAclntDRMRecorderNoRights::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
sl@0
   289
	{
sl@0
   290
	iError = aErrorCode;
sl@0
   291
	//iObject = aObject;
sl@0
   292
	iPreviousState = aPreviousState;
sl@0
   293
	iCurrentState = aCurrentState;
sl@0
   294
sl@0
   295
	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
sl@0
   296
	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
sl@0
   297
	CActiveScheduler::Stop();
sl@0
   298
	}
sl@0
   299
sl@0
   300
//--------------------------------------------------------------------------------
sl@0
   301
sl@0
   302
/**
sl@0
   303
 * Constructor
sl@0
   304
 */
sl@0
   305
CTestMmfAclntDRMRecorderRightsCount::CTestMmfAclntDRMRecorderRightsCount()
sl@0
   306
	{
sl@0
   307
	// store the name of this test case
sl@0
   308
	// this is the name that is used by the script file
sl@0
   309
	// Each test step initialises it's own name
sl@0
   310
	iTestStepName = _L("MM-MMF-ACLNT-I-9003-LP");
sl@0
   311
sl@0
   312
	}
sl@0
   313
sl@0
   314
CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewL()
sl@0
   315
	{
sl@0
   316
	CTestMmfAclntDRMRecorderRightsCount* self = new (ELeave) CTestMmfAclntDRMRecorderRightsCount();
sl@0
   317
	return self;
sl@0
   318
	}
sl@0
   319
sl@0
   320
CTestMmfAclntDRMRecorderRightsCount* CTestMmfAclntDRMRecorderRightsCount::NewLC()
sl@0
   321
	{
sl@0
   322
	CTestMmfAclntDRMRecorderRightsCount* self = CTestMmfAclntDRMRecorderRightsCount::NewL();
sl@0
   323
	CleanupStack::PushL(self);
sl@0
   324
	return self;
sl@0
   325
	}
sl@0
   326
sl@0
   327
/** Load and initialise an audio file.
sl@0
   328
 */
sl@0
   329
TVerdict CTestMmfAclntDRMRecorderRightsCount::DoTestStepL( void )
sl@0
   330
	{
sl@0
   331
	INFO_PRINTF1( _L("TestRecorderUtils : File"));
sl@0
   332
	TVerdict ret = EFail;
sl@0
   333
sl@0
   334
	iError = KErrTimedOut;
sl@0
   335
sl@0
   336
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   337
	CleanupStack::PushL(rights);
sl@0
   338
	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count 
sl@0
   339
	CleanupStack::PopAndDestroy(rights); // cleanup rights object
sl@0
   340
sl@0
   341
	TBuf<KSizeBuf>	filename;
sl@0
   342
	TPtrC			filename1; 
sl@0
   343
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   344
		return EInconclusive;
sl@0
   345
	GetDriveName(filename);
sl@0
   346
	filename.Append(filename1);
sl@0
   347
sl@0
   348
	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
sl@0
   349
	CleanupStack::PushL(recorder);
sl@0
   350
sl@0
   351
	recorder->OpenFileL(filename);
sl@0
   352
sl@0
   353
	// Wait for initialisation callback
sl@0
   354
	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
sl@0
   355
	CActiveScheduler::Start();
sl@0
   356
sl@0
   357
	// Check for errors.
sl@0
   358
	if (iError == KErrNone && recorder != NULL)
sl@0
   359
		{
sl@0
   360
		iError = KErrTimedOut;
sl@0
   361
sl@0
   362
		for (TInt i=0;i<KDefaultRightsCount;i++)
sl@0
   363
			{
sl@0
   364
			recorder->PlayL();
sl@0
   365
			
sl@0
   366
			// Wait for play callback
sl@0
   367
			INFO_PRINTF2( _L("Play CMdaAudioRecorderUtility: DRM play number %d"),i);
sl@0
   368
			CActiveScheduler::Start();
sl@0
   369
sl@0
   370
			if (iError != KErrNone)
sl@0
   371
				{
sl@0
   372
				INFO_PRINTF2(_L("Unexpected error %d"),iError);
sl@0
   373
				break;
sl@0
   374
				}
sl@0
   375
			}
sl@0
   376
sl@0
   377
		if (iError == KErrNone)
sl@0
   378
			{
sl@0
   379
			recorder->PlayL();
sl@0
   380
			
sl@0
   381
			// Wait for play callback
sl@0
   382
			INFO_PRINTF1( _L("Play CMdaAudioRecorderUtility with expired rights"));
sl@0
   383
			CActiveScheduler::Start();
sl@0
   384
sl@0
   385
			if (iError != KErrCANoPermission)
sl@0
   386
				{
sl@0
   387
				INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
sl@0
   388
				}
sl@0
   389
			else
sl@0
   390
				{
sl@0
   391
				INFO_PRINTF1(_L("Expected failure: rights denied"));
sl@0
   392
				ret = EPass;
sl@0
   393
				}
sl@0
   394
sl@0
   395
			}
sl@0
   396
		}
sl@0
   397
	
sl@0
   398
	CleanupStack::PopAndDestroy(recorder);
sl@0
   399
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   400
	return	ret;
sl@0
   401
	}
sl@0
   402
sl@0
   403
sl@0
   404
sl@0
   405
sl@0
   406
void CTestMmfAclntDRMRecorderRightsCount::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
sl@0
   407
	{
sl@0
   408
	iError = aErrorCode;
sl@0
   409
	//iObject = aObject;
sl@0
   410
	iPreviousState = aPreviousState;
sl@0
   411
	iCurrentState = aCurrentState;
sl@0
   412
sl@0
   413
	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
sl@0
   414
	if (!busy || iError!=KErrNone)
sl@0
   415
		CActiveScheduler::Stop();
sl@0
   416
	
sl@0
   417
	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
sl@0
   418
	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
sl@0
   419
	
sl@0
   420
	}
sl@0
   421
sl@0
   422
//--------------------------------------------------------------------------------
sl@0
   423
sl@0
   424
/**
sl@0
   425
 * Constructor
sl@0
   426
 */
sl@0
   427
CTestMmfAclntDRMPlayerOpen::CTestMmfAclntDRMPlayerOpen()
sl@0
   428
	{
sl@0
   429
	// store the name of this test case
sl@0
   430
	// this is the name that is used by the script file
sl@0
   431
	// Each test step initialises it's own name
sl@0
   432
	iTestStepName = _L("MM-MMF-ACLNT-I-9004-LP");
sl@0
   433
sl@0
   434
	}
sl@0
   435
sl@0
   436
CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewL()
sl@0
   437
	{
sl@0
   438
	CTestMmfAclntDRMPlayerOpen* self = new (ELeave) CTestMmfAclntDRMPlayerOpen();
sl@0
   439
	return self;
sl@0
   440
	}
sl@0
   441
sl@0
   442
CTestMmfAclntDRMPlayerOpen* CTestMmfAclntDRMPlayerOpen::NewLC()
sl@0
   443
	{
sl@0
   444
	CTestMmfAclntDRMPlayerOpen* self = CTestMmfAclntDRMPlayerOpen::NewL();
sl@0
   445
	CleanupStack::PushL(self);
sl@0
   446
	return self;
sl@0
   447
	}
sl@0
   448
sl@0
   449
void CTestMmfAclntDRMPlayerOpen::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
sl@0
   450
	{
sl@0
   451
	iError = aError;
sl@0
   452
	iDuration = aDuration;
sl@0
   453
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
sl@0
   454
	CActiveScheduler::Stop();
sl@0
   455
	}
sl@0
   456
sl@0
   457
void CTestMmfAclntDRMPlayerOpen::MapcPlayComplete(TInt aError)
sl@0
   458
	{
sl@0
   459
	iError = aError;
sl@0
   460
	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
sl@0
   461
	CActiveScheduler::Stop();
sl@0
   462
	}
sl@0
   463
sl@0
   464
/** Load and initialise an audio file.
sl@0
   465
 */
sl@0
   466
TVerdict CTestMmfAclntDRMPlayerOpen::DoTestStepL( void )
sl@0
   467
	{
sl@0
   468
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
sl@0
   469
	TVerdict ret = EFail;
sl@0
   470
	TInt err=KErrNone;
sl@0
   471
	iError = KErrTimedOut;
sl@0
   472
	
sl@0
   473
	//fectch MIME type from config file
sl@0
   474
	TBuf8<KMaxMimeLength> mimeType;
sl@0
   475
	TPtrC				  mimeTypePtr; 
sl@0
   476
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
sl@0
   477
		return EInconclusive;
sl@0
   478
	mimeType.Copy(mimeTypePtr);
sl@0
   479
sl@0
   480
sl@0
   481
	//setup file to open
sl@0
   482
	TBuf<KSizeBuf>	filename;
sl@0
   483
	TPtrC			filename1; 
sl@0
   484
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   485
		return EInconclusive;
sl@0
   486
	GetDriveName(filename);
sl@0
   487
	filename.Append(filename1);
sl@0
   488
sl@0
   489
	//setup DRM rights
sl@0
   490
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   491
	CleanupStack::PushL(rights);
sl@0
   492
	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
sl@0
   493
	CleanupStack::PopAndDestroy(rights); // cleanup rights object
sl@0
   494
sl@0
   495
	//create instance of Audio Player, which should try open the file as well
sl@0
   496
	CMdaAudioPlayerUtility* player = NULL;
sl@0
   497
	TRAP(err, player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this));
sl@0
   498
	
sl@0
   499
	if (iError == KErrNone)//call back OK
sl@0
   500
	{
sl@0
   501
		// Wait for initialisation callback
sl@0
   502
		INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
sl@0
   503
		CActiveScheduler::Start();
sl@0
   504
	}
sl@0
   505
	else
sl@0
   506
	{
sl@0
   507
		INFO_PRINTF2(_L("Unexpected error %d"),iError);
sl@0
   508
	}
sl@0
   509
sl@0
   510
sl@0
   511
	if (err != KErrNone)
sl@0
   512
		{
sl@0
   513
			INFO_PRINTF3(_L("Unexpected error %d, expected %d"),iError,KErrCANoPermission);
sl@0
   514
		}
sl@0
   515
	else
sl@0
   516
		{
sl@0
   517
			INFO_PRINTF1(_L("Expected: PASS"));
sl@0
   518
			ret = EPass;
sl@0
   519
		}
sl@0
   520
		
sl@0
   521
	delete player;
sl@0
   522
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   523
	return	ret;
sl@0
   524
	}
sl@0
   525
sl@0
   526
//--------------------------------------------------------------------------------
sl@0
   527
sl@0
   528
/**
sl@0
   529
 * Constructor
sl@0
   530
 */
sl@0
   531
CTestMmfAclntDRMRecorderPlay::CTestMmfAclntDRMRecorderPlay()
sl@0
   532
	{
sl@0
   533
	// store the name of this test case
sl@0
   534
	// this is the name that is used by the script file
sl@0
   535
	// Each test step initialises it's own name
sl@0
   536
	iTestStepName = _L("MM-MMF-ACLNT-I-9005-LP");
sl@0
   537
sl@0
   538
	}
sl@0
   539
sl@0
   540
CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewL()
sl@0
   541
	{
sl@0
   542
	CTestMmfAclntDRMRecorderPlay* self = new (ELeave) CTestMmfAclntDRMRecorderPlay();
sl@0
   543
	return self;
sl@0
   544
	}
sl@0
   545
sl@0
   546
CTestMmfAclntDRMRecorderPlay* CTestMmfAclntDRMRecorderPlay::NewLC()
sl@0
   547
	{
sl@0
   548
	CTestMmfAclntDRMRecorderPlay* self = CTestMmfAclntDRMRecorderPlay::NewL();
sl@0
   549
	CleanupStack::PushL(self);
sl@0
   550
	return self;
sl@0
   551
	}
sl@0
   552
sl@0
   553
/** Load and initialise an audio file.
sl@0
   554
 */
sl@0
   555
TVerdict CTestMmfAclntDRMRecorderPlay::DoTestStepL( void )
sl@0
   556
	{
sl@0
   557
	INFO_PRINTF1( _L("TestRecorderUtils : File"));
sl@0
   558
	TVerdict ret = EFail;
sl@0
   559
sl@0
   560
	iError = KErrTimedOut;
sl@0
   561
sl@0
   562
	//fectch MIME type from config file
sl@0
   563
	TBuf8<KMaxMimeLength> mimeType;
sl@0
   564
	TPtrC				  mimeTypePtr; 
sl@0
   565
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
sl@0
   566
		return EInconclusive;
sl@0
   567
	mimeType.Copy(mimeTypePtr);
sl@0
   568
sl@0
   569
	//setup DRM rights
sl@0
   570
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   571
	CleanupStack::PushL(rights);
sl@0
   572
	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
sl@0
   573
	CleanupStack::PopAndDestroy(rights); // cleanup rights object
sl@0
   574
sl@0
   575
sl@0
   576
	TBuf<KSizeBuf>	filename;
sl@0
   577
	TPtrC			filename1; 
sl@0
   578
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   579
		return EInconclusive;
sl@0
   580
	GetDriveName(filename);
sl@0
   581
	filename.Append(filename1);
sl@0
   582
sl@0
   583
	CMdaAudioRecorderUtility* recorder = CMdaAudioRecorderUtility::NewL(*this);
sl@0
   584
	CleanupStack::PushL(recorder);
sl@0
   585
sl@0
   586
	recorder->OpenFileL(filename);
sl@0
   587
sl@0
   588
	// Wait for initialisation callback
sl@0
   589
	INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
sl@0
   590
	CActiveScheduler::Start();
sl@0
   591
sl@0
   592
	// Check for errors.
sl@0
   593
	if (iError == KErrNone && recorder != NULL)
sl@0
   594
		{
sl@0
   595
		iError = KErrTimedOut;
sl@0
   596
sl@0
   597
		recorder->PlayL();
sl@0
   598
			
sl@0
   599
		// Wait for play callback
sl@0
   600
		INFO_PRINTF1( _L("Play DRM protected file with CMdaAudioRecorderUtility(with sufficient permission)"));
sl@0
   601
		CActiveScheduler::Start();
sl@0
   602
sl@0
   603
		if (iError != KErrNone)
sl@0
   604
			{
sl@0
   605
			INFO_PRINTF2(_L("Unexpected error trying to play protected file %d"),iError);
sl@0
   606
			}
sl@0
   607
		else
sl@0
   608
			{
sl@0
   609
			INFO_PRINTF1(_L("DRM Protected file played successfully"));
sl@0
   610
			ret = EPass;
sl@0
   611
			}
sl@0
   612
		}
sl@0
   613
	
sl@0
   614
	CleanupStack::PopAndDestroy(recorder);
sl@0
   615
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   616
	return	ret;
sl@0
   617
	}
sl@0
   618
sl@0
   619
sl@0
   620
sl@0
   621
sl@0
   622
void CTestMmfAclntDRMRecorderPlay::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
sl@0
   623
	{
sl@0
   624
	iError = aErrorCode;
sl@0
   625
	//iObject = aObject;
sl@0
   626
	iPreviousState = aPreviousState;
sl@0
   627
	iCurrentState = aCurrentState;
sl@0
   628
sl@0
   629
	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
sl@0
   630
	if (!busy || iError!=KErrNone)
sl@0
   631
		CActiveScheduler::Stop();
sl@0
   632
	
sl@0
   633
	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
sl@0
   634
	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
sl@0
   635
	
sl@0
   636
	}
sl@0
   637
sl@0
   638
sl@0
   639
//--------------------------------------------------------------------------------
sl@0
   640
sl@0
   641
/**
sl@0
   642
 * Constructor
sl@0
   643
 */
sl@0
   644
CTestMmfAclntDRMConverterFail::CTestMmfAclntDRMConverterFail()
sl@0
   645
	{
sl@0
   646
	// store the name of this test case
sl@0
   647
	// this is the name that is used by the script file
sl@0
   648
	// Each test step initialises it's own name
sl@0
   649
	iTestStepName = _L("MM-MMF-ACLNT-I-9006-LP");
sl@0
   650
sl@0
   651
	}
sl@0
   652
sl@0
   653
CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewL()
sl@0
   654
	{
sl@0
   655
	CTestMmfAclntDRMConverterFail* self = new (ELeave) CTestMmfAclntDRMConverterFail();
sl@0
   656
	return self;
sl@0
   657
	}
sl@0
   658
sl@0
   659
CTestMmfAclntDRMConverterFail* CTestMmfAclntDRMConverterFail::NewLC()
sl@0
   660
	{
sl@0
   661
	CTestMmfAclntDRMConverterFail* self = CTestMmfAclntDRMConverterFail::NewL();
sl@0
   662
	CleanupStack::PushL(self);
sl@0
   663
	return self;
sl@0
   664
	}
sl@0
   665
sl@0
   666
/** Load and initialise an audio file.
sl@0
   667
 */
sl@0
   668
TVerdict CTestMmfAclntDRMConverterFail::DoTestStepL( void )
sl@0
   669
	{
sl@0
   670
	INFO_PRINTF1( _L("TestconverterUtils : File"));
sl@0
   671
	TVerdict ret = EFail;
sl@0
   672
sl@0
   673
	iError = KErrTimedOut;
sl@0
   674
sl@0
   675
	//fectch MIME type from config file
sl@0
   676
	TBuf8<KMaxMimeLength> mimeType;
sl@0
   677
	TPtrC				  mimeTypePtr; 
sl@0
   678
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavMime"),mimeTypePtr))
sl@0
   679
		return EInconclusive;
sl@0
   680
	mimeType.Copy(mimeTypePtr);
sl@0
   681
sl@0
   682
	//setup DRM rights
sl@0
   683
	CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one
sl@0
   684
	CleanupStack::PushL(rights);
sl@0
   685
	rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount,mimeType); // add rights count 
sl@0
   686
	CleanupStack::PopAndDestroy(rights); // cleanup rights object
sl@0
   687
sl@0
   688
sl@0
   689
	TBuf<KSizeBuf>	filename;
sl@0
   690
	TBuf<KSizeBuf>	destFilename;
sl@0
   691
	TPtrC			filename1; 
sl@0
   692
	TPtrC			filename2;
sl@0
   693
	if(!GetStringFromConfig(_L("SectionDRM"),_L("DRMWavFile"),filename1))
sl@0
   694
		return EInconclusive;
sl@0
   695
	if(!GetStringFromConfig(_L("SectionDRM"),_L("TestConvertFile"),filename2))
sl@0
   696
		return EInconclusive;
sl@0
   697
	GetDriveName(filename);
sl@0
   698
	filename.Append(filename1);
sl@0
   699
	GetDriveName(destFilename);
sl@0
   700
	destFilename.Append(filename2);
sl@0
   701
sl@0
   702
	RFs		theFs;
sl@0
   703
	theFs.Connect();
sl@0
   704
	theFs.Delete(destFilename);
sl@0
   705
	theFs.Close();
sl@0
   706
sl@0
   707
sl@0
   708
	iError = KErrTimedOut;
sl@0
   709
	TMdaFileClipLocation location(destFilename);
sl@0
   710
	TMdaWavClipFormat	format;
sl@0
   711
	TMdaPcmWavCodec		codec;
sl@0
   712
sl@0
   713
	CMdaAudioConvertUtility* converter = CMdaAudioConvertUtility::NewL(*this);
sl@0
   714
	CleanupStack::PushL(converter);
sl@0
   715
sl@0
   716
	converter->OpenL(filename, &location, &format, &codec);
sl@0
   717
sl@0
   718
	// Wait for initialisation callback
sl@0
   719
	INFO_PRINTF1( _L("Initialise CMdaAudioConvertUtility"));
sl@0
   720
	CActiveScheduler::Start();
sl@0
   721
sl@0
   722
	// Check for errors.
sl@0
   723
	if (iError == KErrNone && converter != NULL)
sl@0
   724
		{
sl@0
   725
		iError = KErrTimedOut;
sl@0
   726
sl@0
   727
		converter->ConvertL();
sl@0
   728
			
sl@0
   729
		// Wait for convert callback
sl@0
   730
		INFO_PRINTF1( _L("Convert CMdaAudioconverterUtility: DRM play number"));
sl@0
   731
		CActiveScheduler::Start();
sl@0
   732
sl@0
   733
		if (iError == KErrNotSupported)
sl@0
   734
			{
sl@0
   735
			INFO_PRINTF1(_L("Correctly received KErrNotSupported, for converting protected file"));
sl@0
   736
			ret = EPass;
sl@0
   737
			}
sl@0
   738
		else
sl@0
   739
			{
sl@0
   740
			INFO_PRINTF3(_L("Unexpected error %d, expecting %d"),iError, KErrNotSupported);
sl@0
   741
			}
sl@0
   742
		}
sl@0
   743
	
sl@0
   744
	CleanupStack::PopAndDestroy(converter);
sl@0
   745
	User::After(KOneSecond); // wait for deletion to shut down devsound
sl@0
   746
	return	ret;
sl@0
   747
	}
sl@0
   748
sl@0
   749
sl@0
   750
sl@0
   751
sl@0
   752
void CTestMmfAclntDRMConverterFail::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
sl@0
   753
	{
sl@0
   754
	iError = aErrorCode;
sl@0
   755
	//iObject = aObject;
sl@0
   756
	iPreviousState = aPreviousState;
sl@0
   757
	iCurrentState = aCurrentState;
sl@0
   758
sl@0
   759
	TBool busy = (iCurrentState == CMdaAudioClipUtility::ERecording || iCurrentState == CMdaAudioClipUtility::EPlaying);
sl@0
   760
	if (!busy || iError!=KErrNone)
sl@0
   761
		CActiveScheduler::Stop();
sl@0
   762
sl@0
   763
	INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioconverterUtility complete"));
sl@0
   764
	INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState);
sl@0
   765
	
sl@0
   766
	}
sl@0
   767