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