os/security/contentmgmt/referencedrmagent/tcaf/source/ManagerStep.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <test/testexecutelog.h>
sl@0
    20
#include <apmstd.h>
sl@0
    21
sl@0
    22
#include "cafserver.h"
sl@0
    23
#include "ManagerStep.h"
sl@0
    24
#include "manager.h"
sl@0
    25
#include "dirstreamable.h"
sl@0
    26
#include "virtualpathptr.h"
sl@0
    27
#include "agent.h"
sl@0
    28
#include "attributeset.h"
sl@0
    29
#include "stringattributeset.h"
sl@0
    30
#include "contentIterator.h"
sl@0
    31
sl@0
    32
using namespace ContentAccess;
sl@0
    33
sl@0
    34
sl@0
    35
sl@0
    36
/* 
sl@0
    37
 * This step deletes a file using the CAF framework
sl@0
    38
 *
sl@0
    39
 */
sl@0
    40
sl@0
    41
CCAFDeleteStep::~CCAFDeleteStep()
sl@0
    42
	{
sl@0
    43
	}
sl@0
    44
sl@0
    45
CCAFDeleteStep::CCAFDeleteStep(CCAFServer& aParent) : iParent(aParent)
sl@0
    46
	{
sl@0
    47
	SetTestStepName(KCAFDeleteStep);
sl@0
    48
	}
sl@0
    49
sl@0
    50
sl@0
    51
TVerdict CCAFDeleteStep::doTestStepL()
sl@0
    52
	{
sl@0
    53
	TPtrC fileName;
sl@0
    54
sl@0
    55
	TInt expectedResult;
sl@0
    56
	TInt result;
sl@0
    57
sl@0
    58
	SetTestStepResult(EFail);
sl@0
    59
sl@0
    60
	// Find the file to delete and the expected return code from the INI file
sl@0
    61
	GetStringFromConfig(ConfigSection(),_L("filename"),fileName);
sl@0
    62
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
    63
sl@0
    64
	INFO_PRINTF3(_L("Delete File %S Expected result: %d"), &fileName, expectedResult);
sl@0
    65
sl@0
    66
	__UHEAP_MARK;
sl@0
    67
sl@0
    68
	TRAP(result, CManager::DeleteFileL(fileName));
sl@0
    69
sl@0
    70
	if(result != KErrNone)
sl@0
    71
		{
sl@0
    72
		INFO_PRINTF2(_L("Delete file left: %d"), result);
sl@0
    73
		if(result== expectedResult)
sl@0
    74
			{
sl@0
    75
			SetTestStepResult(EPass);
sl@0
    76
			}
sl@0
    77
		}
sl@0
    78
	else if(result == expectedResult)
sl@0
    79
		{	
sl@0
    80
		SetTestStepResult(EPass);
sl@0
    81
		}
sl@0
    82
	else INFO_PRINTF2(_L("Delete file left with error: %d"), result);
sl@0
    83
    		
sl@0
    84
	__UHEAP_MARKEND;
sl@0
    85
	return TestStepResult();
sl@0
    86
	}
sl@0
    87
sl@0
    88
sl@0
    89
/* 
sl@0
    90
 * This step copies a file using the CAF framework
sl@0
    91
 *
sl@0
    92
 */
sl@0
    93
sl@0
    94
CCAFCopyFileStep::~CCAFCopyFileStep()
sl@0
    95
	{
sl@0
    96
	}
sl@0
    97
sl@0
    98
CCAFCopyFileStep::CCAFCopyFileStep(CCAFServer& aParent) : iParent(aParent)
sl@0
    99
	{
sl@0
   100
	SetTestStepName(KCAFCopyFileStep);
sl@0
   101
	}
sl@0
   102
sl@0
   103
sl@0
   104
TVerdict CCAFCopyFileStep::doTestStepL()
sl@0
   105
	{
sl@0
   106
	TPtrC source;
sl@0
   107
	TPtrC destination;
sl@0
   108
sl@0
   109
	TInt expectedResult;
sl@0
   110
	TInt result;
sl@0
   111
sl@0
   112
	SetTestStepResult(EFail);
sl@0
   113
sl@0
   114
	// Find the file to copy and the expected return code from the INI file
sl@0
   115
	GetStringFromConfig(ConfigSection(),_L("source"),source);
sl@0
   116
	GetStringFromConfig(ConfigSection(),_L("destination"),destination);
sl@0
   117
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   118
sl@0
   119
	INFO_PRINTF4(_L("Copy %S to %S, Expected result: %d"), &source, &destination, expectedResult);
sl@0
   120
sl@0
   121
	__UHEAP_MARK;
sl@0
   122
sl@0
   123
	CManager *manager = CManager::NewLC();
sl@0
   124
sl@0
   125
	result = manager->CopyFile(source, destination);
sl@0
   126
	if(result == expectedResult)
sl@0
   127
		{
sl@0
   128
		SetTestStepResult(EPass);			
sl@0
   129
		}
sl@0
   130
	else 
sl@0
   131
		{
sl@0
   132
		INFO_PRINTF2(_L("CopyFile(source as filename overload) returned with unexpected error: %d"), result);
sl@0
   133
		}
sl@0
   134
	// set up 2nd overload testing
sl@0
   135
	RFs fs;
sl@0
   136
	RFile file;
sl@0
   137
sl@0
   138
	// read the input file and pass it to the CAF
sl@0
   139
	fs.Connect();
sl@0
   140
	CleanupClosePushL(fs);
sl@0
   141
	User::LeaveIfError(fs.ShareProtected());		
sl@0
   142
sl@0
   143
	result = file.Open(fs, source, EFileRead | EFileStream | EFileShareAny);
sl@0
   144
	if (result == KErrNone)
sl@0
   145
		{
sl@0
   146
		CleanupClosePushL(file);
sl@0
   147
		
sl@0
   148
		// test the RFile overload
sl@0
   149
		result = manager->CopyFile(file, destination);
sl@0
   150
		
sl@0
   151
		if ((result == expectedResult)&&(TestStepResult()==EPass))
sl@0
   152
			{
sl@0
   153
			SetTestStepResult(EPass);			
sl@0
   154
			}
sl@0
   155
		else 
sl@0
   156
			{
sl@0
   157
			INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result);
sl@0
   158
			}
sl@0
   159
			
sl@0
   160
		CleanupStack::PopAndDestroy(&file); 
sl@0
   161
		
sl@0
   162
		}
sl@0
   163
	else if ((result == expectedResult)&&(TestStepResult()==EPass))
sl@0
   164
		{
sl@0
   165
		SetTestStepResult(EPass);			
sl@0
   166
		}
sl@0
   167
	else 
sl@0
   168
		{
sl@0
   169
		INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result);
sl@0
   170
		}
sl@0
   171
		
sl@0
   172
	CleanupStack::PopAndDestroy(&fs); 
sl@0
   173
sl@0
   174
	CleanupStack::PopAndDestroy(manager);
sl@0
   175
	    		
sl@0
   176
	__UHEAP_MARKEND;
sl@0
   177
	return TestStepResult();
sl@0
   178
	}
sl@0
   179
/* 
sl@0
   180
 * This step renames a file using the CAF framework
sl@0
   181
 *
sl@0
   182
 */
sl@0
   183
sl@0
   184
CCAFRenameFileStep::~CCAFRenameFileStep()
sl@0
   185
	{
sl@0
   186
	}
sl@0
   187
sl@0
   188
CCAFRenameFileStep::CCAFRenameFileStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   189
	{
sl@0
   190
	SetTestStepName(KCAFRenameFileStep);
sl@0
   191
	}
sl@0
   192
sl@0
   193
sl@0
   194
TVerdict CCAFRenameFileStep::doTestStepL()
sl@0
   195
	{
sl@0
   196
	TPtrC source;
sl@0
   197
	TPtrC destination;
sl@0
   198
sl@0
   199
	TInt expectedResult;
sl@0
   200
	TInt result;
sl@0
   201
sl@0
   202
	SetTestStepResult(EFail);
sl@0
   203
sl@0
   204
	// Find the file to copy and the expected return code from the INI file
sl@0
   205
	GetStringFromConfig(ConfigSection(),_L("source"),source);
sl@0
   206
	GetStringFromConfig(ConfigSection(),_L("destination"),destination);
sl@0
   207
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   208
sl@0
   209
	INFO_PRINTF4(_L("Rename from %S to %S, Expected result: %d"), &source, &destination, expectedResult);
sl@0
   210
sl@0
   211
	__UHEAP_MARK;
sl@0
   212
sl@0
   213
	CManager *manager = CManager::NewLC();
sl@0
   214
	result = manager->RenameFile(source, destination);
sl@0
   215
	CleanupStack::PopAndDestroy(manager);
sl@0
   216
	
sl@0
   217
	if(result == expectedResult)
sl@0
   218
		{	
sl@0
   219
		SetTestStepResult(EPass);
sl@0
   220
		}
sl@0
   221
	else 
sl@0
   222
		{
sl@0
   223
		INFO_PRINTF2(_L("RenameFile() returned with unexpected error: %d"), result);
sl@0
   224
		}
sl@0
   225
    		
sl@0
   226
	__UHEAP_MARKEND;
sl@0
   227
	return TestStepResult();
sl@0
   228
	}
sl@0
   229
sl@0
   230
sl@0
   231
/* 
sl@0
   232
 * This step creates a directory using the CAF framework
sl@0
   233
 *
sl@0
   234
 */
sl@0
   235
sl@0
   236
CCAFMkDirStep::~CCAFMkDirStep()
sl@0
   237
	{
sl@0
   238
	}
sl@0
   239
sl@0
   240
CCAFMkDirStep::CCAFMkDirStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   241
	{
sl@0
   242
	SetTestStepName(KCAFMkDirStep);
sl@0
   243
	}
sl@0
   244
sl@0
   245
sl@0
   246
TVerdict CCAFMkDirStep::doTestStepL()
sl@0
   247
	{
sl@0
   248
	TPtrC path;
sl@0
   249
	TInt expectedResult;
sl@0
   250
	TInt result;
sl@0
   251
sl@0
   252
	SetTestStepResult(EFail);
sl@0
   253
sl@0
   254
	// Find the file to copy and the expected return code from the INI file
sl@0
   255
	GetStringFromConfig(ConfigSection(),_L("path"),path);
sl@0
   256
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   257
sl@0
   258
	INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult);
sl@0
   259
sl@0
   260
	__UHEAP_MARK;
sl@0
   261
sl@0
   262
	CManager *manager = CManager::NewLC();
sl@0
   263
	result = manager->MkDir(path);
sl@0
   264
	CleanupStack::PopAndDestroy(manager);
sl@0
   265
	
sl@0
   266
	if(result == expectedResult)
sl@0
   267
		{	
sl@0
   268
		SetTestStepResult(EPass);
sl@0
   269
		}
sl@0
   270
	else 
sl@0
   271
		{
sl@0
   272
		INFO_PRINTF2(_L("MkDir() returned with unexpected error: %d"), result);
sl@0
   273
		}
sl@0
   274
    		
sl@0
   275
	__UHEAP_MARKEND;
sl@0
   276
	return TestStepResult();
sl@0
   277
	}
sl@0
   278
sl@0
   279
sl@0
   280
/* 
sl@0
   281
 * This step creates several directory using the CAF framework
sl@0
   282
 *
sl@0
   283
 */
sl@0
   284
sl@0
   285
CCAFMkDirAllStep::~CCAFMkDirAllStep()
sl@0
   286
	{
sl@0
   287
	}
sl@0
   288
sl@0
   289
CCAFMkDirAllStep::CCAFMkDirAllStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   290
	{
sl@0
   291
	SetTestStepName(KCAFMkDirAllStep);
sl@0
   292
	}
sl@0
   293
sl@0
   294
sl@0
   295
TVerdict CCAFMkDirAllStep::doTestStepL()
sl@0
   296
	{
sl@0
   297
	TPtrC path;
sl@0
   298
	TInt expectedResult;
sl@0
   299
	TInt result;
sl@0
   300
sl@0
   301
	SetTestStepResult(EFail);
sl@0
   302
sl@0
   303
	// Find the file to copy and the expected return code from the INI file
sl@0
   304
	GetStringFromConfig(ConfigSection(),_L("path"),path);
sl@0
   305
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   306
sl@0
   307
	INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult);
sl@0
   308
sl@0
   309
	__UHEAP_MARK;
sl@0
   310
sl@0
   311
	CManager *manager = CManager::NewLC();
sl@0
   312
	// remove directory in case it already exists
sl@0
   313
	manager->RmDir(path);
sl@0
   314
	result = manager->MkDirAll(path);
sl@0
   315
	CleanupStack::PopAndDestroy(manager);
sl@0
   316
	
sl@0
   317
	if(result == expectedResult)
sl@0
   318
		{	
sl@0
   319
		SetTestStepResult(EPass);
sl@0
   320
		}
sl@0
   321
	else 
sl@0
   322
		{
sl@0
   323
		INFO_PRINTF2(_L("MkDirAll() returned with unexpected error: %d"), result);
sl@0
   324
		}
sl@0
   325
    		
sl@0
   326
	__UHEAP_MARKEND;
sl@0
   327
	return TestStepResult();
sl@0
   328
	}
sl@0
   329
sl@0
   330
/* 
sl@0
   331
 * This step removes a directory using the CAF framework
sl@0
   332
 *
sl@0
   333
 */
sl@0
   334
sl@0
   335
CCAFRmDirStep::~CCAFRmDirStep()
sl@0
   336
	{
sl@0
   337
	}
sl@0
   338
sl@0
   339
CCAFRmDirStep::CCAFRmDirStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   340
	{
sl@0
   341
	SetTestStepName(KCAFRmDirStep);
sl@0
   342
	}
sl@0
   343
sl@0
   344
sl@0
   345
TVerdict CCAFRmDirStep::doTestStepL()
sl@0
   346
	{
sl@0
   347
	TPtrC path;
sl@0
   348
	TInt expectedResult;
sl@0
   349
	TInt result;
sl@0
   350
sl@0
   351
	SetTestStepResult(EFail);
sl@0
   352
sl@0
   353
	// Find the file to copy and the expected return code from the INI file
sl@0
   354
	GetStringFromConfig(ConfigSection(),_L("path"),path);
sl@0
   355
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   356
sl@0
   357
	INFO_PRINTF3(_L("Remove directory %S, Expected result: %d"), &path, expectedResult);
sl@0
   358
sl@0
   359
	__UHEAP_MARK;
sl@0
   360
sl@0
   361
	CManager *manager = CManager::NewLC();
sl@0
   362
	result = manager->RmDir(path);
sl@0
   363
	CleanupStack::PopAndDestroy(manager);
sl@0
   364
	
sl@0
   365
	if(result == expectedResult)
sl@0
   366
		{	
sl@0
   367
		SetTestStepResult(EPass);
sl@0
   368
		}
sl@0
   369
	else 
sl@0
   370
		{
sl@0
   371
		INFO_PRINTF2(_L("RmDir() returned with unexpected error: %d"), result);
sl@0
   372
		}
sl@0
   373
    		
sl@0
   374
	__UHEAP_MARKEND;
sl@0
   375
	return TestStepResult();
sl@0
   376
	}
sl@0
   377
sl@0
   378
/* 
sl@0
   379
 * This step lists the contents of a directory using the CAF framework
sl@0
   380
 *
sl@0
   381
 */
sl@0
   382
sl@0
   383
CCAFGetDirStep::~CCAFGetDirStep()
sl@0
   384
	{
sl@0
   385
	}
sl@0
   386
sl@0
   387
CCAFGetDirStep::CCAFGetDirStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   388
	{
sl@0
   389
	SetTestStepName(KCAFGetDirStep);
sl@0
   390
	}
sl@0
   391
sl@0
   392
sl@0
   393
TVerdict CCAFGetDirStep::doTestStepL()
sl@0
   394
	{
sl@0
   395
	TPtrC path;
sl@0
   396
	TInt expectedResult;
sl@0
   397
	TInt result;
sl@0
   398
	TInt GetDirAPI = 0;
sl@0
   399
sl@0
   400
	CDir *entrylist = NULL;
sl@0
   401
	CDir *dirlist = NULL;
sl@0
   402
	CDir *filelist = NULL;
sl@0
   403
sl@0
   404
sl@0
   405
	SetTestStepResult(EFail);
sl@0
   406
sl@0
   407
	// Find the file to copy and the expected return code from the INI file
sl@0
   408
	GetStringFromConfig(ConfigSection(),_L("path"),path);
sl@0
   409
	GetIntFromConfig(ConfigSection(),_L("API"),GetDirAPI);
sl@0
   410
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   411
sl@0
   412
	INFO_PRINTF3(_L("List contents of directory %S, Expected result: %d"), &path, expectedResult);
sl@0
   413
sl@0
   414
	__UHEAP_MARK;
sl@0
   415
sl@0
   416
	CManager *manager = CManager::NewLC();
sl@0
   417
	if(GetDirAPI == 1)
sl@0
   418
		{
sl@0
   419
		result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist);
sl@0
   420
		}
sl@0
   421
	else if(GetDirAPI == 2)
sl@0
   422
		{
sl@0
   423
		result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist, dirlist);
sl@0
   424
		}
sl@0
   425
	else
sl@0
   426
		{
sl@0
   427
		result = manager->GetDir(path,TUidType(), ESortByName, filelist);
sl@0
   428
		}
sl@0
   429
	CleanupStack::PopAndDestroy(manager);
sl@0
   430
sl@0
   431
	if(entrylist)
sl@0
   432
		{
sl@0
   433
		INFO_PRINTF2(_L("%d items in EntryList:"), entrylist->Count());	
sl@0
   434
		DisplayList(*entrylist);
sl@0
   435
		delete entrylist;
sl@0
   436
		entrylist = NULL;
sl@0
   437
		}
sl@0
   438
sl@0
   439
	if(dirlist)
sl@0
   440
		{
sl@0
   441
		INFO_PRINTF2(_L("%d items in DirList:"), dirlist->Count());	
sl@0
   442
		DisplayList(*dirlist);
sl@0
   443
		delete dirlist;
sl@0
   444
		dirlist = NULL;
sl@0
   445
		}
sl@0
   446
	
sl@0
   447
	if(filelist)
sl@0
   448
		{
sl@0
   449
		INFO_PRINTF2(_L("%d items in FileList:"), filelist->Count());	
sl@0
   450
		DisplayList(*filelist);
sl@0
   451
		delete filelist;
sl@0
   452
		filelist = NULL;
sl@0
   453
		}
sl@0
   454
	
sl@0
   455
	if(result == expectedResult)
sl@0
   456
		{	
sl@0
   457
		SetTestStepResult(EPass);
sl@0
   458
		}
sl@0
   459
	else 
sl@0
   460
		{
sl@0
   461
		INFO_PRINTF2(_L("GetDir() returned with unexpected error: %d"), result);
sl@0
   462
		}
sl@0
   463
    		
sl@0
   464
	__UHEAP_MARKEND;
sl@0
   465
	return TestStepResult();
sl@0
   466
	}
sl@0
   467
sl@0
   468
sl@0
   469
void CCAFGetDirStep::DisplayList(CDir& aDir)
sl@0
   470
	{
sl@0
   471
	TInt i = 0;
sl@0
   472
	for(i = 0; i < aDir.Count(); i++)
sl@0
   473
		{
sl@0
   474
		INFO_PRINTF2(_L("			%S"), &aDir[i].iName );	
sl@0
   475
		}
sl@0
   476
	}
sl@0
   477
	
sl@0
   478
	
sl@0
   479
/* 
sl@0
   480
 * This step tests the notification functions
sl@0
   481
 *
sl@0
   482
 */
sl@0
   483
sl@0
   484
CCAFManagerNotifyStep::~CCAFManagerNotifyStep()
sl@0
   485
	{
sl@0
   486
	}
sl@0
   487
sl@0
   488
CCAFManagerNotifyStep::CCAFManagerNotifyStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   489
	{
sl@0
   490
	SetTestStepName(KCAFManagerNotifyStep);
sl@0
   491
	}
sl@0
   492
sl@0
   493
sl@0
   494
TVerdict CCAFManagerNotifyStep::doTestStepL()
sl@0
   495
	{
sl@0
   496
	TPtrC uri;
sl@0
   497
	TInt result;
sl@0
   498
	TRequestStatus status = KRequestPending;
sl@0
   499
	
sl@0
   500
	TInt Status1;
sl@0
   501
	TInt Cancel1;
sl@0
   502
	TInt Cancel2;
sl@0
   503
	
sl@0
   504
	
sl@0
   505
	SetTestStepResult(EPass);
sl@0
   506
sl@0
   507
	// Find the file to copy and the expected return code from the INI file
sl@0
   508
	GetStringFromConfig(ConfigSection(),_L("path"),uri);
sl@0
   509
	GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
sl@0
   510
	GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
sl@0
   511
	GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
sl@0
   512
sl@0
   513
	INFO_PRINTF2(_L("Performing notification tests on %S"), &uri);
sl@0
   514
sl@0
   515
	__UHEAP_MARK;
sl@0
   516
	CManager *manager = CManager::NewLC();
sl@0
   517
	// Wait for rights 
sl@0
   518
	manager->NotifyStatusChange(uri, ERightsAvailable, status);
sl@0
   519
	User::WaitForRequest(status);
sl@0
   520
	if(status.Int() != Status1)
sl@0
   521
		{
sl@0
   522
		INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
sl@0
   523
		SetTestStepResult(EFail);
sl@0
   524
		}
sl@0
   525
	result = manager->CancelNotifyStatusChange(uri, status);
sl@0
   526
	if(result != Cancel1)
sl@0
   527
		{
sl@0
   528
		INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
sl@0
   529
		SetTestStepResult(EFail);
sl@0
   530
		}
sl@0
   531
	
sl@0
   532
	// Wait for rights expired but cancel before they arrive
sl@0
   533
	manager->NotifyStatusChange(uri, ERightsExpired, status);
sl@0
   534
	result = manager->CancelNotifyStatusChange(uri, status);
sl@0
   535
	if(result != Cancel2)
sl@0
   536
		{
sl@0
   537
		INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
sl@0
   538
		SetTestStepResult(EFail);
sl@0
   539
		}
sl@0
   540
	
sl@0
   541
	CleanupStack::PopAndDestroy(manager);
sl@0
   542
	
sl@0
   543
   		
sl@0
   544
	__UHEAP_MARKEND;
sl@0
   545
	return TestStepResult();
sl@0
   546
	}
sl@0
   547
sl@0
   548
/* 
sl@0
   549
 * This step sets a property in the agents
sl@0
   550
 *
sl@0
   551
 */
sl@0
   552
sl@0
   553
CCAFManagerSetPropertyStep::~CCAFManagerSetPropertyStep()
sl@0
   554
	{
sl@0
   555
	}
sl@0
   556
sl@0
   557
CCAFManagerSetPropertyStep::CCAFManagerSetPropertyStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   558
	{
sl@0
   559
	SetTestStepName(KCAFManagerSetPropertyStep);
sl@0
   560
	}
sl@0
   561
sl@0
   562
sl@0
   563
TVerdict CCAFManagerSetPropertyStep::doTestStepL()
sl@0
   564
	{
sl@0
   565
	TInt expectedResult;
sl@0
   566
	TInt result;
sl@0
   567
sl@0
   568
	SetTestStepResult(EFail);
sl@0
   569
sl@0
   570
	// Find the file to copy and the expected return code from the INI file
sl@0
   571
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   572
sl@0
   573
	INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult);
sl@0
   574
sl@0
   575
	__UHEAP_MARK;
sl@0
   576
sl@0
   577
	CManager *manager = CManager::NewLC();
sl@0
   578
	result = manager->SetProperty(EAgentPropertyBufferSize, 100);
sl@0
   579
	CleanupStack::PopAndDestroy(manager);
sl@0
   580
	
sl@0
   581
	// dummy test Agent expects KErrNotSupported
sl@0
   582
	if(result == expectedResult || result == KErrNotSupported)
sl@0
   583
		{	
sl@0
   584
		SetTestStepResult(EPass);
sl@0
   585
		}
sl@0
   586
	else 
sl@0
   587
		{
sl@0
   588
		INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result);
sl@0
   589
		}
sl@0
   590
    		
sl@0
   591
	__UHEAP_MARKEND;
sl@0
   592
	return TestStepResult();
sl@0
   593
	}
sl@0
   594
sl@0
   595
sl@0
   596
/* 
sl@0
   597
 * This step asks the agent to display information about a file
sl@0
   598
 *
sl@0
   599
 */
sl@0
   600
sl@0
   601
CCAFManagerDisplayInfoStep::~CCAFManagerDisplayInfoStep()
sl@0
   602
	{
sl@0
   603
	}
sl@0
   604
sl@0
   605
CCAFManagerDisplayInfoStep::CCAFManagerDisplayInfoStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   606
	{
sl@0
   607
	SetTestStepName(KCAFManagerDisplayInfoStep);
sl@0
   608
	}
sl@0
   609
sl@0
   610
sl@0
   611
TVerdict CCAFManagerDisplayInfoStep::doTestStepL()
sl@0
   612
	{
sl@0
   613
	TPtrC uri;
sl@0
   614
	TInt expectedResult;
sl@0
   615
	TInt result;
sl@0
   616
sl@0
   617
	SetTestStepResult(EFail);
sl@0
   618
sl@0
   619
	// Find the file to copy and the expected return code from the INI file
sl@0
   620
	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
sl@0
   621
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   622
sl@0
   623
	INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult);
sl@0
   624
sl@0
   625
	__UHEAP_MARK;
sl@0
   626
sl@0
   627
	CManager *manager = CManager::NewLC();
sl@0
   628
	TRAP(result, manager->DisplayInfoL(EFileProperties, TVirtualPathPtr(uri)));
sl@0
   629
	CleanupStack::PopAndDestroy(manager);
sl@0
   630
	
sl@0
   631
	if(result == expectedResult)
sl@0
   632
		{	
sl@0
   633
		SetTestStepResult(EPass);
sl@0
   634
		}
sl@0
   635
	else 
sl@0
   636
		{
sl@0
   637
		INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result);
sl@0
   638
		}
sl@0
   639
    		
sl@0
   640
	__UHEAP_MARKEND;
sl@0
   641
	return TestStepResult();
sl@0
   642
	}
sl@0
   643
sl@0
   644
/* 
sl@0
   645
 * This step asks CAF for a list of agents
sl@0
   646
 *
sl@0
   647
 */
sl@0
   648
sl@0
   649
CCAFManagerListAgentsStep::~CCAFManagerListAgentsStep()
sl@0
   650
	{
sl@0
   651
	}
sl@0
   652
sl@0
   653
CCAFManagerListAgentsStep::CCAFManagerListAgentsStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   654
	{
sl@0
   655
	SetTestStepName(KCAFManagerListAgentsStep);
sl@0
   656
	}
sl@0
   657
sl@0
   658
sl@0
   659
TVerdict CCAFManagerListAgentsStep::doTestStepL()
sl@0
   660
	{
sl@0
   661
	TPtrC uri;
sl@0
   662
	TInt expectedResult;
sl@0
   663
	TInt expectedNumber;
sl@0
   664
	TInt result;
sl@0
   665
sl@0
   666
	RArray <TAgent> agents;
sl@0
   667
	
sl@0
   668
	SetTestStepResult(EFail);
sl@0
   669
sl@0
   670
	// Find the file to copy and the expected return code from the INI file
sl@0
   671
	GetIntFromConfig(ConfigSection(),_L("count"),expectedNumber);
sl@0
   672
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   673
sl@0
   674
	INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult);
sl@0
   675
sl@0
   676
	__UHEAP_MARK;
sl@0
   677
sl@0
   678
	CManager *manager = CManager::NewLC();
sl@0
   679
	TRAP(result, manager->ListAgentsL(agents));
sl@0
   680
	CleanupStack::PopAndDestroy(manager);
sl@0
   681
	
sl@0
   682
	TInt i = 0;
sl@0
   683
	for (i = 0; i < agents.Count(); i++)
sl@0
   684
		{
sl@0
   685
		TPtrC agentName = agents[i].Name();
sl@0
   686
		INFO_PRINTF2(_L("			%S"), &agentName);
sl@0
   687
		}
sl@0
   688
		
sl@0
   689
	INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult);
sl@0
   690
sl@0
   691
	if(result == expectedResult)
sl@0
   692
		{	
sl@0
   693
		if(expectedNumber == agents.Count())
sl@0
   694
			{
sl@0
   695
			SetTestStepResult(EPass);
sl@0
   696
			}
sl@0
   697
		else
sl@0
   698
			{
sl@0
   699
			INFO_PRINTF2(_L("Expected number of agents: %d"), expectedNumber);
sl@0
   700
			}
sl@0
   701
		}
sl@0
   702
	else 
sl@0
   703
		{
sl@0
   704
		INFO_PRINTF2(_L("ListAgents left with unexpected error: %d"), result);
sl@0
   705
		}
sl@0
   706
		
sl@0
   707
	agents.Close();
sl@0
   708
    		
sl@0
   709
	__UHEAP_MARKEND;
sl@0
   710
	return TestStepResult();
sl@0
   711
	}
sl@0
   712
sl@0
   713
/* 
sl@0
   714
 * This step attempts to perform an agent specific command
sl@0
   715
 *
sl@0
   716
 */
sl@0
   717
sl@0
   718
CCAFManagerAgentSpecificStep::~CCAFManagerAgentSpecificStep()
sl@0
   719
	{
sl@0
   720
	}
sl@0
   721
sl@0
   722
CCAFManagerAgentSpecificStep::CCAFManagerAgentSpecificStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   723
	{
sl@0
   724
	SetTestStepName(KCAFManagerAgentSpecificStep);
sl@0
   725
	}
sl@0
   726
sl@0
   727
sl@0
   728
TVerdict CCAFManagerAgentSpecificStep::doTestStepL()
sl@0
   729
	{
sl@0
   730
	TPtrC input16;
sl@0
   731
	TPtrC output16;
sl@0
   732
	TInt expectedResult;
sl@0
   733
	TInt command;
sl@0
   734
	TInt result;
sl@0
   735
	TBuf8 <100> actualOutput;
sl@0
   736
	TBuf8 <100> output;
sl@0
   737
	TBuf8 <100> input;
sl@0
   738
	TInt index = 0;
sl@0
   739
sl@0
   740
	RArray <TAgent> agents;
sl@0
   741
	_LIT(KTestAgentName, "Reference Test Agent");
sl@0
   742
	
sl@0
   743
	SetTestStepResult(EPass);
sl@0
   744
sl@0
   745
	GetIntFromConfig(ConfigSection(),_L("command"),command);
sl@0
   746
	GetStringFromConfig(ConfigSection(),_L("input"),input16);
sl@0
   747
	GetStringFromConfig(ConfigSection(),_L("output"),output16);
sl@0
   748
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   749
sl@0
   750
	input.Copy(input16);
sl@0
   751
	output.Copy(output16);
sl@0
   752
sl@0
   753
	__UHEAP_MARK;
sl@0
   754
	CManager *manager = CManager::NewLC();
sl@0
   755
	TRAP(result, manager->ListAgentsL(agents));
sl@0
   756
sl@0
   757
	INFO_PRINTF1(_L("Running synchronous Agent specific command"));
sl@0
   758
	actualOutput.SetLength(0);
sl@0
   759
	if(result == KErrNone && agents.Count() > 0)
sl@0
   760
		{
sl@0
   761
		for(index = 0; index < agents.Count(); index++)
sl@0
   762
			{
sl@0
   763
			if(agents[index].Name() == KTestAgentName())
sl@0
   764
				{
sl@0
   765
				break;
sl@0
   766
				}
sl@0
   767
			}
sl@0
   768
		result = manager->AgentSpecificCommand(agents[index],command, input, actualOutput);
sl@0
   769
		}
sl@0
   770
	else
sl@0
   771
		{
sl@0
   772
		SetTestStepResult(EFail);
sl@0
   773
		}
sl@0
   774
	if(result != expectedResult)
sl@0
   775
		{	
sl@0
   776
		SetTestStepResult(EFail);
sl@0
   777
		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result);
sl@0
   778
		}
sl@0
   779
	else if(actualOutput != output)
sl@0
   780
		{
sl@0
   781
		SetTestStepResult(EFail);
sl@0
   782
		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
sl@0
   783
		}
sl@0
   784
sl@0
   785
	INFO_PRINTF1(_L("Running asynchronous Agent specific command"));
sl@0
   786
	TRequestStatus status;
sl@0
   787
	actualOutput.SetLength(0);
sl@0
   788
	if((result == KErrNone || result == expectedResult) && agents.Count() > 0)
sl@0
   789
		{
sl@0
   790
		manager->AgentSpecificCommand(agents[index], command, input, actualOutput, status);
sl@0
   791
		User::WaitForRequest(status);
sl@0
   792
		}
sl@0
   793
	else
sl@0
   794
		{
sl@0
   795
		SetTestStepResult(EFail);
sl@0
   796
		}
sl@0
   797
	if(status.Int() != expectedResult)
sl@0
   798
		{	
sl@0
   799
		SetTestStepResult(EFail);
sl@0
   800
		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int());
sl@0
   801
		}
sl@0
   802
	else if(actualOutput != output)
sl@0
   803
		{
sl@0
   804
		SetTestStepResult(EFail);
sl@0
   805
		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
sl@0
   806
		}
sl@0
   807
	
sl@0
   808
	CleanupStack::PopAndDestroy(manager);		
sl@0
   809
	agents.Close();
sl@0
   810
    		
sl@0
   811
	__UHEAP_MARKEND;
sl@0
   812
	return TestStepResult();
sl@0
   813
	}
sl@0
   814
sl@0
   815
/* 
sl@0
   816
 * This step attempts to display configuration information
sl@0
   817
 *
sl@0
   818
 */
sl@0
   819
sl@0
   820
CCAFManagerDisplayConfigStep::~CCAFManagerDisplayConfigStep()
sl@0
   821
	{
sl@0
   822
	}
sl@0
   823
sl@0
   824
CCAFManagerDisplayConfigStep::CCAFManagerDisplayConfigStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   825
	{
sl@0
   826
	SetTestStepName(KCAFManagerDisplayConfigStep);
sl@0
   827
	}
sl@0
   828
sl@0
   829
TVerdict CCAFManagerDisplayConfigStep::doTestStepL()
sl@0
   830
	{
sl@0
   831
	TInt expectedResult;
sl@0
   832
	TInt result = KErrNone;
sl@0
   833
sl@0
   834
	RArray <TAgent> agents;
sl@0
   835
	CManager *manager;
sl@0
   836
sl@0
   837
	SetTestStepResult(EPass);
sl@0
   838
sl@0
   839
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
   840
sl@0
   841
	__UHEAP_MARK;
sl@0
   842
	manager = CManager::NewL();
sl@0
   843
	CleanupStack::PushL(manager);
sl@0
   844
	TRAP(result, manager->ListAgentsL(agents));
sl@0
   845
		
sl@0
   846
	if(result == KErrNone && agents.Count() > 0)
sl@0
   847
		{
sl@0
   848
		TRAP(result, manager->DisplayManagementInfoL(agents[0]));
sl@0
   849
		}
sl@0
   850
	else
sl@0
   851
		{
sl@0
   852
		SetTestStepResult(EFail);
sl@0
   853
		}
sl@0
   854
	if(result != expectedResult && result != KErrNotSupported) // dummy test agent expects -5
sl@0
   855
		{	
sl@0
   856
		SetTestStepResult(EFail);
sl@0
   857
		INFO_PRINTF3(_L("Expected result: %d, actual result: %d"), expectedResult, result);
sl@0
   858
		}
sl@0
   859
sl@0
   860
	CleanupStack::PopAndDestroy(manager);		
sl@0
   861
	agents.Close();
sl@0
   862
    		
sl@0
   863
	__UHEAP_MARKEND;
sl@0
   864
	return TestStepResult();
sl@0
   865
	}
sl@0
   866
sl@0
   867
/* 
sl@0
   868
 * Manager attribute step
sl@0
   869
 *
sl@0
   870
 */
sl@0
   871
sl@0
   872
CCAFManagerAttributeStep::~CCAFManagerAttributeStep()
sl@0
   873
	{
sl@0
   874
	}
sl@0
   875
sl@0
   876
CCAFManagerAttributeStep::CCAFManagerAttributeStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   877
	{
sl@0
   878
	SetTestStepName(KCAFManagerAttributeStep);
sl@0
   879
	}
sl@0
   880
sl@0
   881
TVerdict CCAFManagerAttributeStep::doTestStepL()
sl@0
   882
	{
sl@0
   883
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
sl@0
   884
    TBool wmdrmFlag = EFalse;     
sl@0
   885
    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
sl@0
   886
         
sl@0
   887
    if(wmdrmFlag)     
sl@0
   888
        {     
sl@0
   889
        TVerdict verdict = doWmdrmTestStepL();     
sl@0
   890
        return verdict;     
sl@0
   891
        }     
sl@0
   892
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT    
sl@0
   893
sl@0
   894
	TInt attribute;
sl@0
   895
	TInt value = KErrNone;
sl@0
   896
	TInt expectedValue;
sl@0
   897
	TPtrC uri;
sl@0
   898
	TPtrC uniqueId;
sl@0
   899
sl@0
   900
	CManager *manager;
sl@0
   901
sl@0
   902
	SetTestStepResult(EPass);
sl@0
   903
sl@0
   904
	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
sl@0
   905
	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
sl@0
   906
	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
sl@0
   907
	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
sl@0
   908
sl@0
   909
	__UHEAP_MARK;
sl@0
   910
	manager = CManager::NewL();
sl@0
   911
	if(manager)
sl@0
   912
		{
sl@0
   913
		CleanupStack::PushL(manager);
sl@0
   914
		User::LeaveIfError(manager->GetAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId)));
sl@0
   915
		if(expectedValue!= value)
sl@0
   916
			{
sl@0
   917
			SetTestStepResult(EFail);
sl@0
   918
			INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
sl@0
   919
			}
sl@0
   920
		CleanupStack::PopAndDestroy(manager);		
sl@0
   921
		}
sl@0
   922
	else
sl@0
   923
		{
sl@0
   924
		SetTestStepResult(EFail);
sl@0
   925
		INFO_PRINTF1(_L("CManager construction failed"));
sl@0
   926
		}
sl@0
   927
	
sl@0
   928
    		
sl@0
   929
	__UHEAP_MARKEND;
sl@0
   930
	return TestStepResult();
sl@0
   931
	}
sl@0
   932
sl@0
   933
/* 
sl@0
   934
 * Manager attributeset step
sl@0
   935
 *
sl@0
   936
 */
sl@0
   937
sl@0
   938
CCAFManagerAttributeSetStep::~CCAFManagerAttributeSetStep()
sl@0
   939
	{
sl@0
   940
	}
sl@0
   941
sl@0
   942
CCAFManagerAttributeSetStep::CCAFManagerAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
sl@0
   943
	{
sl@0
   944
	SetTestStepName(KCAFManagerAttributeSetStep);
sl@0
   945
	}
sl@0
   946
sl@0
   947
TVerdict CCAFManagerAttributeSetStep::doTestStepL()
sl@0
   948
	{
sl@0
   949
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
   950
    TBool wmdrmFlag = EFalse;     
sl@0
   951
    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
sl@0
   952
         
sl@0
   953
    if(wmdrmFlag)     
sl@0
   954
        {     
sl@0
   955
        TVerdict verdict = doWmdrmTestStepL();     
sl@0
   956
        return verdict;     
sl@0
   957
        }     
sl@0
   958
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT    
sl@0
   959
sl@0
   960
	TInt value1;
sl@0
   961
	TInt value2;
sl@0
   962
	TInt expectedValue1;
sl@0
   963
	TInt expectedValue2;
sl@0
   964
	TInt attribute1;
sl@0
   965
	TInt attribute2;
sl@0
   966
	TInt result = KErrNone;
sl@0
   967
	TPtrC uri;
sl@0
   968
	TPtrC uniqueId;
sl@0
   969
sl@0
   970
	CManager *manager;
sl@0
   971
sl@0
   972
	SetTestStepResult(EPass);
sl@0
   973
sl@0
   974
	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
sl@0
   975
	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
sl@0
   976
	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
sl@0
   977
	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
sl@0
   978
	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
sl@0
   979
	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
sl@0
   980
sl@0
   981
	__UHEAP_MARK;
sl@0
   982
	manager = CManager::NewL();
sl@0
   983
	if(manager)
sl@0
   984
		{
sl@0
   985
		CleanupStack::PushL(manager);
sl@0
   986
		RAttributeSet attributeSet;
sl@0
   987
		CleanupClosePushL(attributeSet);
sl@0
   988
		attributeSet.AddL(attribute1);
sl@0
   989
		attributeSet.AddL(attribute2);
sl@0
   990
		result = manager->GetAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId));
sl@0
   991
		if(result != KErrNone)
sl@0
   992
			{
sl@0
   993
			SetTestStepResult(EFail);
sl@0
   994
			INFO_PRINTF1(_L("CManager::GetAttribute() failed"));
sl@0
   995
			}
sl@0
   996
		User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
sl@0
   997
		User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
sl@0
   998
		if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
sl@0
   999
			{
sl@0
  1000
			SetTestStepResult(EFail);
sl@0
  1001
			INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));
sl@0
  1002
			}
sl@0
  1003
		CleanupStack::PopAndDestroy(&attributeSet);		
sl@0
  1004
		CleanupStack::PopAndDestroy(manager);		
sl@0
  1005
		}
sl@0
  1006
	else
sl@0
  1007
		{
sl@0
  1008
		SetTestStepResult(EFail);
sl@0
  1009
		INFO_PRINTF1(_L("CManager construction failed"));
sl@0
  1010
		}
sl@0
  1011
	
sl@0
  1012
    		
sl@0
  1013
	__UHEAP_MARKEND;
sl@0
  1014
	return TestStepResult();
sl@0
  1015
	}
sl@0
  1016
sl@0
  1017
sl@0
  1018
/* 
sl@0
  1019
 * Manager string attribute step
sl@0
  1020
 *
sl@0
  1021
 */
sl@0
  1022
sl@0
  1023
CCAFManagerStringAttributeStep::~CCAFManagerStringAttributeStep()
sl@0
  1024
	{
sl@0
  1025
	}
sl@0
  1026
sl@0
  1027
CCAFManagerStringAttributeStep::CCAFManagerStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1028
	{
sl@0
  1029
	SetTestStepName(KCAFManagerStringAttributeStep);
sl@0
  1030
	}
sl@0
  1031
sl@0
  1032
TVerdict CCAFManagerStringAttributeStep::doTestStepL()
sl@0
  1033
	{
sl@0
  1034
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
  1035
    TBool wmdrmFlag = EFalse;     
sl@0
  1036
    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
sl@0
  1037
         
sl@0
  1038
    if(wmdrmFlag)     
sl@0
  1039
        {     
sl@0
  1040
        TVerdict verdict = doWmdrmTestStepL();     
sl@0
  1041
        return verdict;     
sl@0
  1042
        }     
sl@0
  1043
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT        
sl@0
  1044
     
sl@0
  1045
	TInt expectedResult;
sl@0
  1046
	TInt attribute;
sl@0
  1047
	TPtrC expectedValue;
sl@0
  1048
	TBuf <200> value;
sl@0
  1049
	TInt result = KErrNone;
sl@0
  1050
	TPtrC uri;
sl@0
  1051
	TPtrC uniqueId;
sl@0
  1052
sl@0
  1053
	CManager *manager;
sl@0
  1054
sl@0
  1055
	SetTestStepResult(EPass);
sl@0
  1056
sl@0
  1057
	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
sl@0
  1058
	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
sl@0
  1059
	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
sl@0
  1060
	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
sl@0
  1061
	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
sl@0
  1062
sl@0
  1063
	__UHEAP_MARK;
sl@0
  1064
	manager = CManager::NewL();
sl@0
  1065
	if(manager)
sl@0
  1066
		{
sl@0
  1067
		CleanupStack::PushL(manager);
sl@0
  1068
		result = manager->GetStringAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId));
sl@0
  1069
		if(result != expectedResult)
sl@0
  1070
			{
sl@0
  1071
			SetTestStepResult(EFail);
sl@0
  1072
			INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
sl@0
  1073
			}
sl@0
  1074
		if(value != expectedValue)
sl@0
  1075
			{
sl@0
  1076
			SetTestStepResult(EFail);
sl@0
  1077
			INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
sl@0
  1078
			}
sl@0
  1079
sl@0
  1080
		CleanupStack::PopAndDestroy(manager);		
sl@0
  1081
		}
sl@0
  1082
	else
sl@0
  1083
		{
sl@0
  1084
		SetTestStepResult(EFail);
sl@0
  1085
		INFO_PRINTF1(_L("CManager construction failed"));
sl@0
  1086
		}
sl@0
  1087
	
sl@0
  1088
    		
sl@0
  1089
	__UHEAP_MARKEND;
sl@0
  1090
	return TestStepResult();
sl@0
  1091
	}
sl@0
  1092
sl@0
  1093
/* 
sl@0
  1094
 * Manager StringAttributeSet step
sl@0
  1095
 *
sl@0
  1096
 */
sl@0
  1097
sl@0
  1098
CCAFManagerStringAttributeSetStep::~CCAFManagerStringAttributeSetStep()
sl@0
  1099
	{
sl@0
  1100
	}
sl@0
  1101
sl@0
  1102
CCAFManagerStringAttributeSetStep::CCAFManagerStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1103
	{
sl@0
  1104
	SetTestStepName(KCAFManagerStringAttributeSetStep);
sl@0
  1105
	}
sl@0
  1106
sl@0
  1107
TVerdict CCAFManagerStringAttributeSetStep::doTestStepL()
sl@0
  1108
	{
sl@0
  1109
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
  1110
    TBool wmdrmFlag = EFalse;     
sl@0
  1111
    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
sl@0
  1112
         
sl@0
  1113
    if(wmdrmFlag)     
sl@0
  1114
        {     
sl@0
  1115
        TVerdict verdict = doWmdrmTestStepL();     
sl@0
  1116
        return verdict;     
sl@0
  1117
        }     
sl@0
  1118
#endif  //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
sl@0
  1119
     
sl@0
  1120
	TPtrC expectedValue1;
sl@0
  1121
	TPtrC expectedValue2;
sl@0
  1122
	TBuf <200> value1;
sl@0
  1123
	TBuf <200> value2;
sl@0
  1124
	TInt result1;
sl@0
  1125
	TInt result2;
sl@0
  1126
	TInt attribute1;
sl@0
  1127
	TInt attribute2;
sl@0
  1128
	TInt result = KErrNone;
sl@0
  1129
	TPtrC uri;
sl@0
  1130
	TPtrC uniqueId;
sl@0
  1131
sl@0
  1132
	CManager *manager;
sl@0
  1133
sl@0
  1134
	SetTestStepResult(EPass);
sl@0
  1135
sl@0
  1136
	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
sl@0
  1137
	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
sl@0
  1138
	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
sl@0
  1139
	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
sl@0
  1140
	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
sl@0
  1141
	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
sl@0
  1142
	GetIntFromConfig(ConfigSection(),_L("result1"),result1);
sl@0
  1143
	GetIntFromConfig(ConfigSection(),_L("result2"),result2);
sl@0
  1144
sl@0
  1145
sl@0
  1146
	__UHEAP_MARK;
sl@0
  1147
	manager = CManager::NewL();
sl@0
  1148
	if(manager)
sl@0
  1149
		{
sl@0
  1150
		CleanupStack::PushL(manager);
sl@0
  1151
		RStringAttributeSet attributeSet;
sl@0
  1152
		CleanupClosePushL(attributeSet);
sl@0
  1153
		attributeSet.AddL(attribute1);
sl@0
  1154
		attributeSet.AddL(attribute2);
sl@0
  1155
		result = manager->GetStringAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId));
sl@0
  1156
		if(result != KErrNone)
sl@0
  1157
			{
sl@0
  1158
			SetTestStepResult(EFail);
sl@0
  1159
			INFO_PRINTF1(_L("CManager::GetAttribute() failed"));
sl@0
  1160
			}
sl@0
  1161
	if(result1 != attributeSet.GetValue(attribute1, value1))
sl@0
  1162
		{
sl@0
  1163
		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
sl@0
  1164
		}
sl@0
  1165
	if(result2 != attributeSet.GetValue(attribute2, value2))
sl@0
  1166
		{
sl@0
  1167
		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
sl@0
  1168
		}
sl@0
  1169
	if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
sl@0
  1170
			{
sl@0
  1171
			SetTestStepResult(EFail);
sl@0
  1172
			INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));
sl@0
  1173
			}
sl@0
  1174
		CleanupStack::PopAndDestroy(&attributeSet);		
sl@0
  1175
		CleanupStack::PopAndDestroy(manager);		
sl@0
  1176
		}
sl@0
  1177
	else
sl@0
  1178
		{
sl@0
  1179
		SetTestStepResult(EFail);
sl@0
  1180
		INFO_PRINTF1(_L("CManager construction failed"));
sl@0
  1181
		}
sl@0
  1182
	
sl@0
  1183
    		
sl@0
  1184
	__UHEAP_MARKEND;
sl@0
  1185
	return TestStepResult();
sl@0
  1186
	}
sl@0
  1187
sl@0
  1188
sl@0
  1189
sl@0
  1190
sl@0
  1191
CIteratorTestStateMachine::CIteratorTestStateMachine(CCAFContentIteratorStep *aParent) : CActive(EPriorityStandard) 
sl@0
  1192
	{
sl@0
  1193
	iParent = aParent;
sl@0
  1194
	}
sl@0
  1195
		
sl@0
  1196
CIteratorTestStateMachine::~CIteratorTestStateMachine()
sl@0
  1197
	{
sl@0
  1198
	delete iter;	
sl@0
  1199
	delete iPath;
sl@0
  1200
	delete iMimeType;
sl@0
  1201
	}
sl@0
  1202
sl@0
  1203
void CIteratorTestStateMachine::DoCancel()
sl@0
  1204
	{
sl@0
  1205
	// Not used
sl@0
  1206
	CActiveScheduler::Stop();
sl@0
  1207
	}
sl@0
  1208
sl@0
  1209
sl@0
  1210
void CIteratorTestStateMachine::RunTestL(const TDesC& aPath, TBool aRecursive, const TDesC8& aMimeType)
sl@0
  1211
		{
sl@0
  1212
		iPath = aPath.AllocL();
sl@0
  1213
		iMimeType = aMimeType.AllocL();
sl@0
  1214
		iRecursive = aRecursive;
sl@0
  1215
			
sl@0
  1216
		// This function will only return once all files have been found
sl@0
  1217
		// and the RunL() method calls CActiveScheduler::Stop()
sl@0
  1218
		CActiveScheduler::Add(this);
sl@0
  1219
		iStatus = KRequestPending;
sl@0
  1220
		SetActive();
sl@0
  1221
		TRequestStatus *ptr = &iStatus;
sl@0
  1222
		User::RequestComplete(ptr, KErrNone);
sl@0
  1223
		CActiveScheduler::Start();		
sl@0
  1224
		}
sl@0
  1225
		
sl@0
  1226
void CIteratorTestStateMachine::RunL()
sl@0
  1227
	{
sl@0
  1228
	TBuf <KMaxDataTypeLength> mime16;
sl@0
  1229
	TVirtualPathPtr location(KNullDesC(), KNullDesC());
sl@0
  1230
	
sl@0
  1231
	if(iStatus.Int() != KErrNone)
sl@0
  1232
		{
sl@0
  1233
		delete iter;
sl@0
  1234
		iter = NULL;
sl@0
  1235
		CActiveScheduler::Stop();
sl@0
  1236
		}
sl@0
  1237
	else
sl@0
  1238
		{
sl@0
  1239
		switch(iState)
sl@0
  1240
			{
sl@0
  1241
		case 0: // create iterator
sl@0
  1242
			iter = CContentIterator::NewL(*iPath, iRecursive, *iMimeType);
sl@0
  1243
			iStatus = KRequestPending;
sl@0
  1244
			iter->Next(iStatus);
sl@0
  1245
			SetActive();
sl@0
  1246
			iState = 1;
sl@0
  1247
			break;
sl@0
  1248
			
sl@0
  1249
		case 1:   // get result of Next request
sl@0
  1250
			location = iter->VirtualPath();
sl@0
  1251
			mime16.Copy(iter->MimeType());
sl@0
  1252
			iParent->PrintResult(location.URI(), location.UniqueId(), mime16);
sl@0
  1253
			iStatus = KRequestPending;
sl@0
  1254
			iter->Next(iStatus);
sl@0
  1255
			SetActive();
sl@0
  1256
			break;
sl@0
  1257
		default:
sl@0
  1258
			CActiveScheduler::Stop();
sl@0
  1259
			break;
sl@0
  1260
			};
sl@0
  1261
		}
sl@0
  1262
	}
sl@0
  1263
sl@0
  1264
/* 
sl@0
  1265
 * Content Iterator Step
sl@0
  1266
 *
sl@0
  1267
 */
sl@0
  1268
sl@0
  1269
CCAFContentIteratorStep::~CCAFContentIteratorStep()
sl@0
  1270
	{
sl@0
  1271
	}
sl@0
  1272
sl@0
  1273
CCAFContentIteratorStep::CCAFContentIteratorStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1274
	{
sl@0
  1275
	SetTestStepName(KCAFContentIteratorStep);
sl@0
  1276
	}
sl@0
  1277
sl@0
  1278
TVerdict CCAFContentIteratorStep::doTestStepL()
sl@0
  1279
	{
sl@0
  1280
	TPtrC path;
sl@0
  1281
	TPtrC mimeType;
sl@0
  1282
	TBuf8 <KMaxDataTypeLength> mimeType8;
sl@0
  1283
		
sl@0
  1284
	SetTestStepResult(EPass);
sl@0
  1285
sl@0
  1286
	GetStringFromConfig(ConfigSection(),_L("path"),path);
sl@0
  1287
	GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType);
sl@0
  1288
sl@0
  1289
	mimeType8.Copy(mimeType);
sl@0
  1290
	
sl@0
  1291
	__UHEAP_MARK;
sl@0
  1292
	
sl@0
  1293
	CIteratorTestStateMachine *t = new CIteratorTestStateMachine(this);
sl@0
  1294
	
sl@0
  1295
	t->RunTestL(path, ETrue, mimeType8);
sl@0
  1296
	
sl@0
  1297
	delete t;	
sl@0
  1298
	__UHEAP_MARKEND;
sl@0
  1299
	return TestStepResult();
sl@0
  1300
	}
sl@0
  1301
sl@0
  1302
void CCAFContentIteratorStep::PrintResult(const TDesC& aFileName, const TDesC& aUniqueId, const TDesC& aMimeType)
sl@0
  1303
	{
sl@0
  1304
	INFO_PRINTF4(_L("File: %S, UniqueId: %S, MimeType: %S"), &aFileName, &aUniqueId, &aMimeType);
sl@0
  1305
	}
sl@0
  1306
sl@0
  1307
sl@0
  1308
/* 
sl@0
  1309
 * This step asks the agent to display information about a file using the file handle
sl@0
  1310
 *
sl@0
  1311
 */
sl@0
  1312
CCAFManagerDisplayInfoByFileHandleStep::~CCAFManagerDisplayInfoByFileHandleStep()
sl@0
  1313
	{
sl@0
  1314
	}
sl@0
  1315
sl@0
  1316
CCAFManagerDisplayInfoByFileHandleStep::CCAFManagerDisplayInfoByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1317
	{
sl@0
  1318
	SetTestStepName(KCAFManagerDisplayInfoByFileHandleStep);
sl@0
  1319
	}
sl@0
  1320
sl@0
  1321
sl@0
  1322
TVerdict CCAFManagerDisplayInfoByFileHandleStep::doTestStepL()
sl@0
  1323
	{
sl@0
  1324
	TInt result;
sl@0
  1325
	
sl@0
  1326
	//initialisation for testing purposes such as  iUri, iFs, iFile, iExpectedResult and iUniqueId. 
sl@0
  1327
	InitialiseFileHandleParametersL();
sl@0
  1328
sl@0
  1329
	SetTestStepResult(EFail);
sl@0
  1330
sl@0
  1331
	__UHEAP_MARK;
sl@0
  1332
	CManager *manager = CManager::NewLC();
sl@0
  1333
sl@0
  1334
	TRAP(result, manager->DisplayInfoL(EFileProperties, iFile, iUniqueId));	
sl@0
  1335
	if(result == iExpectedResult)
sl@0
  1336
		{
sl@0
  1337
		SetTestStepResult(EPass);
sl@0
  1338
		INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) PASSED"));
sl@0
  1339
		}
sl@0
  1340
	else
sl@0
  1341
		{
sl@0
  1342
		INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) returned unexpected error"));
sl@0
  1343
		INFO_PRINTF3(_L("CManager::DisplayInfoL()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);	
sl@0
  1344
		}
sl@0
  1345
	
sl@0
  1346
	//cleanup manager instance
sl@0
  1347
	CleanupStack::PopAndDestroy(manager);	
sl@0
  1348
	//cleanup iFs and iFile instances by closing the handles.
sl@0
  1349
	CleanupStack::PopAndDestroy(2, &iFs);	
sl@0
  1350
sl@0
  1351
	__UHEAP_MARKEND;
sl@0
  1352
	return TestStepResult();
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
/* 
sl@0
  1356
 * Manager attribute step using file handle.
sl@0
  1357
 *
sl@0
  1358
 */
sl@0
  1359
sl@0
  1360
CCAFManagerAttributeByFileHandleStep::~CCAFManagerAttributeByFileHandleStep()
sl@0
  1361
	{
sl@0
  1362
	}
sl@0
  1363
sl@0
  1364
CCAFManagerAttributeByFileHandleStep::CCAFManagerAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1365
	{
sl@0
  1366
	SetTestStepName(KCAFManagerAttributeByFileHandleStep);
sl@0
  1367
	}
sl@0
  1368
sl@0
  1369
TVerdict CCAFManagerAttributeByFileHandleStep::doTestStepL()
sl@0
  1370
	{
sl@0
  1371
	TInt attribute;
sl@0
  1372
	TInt value = KErrNone;
sl@0
  1373
	TInt result= KErrNone;
sl@0
  1374
	TInt expectedValue;
sl@0
  1375
sl@0
  1376
	//initialisation for testing purposes such as  iUri, iFs, iFile, iExpectedResult and iUniqueId. 
sl@0
  1377
	InitialiseFileHandleParametersL();
sl@0
  1378
	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
sl@0
  1379
	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
sl@0
  1380
	
sl@0
  1381
	SetTestStepResult(EFail);
sl@0
  1382
sl@0
  1383
	__UHEAP_MARK;
sl@0
  1384
	CManager *manager = CManager::NewLC();
sl@0
  1385
sl@0
  1386
	result = manager->GetAttribute(attribute, value, iFile, iUniqueId);
sl@0
  1387
	//expectedResult has priority over the values collected.
sl@0
  1388
	if(result == iExpectedResult)
sl@0
  1389
		{
sl@0
  1390
		if(value == expectedValue)
sl@0
  1391
			{
sl@0
  1392
			SetTestStepResult(EPass);
sl@0
  1393
			INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) PASSED"));
sl@0
  1394
			}
sl@0
  1395
		else
sl@0
  1396
			{
sl@0
  1397
			INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) values don't match expected values"));
sl@0
  1398
			INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue, value);	
sl@0
  1399
			}	
sl@0
  1400
		}
sl@0
  1401
	else
sl@0
  1402
		{
sl@0
  1403
		INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) returned unexpected error"));
sl@0
  1404
		INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);	
sl@0
  1405
		}
sl@0
  1406
	
sl@0
  1407
	//cleanup manager instance
sl@0
  1408
	CleanupStack::PopAndDestroy(manager);		
sl@0
  1409
	//cleanup iFs and iFile instances by closing the handles.
sl@0
  1410
	CleanupStack::PopAndDestroy(2, &iFs);
sl@0
  1411
   		
sl@0
  1412
	__UHEAP_MARKEND;
sl@0
  1413
	return TestStepResult();
sl@0
  1414
	}
sl@0
  1415
sl@0
  1416
/* 
sl@0
  1417
 * Manager attributeset step by file handle.
sl@0
  1418
 *
sl@0
  1419
 */
sl@0
  1420
sl@0
  1421
CCAFManagerAttributeSetByFileHandleStep::~CCAFManagerAttributeSetByFileHandleStep()
sl@0
  1422
	{
sl@0
  1423
	}
sl@0
  1424
sl@0
  1425
CCAFManagerAttributeSetByFileHandleStep::CCAFManagerAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1426
	{
sl@0
  1427
	SetTestStepName(KCAFManagerAttributeSetByFileHandleStep);
sl@0
  1428
	}
sl@0
  1429
sl@0
  1430
TVerdict CCAFManagerAttributeSetByFileHandleStep::doTestStepL()
sl@0
  1431
	{
sl@0
  1432
	TInt value1;
sl@0
  1433
	TInt value2;
sl@0
  1434
	TInt expectedValue1;
sl@0
  1435
	TInt expectedValue2;
sl@0
  1436
	TInt attribute1;
sl@0
  1437
	TInt attribute2;
sl@0
  1438
	TInt result = KErrNone;
sl@0
  1439
sl@0
  1440
	//initialisation for testing purposes such as  iUri, iFs, iFile, iExpectedResult and iUniqueId. 
sl@0
  1441
	InitialiseFileHandleParametersL();
sl@0
  1442
	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
sl@0
  1443
	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
sl@0
  1444
	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
sl@0
  1445
	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
sl@0
  1446
sl@0
  1447
	SetTestStepResult(EFail);
sl@0
  1448
sl@0
  1449
	__UHEAP_MARK;
sl@0
  1450
	CManager *manager = CManager::NewLC();
sl@0
  1451
	
sl@0
  1452
	RAttributeSet attributeSet;
sl@0
  1453
	CleanupClosePushL(attributeSet);
sl@0
  1454
	attributeSet.AddL(attribute1);
sl@0
  1455
	attributeSet.AddL(attribute2);
sl@0
  1456
sl@0
  1457
	result = manager->GetAttributeSet(attributeSet, iFile, iUniqueId);
sl@0
  1458
	//expectedResult has priority over the values collected.		
sl@0
  1459
	if(result == iExpectedResult)
sl@0
  1460
		{
sl@0
  1461
		User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
sl@0
  1462
		User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
sl@0
  1463
		if(value1 == expectedValue1 && value2 == expectedValue2)
sl@0
  1464
			{
sl@0
  1465
			SetTestStepResult(EPass);						
sl@0
  1466
			INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) PASSED"));	
sl@0
  1467
			}
sl@0
  1468
		else
sl@0
  1469
			{
sl@0
  1470
			INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) values don't match expected values"));
sl@0
  1471
			INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue1, value1);	
sl@0
  1472
			INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue2, value2);	
sl@0
  1473
			}	
sl@0
  1474
		}
sl@0
  1475
	else
sl@0
  1476
		{
sl@0
  1477
		INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) returned unexpected error"));
sl@0
  1478
		INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);	
sl@0
  1479
		}
sl@0
  1480
sl@0
  1481
	//cleanup manager and attributeSet instances		
sl@0
  1482
	CleanupStack::PopAndDestroy(2, manager);	
sl@0
  1483
	//cleanup iFs and iFile instances by closing the handles.
sl@0
  1484
	CleanupStack::PopAndDestroy(2, &iFs);
sl@0
  1485
	    		
sl@0
  1486
	__UHEAP_MARKEND;
sl@0
  1487
	return TestStepResult();
sl@0
  1488
	}
sl@0
  1489
sl@0
  1490
sl@0
  1491
/* 
sl@0
  1492
 * Manager string attribute step by file handle
sl@0
  1493
 *
sl@0
  1494
 */
sl@0
  1495
sl@0
  1496
CCAFManagerStringAttributeByFileHandleStep::~CCAFManagerStringAttributeByFileHandleStep()
sl@0
  1497
	{
sl@0
  1498
	}
sl@0
  1499
sl@0
  1500
CCAFManagerStringAttributeByFileHandleStep::CCAFManagerStringAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1501
	{
sl@0
  1502
	SetTestStepName(KCAFManagerStringAttributeByFileHandleStep);
sl@0
  1503
	}
sl@0
  1504
sl@0
  1505
TVerdict CCAFManagerStringAttributeByFileHandleStep::doTestStepL()
sl@0
  1506
	{
sl@0
  1507
	TInt attribute;
sl@0
  1508
	TInt result = KErrNone;
sl@0
  1509
	TPtrC expectedValue;
sl@0
  1510
	TBuf <200> value;
sl@0
  1511
	
sl@0
  1512
	//initialisation for testing purposes such as  iUri, iFs, iFile, iExpectedResult and iUniqueId. 
sl@0
  1513
	InitialiseFileHandleParametersL();
sl@0
  1514
	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
sl@0
  1515
	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
sl@0
  1516
	
sl@0
  1517
	SetTestStepResult(EFail);	
sl@0
  1518
	
sl@0
  1519
	__UHEAP_MARK;
sl@0
  1520
	CManager* manager = CManager::NewLC();
sl@0
  1521
sl@0
  1522
	result = manager->GetStringAttribute(attribute, value, iFile, iUniqueId);
sl@0
  1523
	//expectedResult has priority over the values collected.		
sl@0
  1524
	if(result == iExpectedResult)
sl@0
  1525
		{
sl@0
  1526
		if (value == expectedValue) 
sl@0
  1527
			{
sl@0
  1528
			SetTestStepResult(EPass);
sl@0
  1529
			INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) PASSED"));
sl@0
  1530
			}
sl@0
  1531
		else
sl@0
  1532
			{
sl@0
  1533
			INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) values don't match expected values"));
sl@0
  1534
			INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue, &value);	
sl@0
  1535
			}	
sl@0
  1536
		}
sl@0
  1537
	else
sl@0
  1538
		{
sl@0
  1539
		INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) returned unexpected error"));
sl@0
  1540
		INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);	
sl@0
  1541
		}
sl@0
  1542
sl@0
  1543
	//cleanup manager instance		
sl@0
  1544
	CleanupStack::PopAndDestroy(manager);	
sl@0
  1545
	//cleanup iFs and iFile instances by closing the handles.
sl@0
  1546
	CleanupStack::PopAndDestroy(2, &iFs);	
sl@0
  1547
    		
sl@0
  1548
	__UHEAP_MARKEND;
sl@0
  1549
	return TestStepResult();
sl@0
  1550
	}
sl@0
  1551
sl@0
  1552
/* 
sl@0
  1553
 * Manager StringAttributeSet step by file handle.
sl@0
  1554
 *
sl@0
  1555
 */
sl@0
  1556
sl@0
  1557
CCAFManagerStringAttributeSetByFileHandleStep::~CCAFManagerStringAttributeSetByFileHandleStep()
sl@0
  1558
	{
sl@0
  1559
	}
sl@0
  1560
sl@0
  1561
CCAFManagerStringAttributeSetByFileHandleStep::CCAFManagerStringAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
sl@0
  1562
	{
sl@0
  1563
	SetTestStepName(KCAFManagerStringAttributeSetByFileHandleStep);
sl@0
  1564
	}
sl@0
  1565
sl@0
  1566
TVerdict CCAFManagerStringAttributeSetByFileHandleStep::doTestStepL()
sl@0
  1567
	{
sl@0
  1568
	TInt attribute1;
sl@0
  1569
	TInt attribute2;
sl@0
  1570
	TInt result = KErrNone;
sl@0
  1571
	TPtrC expectedValue1;
sl@0
  1572
	TPtrC expectedValue2;
sl@0
  1573
	TBuf <200> value1;
sl@0
  1574
	TBuf <200> value2;
sl@0
  1575
	
sl@0
  1576
	//initialisation for testing purposes such as  iUri, iFs, iFile, iExpectedResult and iUniqueId. 
sl@0
  1577
	InitialiseFileHandleParametersL();
sl@0
  1578
	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
sl@0
  1579
	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
sl@0
  1580
	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
sl@0
  1581
	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
sl@0
  1582
	
sl@0
  1583
	SetTestStepResult(EFail);
sl@0
  1584
sl@0
  1585
	__UHEAP_MARK;
sl@0
  1586
	CManager* manager = CManager::NewLC();
sl@0
  1587
sl@0
  1588
	RStringAttributeSet attributeSet;
sl@0
  1589
	CleanupClosePushL(attributeSet);
sl@0
  1590
	attributeSet.AddL(attribute1);
sl@0
  1591
	attributeSet.AddL(attribute2);
sl@0
  1592
sl@0
  1593
	result = manager->GetStringAttributeSet(attributeSet, iFile, iUniqueId);
sl@0
  1594
	//expectedResult has priority over the values collected.	
sl@0
  1595
	if(result == iExpectedResult)
sl@0
  1596
		{
sl@0
  1597
		User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
sl@0
  1598
		User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
sl@0
  1599
		if (value1 == expectedValue1 && value2 == expectedValue2) 
sl@0
  1600
			{
sl@0
  1601
			SetTestStepResult(EPass);						
sl@0
  1602
			INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) PASSED"));
sl@0
  1603
			}
sl@0
  1604
		else
sl@0
  1605
			{
sl@0
  1606
			INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) values don't match expected values"));
sl@0
  1607
			INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue1, &value1);	
sl@0
  1608
			INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue2, &value2);				
sl@0
  1609
			}	
sl@0
  1610
		}
sl@0
  1611
	else
sl@0
  1612
		{
sl@0
  1613
		INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) returned unexpected error"));
sl@0
  1614
		INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);	
sl@0
  1615
		}
sl@0
  1616
sl@0
  1617
	//cleanup manager and attributeSet instances		
sl@0
  1618
	CleanupStack::PopAndDestroy(2, manager);
sl@0
  1619
	//cleanup iFs and iFile instances by closing the handles.
sl@0
  1620
	CleanupStack::PopAndDestroy(2, &iFs);	
sl@0
  1621
    		
sl@0
  1622
	__UHEAP_MARKEND;
sl@0
  1623
	return TestStepResult();
sl@0
  1624
	}
sl@0
  1625
sl@0
  1626
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
sl@0
  1627
      
sl@0
  1628
// The following methods test the various manager attribute APIs for WMDRM content.     
sl@0
  1629
      
sl@0
  1630
TVerdict CCAFManagerAttributeStep::doWmdrmTestStepL()     
sl@0
  1631
    {     
sl@0
  1632
    SetTestStepResult(EFail);     
sl@0
  1633
         
sl@0
  1634
    TInt attribVal;     
sl@0
  1635
    GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
sl@0
  1636
         
sl@0
  1637
    TInt expectedValue;     
sl@0
  1638
    GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
sl@0
  1639
      
sl@0
  1640
    __UHEAP_MARK;     
sl@0
  1641
         
sl@0
  1642
    TPtrC header;     
sl@0
  1643
    HBufC8* headerData = NULL;     
sl@0
  1644
         
sl@0
  1645
    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
sl@0
  1646
        {     
sl@0
  1647
        headerData = ConvertDes16toHBufC8LC(header);     
sl@0
  1648
        }     
sl@0
  1649
    else     
sl@0
  1650
        {     
sl@0
  1651
        headerData = CreateWmdrmHeaderLC();      
sl@0
  1652
        }     
sl@0
  1653
         
sl@0
  1654
    TInt value;     
sl@0
  1655
    CManager *manager = CManager::NewLC();     
sl@0
  1656
         
sl@0
  1657
    User::LeaveIfError(manager->GetAttribute(*headerData, attribVal, value));     
sl@0
  1658
    if(expectedValue == value)     
sl@0
  1659
        {     
sl@0
  1660
        SetTestStepResult(EPass);     
sl@0
  1661
        }     
sl@0
  1662
    else     
sl@0
  1663
        {     
sl@0
  1664
        INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);     
sl@0
  1665
        }     
sl@0
  1666
             
sl@0
  1667
    CleanupStack::PopAndDestroy(2, headerData);          
sl@0
  1668
                 
sl@0
  1669
    __UHEAP_MARKEND;     
sl@0
  1670
    return TestStepResult();     
sl@0
  1671
    }     
sl@0
  1672
         
sl@0
  1673
      
sl@0
  1674
TVerdict CCAFManagerAttributeSetStep::doWmdrmTestStepL()     
sl@0
  1675
    {     
sl@0
  1676
    SetTestStepResult(EFail);     
sl@0
  1677
         
sl@0
  1678
    TInt attribute1;     
sl@0
  1679
    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
sl@0
  1680
         
sl@0
  1681
    TInt attribute2;     
sl@0
  1682
    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
sl@0
  1683
         
sl@0
  1684
    TInt expectedValue1;     
sl@0
  1685
    GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
sl@0
  1686
         
sl@0
  1687
    TInt expectedValue2;     
sl@0
  1688
    GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
sl@0
  1689
      
sl@0
  1690
__UHEAP_MARK;     
sl@0
  1691
         
sl@0
  1692
    TPtrC header;     
sl@0
  1693
    HBufC8* headerData = NULL;     
sl@0
  1694
         
sl@0
  1695
    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
sl@0
  1696
        {     
sl@0
  1697
        headerData = ConvertDes16toHBufC8LC(header);     
sl@0
  1698
        }     
sl@0
  1699
    else     
sl@0
  1700
        {     
sl@0
  1701
        headerData = CreateWmdrmHeaderLC();      
sl@0
  1702
        }     
sl@0
  1703
                 
sl@0
  1704
    RAttributeSet attributeSet;     
sl@0
  1705
    CleanupClosePushL(attributeSet);     
sl@0
  1706
    attributeSet.AddL(attribute1);     
sl@0
  1707
    attributeSet.AddL(attribute2);     
sl@0
  1708
             
sl@0
  1709
    CManager *manager = CManager::NewLC();       
sl@0
  1710
    TInt result = manager->GetAttributeSet(*headerData, attributeSet);     
sl@0
  1711
    if(result == KErrNone)     
sl@0
  1712
        {     
sl@0
  1713
        SetTestStepResult(EPass);     
sl@0
  1714
        }     
sl@0
  1715
    else     
sl@0
  1716
        {     
sl@0
  1717
        INFO_PRINTF1(_L("CManager::GetAttributeSet() failed"));     
sl@0
  1718
        }     
sl@0
  1719
             
sl@0
  1720
    TInt value1;         
sl@0
  1721
    User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
sl@0
  1722
             
sl@0
  1723
    TInt value2;     
sl@0
  1724
    User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
sl@0
  1725
             
sl@0
  1726
    if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
sl@0
  1727
        {     
sl@0
  1728
        SetTestStepResult(EPass);     
sl@0
  1729
        }     
sl@0
  1730
    else     
sl@0
  1731
        {     
sl@0
  1732
        INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));     
sl@0
  1733
        }     
sl@0
  1734
             
sl@0
  1735
    CleanupStack::PopAndDestroy(3, headerData);          
sl@0
  1736
      
sl@0
  1737
__UHEAP_MARKEND;     
sl@0
  1738
      
sl@0
  1739
    return TestStepResult();     
sl@0
  1740
    }     
sl@0
  1741
      
sl@0
  1742
      
sl@0
  1743
TVerdict CCAFManagerStringAttributeStep::doWmdrmTestStepL()     
sl@0
  1744
    {     
sl@0
  1745
    SetTestStepResult(EFail);     
sl@0
  1746
         
sl@0
  1747
    TInt attribVal;     
sl@0
  1748
    GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
sl@0
  1749
         
sl@0
  1750
    TPtrC expectedValue;     
sl@0
  1751
    GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
sl@0
  1752
         
sl@0
  1753
    TInt expectedResult;     
sl@0
  1754
    GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
sl@0
  1755
      
sl@0
  1756
__UHEAP_MARK;     
sl@0
  1757
         
sl@0
  1758
    TPtrC header;     
sl@0
  1759
    HBufC8* headerData = NULL;     
sl@0
  1760
         
sl@0
  1761
    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
sl@0
  1762
        {     
sl@0
  1763
        headerData = ConvertDes16toHBufC8LC(header);     
sl@0
  1764
        }     
sl@0
  1765
    else     
sl@0
  1766
        {     
sl@0
  1767
        headerData = CreateWmdrmHeaderLC();      
sl@0
  1768
        }     
sl@0
  1769
         
sl@0
  1770
    CManager* manager = CManager::NewLC();           
sl@0
  1771
    TBuf <200> value;     
sl@0
  1772
    TInt result = manager->GetStringAttribute(*headerData, attribVal, value);     
sl@0
  1773
    if(result == expectedResult && value == expectedValue)     
sl@0
  1774
        {     
sl@0
  1775
        SetTestStepResult(EPass);     
sl@0
  1776
        }     
sl@0
  1777
    else     
sl@0
  1778
        {     
sl@0
  1779
        INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
sl@0
  1780
        INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
sl@0
  1781
        }     
sl@0
  1782
             
sl@0
  1783
    CleanupStack::PopAndDestroy(2, headerData);          
sl@0
  1784
         
sl@0
  1785
__UHEAP_MARKEND;     
sl@0
  1786
      
sl@0
  1787
    return TestStepResult();     
sl@0
  1788
    }     
sl@0
  1789
      
sl@0
  1790
      
sl@0
  1791
TVerdict CCAFManagerStringAttributeSetStep::doWmdrmTestStepL()     
sl@0
  1792
    {     
sl@0
  1793
    SetTestStepResult(EFail);     
sl@0
  1794
      
sl@0
  1795
    TInt attribute1;         
sl@0
  1796
    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
sl@0
  1797
         
sl@0
  1798
    TInt attribute2;     
sl@0
  1799
    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
sl@0
  1800
         
sl@0
  1801
    TPtrC expectedValue1;     
sl@0
  1802
    GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
sl@0
  1803
         
sl@0
  1804
    TPtrC expectedValue2;     
sl@0
  1805
    GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
sl@0
  1806
         
sl@0
  1807
__UHEAP_MARK;     
sl@0
  1808
         
sl@0
  1809
    TPtrC header;     
sl@0
  1810
    HBufC8* headerData = NULL;     
sl@0
  1811
         
sl@0
  1812
    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
sl@0
  1813
        {     
sl@0
  1814
        headerData = ConvertDes16toHBufC8LC(header);     
sl@0
  1815
        }     
sl@0
  1816
    else     
sl@0
  1817
        {     
sl@0
  1818
        headerData = CreateWmdrmHeaderLC();      
sl@0
  1819
        }     
sl@0
  1820
      
sl@0
  1821
    RStringAttributeSet attributeSet;     
sl@0
  1822
    CleanupClosePushL(attributeSet);     
sl@0
  1823
    attributeSet.AddL(attribute1);     
sl@0
  1824
    attributeSet.AddL(attribute2);     
sl@0
  1825
             
sl@0
  1826
    CManager* manager = CManager::NewLC();       
sl@0
  1827
    TInt result = manager->GetStringAttributeSet(*headerData, attributeSet);     
sl@0
  1828
    TBuf <200> value1;     
sl@0
  1829
    TBuf <200> value2;     
sl@0
  1830
    if(result == KErrNone)     
sl@0
  1831
        {     
sl@0
  1832
        TInt result3 = attributeSet.GetValue(attribute1, value1);     
sl@0
  1833
        TInt result4 = attributeSet.GetValue(attribute2, value2);     
sl@0
  1834
                 
sl@0
  1835
        if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
sl@0
  1836
         && result3 == KErrNone && result4 == KErrNone)     
sl@0
  1837
            {     
sl@0
  1838
            SetTestStepResult(EPass);     
sl@0
  1839
            }     
sl@0
  1840
        else     
sl@0
  1841
            {     
sl@0
  1842
            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
sl@0
  1843
            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
sl@0
  1844
            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
sl@0
  1845
            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
sl@0
  1846
            }     
sl@0
  1847
            }     
sl@0
  1848
    else     
sl@0
  1849
        {     
sl@0
  1850
        INFO_PRINTF1(_L("CManager::GetStringAttributeSet() failed"));     
sl@0
  1851
        }        
sl@0
  1852
         
sl@0
  1853
    CleanupStack::PopAndDestroy(3, headerData);          
sl@0
  1854
      
sl@0
  1855
__UHEAP_MARKEND;     
sl@0
  1856
      
sl@0
  1857
    return TestStepResult();     
sl@0
  1858
    }     
sl@0
  1859
      
sl@0
  1860
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT