os/security/contentmgmt/referencedrmagent/tcaf/source/Consumerstep.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 <caf/content.h>
    21 #include <caf/data.h>
    22 #include <caf/attribute.h>
    23 #include "cafserver.h"
    24 #include "bitset.h"
    25 #include "Consumerstep.h"
    26 #include "attributeset.h"
    27 #include "stringattributeset.h"
    28 #include <caf/virtualpath.h>
    29 #include <e32hal.h>
    30 #include <hal.h>
    31 
    32 using namespace ContentAccess;
    33 
    34 const TInt KCafTestMaxDataTypeLength = 255;
    35 const TInt KCafTestSecToMS = 1000;
    36 
    37 _LIT(KCDataThreadSemaphore, "CData_Thread_Test");
    38 
    39 /* 
    40  * Step1 compares an agent 'size' call with that obtained by RFile
    41  *
    42  */
    43 
    44 CCAFSizeStep::~CCAFSizeStep()
    45 	{
    46 	}
    47 
    48 CCAFSizeStep::CCAFSizeStep(CCAFServer& aParent)
    49 : iParent(aParent)
    50 	{
    51 	SetTestStepName(KCAFSizeStep);
    52 	}
    53 
    54 TVerdict CCAFSizeStep::doTestStepL()
    55 	{
    56 	__UHEAP_MARK;
    57 	
    58 	SetTestStepResult(EInconclusive);
    59 	
    60 	INFO_PRINTF1(_L("Basic Open Content Test"));
    61 	
    62 	TPtrC uri1;
    63 	TPtrC uri2;
    64 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
    65 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
    66 
    67 	INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
    68 	CContent* content = CContent::NewLC(uri1);
    69 	INFO_PRINTF1(_L("Creating CData object from content"));
    70 
    71 	CData* data = content->OpenContentL(EPeek);
    72 	CleanupStack::PushL(data);
    73 
    74 	TInt size = 0;
    75 	data->DataSizeL(size);
    76 	INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %d"),size);
    77 	CleanupStack::PopAndDestroy(data);
    78 	CleanupStack::PopAndDestroy(content);
    79 
    80 	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
    81 	TInt size1 = 0;
    82 	
    83 	TBool withoutIntent;
    84 	if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
    85 		{
    86 		INFO_PRINTF1(_L("With Intent"));
    87 		data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);			
    88 		}
    89 	else
    90 		{
    91 		INFO_PRINTF1(_L("Without Intent"));
    92 		data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
    93 		data->SetProperty(EAgentPropertyAgentUI, 0);
    94 		User::LeaveIfError(data->EvaluateIntent(EPeek));		
    95 		}
    96 	
    97 	CleanupStack::PushL(data);
    98 	data->DataSizeL(size1);
    99 	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
   100 	CleanupStack::PopAndDestroy(data);
   101 
   102 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   103 	RFile file;
   104 	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
   105 
   106 	TInt size2;
   107 	file.Size(size2);
   108 	file.Close();
   109 
   110 	INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
   111 
   112 	if(size == size2 && size == size1)
   113 		{
   114 		SetTestStepResult(EPass);
   115 		}
   116 	else
   117 		{
   118 		SetTestStepResult(EFail);
   119 		}
   120 	
   121 	__UHEAP_MARKEND;
   122 	return TestStepResult();
   123 	}
   124 
   125 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   126 /* 
   127  * This is the 64bit version of CCAFSizeStep
   128  */
   129 
   130 CCAFSizeStep64::~CCAFSizeStep64()
   131 	{
   132 	}
   133 
   134 CCAFSizeStep64::CCAFSizeStep64(CCAFServer& aParent)
   135 : iParent(aParent)
   136 	{
   137 	SetTestStepName(KCAFSizeStep);
   138 	}
   139 
   140 TVerdict CCAFSizeStep64::doTestStepL()
   141 	{
   142 	__UHEAP_MARK;
   143 	
   144 	SetTestStepResult(EInconclusive);
   145 	
   146 	INFO_PRINTF1(_L("Basic Open Content Test"));
   147 	
   148 	TPtrC uri1;
   149 	TPtrC uri2;
   150 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   151 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   152 
   153 	INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
   154 	CContent* content = CContent::NewLC(uri1);
   155 	INFO_PRINTF1(_L("Creating CData object from content"));
   156 
   157 	CData* data = content->OpenContentL(EPeek);
   158 	CleanupStack::PushL(data);
   159 
   160 	TInt64 size = 0;
   161 	data->DataSize64L(size);
   162 	INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %Ld"),size);
   163 	CleanupStack::PopAndDestroy(data);
   164 	CleanupStack::PopAndDestroy(content);
   165 
   166 	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
   167 	TInt64 size1 = 0;
   168 	
   169 	TBool withoutIntent;
   170 	if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
   171 		{
   172 		INFO_PRINTF1(_L("With Intent"));
   173 		data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);			
   174 		}
   175 	else
   176 		{
   177 		INFO_PRINTF1(_L("Without Intent"));
   178 		data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
   179 		data->SetProperty(EAgentPropertyAgentUI, 0);
   180 		User::LeaveIfError(data->EvaluateIntent(EPeek));		
   181 		}
   182 	
   183 	CleanupStack::PushL(data);
   184 	data->DataSize64L(size1);
   185 	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %Ld"),size1);
   186 	CleanupStack::PopAndDestroy(data);
   187 
   188 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   189 	RFile64 file;
   190 	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
   191 
   192 	TInt64 size2;
   193 	file.Size(size2);
   194 	file.Close();
   195 
   196 	INFO_PRINTF2(_L("Size of content from f32: %Ld"),size2);
   197 
   198 	if(size == size2 && size == size1)
   199 		{
   200 		SetTestStepResult(EPass);
   201 		}
   202 	else
   203 		{
   204 		SetTestStepResult(EFail);
   205 		}
   206 	
   207 	__UHEAP_MARKEND;
   208 	return TestStepResult();
   209 	}
   210 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   211 
   212 /*
   213  * This step compares a seek and read using CAF with that using RFile
   214  *
   215  */
   216 
   217 CCAFSeekReadStep::~CCAFSeekReadStep()
   218 	{
   219 	}
   220 
   221 CCAFSeekReadStep::CCAFSeekReadStep(CCAFServer& aParent)
   222 : iParent(aParent)
   223 	{
   224 	SetTestStepName(KCAFSeekReadStep);
   225 	}
   226 
   227 void CCAFSeekReadStep::StandardCheckReturnValue(TInt aReturnValue)
   228 	{
   229 	if (aReturnValue != KErrNone)
   230 		{
   231 		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
   232 		SetTestStepResult(EFail);
   233 		}	
   234 	}
   235 TVerdict CCAFSeekReadStep::doTestStepL()
   236 	{
   237 	SetTestStepResult(EInconclusive);
   238 	
   239 	TBuf8<2> buf1;
   240 	TBuf8<2> buf2;
   241 	TRequestStatus status;
   242 
   243 	__UHEAP_MARK;
   244 	INFO_PRINTF1(_L("Basic Open Content Test"));
   245 	
   246 	TPtrC uri1;
   247 	TPtrC uri2;
   248 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   249 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   250 
   251 	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
   252 	CContent* content = CContent::NewLC(uri1);
   253 
   254 	INFO_PRINTF1(_L("Creating data object from content"));
   255 	CData* data = content->OpenContentL(EPeek);
   256 	
   257 	// don't need CContent any more
   258 	CleanupStack::PopAndDestroy(content);
   259 	CleanupStack::PushL(data);
   260 
   261 	// Now, open the same file using RFile
   262 	RFile file;
   263 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   264 	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
   265 	CleanupClosePushL(file);
   266 
   267 	TInt size = 0;
   268 	file.Size(size);
   269 	INFO_PRINTF2(_L("Size of content from f32: %d"),size);
   270 	
   271 	// Seek and read from start using both CAF and RFile
   272 	TInt pos1 = size/4;
   273 	data->Seek(ESeekStart, pos1);
   274 	TInt pos2 = size/4;
   275 	file.Seek(ESeekStart, pos2);
   276 	data->Read(buf1);
   277 	file.Read(buf2);
   278 	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
   279 	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
   280 	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
   281 		{
   282 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   283 		SetTestStepResult(EFail);
   284 		}
   285 
   286 	// set the location within the file then retrieve the current location within the file
   287 	pos1=0;
   288 	pos2=0;
   289 	data->Seek(ESeekCurrent, pos1);
   290 	file.Seek(ESeekCurrent, pos2);
   291 
   292 	INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
   293 	INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
   294 
   295 	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
   296 		{
   297 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   298 		SetTestStepResult(EFail);
   299 		}
   300 
   301 	// Seek and read from current using both CAF and RFile
   302 	pos1 = size/4;
   303 	data->Seek(ESeekCurrent, pos1);
   304 	pos2 = size/4;
   305 	file.Seek(ESeekCurrent, pos2);
   306 	data->Read(buf1);
   307 	file.Read(buf2);
   308 	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
   309 	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
   310 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
   311 		{
   312 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   313 		SetTestStepResult(EFail);
   314 		}
   315 
   316 	// Seek and read from end using both CAF and RFile
   317 	pos1 = -size/4;
   318 	data->Seek(ESeekEnd, pos1);
   319 	pos2 = -size/4;
   320 	file.Seek(ESeekEnd, pos2);
   321 	data->Read(buf1);
   322 	file.Read(buf2);
   323 	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
   324 	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
   325 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
   326 		{
   327 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   328 		SetTestStepResult(EFail);
   329 		}
   330 
   331 	// Test other overloaded forms of CData::Read
   332 
   333 	// Read only 1 byte using both CAF and RFile
   334 	pos1 = size/4;
   335 	data->Seek(ESeekStart, pos1);
   336 	pos2 = size/4;
   337 	file.Seek(ESeekStart, pos2);
   338 	data->Read(buf1,1);
   339 	file.Read(buf2,1);
   340 	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
   341 	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
   342 	
   343 	pos1=0;
   344 	pos2=0;
   345 	data->Seek(ESeekCurrent, pos1);
   346 	file.Seek(ESeekCurrent,pos2);
   347 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   348 		{
   349 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   350 		SetTestStepResult(EFail);
   351 		}
   352 
   353 	// Read asynchronously using both CAF and RFile
   354 	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
   355 	pos1 = size/4;
   356 	data->Seek(ESeekStart, pos1);
   357 	pos2 = size/4;
   358 	file.Seek(ESeekStart, pos2);
   359 	status = KRequestPending;
   360 	data->Read(buf1,status);
   361 	User::WaitForRequest(status);
   362 	status = KRequestPending;
   363 	file.Read(buf2,status);
   364 	User::WaitForRequest(status);
   365 	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
   366 	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
   367 
   368 	pos1=0;
   369 	pos2=0;
   370 	data->Seek(ESeekCurrent, pos1);
   371 	file.Seek(ESeekCurrent,pos2);
   372 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   373 		{
   374 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   375 		SetTestStepResult(EFail);
   376 		}
   377 
   378 	// Read only 1 byte asynchronously using both CAF and RFile
   379 	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
   380 	pos1 = size/4;
   381 	data->Seek(ESeekStart, pos1);
   382 	pos2 = size/4;
   383 	file.Seek(ESeekStart, pos2);
   384 	status = KRequestPending;
   385 	data->Read(buf1,1,status);
   386 	User::WaitForRequest(status);
   387 	status = KRequestPending;
   388 	file.Read(buf2,1, status);
   389 	User::WaitForRequest(status);
   390 	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   391 	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   392 
   393 	pos1=0;
   394 	pos2=0;
   395 	data->Seek(ESeekCurrent, pos1);
   396 	file.Seek(ESeekCurrent,pos2);
   397 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   398 		{
   399 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   400 		SetTestStepResult(EFail);
   401 		}
   402 
   403 	// read past EOF
   404 	pos1 = size+1;
   405 	pos2 = size+1;
   406 	data->Seek(ESeekStart, pos1);
   407 	file.Seek(ESeekStart, pos2);
   408 	data->Read(buf1);
   409 	file.Read(buf2);
   410 
   411 	if(buf1.Length() != 0 || buf1.Length() != 0)
   412 		{
   413 		INFO_PRINTF1(_L("ERROR data read past EOF"));
   414 		SetTestStepResult(EFail);
   415 		}
   416 
   417 	
   418 	// Read asynchronously supplying an offset using both CAF and RFile
   419 	TInt err;
   420 	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
   421 	pos1 = size/4;
   422 	pos2 = size/4;
   423 	status = KRequestPending;
   424 	err = data->Read(pos1,buf1,1,status);
   425 	
   426 	StandardCheckReturnValue(err);
   427 	
   428 	User::WaitForRequest(status);
   429 	status = KRequestPending;
   430 	file.Read(pos2, buf2,1, status);
   431 	User::WaitForRequest(status);
   432 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   433 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   434 
   435 	pos1=0;
   436 	pos2=0;
   437 	data->Seek(ESeekCurrent, pos1);
   438 	file.Seek(ESeekCurrent,pos2);
   439 	if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   440 		{
   441 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   442 		SetTestStepResult(EFail);
   443 		}
   444 		
   445 	// Check asynchronous cancellation
   446 	err = 0;
   447 	INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));	
   448 	pos1 = size/4;
   449 	pos2 = size/4;
   450 	status = KRequestPending;
   451 	err = data->Read(pos1,buf1,1,status);
   452 	StandardCheckReturnValue(err);
   453 	data->ReadCancel(status);
   454 	User::WaitForRequest(status);
   455 	TRequestStatus status2(KRequestPending);
   456 	file.Read(pos2, buf2,1, status2);	
   457 	file.ReadCancel();
   458 	User::WaitForRequest(status2);	
   459 	INFO_PRINTF3(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
   460 	INFO_PRINTF3(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());	
   461 	if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   462 		{
   463 		INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
   464 		SetTestStepResult(EFail);
   465 		}
   466 		
   467 	// read past EOF
   468 	pos1 = size+1;
   469 	pos2 = size+1;
   470 	status = KRequestPending;
   471 	data->Read(pos1,buf1,1,status);
   472 	StandardCheckReturnValue(err);
   473 	User::WaitForRequest(status);
   474 	status = KRequestPending;
   475 	file.Read(pos2,buf2,1,status);
   476 	User::WaitForRequest(status);
   477 	
   478 	if(buf1.Length() != 0 || buf1.Length() != 0)
   479 		{
   480 		INFO_PRINTF1(_L("ERROR data read past EOF"));
   481 		SetTestStepResult(EFail);
   482 		}
   483 		
   484 	// read over the length of the buffer
   485 	INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
   486 	pos1 = size/4;
   487 	pos2 = size/4;
   488 	status = KRequestPending;
   489 	err = data->Read(pos1,buf1,5,status);
   490 	StandardCheckReturnValue(err);
   491 	User::WaitForRequest(status);
   492 	if(status.Int()!=KErrOverflow)
   493 		{
   494 		INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
   495 		SetTestStepResult(EFail);
   496 		}
   497 	status = KRequestPending;
   498 	file.Read(pos2, buf2,5, status);
   499 	User::WaitForRequest(status);
   500 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   501 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   502 
   503 	if (buf1 !=buf2 ||  buf1.Length() != buf2.Length())
   504 		{
   505 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   506 		SetTestStepResult(EFail);
   507 		}
   508 	// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
   509 	INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
   510 	pos1 = -1;
   511 	status = KRequestPending;
   512 	err = data->Read(pos1,buf1,5,status);
   513 	if(err!=KErrArgument)
   514 		{
   515 		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
   516 		SetTestStepResult(EFail);
   517 		}
   518 		
   519 	// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
   520 	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
   521 	TBuf8<256> buf3;
   522 	TBuf8<256> buf4;
   523 	pos1 = 0;
   524 	pos2 = 0;
   525 	status = KRequestPending;
   526 	err = data->Read(pos1,buf3,size+1,status);
   527 	StandardCheckReturnValue(err);
   528 	User::WaitForRequest(status);
   529 	status = KRequestPending;
   530 	file.Read(pos2, buf4,size+1, status);
   531 	User::WaitForRequest(status);
   532 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   533 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   534 
   535 	pos1=0;
   536 	pos2=0;
   537 	data->Seek(ESeekCurrent, pos1);
   538 	file.Seek(ESeekCurrent,pos2);
   539 	if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size || 
   540 									pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
   541 		{
   542 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   543 		SetTestStepResult(EFail);
   544 		}
   545 
   546 	// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
   547 	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
   548 	pos1 = size/4;
   549 	pos2 = size/4;
   550 	status = KRequestPending;
   551 	err = data->Read(pos1,buf3,size+1,status);
   552 	StandardCheckReturnValue(err);
   553 	User::WaitForRequest(status);
   554 	status = KRequestPending;
   555 	file.Read(pos2, buf4,size+1, status);
   556 	User::WaitForRequest(status);
   557 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   558 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   559 
   560 	pos1=0;
   561 	pos2=0;
   562 	data->Seek(ESeekCurrent, pos1);
   563 	file.Seek(ESeekCurrent,pos2);
   564 	if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
   565 		{
   566 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   567 		SetTestStepResult(EFail);
   568 		}	
   569 		
   570 	CleanupStack::PopAndDestroy(2, data);
   571 
   572 	__UHEAP_MARKEND;
   573 
   574 	if (TestStepResult() != EFail)
   575 		{
   576 		SetTestStepResult(EPass);
   577 		}
   578 
   579 	return TestStepResult();
   580 	}
   581 
   582 
   583 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   584 /*
   585  * This is the 64bit version of CCAFSeekReadStep. 
   586 */
   587 
   588 CCAFSeekReadStep64::~CCAFSeekReadStep64()
   589 	{
   590 	}
   591 
   592 CCAFSeekReadStep64::CCAFSeekReadStep64(CCAFServer& aParent)
   593 : iParent(aParent)
   594 	{
   595 	SetTestStepName(KCAFSeekReadStep);
   596 	}
   597 
   598 void CCAFSeekReadStep64::StandardCheckReturnValue(TInt aReturnValue)
   599 	{
   600 	if (aReturnValue != KErrNone)
   601 		{
   602 		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
   603 		SetTestStepResult(EFail);
   604 		}	
   605 	}
   606 TVerdict CCAFSeekReadStep64::doTestStepL()
   607 	{
   608 	SetTestStepResult(EInconclusive);
   609 	
   610 	TBuf8<2> buf1;
   611 	TBuf8<2> buf2;
   612 	TRequestStatus status;
   613 
   614 	__UHEAP_MARK;
   615 	INFO_PRINTF1(_L("Basic Open Content Test"));
   616 	
   617 	TPtrC uri1;
   618 	TPtrC uri2;
   619 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   620 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   621 
   622 	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
   623 	CContent* content = CContent::NewLC(uri1);
   624 
   625 	INFO_PRINTF1(_L("Creating data object from content"));
   626 	CData* data = content->OpenContentL(EPeek);
   627 	
   628 	// don't need CContent any more
   629 	CleanupStack::PopAndDestroy(content);
   630 	CleanupStack::PushL(data);
   631 
   632 	// Now, open the same file using RFile
   633 	RFile64 file;
   634 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   635 	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
   636 	CleanupClosePushL(file);
   637 
   638 	TInt64 size = 0;
   639 	file.Size(size);
   640 	INFO_PRINTF2(_L("Size of content from f32: %Ld"),size);
   641 	
   642 	// Seek and read from start using both CAF and RFile
   643 	TInt64 pos1 = size/4;
   644 	data->Seek64(ESeekStart, pos1);
   645 	//pos2 needs to be modified to TInt64 when file server supports 64bit
   646 	TInt64 pos2 = size/4;
   647 	file.Seek(ESeekStart, pos2);
   648 	data->Read(buf1);
   649 	file.Read(buf2);
   650 	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %Ld"), pos1);
   651 	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %Ld"), pos2);
   652 	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
   653 		{
   654 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   655 		SetTestStepResult(EFail);
   656 		}
   657 
   658 	// set the location within the file then retrieve the current location within the file
   659 	pos1=0;
   660 	pos2=0;
   661 	data->Seek64(ESeekCurrent, pos1);
   662 	file.Seek(ESeekCurrent, pos2);
   663 
   664 	INFO_PRINTF2(_L("Current position using CData: %Ld"), pos1);
   665 	INFO_PRINTF2(_L("Current position using RFile: %Ld"), pos2);
   666 
   667 	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
   668 		{
   669 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   670 		SetTestStepResult(EFail);
   671 		}
   672 
   673 	// Seek and read from current using both CAF and RFile
   674 	pos1 = size/4;
   675 	data->Seek64(ESeekCurrent, pos1);
   676 	pos2 = size/4;
   677 	file.Seek(ESeekCurrent, pos2);
   678 	data->Read(buf1);
   679 	file.Read(buf2);
   680 	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %Ld"), pos1);
   681 	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %Ld"), pos2);
   682 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
   683 		{
   684 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   685 		SetTestStepResult(EFail);
   686 		}
   687 
   688 	// Seek and read from end using both CAF and RFile
   689 	pos1 = -size/4;
   690 	data->Seek64(ESeekEnd, pos1);
   691 	pos2 = -size/4;
   692 	file.Seek(ESeekEnd, pos2);
   693 	data->Read(buf1);
   694 	file.Read(buf2);
   695 	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %Ld"), pos1);
   696 	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %Ld"), pos2);
   697 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
   698 		{
   699 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   700 		SetTestStepResult(EFail);
   701 		}
   702 
   703 	// Test other overloaded forms of CData::Read
   704 
   705 	// Read only 1 byte using both CAF and RFile
   706 	pos1 = size/4;
   707 	data->Seek64(ESeekStart, pos1);
   708 	pos2 = size/4;
   709 	file.Seek(ESeekStart, pos2);
   710 	data->Read(buf1,1);
   711 	file.Read(buf2,1);
   712 	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
   713 	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
   714 	
   715 	pos1=0;
   716 	pos2=0;
   717 	data->Seek64(ESeekCurrent, pos1);
   718 	file.Seek(ESeekCurrent,pos2);
   719 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   720 		{
   721 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   722 		SetTestStepResult(EFail);
   723 		}
   724 
   725 	// Read asynchronously using both CAF and RFile
   726 	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
   727 	pos1 = size/4;
   728 	data->Seek64(ESeekStart, pos1);
   729 	pos2 = size/4;
   730 	file.Seek(ESeekStart, pos2);
   731 	status = KRequestPending;
   732 	data->Read(buf1,status);
   733 	User::WaitForRequest(status);
   734 	status = KRequestPending;
   735 	file.Read(buf2,status);
   736 	User::WaitForRequest(status);
   737 	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
   738 	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
   739 
   740 	pos1=0;
   741 	pos2=0;
   742 	data->Seek64(ESeekCurrent, pos1);
   743 	file.Seek(ESeekCurrent,pos2);
   744 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   745 		{
   746 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   747 		SetTestStepResult(EFail);
   748 		}
   749 
   750 	// Read only 1 byte asynchronously using both CAF and RFile
   751 	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
   752 	pos1 = size/4;
   753 	data->Seek64(ESeekStart, pos1);
   754 	pos2 = size/4;
   755 	file.Seek(ESeekStart, pos2);
   756 	status = KRequestPending;
   757 	data->Read(buf1,1,status);
   758 	User::WaitForRequest(status);
   759 	status = KRequestPending;
   760 	file.Read(buf2,1, status);
   761 	User::WaitForRequest(status);
   762 	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   763 	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   764 
   765 	pos1=0;
   766 	pos2=0;
   767 	data->Seek64(ESeekCurrent, pos1);
   768 	file.Seek(ESeekCurrent,pos2);
   769 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   770 		{
   771 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   772 		SetTestStepResult(EFail);
   773 		}
   774 
   775 	// read past EOF
   776 	pos1 = size+1;
   777 	pos2 = size+1;
   778 	data->Seek64(ESeekStart, pos1);
   779 	file.Seek(ESeekStart, pos2);
   780 	data->Read(buf1);
   781 	file.Read(buf2);
   782 
   783 	if(buf1.Length() != 0 || buf1.Length() != 0)
   784 		{
   785 		INFO_PRINTF1(_L("ERROR data read past EOF"));
   786 		SetTestStepResult(EFail);
   787 		}
   788 
   789 	
   790 	// Read asynchronously supplying an offset using both CAF and RFile
   791 	TInt err;
   792 	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
   793 	pos1 = size/4;
   794 	pos2 = size/4;
   795 	status = KRequestPending;
   796 	err = data->Read(pos1,buf1,1,status);
   797 	
   798 	StandardCheckReturnValue(err);
   799 	
   800 	User::WaitForRequest(status);
   801 	status = KRequestPending;
   802 	file.Read(pos2, buf2,1, status);
   803 	User::WaitForRequest(status);
   804 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   805 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   806 
   807 	pos1=0;
   808 	pos2=0;
   809 	data->Seek64(ESeekCurrent, pos1);
   810 	file.Seek(ESeekCurrent,pos2);
   811 	if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   812 		{
   813 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   814 		SetTestStepResult(EFail);
   815 		}
   816 		
   817 	// Check asynchronous cancellation
   818 	err = 0;
   819 	INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));	
   820 	pos1 = size/4;
   821 	pos2 = size/4;
   822 	status = KRequestPending;
   823 	err = data->Read(pos1,buf1,1,status);
   824 	StandardCheckReturnValue(err);
   825 	data->ReadCancel(status);
   826 	User::WaitForRequest(status);
   827 	TRequestStatus status2(KRequestPending);
   828 	file.Read(pos2, buf2,1, status2);	
   829 	file.ReadCancel();
   830 	User::WaitForRequest(status2);	
   831 	INFO_PRINTF3(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
   832 	INFO_PRINTF3(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());	
   833 	if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   834 		{
   835 		INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
   836 		SetTestStepResult(EFail);
   837 		}
   838 		
   839 	// read past EOF
   840 	pos1 = size+1;
   841 	pos2 = size+1;
   842 	status = KRequestPending;
   843 	data->Read(pos1,buf1,1,status);
   844 	StandardCheckReturnValue(err);
   845 	User::WaitForRequest(status);
   846 	status = KRequestPending;
   847 	file.Read(pos2,buf2,1,status);
   848 	User::WaitForRequest(status);
   849 	
   850 	if(buf1.Length() != 0 || buf1.Length() != 0)
   851 		{
   852 		INFO_PRINTF1(_L("ERROR data read past EOF"));
   853 		SetTestStepResult(EFail);
   854 		}
   855 		
   856 	// read over the length of the buffer
   857 	INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
   858 	pos1 = size/4;
   859 	pos2 = size/4;
   860 	status = KRequestPending;
   861 	err = data->Read(pos1,buf1,5,status);
   862 	StandardCheckReturnValue(err);
   863 	User::WaitForRequest(status);
   864 	if(status.Int()!=KErrOverflow)
   865 		{
   866 		INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
   867 		SetTestStepResult(EFail);
   868 		}
   869 	status = KRequestPending;
   870 	file.Read(pos2, buf2,5, status);
   871 	User::WaitForRequest(status);
   872 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   873 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   874 
   875 	if (buf1 !=buf2 ||  buf1.Length() != buf2.Length())
   876 		{
   877 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   878 		SetTestStepResult(EFail);
   879 		}
   880 	// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
   881 	INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
   882 	pos1 = -1;
   883 	status = KRequestPending;
   884 	err = data->Read(pos1,buf1,5,status);
   885 	if(err!=KErrArgument)
   886 		{
   887 		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
   888 		SetTestStepResult(EFail);
   889 		}
   890 		
   891 	// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
   892 	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
   893 	TBuf8<256> buf3;
   894 	TBuf8<256> buf4;
   895 	pos1 = 0;
   896 	pos2 = 0;
   897 	status = KRequestPending;
   898 	err = data->Read(pos1,buf3,size+1,status);
   899 	StandardCheckReturnValue(err);
   900 	User::WaitForRequest(status);
   901 	status = KRequestPending;
   902 	file.Read(pos2, buf4,size+1, status);
   903 	User::WaitForRequest(status);
   904 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   905 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   906 
   907 	pos1=0;
   908 	pos2=0;
   909 	data->Seek64(ESeekCurrent, pos1);
   910 	file.Seek(ESeekCurrent,pos2);
   911 	if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size || 
   912 									pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
   913 		{
   914 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   915 		SetTestStepResult(EFail);
   916 		}
   917 
   918 	// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
   919 	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
   920 	pos1 = size/4;
   921 	pos2 = size/4;
   922 	status = KRequestPending;
   923 	err = data->Read(pos1,buf3,size+1,status);
   924 	StandardCheckReturnValue(err);
   925 	User::WaitForRequest(status);
   926 	status = KRequestPending;
   927 	file.Read(pos2, buf4,size+1, status);
   928 	User::WaitForRequest(status);
   929 	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   930 	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   931 
   932 	pos1=0;
   933 	pos2=0;
   934 	data->Seek64(ESeekCurrent, pos1);
   935 	file.Seek(ESeekCurrent,pos2);
   936 	if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
   937 		{
   938 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   939 		SetTestStepResult(EFail);
   940 		}	
   941 	
   942 	CleanupStack::PopAndDestroy(2, data);
   943 	
   944 	__UHEAP_MARKEND;
   945 	
   946 	if (TestStepResult() != EFail)
   947 		{
   948 		SetTestStepResult(EPass);
   949 		}
   950 
   951 	return TestStepResult();
   952 	}
   953 
   954 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   955 /*
   956  * This step retrieves the attributes of a file using the CAF framework
   957  *
   958  */
   959 
   960 CCAFAttributesStep::~CCAFAttributesStep()
   961 	{
   962 	}
   963 
   964 CCAFAttributesStep::CCAFAttributesStep(CCAFServer& aParent) : iParent(aParent)
   965 	{
   966 	SetTestStepName(KCAFAttributesStep);
   967 	}
   968 
   969 
   970 TVerdict CCAFAttributesStep::doTestStepL()
   971 	{
   972 	CContent *content;
   973 	CAttribute *attrs; 
   974 	TPtrC fileName;
   975 	TBool Protected;
   976 	TBool Forwardable;
   977 	
   978 	
   979 	TBool Value;
   980 
   981 	SetTestStepResult(EFail);
   982 
   983 	GetStringFromConfig(ConfigSection(),_L("filename"),fileName);
   984 	GetBoolFromConfig(ConfigSection(),_L("Protected"),Protected);
   985 	GetBoolFromConfig(ConfigSection(),_L("Forwardable"),Forwardable);
   986 
   987 
   988 	INFO_PRINTF2(_L("Check attributes of file: %S"), &fileName);	
   989 
   990 	__UHEAP_MARK;
   991 
   992 	// Open a file and retrieve the attributes
   993 	content = CContent::NewLC(fileName);
   994 	attrs = content->NewAttributeL(ETrue);
   995 	CleanupStack::PushL(attrs);
   996 
   997 	// Assume all the attributes are what we expect them to be
   998 	SetTestStepResult(EPass);
   999 
  1000 	Value = attrs->ResponseSet().IsSet(EIsProtected);
  1001 	if(Value != Protected)
  1002 		{
  1003 		SetTestStepResult(EFail);
  1004 		Protected ? INFO_PRINTF1(_L("File is Protected")) : INFO_PRINTF1(_L("File is not Protected"));
  1005 		}
  1006 
  1007 	Value = attrs->ResponseSet().IsSet(EIsForwardable);
  1008 	if(Value != Forwardable)
  1009 		{
  1010 		SetTestStepResult(EFail);
  1011 		Forwardable ? INFO_PRINTF1(_L("File is Forwardable")) : INFO_PRINTF1(_L("File is not Forwardable"));
  1012 		}
  1013 
  1014 	CleanupStack::PopAndDestroy(2, content); 
  1015 
  1016 	__UHEAP_MARKEND;
  1017 	return TestStepResult();
  1018 	}
  1019 
  1020 
  1021 /*
  1022  * This step retrieves the string attributes of a file using the CAF framework
  1023  *
  1024  */
  1025 
  1026 CCAFStringAttributesStep::~CCAFStringAttributesStep()
  1027 	{
  1028 	}
  1029 
  1030 CCAFStringAttributesStep::CCAFStringAttributesStep(CCAFServer& aParent) : iParent(aParent)
  1031 	{
  1032 	SetTestStepName(KCAFStringAttributesStep);
  1033 	}
  1034 
  1035 
  1036 TVerdict CCAFStringAttributesStep::doTestStepL()
  1037 	{
  1038 	TInt expectedResult;
  1039 	TInt attribute;
  1040 	TPtrC expectedValue;
  1041 	TBuf <256> value; //this will be used to test KErrOverFlow when transactionid is 257char long.
  1042 	TInt result = KErrNone;
  1043 	TPtrC uri;
  1044 	TPtrC uniqueId;
  1045 
  1046 	SetTestStepResult(EPass);
  1047 
  1048 	GetIntFromConfig(ConfigSection(),_L("stringattribute"),attribute);
  1049 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1050 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1051 	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
  1052 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
  1053 
  1054 	__UHEAP_MARK;
  1055 	CContent *content = CContent::NewLC(uri);
  1056 	CData *data = content->OpenContentL(EPeek, uniqueId);
  1057 	result = data->GetStringAttribute(attribute, value);
  1058 	delete data;
  1059 	if(result != expectedResult)
  1060 		{
  1061 		SetTestStepResult(EFail);
  1062 		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
  1063 		}
  1064 	if(value != expectedValue)
  1065 		{
  1066 		SetTestStepResult(EFail);
  1067 		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
  1068 		}
  1069 
  1070 	CleanupStack::PopAndDestroy(content);		
  1071     		
  1072 	__UHEAP_MARKEND;
  1073 	return TestStepResult();
  1074 
  1075 	}
  1076 
  1077 
  1078 
  1079 
  1080 /* 
  1081  * Step reads from a CData from multiple threads
  1082  *
  1083  */
  1084 
  1085 CCAFMultiThreadCDataStep::~CCAFMultiThreadCDataStep()
  1086 	{
  1087 	}
  1088 
  1089 CCAFMultiThreadCDataStep::CCAFMultiThreadCDataStep(CCAFServer& aParent)
  1090 : iParent(aParent)
  1091 	{
  1092 	SetTestStepName(KCAFMultiThreadCDataStep);
  1093 	}
  1094 
  1095 TVerdict CCAFMultiThreadCDataStep::doTestStepL()
  1096 	{
  1097 	TBuf8<2> buf;
  1098 
  1099 	__UHEAP_MARK;
  1100 	_LIT(KCDataThread,"CData_Thread");
  1101 
  1102 	SetTestStepResult(EInconclusive);
  1103 	
  1104 	INFO_PRINTF1(_L("Multi Thread CData Test"));
  1105 	
  1106 	TPtrC uri;
  1107 	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1108 
  1109 	INFO_PRINTF1(_L("Creating data object from content"));
  1110 	CContent* content = CContent::NewLC(uri);
  1111 	CData* data = content->OpenContentL(EPeek);
  1112 	CleanupStack::PushL(data);
  1113 
  1114 	TInt size, pos;
  1115 
  1116 	// Create a mutex for communication between our thread and the new thread
  1117 	RSemaphore threadSemaphore;
  1118 	threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
  1119 	threadSemaphore.Wait(); 
  1120 
  1121 	// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future 
  1122 	RThread readerThread;
  1123 	User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
  1124 	
  1125 	// request notification of thread completion
  1126 	TRequestStatus stat;
  1127 	readerThread.Logon(stat);
  1128 	readerThread.Resume();	
  1129 	
  1130 	data->DataSizeL(size);
  1131 	pos = size/2;
  1132 	data->Seek(ESeekStart,pos);
  1133 	data->Read(buf);
  1134 
  1135 	threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
  1136 	threadSemaphore.Signal(); // finished with semaphore
  1137 	threadSemaphore.Close(); // so close
  1138 
  1139 	User::WaitForRequest(stat); // wait for thread to finish
  1140 	TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
  1141 	User::LeaveIfError(error);
  1142 	readerThread.Close();  // close the thread
  1143 	
  1144 	CleanupStack::PopAndDestroy(data);
  1145 	CleanupStack::PopAndDestroy(content);
  1146 
  1147 	__UHEAP_MARKEND;
  1148 	
  1149 	SetTestStepResult(EPass);
  1150 	return TestStepResult();
  1151 	}
  1152 
  1153 TInt CCAFMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
  1154 	{
  1155 	TBuf8 <2> buf;
  1156 	CData *data = reinterpret_cast <CData *> (aPtr);
  1157 
  1158 	// create a trap handler
  1159 	CTrapCleanup* cleanup = CTrapCleanup::New();
  1160 
  1161 	RSemaphore threadSemaphore;
  1162 	threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
  1163 
  1164 	data->Read(buf);
  1165 	threadSemaphore.Signal(); // allow original thread to continue
  1166 	threadSemaphore.Close();
  1167 	
  1168 	delete cleanup;
  1169 	return KErrNone;
  1170 	}
  1171 
  1172 
  1173 /* 
  1174  * Obtains the mime type from a CData
  1175  *
  1176  */
  1177 
  1178 CCAFMimeTypeCDataStep::~CCAFMimeTypeCDataStep()
  1179 	{
  1180 	}
  1181 
  1182 CCAFMimeTypeCDataStep::CCAFMimeTypeCDataStep(CCAFServer& aParent)
  1183 : iParent(aParent)
  1184 	{
  1185 	SetTestStepName(KCAFMimeTypeCDataStep);
  1186 	}
  1187 
  1188 TVerdict CCAFMimeTypeCDataStep::doTestStepL()
  1189 	{
  1190 	__UHEAP_MARK;
  1191 
  1192 
  1193 	SetTestStepResult(EFail);
  1194 	
  1195 	INFO_PRINTF1(_L("CData MimeType Test"));
  1196 	
  1197 	TPtrC uri;
  1198 	TPtrC expectedMimeType;
  1199 	TBool mimeTypeKnown=EFalse;
  1200 
  1201 	// Load INI parameters
  1202 	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1203 	GetStringFromConfig(ConfigSection(),_L("ContentMimeType"),expectedMimeType);
  1204 	GetBoolFromConfig(ConfigSection(),_L("Known"),mimeTypeKnown);
  1205 
  1206 	// convert to Des8
  1207 	HBufC8 *expected = ConvertDes16toHBufC8LC(expectedMimeType);
  1208 
  1209 	// Create CContent and CData
  1210 	INFO_PRINTF1(_L("Creating data object from content"));
  1211 	CContent* content = CContent::NewLC(uri);
  1212 	CData* data = content->OpenContentL(EPeek);
  1213 	CleanupStack::PushL(data);
  1214 
  1215 	// Get mime type from CData
  1216 	INFO_PRINTF1(_L("Checking mime type"));
  1217 	HBufC8 *buffer = HBufC8::NewLC(KCafTestMaxDataTypeLength);
  1218 	TPtr8 ptr = buffer->Des();
  1219 	TBool r = data->GetMimeTypeL(ptr);
  1220 
  1221 	// check if result matches expected result
  1222 	if(r == mimeTypeKnown && *buffer == *expected)
  1223 		{
  1224 		SetTestStepResult(EPass);
  1225 		}
  1226 
  1227 	CleanupStack::PopAndDestroy(4,expected);
  1228 	__UHEAP_MARKEND;
  1229 	return TestStepResult();
  1230 	}
  1231 
  1232 	/*
  1233  * This step tests file sharing modes
  1234  *
  1235  */
  1236 
  1237 CCAFShareModeStep::~CCAFShareModeStep()
  1238 	{
  1239 	}
  1240 
  1241 CCAFShareModeStep::CCAFShareModeStep(CCAFServer& aParent) : iParent(aParent)
  1242 	{
  1243 	SetTestStepName(KCAFShareModeStep);
  1244 	}
  1245 
  1246 
  1247 TVerdict CCAFShareModeStep::doTestStepL()
  1248 	{
  1249 	TVerdict verdict = EFail;
  1250 	TRAPD(err, verdict = doShareModeStepL());
  1251 	if(err != KErrNone)
  1252 		{
  1253 		if(err != KErrInUse)
  1254 			{
  1255 			User::Leave(err);
  1256 			}
  1257 		else
  1258 			{
  1259 			User::Leave(KErrGeneral);
  1260 			}
  1261 		}
  1262 	return verdict;	
  1263 	}
  1264 
  1265 TVerdict CCAFShareModeStep::doShareModeStepL()	
  1266 	{
  1267 	CAttribute *attr = NULL;
  1268 	RFile file;	
  1269 	RFs fs;
  1270 	TPtrC fileName;
  1271 	TInt err = 0;
  1272 	
  1273 	SetTestStepResult(EPass);
  1274 
  1275 	GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
  1276 
  1277 	// This function works if I step through everything but fails
  1278 	// when run or step over the TRAP
  1279 //	User::Leave(KErrGeneral);
  1280 	
  1281 
  1282 	__UHEAP_MARK;
  1283 	
  1284 	INFO_PRINTF2(_L("Creating Content object for file: %S"), &fileName);	
  1285 	CContent* content= CContent::NewL(fileName);	
  1286 	CData *data = NULL;
  1287 	
  1288 	fs.Connect();
  1289 	CleanupClosePushL(fs);
  1290 
  1291 
  1292 	INFO_PRINTF1(_L("Testing EContentShareReadOnly"));	
  1293 	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOnly | EFileRead | EFileStream));
  1294 	CleanupClosePushL(file);
  1295 	data = content->OpenContentL(EPeek);
  1296 	delete data;
  1297 	data = NULL;
  1298 	data = content->OpenContentL(EPeek, EContentShareReadOnly);
  1299 	delete data;
  1300 	data = NULL;
  1301 	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadWrite));
  1302 	delete data;
  1303 	data = NULL;
  1304 	
  1305 	// We can open read-write because CAF never writes.
  1306 	
  1307 	if(err != KErrNone)
  1308 		{
  1309 		SetTestStepResult(EFail);
  1310 		}
  1311 	
  1312 	// However, exclusive mode should be impossible.
  1313 	
  1314 	TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
  1315 	delete data;
  1316 	data = NULL;
  1317 	if(err != KErrInUse)
  1318 		{
  1319 		SetTestStepResult(EFail);
  1320 		}
  1321 	CleanupStack::PopAndDestroy(&file); 
  1322 	delete content;
  1323 
  1324 	
  1325 	INFO_PRINTF1(_L("Testing EContentShareReadWrite"));	
  1326 	content = CContent::NewL(fileName, EContentShareReadWrite);
  1327 	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileStream));
  1328 	CleanupClosePushL(file);
  1329 	data = content->OpenContentL(EPeek, EContentShareReadWrite);
  1330 	delete data;
  1331 	data = NULL;
  1332 	
  1333 	// We should be able to open read-only
  1334 	
  1335 	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
  1336 	delete data;
  1337 	data = NULL;
  1338 	if(err != KErrNone)
  1339 		{
  1340 		SetTestStepResult(EFail);
  1341 		}
  1342 		
  1343 	// but not share exclusive
  1344 		
  1345 	TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
  1346 	delete data;
  1347 	data = NULL;
  1348 	if(err != KErrInUse)
  1349 		{
  1350 		SetTestStepResult(EFail);
  1351 		}
  1352 	CleanupStack::PopAndDestroy(&file);
  1353 	
  1354 	
  1355 	// Reopen the file with write attributes, and make sure ReadOnly becomes impossible 
  1356 	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileWrite | EFileStream));
  1357 	CleanupClosePushL(file);
  1358 	
  1359 	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
  1360 	delete data;
  1361 	data = NULL;
  1362 	if(err != KErrInUse)
  1363 		{
  1364 		SetTestStepResult(EFail);
  1365 		}
  1366 	
  1367 	CleanupStack::PopAndDestroy(&file);
  1368 	delete content;
  1369 	
  1370 	
  1371 	INFO_PRINTF1(_L("Testing EContentShareExclusive"));	
  1372 	User::LeaveIfError(file.Open(fs, fileName, EFileShareExclusive | EFileRead | EFileStream));
  1373 	CleanupClosePushL(file);
  1374 	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadOnly));
  1375 	delete data;
  1376 	data = NULL;
  1377 	if(err != KErrInUse)
  1378 		{
  1379 		SetTestStepResult(EFail);
  1380 		}
  1381 	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadWrite));
  1382 	delete data;
  1383 	data = NULL;
  1384 	if(err != KErrInUse)
  1385 		{
  1386 		SetTestStepResult(EFail);
  1387 		}
  1388 	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareExclusive));
  1389 	delete data;
  1390 	data = NULL;
  1391 	if(err != KErrInUse)
  1392 		{
  1393 		SetTestStepResult(EFail);
  1394 		}
  1395 	CleanupStack::PopAndDestroy(&file); 
  1396 	
  1397 	INFO_PRINTF1(_L("Testing CContent::NewAttributeL"));	
  1398 	content = CContent::NewL(fileName, EContentShareReadWrite);
  1399 	User::LeaveIfError(file.Open(fs, fileName, EFileShareAny | EFileRead | EFileStream));
  1400 	CleanupClosePushL(file);
  1401 	attr = content->NewAttributeL(ETrue,EContentShareReadWrite);
  1402 	delete attr;
  1403 	attr = NULL;
  1404 	TRAP(err, attr = content->NewAttributeL(ETrue));
  1405 	delete attr;
  1406 	attr = NULL;
  1407 	if(err != KErrInUse)
  1408 		{
  1409 		SetTestStepResult(EFail);
  1410 		}
  1411 	CleanupStack::PopAndDestroy(2, &fs); // fs, file
  1412 	delete content;
  1413 
  1414 	__UHEAP_MARKEND;
  1415 	return TestStepResult();
  1416 	}
  1417 
  1418 CCAFHandleSizeStep::CCAFHandleSizeStep(CCAFServer& aParent)
  1419 :iParent(aParent)
  1420 {
  1421 	SetTestStepName(KCAFHandleSizeStep);	
  1422 }
  1423 
  1424 CCAFHandleSizeStep::~CCAFHandleSizeStep()
  1425 {
  1426 	
  1427 	
  1428 }	
  1429 
  1430 TVerdict CCAFHandleSizeStep::doTestStepL()
  1431 	{
  1432 	__UHEAP_MARK;
  1433 	
  1434 	SetTestStepResult(EInconclusive);
  1435 	
  1436 	INFO_PRINTF1(_L("Basic Open Content Test"));
  1437 	
  1438 	TPtrC uri1;
  1439 	TPtrC uri2;
  1440 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
  1441 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
  1442 
  1443 	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
  1444 	
  1445 	RFile file1;
  1446 	User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead));	
  1447 	CleanupClosePushL(file1);	
  1448 		
  1449 	CContent* content = CContent::NewLC(file1);
  1450 
  1451 	INFO_PRINTF1(_L("Creating data object from content"));
  1452 
  1453 	CData* data = content->OpenContentL(EPeek);
  1454 	CleanupStack::PushL(data);
  1455 
  1456 	TInt size = 0;
  1457 	data->DataSizeL(size);
  1458 	INFO_PRINTF2(_L("Size of content from caf: %d"),size);
  1459 	CleanupStack::PopAndDestroy(data);
  1460 	CleanupStack::PopAndDestroy(content);
  1461 	
  1462 	TInt pos = 0;
  1463 	file1.Seek(ESeekStart, pos);
  1464 
  1465 	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
  1466 	TInt size1 = 0;
  1467 	data = CData::NewL(file1, KDefaultContentObject(), EPeek);
  1468 	CleanupStack::PushL(data);
  1469 	data->DataSizeL(size1);
  1470 	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
  1471 	CleanupStack::PopAndDestroy(data);
  1472 	CleanupStack::PopAndDestroy(&file1);
  1473 	
  1474 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
  1475 	RFile file2;
  1476 	User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead));
  1477 	
  1478 	TInt size2;
  1479 	file2.Size(size2);
  1480 	file2.Close();
  1481 
  1482 	INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
  1483 
  1484 	if(size == size2 && size1 == size2)
  1485 		{
  1486 		SetTestStepResult(EPass);
  1487 		}
  1488 	else
  1489 		{
  1490 		SetTestStepResult(EFail);
  1491 		}
  1492 	
  1493 	__UHEAP_MARKEND;
  1494 	return TestStepResult();
  1495 	}
  1496 
  1497 
  1498 CCAFHandleSeekReadStep::~CCAFHandleSeekReadStep()
  1499 {
  1500 	
  1501 }
  1502 
  1503 CCAFHandleSeekReadStep::CCAFHandleSeekReadStep(CCAFServer& aParent)
  1504 : iParent(aParent)
  1505 	{
  1506 	SetTestStepName(KCAFHandleSeekReadStep);
  1507 	}
  1508 	
  1509 TVerdict CCAFHandleSeekReadStep::doTestStepL()
  1510 	{
  1511 	SetTestStepResult(EInconclusive);
  1512 	
  1513 	TBuf8<2> buf1;
  1514 	TBuf8<2> buf2;
  1515 	TRequestStatus status;
  1516 
  1517 	__UHEAP_MARK;
  1518 	INFO_PRINTF1(_L("Basic Open Content Test"));
  1519 	
  1520 	TPtrC uri1;
  1521 	TPtrC uri2;
  1522 	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
  1523 	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
  1524 
  1525 	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
  1526 	RFile file1;
  1527 	User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead | EFileShareReadersOnly));	
  1528 	CleanupClosePushL(file1);		
  1529 	CContent* content = CContent::NewLC(file1);
  1530 
  1531 	INFO_PRINTF1(_L("Creating data object from content"));
  1532 	CData* data = content->OpenContentL(EPeek);
  1533 	CleanupStack::PushL(data);
  1534 
  1535 	// Now, open the same file using RFile
  1536 	RFile file2;
  1537 	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
  1538 	//User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
  1539 	TInt res = file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly);
  1540 	CleanupClosePushL(file2);
  1541 
  1542 	TInt size = 0;
  1543 	file2.Size(size);
  1544 	INFO_PRINTF2(_L("Size of content from f32: %d"),size);
  1545 	
  1546 	// Seek and read from start using both CAF and RFile
  1547 	TInt pos1 = size/4;
  1548 	data->Seek(ESeekStart, pos1);
  1549 	TInt pos2 = size/4;
  1550 	file2.Seek(ESeekStart, pos2);
  1551 	data->Read(buf1);
  1552 	file2.Read(buf2);
  1553 	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
  1554 	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
  1555 	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
  1556 		{
  1557 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1558 		SetTestStepResult(EFail);
  1559 		}
  1560 
  1561 	// set the location within the file then retrieve the current location within the file
  1562 	pos1=0;
  1563 	pos2=0;
  1564 	data->Seek(ESeekCurrent, pos1);
  1565 	file2.Seek(ESeekCurrent, pos2);
  1566 
  1567 	INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
  1568 	INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
  1569 
  1570 	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
  1571 		{
  1572 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1573 		SetTestStepResult(EFail);
  1574 		}
  1575 
  1576 	// Seek and read from current using both CAF and RFile
  1577 	pos1 = size/4;
  1578 	data->Seek(ESeekCurrent, pos1);
  1579 	pos2 = size/4;
  1580 	file2.Seek(ESeekCurrent, pos2);
  1581 	data->Read(buf1);
  1582 	file2.Read(buf2);
  1583 	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
  1584 	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
  1585 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
  1586 		{
  1587 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1588 		SetTestStepResult(EFail);
  1589 		}
  1590 
  1591 	// Seek and read from end using both CAF and RFile
  1592 	pos1 = -size/4;
  1593 	data->Seek(ESeekEnd, pos1);
  1594 	pos2 = -size/4;
  1595 	file2.Seek(ESeekEnd, pos2);
  1596 	data->Read(buf1);
  1597 	file2.Read(buf2);
  1598 	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
  1599 	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
  1600 	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
  1601 		{
  1602 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1603 		SetTestStepResult(EFail);
  1604 		}
  1605 
  1606 	// Test other overloaded forms of CData::Read
  1607 
  1608 	// Read only 1 byte using both CAF and RFile
  1609 	pos1 = size/4;
  1610 	data->Seek(ESeekStart, pos1);
  1611 	pos2 = size/4;
  1612 	file2.Seek(ESeekStart, pos2);
  1613 	data->Read(buf1,1);
  1614 	file2.Read(buf2,1);
  1615 	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
  1616 	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
  1617 	
  1618 	pos1=0;
  1619 	pos2=0;
  1620 	data->Seek(ESeekCurrent, pos1);
  1621 	file2.Seek(ESeekCurrent,pos2);
  1622 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1623 		{
  1624 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1625 		SetTestStepResult(EFail);
  1626 		}
  1627 
  1628 	// Read asynchronously using both CAF and RFile
  1629 	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
  1630 	pos1 = size/4;
  1631 	data->Seek(ESeekStart, pos1);
  1632 	pos2 = size/4;
  1633 	file2.Seek(ESeekStart, pos2);
  1634 	status = KRequestPending;
  1635 	data->Read(buf1,status);
  1636 	User::WaitForRequest(status);
  1637 	status = KRequestPending;
  1638 	file2.Read(buf2,status);
  1639 	User::WaitForRequest(status);
  1640 	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
  1641 	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
  1642 
  1643 	pos1=0;
  1644 	pos2=0;
  1645 	data->Seek(ESeekCurrent, pos1);
  1646 	file2.Seek(ESeekCurrent,pos2);
  1647 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1648 		{
  1649 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1650 		SetTestStepResult(EFail);
  1651 		}
  1652 
  1653 	// Read only 1 byte asynchronously using both CAF and RFile
  1654 	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
  1655 	pos1 = size/4;
  1656 	data->Seek(ESeekStart, pos1);
  1657 	pos2 = size/4;
  1658 	file2.Seek(ESeekStart, pos2);
  1659 	status = KRequestPending;
  1660 	data->Read(buf1,1,status);
  1661 	User::WaitForRequest(status);
  1662 	status = KRequestPending;
  1663 	file2.Read(buf2,1, status);
  1664 	User::WaitForRequest(status);
  1665 	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
  1666 	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
  1667 
  1668 	pos1=0;
  1669 	pos2=0;
  1670 	data->Seek(ESeekCurrent, pos1);
  1671 	file2.Seek(ESeekCurrent,pos2);
  1672 	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1673 		{
  1674 		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1675 		SetTestStepResult(EFail);
  1676 		}
  1677 
  1678 	// read past EOF
  1679 	pos1 = size+1;
  1680 	pos2 = size+1;
  1681 	data->Seek(ESeekStart, pos1);
  1682 	file2.Seek(ESeekStart, pos2);
  1683 	data->Read(buf1);
  1684 	file2.Read(buf2);
  1685 
  1686 	if(buf1.Length() != 0 || buf1.Length() != 0)
  1687 		{
  1688 		INFO_PRINTF1(_L("ERROR data read past EOF"));
  1689 		SetTestStepResult(EFail);
  1690 		}
  1691 	
  1692 	CleanupStack::PopAndDestroy(4);
  1693 
  1694 	__UHEAP_MARKEND;
  1695 
  1696 	if (TestStepResult() != EFail)
  1697 		{
  1698 		SetTestStepResult(EPass);
  1699 		}
  1700 
  1701 	return TestStepResult();
  1702 	}
  1703 
  1704 /* 
  1705  * Step reads from a CData from multiple threads using RFile handle
  1706  *
  1707  */
  1708  
  1709 CCAFHandleMultiThreadCDataStep::~CCAFHandleMultiThreadCDataStep()
  1710  {
  1711   	
  1712  }
  1713    
  1714  CCAFHandleMultiThreadCDataStep::CCAFHandleMultiThreadCDataStep(CCAFServer& aParent)
  1715  :iParent(aParent)
  1716  {
  1717  	
  1718  	SetTestStepName(KCAFHandleMultiThreadCDataStep);
  1719  }
  1720  
  1721 TVerdict CCAFHandleMultiThreadCDataStep::doTestStepL()
  1722 	 {
  1723 	TBuf8<2> buf;
  1724 
  1725 	__UHEAP_MARK;
  1726 	_LIT(KCDataThread,"CData_Thread");
  1727 
  1728 	SetTestStepResult(EInconclusive);
  1729 	
  1730 	INFO_PRINTF1(_L("Multi Thread CData Test using RFile Handle"));
  1731 	
  1732 	TPtrC uri;
  1733 	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1734 
  1735 	INFO_PRINTF1(_L("Creating data object from content"));
  1736 	RFile file;
  1737 	User::LeaveIfError(file.Open(iParent.Fs(), uri, EFileRead));	
  1738 		
  1739 	CleanupClosePushL(file);
  1740 		
  1741 	CContent* content = CContent::NewLC(file);
  1742 	CData* data = content->OpenContentL(EPeek);
  1743 	CleanupStack::PushL(data);
  1744 
  1745 	TInt size, pos;
  1746 
  1747 	// Create a mutex for communication between our thread and the new thread
  1748 	RSemaphore threadSemaphore;
  1749 	threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
  1750 	threadSemaphore.Wait(); 
  1751 
  1752 	// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future 
  1753 	RThread readerThread;
  1754 	User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
  1755 	
  1756 	// request notification of thread completion
  1757 	TRequestStatus stat;
  1758 	readerThread.Logon(stat);
  1759 	readerThread.Resume();	
  1760 	
  1761 
  1762 	data->DataSizeL(size);
  1763 	pos = size/2;
  1764 	data->Seek(ESeekStart,pos);
  1765 	data->Read(buf);
  1766 
  1767 	threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
  1768 	threadSemaphore.Signal(); // finished with semaphore
  1769 	threadSemaphore.Close(); // so close
  1770 
  1771 	User::WaitForRequest(stat); // wait for thread to finish
  1772 	TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
  1773 	User::LeaveIfError(error);
  1774 	readerThread.Close();  // close the thread
  1775 	
  1776 	CleanupStack::PopAndDestroy(data);
  1777 	CleanupStack::PopAndDestroy(content);
  1778 	CleanupStack::PopAndDestroy(&file); //file
  1779 	
  1780 
  1781 	__UHEAP_MARKEND;
  1782 	
  1783 	SetTestStepResult(EPass);
  1784 	return TestStepResult();	
  1785 }
  1786 
  1787 TInt CCAFHandleMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
  1788 	{
  1789 	TBuf8 <2> buf;
  1790 	CData *data = reinterpret_cast <CData *> (aPtr);
  1791 
  1792 	// create a trap handler
  1793 	CTrapCleanup* cleanup = CTrapCleanup::New();
  1794 
  1795 	RSemaphore threadSemaphore;
  1796 	threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
  1797 
  1798 	data->Read(buf);
  1799 	threadSemaphore.Signal(); // allow original thread to continue
  1800 	threadSemaphore.Close();
  1801 	
  1802 	delete cleanup;
  1803 	return KErrNone;
  1804 	}
  1805 
  1806 /* 
  1807  * Data attribute step
  1808  *
  1809  */
  1810 
  1811 CCAFDataAttributeStep::~CCAFDataAttributeStep()
  1812 	{
  1813 	}
  1814 
  1815 CCAFDataAttributeStep::CCAFDataAttributeStep(CCAFServer& aParent) : iParent(aParent)
  1816 	{
  1817 	SetTestStepName(KCAFDataAttributeStep);
  1818 	}
  1819 
  1820 TVerdict CCAFDataAttributeStep::doTestStepL()
  1821 	{
  1822 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1823     TBool wmdrmFlag = EFalse;     
  1824     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1825          
  1826     if(wmdrmFlag)     
  1827         {     
  1828         TVerdict verdict = doWmdrmTestStepL();     
  1829         return verdict;     
  1830         }     
  1831 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1832   
  1833 	TInt attribute;
  1834 	TInt value = KErrNone;
  1835 	TInt expectedValue = KErrNone;
  1836 	TPtrC uri;
  1837 	TPtrC uniqueId;
  1838 
  1839 	SetTestStepResult(EPass);
  1840 
  1841 	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
  1842 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1843 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1844 	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
  1845 
  1846 	__UHEAP_MARK;
  1847 	CContent *content = CContent::NewLC(uri);
  1848 	CData *data = content->OpenContentL(EPeek, uniqueId);
  1849 	User::LeaveIfError(data->GetAttribute(attribute, value));
  1850 	delete data;
  1851 	if(expectedValue != value)
  1852 		{
  1853 		SetTestStepResult(EFail);
  1854 		INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
  1855 		}
  1856 	
  1857 	CleanupStack::PopAndDestroy(content);		    		
  1858 	__UHEAP_MARKEND;
  1859 	return TestStepResult();
  1860 	}
  1861 
  1862 /* 
  1863  * Data attributeset step
  1864  *
  1865  */
  1866 
  1867 CCAFDataAttributeSetStep::~CCAFDataAttributeSetStep()
  1868 	{
  1869 	}
  1870 
  1871 CCAFDataAttributeSetStep::CCAFDataAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
  1872 	{
  1873 	SetTestStepName(KCAFDataAttributeSetStep);
  1874 	}
  1875 
  1876 TVerdict CCAFDataAttributeSetStep::doTestStepL()
  1877 	{
  1878 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1879     TBool wmdrmFlag = EFalse;     
  1880     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1881          
  1882     if(wmdrmFlag)     
  1883         {     
  1884         TVerdict verdict = doWmdrmTestStepL();     
  1885         return verdict;     
  1886         }     
  1887 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
  1888 
  1889 	TInt expectedValue1;
  1890 	TInt expectedValue2;
  1891 	TInt value1;
  1892 	TInt value2;
  1893 	TInt attribute1;
  1894 	TInt attribute2;
  1895 	TInt result = KErrNone;
  1896 	TPtrC uri;
  1897 	TPtrC uniqueId;
  1898 
  1899 	SetTestStepResult(EPass);
  1900 
  1901 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1902 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1903 	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
  1904 	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
  1905 	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
  1906 	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
  1907 
  1908 	__UHEAP_MARK;
  1909 	CContent *content = CContent::NewLC(uri);
  1910 	RAttributeSet attributeSet;
  1911 	CleanupClosePushL(attributeSet);
  1912 	attributeSet.AddL(attribute1);
  1913 	attributeSet.AddL(attribute2);
  1914 
  1915 	CData *data = content->OpenContentL(EPeek, uniqueId);
  1916 	result = data->GetAttributeSet(attributeSet);
  1917 	delete data;
  1918 	if(result != KErrNone)
  1919 		{
  1920 		SetTestStepResult(EFail);
  1921 		INFO_PRINTF1(_L("CData::GetAttribute() failed"));
  1922 		}
  1923 	User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
  1924 	User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
  1925 	if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
  1926 		{
  1927 		SetTestStepResult(EFail);
  1928 		INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
  1929 		}
  1930 	CleanupStack::PopAndDestroy(&attributeSet);		
  1931 	CleanupStack::PopAndDestroy(content);		
  1932     		
  1933 	__UHEAP_MARKEND;
  1934 	return TestStepResult();
  1935 	}
  1936 
  1937 
  1938 /* 
  1939  * Data string attribute step
  1940  *
  1941  */
  1942 
  1943 CCAFDataStringAttributeStep::~CCAFDataStringAttributeStep()
  1944 	{
  1945 	}
  1946 
  1947 CCAFDataStringAttributeStep::CCAFDataStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
  1948 	{
  1949 	SetTestStepName(KCAFDataStringAttributeStep);
  1950 	}
  1951 
  1952 TVerdict CCAFDataStringAttributeStep::doTestStepL()
  1953 	{
  1954 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1955     TBool wmdrmFlag = EFalse;     
  1956     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1957          
  1958     if(wmdrmFlag)     
  1959         {     
  1960         TVerdict verdict = doWmdrmTestStepL();     
  1961         return verdict;     
  1962         }     
  1963 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
  1964 
  1965 	TInt expectedResult;
  1966 	TInt attribute;
  1967 	TPtrC expectedValue;
  1968 	TBuf <200> value;
  1969 	TInt result = KErrNone;
  1970 	TPtrC uri;
  1971 	TPtrC uniqueId;
  1972 
  1973 	SetTestStepResult(EPass);
  1974 
  1975 	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
  1976 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1977 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1978 	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
  1979 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
  1980 
  1981 	__UHEAP_MARK;
  1982 	CContent *content = CContent::NewLC(uri);
  1983 	CData *data = content->OpenContentL(EPeek, uniqueId);
  1984 	result = data->GetStringAttribute(attribute, value);
  1985 	delete data;
  1986 	if(result != expectedResult)
  1987 		{
  1988 		SetTestStepResult(EFail);
  1989 		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
  1990 		}
  1991 	if(value != expectedValue)
  1992 		{
  1993 		SetTestStepResult(EFail);
  1994 		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
  1995 		}
  1996 
  1997 	CleanupStack::PopAndDestroy(content);		
  1998     		
  1999 	__UHEAP_MARKEND;
  2000 	return TestStepResult();
  2001 	}
  2002 
  2003 /* 
  2004  * Data StringAttributeSet step
  2005  *
  2006  */
  2007 
  2008 CCAFDataStringAttributeSetStep::~CCAFDataStringAttributeSetStep()
  2009 	{
  2010 	}
  2011 
  2012 CCAFDataStringAttributeSetStep::CCAFDataStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
  2013 	{
  2014 	SetTestStepName(KCAFDataStringAttributeSetStep);
  2015 	}
  2016 
  2017 TVerdict CCAFDataStringAttributeSetStep::doTestStepL()
  2018 	{
  2019 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  2020     TBool wmdrmFlag = EFalse;     
  2021     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  2022          
  2023     if(wmdrmFlag)     
  2024         {     
  2025         TVerdict verdict = doWmdrmTestStepL();     
  2026         return verdict;     
  2027         }     
  2028 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  2029   
  2030 	TPtrC expectedValue1;
  2031 	TPtrC expectedValue2;
  2032 	TBuf <200> value1;
  2033 	TBuf <200> value2;
  2034 	TInt attribute1;
  2035 	TInt attribute2;
  2036 	TInt result = KErrNone;
  2037 	TInt result1;
  2038 	TInt result2;
  2039 	TPtrC uri;
  2040 	TPtrC uniqueId;
  2041 
  2042 	SetTestStepResult(EPass);
  2043 
  2044 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  2045 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  2046 	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
  2047 	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
  2048 	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
  2049 	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
  2050 	GetIntFromConfig(ConfigSection(),_L("result1"),result1);
  2051 	GetIntFromConfig(ConfigSection(),_L("result2"),result2);
  2052 
  2053 	__UHEAP_MARK;
  2054 	CContent *content = CContent::NewLC(uri);
  2055 	RStringAttributeSet attributeSet;
  2056 	CleanupClosePushL(attributeSet);
  2057 	attributeSet.AddL(attribute1);
  2058 	attributeSet.AddL(attribute2);
  2059 	
  2060 	CData *data = content->OpenContentL(EPeek, uniqueId);
  2061 	result = data->GetStringAttributeSet(attributeSet);
  2062 	delete data;
  2063 	if(result != KErrNone)
  2064 		{
  2065 		SetTestStepResult(EFail);
  2066 		INFO_PRINTF1(_L("CData::GetAttribute() failed"));
  2067 		}
  2068 	if(result1 != attributeSet.GetValue(attribute1, value1))
  2069 		{
  2070 		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
  2071 		}
  2072 	if(result2 != attributeSet.GetValue(attribute2, value2))
  2073 		{
  2074 		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
  2075 		}
  2076 	if( value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
  2077 		{
  2078 		SetTestStepResult(EFail);
  2079 		INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
  2080 		}
  2081 	CleanupStack::PopAndDestroy(&attributeSet);		
  2082 	CleanupStack::PopAndDestroy(content);		
  2083 	
  2084     		
  2085 	__UHEAP_MARKEND;
  2086 	return TestStepResult();
  2087 	}
  2088 
  2089 
  2090 CCAFExecuteIntentStep::~CCAFExecuteIntentStep()
  2091 	{
  2092 	}
  2093 
  2094 CCAFExecuteIntentStep::CCAFExecuteIntentStep(CCAFServer& aParent)
  2095 : iParent(aParent)
  2096 	{
  2097 	SetTestStepName(KCAFSizeStep);
  2098 	}
  2099 
  2100 TVerdict CCAFExecuteIntentStep::doTestStepL()
  2101 	{
  2102 	__UHEAP_MARK;
  2103 	
  2104 	SetTestStepResult(EInconclusive);
  2105 	
  2106 	INFO_PRINTF1(_L("Execute Intent Test"));
  2107 	
  2108 	TPtrC fileName;
  2109 	TPtrC uniqueId;
  2110 	TInt intent = EPeek;
  2111 	TInt expectedResult = KErrNone;
  2112 	
  2113 	GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
  2114 	GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueId);
  2115 	GetIntFromConfig(ConfigSection(),_L("Intent"),intent);
  2116 	GetIntFromConfig(ConfigSection(),_L("ExpectedResult"),expectedResult);
  2117 	
  2118 	INFO_PRINTF3(_L("Creating CData object with filename: %S, UniqueId: %S"), &fileName, &uniqueId);
  2119 	
  2120 	CData* data = NULL;
  2121 	
  2122 	TRAPD(err, data = CData::NewL(TVirtualPathPtr(fileName, uniqueId),static_cast<TIntent>(intent), EContentShareReadOnly));
  2123 	
  2124 	if(err != expectedResult)
  2125 		{
  2126 		INFO_PRINTF2(_L("Unexpected result, EvaluateIntent() returned %d"), err);
  2127 		}
  2128 	else
  2129 		{
  2130 		SetTestStepResult(EPass);
  2131 		if(err == KErrNone)
  2132 			{
  2133 			err = data->ExecuteIntent(static_cast<TIntent>(intent));
  2134 			if(err == KErrNone)
  2135 				{
  2136 				TBuf8 <128> buffer;
  2137 				TInt length = 128;
  2138 			
  2139 				// read the entire content object
  2140 				while(err == KErrNone && length > 0)
  2141 					{
  2142 					err = data->Read(buffer);
  2143 					length = buffer.Length();
  2144 					}
  2145 				if(err != KErrEof && err != KErrNone)
  2146 					{
  2147 					INFO_PRINTF2(_L("Unexpected error while reading content object: %d"), err);
  2148 					SetTestStepResult(EFail);
  2149 					}
  2150 				}
  2151 			else
  2152 				{
  2153 				INFO_PRINTF2(_L("Unexpected error, EvaluteIntent succeeded but ExecuteIntent failed with error: %d"), err);
  2154 				SetTestStepResult(EFail);
  2155 				}
  2156 			}
  2157 		}
  2158 		
  2159 	delete data;
  2160 	
  2161 	__UHEAP_MARKEND;
  2162 	return TestStepResult();
  2163 	}
  2164 
  2165 /* 
  2166  * DRM File Open Performance Test Step
  2167  *
  2168  */
  2169 
  2170 CCAFDRMFileOpenPerformanceTest::~CCAFDRMFileOpenPerformanceTest()
  2171 	{
  2172 	iIterationSum = 0;
  2173 	}
  2174 
  2175 CCAFDRMFileOpenPerformanceTest::CCAFDRMFileOpenPerformanceTest(CCAFServer& aParent) : iParent(aParent)
  2176 	{
  2177 	SetTestStepName(KCAFDRMFileOpenPerformanceStep);
  2178 	}
  2179 
  2180 TVerdict CCAFDRMFileOpenPerformanceTest::doTestStepL()
  2181 	{
  2182 	__UHEAP_MARK;
  2183 
  2184 	INFO_PRINTF1(_L("DRM File Open Performance Test"));
  2185 	
  2186 	TPtrC inputFileName;
  2187 	TInt maxValue = 0 ,iterCount = 0;
  2188 
  2189 	GetStringFromConfig(ConfigSection(),_L("FileName"),inputFileName);
  2190 	GetIntFromConfig(ConfigSection(),_L("IterationCount"),iterCount);
  2191 	GetIntFromConfig(ConfigSection(),_L("MaxTimeLimitInMS"),maxValue);
  2192 		
  2193 	iIterationSum=0;
  2194 	// iterated iterCount times to get the average time taken to open the file.
  2195 	for (TInt i = 0; i < iterCount; ++i)
  2196 		{
  2197 		OpenAndReadFileContentL(inputFileName);
  2198 		}
  2199 		
  2200 	TInt tickPeriod;
  2201 	HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
  2202 	TInt nTickPeriodMS = tickPeriod / KCafTestSecToMS;
  2203 
  2204 	TInt avgTimeForFileOpen = (iIterationSum * nTickPeriodMS) / iterCount;
  2205 	if((avgTimeForFileOpen > maxValue))
  2206 		{
  2207 		INFO_PRINTF1(_L("Performance Test failed."));
  2208 		SetTestStepResult(EFail);
  2209 		}
  2210 
  2211 	INFO_PRINTF2(_L("Expected maximum time to open DRM file in millisecs is : %d"), maxValue);
  2212 	INFO_PRINTF2(_L("Obtained time in millisecs is: %d"), avgTimeForFileOpen);
  2213 	
  2214 	__UHEAP_MARKEND;
  2215 	
  2216 	return TestStepResult();
  2217 	}
  2218 	
  2219 void CCAFDRMFileOpenPerformanceTest::OpenAndReadFileContentL(const TDesC& aFileName)
  2220 	{
  2221 	TPtrC uniqueIdentifier;
  2222 
  2223 	GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueIdentifier);
  2224 	CContent *content = CContent::NewLC(aFileName);
  2225 	CData *data = NULL;
  2226 	TUint32 tickCounterValBeforeFileOpen, tickCounterValAfterFileOpen;
  2227 	if(uniqueIdentifier.Length() > 0)
  2228 		{
  2229 		tickCounterValBeforeFileOpen = User::NTickCount();
  2230 		data = content->OpenContentL(EPeek,uniqueIdentifier);
  2231 		tickCounterValAfterFileOpen = User::NTickCount();
  2232 		}
  2233 	else
  2234 		{
  2235 		tickCounterValBeforeFileOpen = User::NTickCount();
  2236 		data = content->OpenContentL(EPeek);
  2237 		tickCounterValAfterFileOpen = User::NTickCount();
  2238 		}
  2239 	delete data;
  2240 	// finished with Data object
  2241 	CleanupStack::PopAndDestroy(content);	
  2242 	iIterationSum += tickCounterValAfterFileOpen - tickCounterValBeforeFileOpen;
  2243 	}
  2244 	
  2245 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  2246       
  2247 CWmdrmCAFContentStep::~CWmdrmCAFContentStep()     
  2248     {     
  2249     }     
  2250       
  2251 CWmdrmCAFContentStep::CWmdrmCAFContentStep()     
  2252     {     
  2253     SetTestStepName(KWmdrmCAFContentStep);     
  2254     }     
  2255       
  2256       
  2257 TVerdict CWmdrmCAFContentStep::doTestStepL()     
  2258     {     
  2259     SetTestStepResult(EFail);     
  2260     
  2261     TBool protectedVal;
  2262     GetBoolFromConfig(ConfigSection(),_L("attribValue1"), protectedVal);     
  2263     TBool forwardable;     
  2264     GetBoolFromConfig(ConfigSection(),_L("attribValue2"), forwardable);     
  2265          
  2266     TBool headerDataPresent = ETrue;     
  2267     GetBoolFromConfig(ConfigSection(),_L("headerDataFlag"), headerDataPresent);     
  2268          
  2269     INFO_PRINTF1(_L("Verify CContent APIs for WMDRM content"));      
  2270          
  2271     __UHEAP_MARK;     
  2272          
  2273     CContent* content = NULL;     
  2274          
  2275     // this condition verifies that CContent construction leaves with KErrMissingWmdrmHeaderData,     
  2276     // when no header data is provided.     
  2277     if(!headerDataPresent)     
  2278         {     
  2279         content = CContent::NewL(KNullDesC8());     
  2280         return EPass;     
  2281         }     
  2282          
  2283     // create a dummy header data.     
  2284     HBufC8* headerData = CreateWmdrmHeaderLC();     
  2285          
  2286     // Open a file and retrieve the attributes.     
  2287     // If headerDataPresent is false, the code will never reach here.s     
  2288     content = CContent::NewL(*headerData);     
  2289     CleanupStack::PushL(content);     
  2290     CAttribute* attrs = content->NewAttributeL(ETrue);     
  2291     CleanupStack::PushL(attrs);     
  2292       
  2293     TBool value1 = attrs->ResponseSet().IsSet(EIsProtected);     
  2294     TBool value2 = attrs->ResponseSet().IsSet(EIsForwardable);     
  2295     if(value1 == protectedVal && value2 == forwardable)     
  2296         {     
  2297         SetTestStepResult(EPass);     
  2298         }     
  2299       
  2300     CleanupStack::PopAndDestroy(3, headerData);      
  2301       
  2302     __UHEAP_MARKEND;     
  2303     return TestStepResult();     
  2304     }     
  2305       
  2306       
  2307 CWmdrmCAFDataStep::~CWmdrmCAFDataStep()     
  2308     {     
  2309     }     
  2310       
  2311 CWmdrmCAFDataStep::CWmdrmCAFDataStep()     
  2312     {     
  2313     SetTestStepName(KWmdrmCAFDataStep);     
  2314     }     
  2315       
  2316 TVerdict CWmdrmCAFDataStep::doTestStepL()     
  2317     {     
  2318     SetTestStepResult(EFail);     
  2319          
  2320     TInt attribute;     
  2321     TInt expectedValue = KErrNone;     
  2322       
  2323     GetIntFromConfig(ConfigSection(),_L("attribute"), attribute);     
  2324     GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
  2325          
  2326 __UHEAP_MARK;     
  2327       
  2328     HBufC8* headerData = CreateWmdrmHeaderLC();     
  2329          
  2330     CContent *content = CContent::NewLC(*headerData);     
  2331     CData *data = content->OpenContentL(EPeek);     
  2332     TInt value = KErrNone;     
  2333     User::LeaveIfError(data->GetAttribute(attribute, value));     
  2334     delete data;     
  2335          
  2336     if(expectedValue == value)     
  2337         {     
  2338         SetTestStepResult(EPass);     
  2339         }     
  2340     else     
  2341         {     
  2342         INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);        
  2343         }     
  2344          
  2345     CleanupStack::PopAndDestroy(2, headerData);                      
  2346 __UHEAP_MARKEND;     
  2347          
  2348     return TestStepResult();     
  2349     }     
  2350       
  2351       
  2352 CWmdrmCAFReadStep::~CWmdrmCAFReadStep()     
  2353     {     
  2354     }     
  2355       
  2356 CWmdrmCAFReadStep::CWmdrmCAFReadStep()     
  2357     {     
  2358     SetTestStepName(KWmdrmCAFReadStep);     
  2359     }     
  2360       
  2361       
  2362 TVerdict CWmdrmCAFReadStep::doTestStepL()     
  2363     {     
  2364     SetTestStepResult(EFail);     
  2365          
  2366     TBool synchronous = EFalse;     
  2367     GetBoolFromConfig(ConfigSection(),_L("synchronous"), synchronous);     
  2368     TBool intent = EFalse;     
  2369     GetBoolFromConfig(ConfigSection(),_L("intent"), intent);     
  2370     TPtrC inputPacket;     
  2371     GetStringFromConfig(ConfigSection(),_L("inputPacket"), inputPacket);     
  2372     TPtrC expectedOutput;     
  2373     GetStringFromConfig(ConfigSection(),_L("outputPacket"), expectedOutput);     
  2374          
  2375 __UHEAP_MARK;     
  2376     TPtrC header;     
  2377     HBufC8* headerData = NULL;     
  2378          
  2379     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  2380         {     
  2381         headerData = ConvertDes16toHBufC8LC(header);     
  2382         }     
  2383     else     
  2384         {     
  2385         headerData = CreateWmdrmHeaderLC();      
  2386         }     
  2387          
  2388     TInt result = 0;     
  2389     if(!synchronous)     
  2390         {     
  2391         result = TestAsynchronousReadL(*headerData, intent, inputPacket, expectedOutput);     
  2392         }     
  2393     else     
  2394         {     
  2395         result = TestSynchronousReadL(*headerData, intent, inputPacket, expectedOutput);     
  2396         }     
  2397       
  2398     if(result == KErrNone)     
  2399         {     
  2400         SetTestStepResult(EPass);     
  2401         }     
  2402              
  2403     CleanupStack::PopAndDestroy(headerData);     
  2404 __UHEAP_MARKEND;     
  2405       
  2406     return TestStepResult();     
  2407     }     
  2408          
  2409 TInt CWmdrmCAFReadStep::TestSynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)     
  2410     {     
  2411 __UHEAP_MARK;     
  2412     CData* data = NULL;     
  2413     TInt returnVal = KErrGeneral;     
  2414          
  2415     if(aIntent)     
  2416         {     
  2417         data = CData::NewL(aHeaderData, EPeek);     
  2418         }     
  2419     else     
  2420         {     
  2421         data = CData::NewL(aHeaderData);     
  2422         }     
  2423          
  2424     CleanupStack::PushL(data);     
  2425          
  2426     if(aInputPacket.Length() <= 0)     
  2427         {     
  2428         // dummy output buffer.This loop essentially tests the error condition KErrInsufficientDataPacketLength.     
  2429         TBuf8<2> outputBuffer;     
  2430         User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));     
  2431         }     
  2432              
  2433     else     
  2434         {     
  2435         HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);     
  2436         HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());     
  2437         TPtr8 outputPacketPtr = outputPacket->Des();     
  2438          
  2439         User::LeaveIfError(data->Read(*inputPacket, outputPacketPtr));     
  2440         HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);     
  2441         if(expectedOutput->Compare(*outputPacket) == KErrNone)     
  2442             {     
  2443             returnVal = KErrNone;        
  2444             }     
  2445          
  2446         CleanupStack::PopAndDestroy(3, inputPacket);         
  2447         }     
  2448          
  2449     CleanupStack::PopAndDestroy(data);     
  2450 __UHEAP_MARKEND;     
  2451          
  2452     return returnVal;     
  2453     }     
  2454          
  2455 TInt CWmdrmCAFReadStep::TestAsynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)     
  2456     {     
  2457 __UHEAP_MARK;     
  2458     CData* data = NULL;     
  2459     TInt returnVal = KErrGeneral;     
  2460          
  2461     if(aIntent)     
  2462         {     
  2463         data = CData::NewL(aHeaderData, EPeek);     
  2464         }     
  2465     else     
  2466         {     
  2467         data = CData::NewL(aHeaderData);     
  2468         }     
  2469          
  2470     CleanupStack::PushL(data);     
  2471          
  2472     if(aInputPacket.Length() <= 0)     
  2473         {     
  2474         TBuf8<2> outputBuffer;     
  2475         User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));     
  2476         }     
  2477              
  2478     else     
  2479         {     
  2480         HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);     
  2481         HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());     
  2482         TPtr8 outputPacketPtr = outputPacket->Des();     
  2483          
  2484         TRequestStatus status;     
  2485         data->Read(*inputPacket, outputPacketPtr, status);     
  2486         User::WaitForRequest(status);     
  2487          
  2488         if(status.Int() != KErrNone)     
  2489             {     
  2490             CleanupStack::PopAndDestroy(3, data);     
  2491             return status.Int();     
  2492             }     
  2493              
  2494         HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);     
  2495         if(expectedOutput->Compare(*outputPacket) == KErrNone)     
  2496             {     
  2497             returnVal = KErrNone;     
  2498             }     
  2499          
  2500         CleanupStack::PopAndDestroy(3, inputPacket);     
  2501         }     
  2502          
  2503     CleanupStack::PopAndDestroy(data);     
  2504 __UHEAP_MARKEND;     
  2505          
  2506     return returnVal;     
  2507     }     
  2508          
  2509 TVerdict CCAFDataAttributeStep::doWmdrmTestStepL()     
  2510     {     
  2511     SetTestStepResult(EFail);     
  2512          
  2513     TInt attribVal;     
  2514     GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
  2515          
  2516     TInt expectedValue;     
  2517     GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
  2518       
  2519 __UHEAP_MARK;     
  2520     TPtrC header;     
  2521     HBufC8* headerData = NULL;     
  2522          
  2523     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  2524         {     
  2525         headerData = ConvertDes16toHBufC8LC(header);     
  2526         }     
  2527     else     
  2528         {     
  2529         headerData = CreateWmdrmHeaderLC();      
  2530         }     
  2531              
  2532     CContent *content = CContent::NewLC(*headerData);     
  2533     CData *data = content->OpenContentL(EPeek);     
  2534     TInt value;     
  2535     User::LeaveIfError(data->GetAttribute(attribVal, value));     
  2536     delete data;     
  2537          
  2538     if(expectedValue == value)     
  2539         {     
  2540         SetTestStepResult(EPass);     
  2541         }     
  2542     else     
  2543         {     
  2544         INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);        
  2545         }     
  2546          
  2547     CleanupStack::PopAndDestroy(2, headerData);                      
  2548 __UHEAP_MARKEND;     
  2549       
  2550     return TestStepResult();     
  2551     }     
  2552          
  2553       
  2554 TVerdict CCAFDataAttributeSetStep::doWmdrmTestStepL()     
  2555     {     
  2556     SetTestStepResult(EFail);     
  2557          
  2558     TInt attribute1;     
  2559     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  2560          
  2561     TInt attribute2;     
  2562     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  2563          
  2564     TInt expectedValue1;     
  2565     GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  2566          
  2567     TInt expectedValue2;     
  2568     GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  2569       
  2570 __UHEAP_MARK;     
  2571       
  2572     TPtrC header;     
  2573     HBufC8* headerData = NULL;     
  2574          
  2575     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  2576         {     
  2577         headerData = ConvertDes16toHBufC8LC(header);     
  2578         }     
  2579     else     
  2580         {     
  2581         headerData = CreateWmdrmHeaderLC();      
  2582         }     
  2583          
  2584     CContent *content = CContent::NewLC(*headerData);     
  2585     CData *data = content->OpenContentL(EPeek);     
  2586                      
  2587     RAttributeSet attributeSet;     
  2588     CleanupClosePushL(attributeSet);     
  2589     attributeSet.AddL(attribute1);     
  2590     attributeSet.AddL(attribute2);     
  2591              
  2592     TInt result = data->GetAttributeSet(attributeSet);     
  2593     delete data;     
  2594          
  2595     if(result == KErrNone)     
  2596         {     
  2597         TInt value1;         
  2598         User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
  2599              
  2600         TInt value2;     
  2601         User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
  2602              
  2603         if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
  2604             {     
  2605             SetTestStepResult(EPass);     
  2606             }     
  2607         else     
  2608             {     
  2609             INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));     
  2610             }     
  2611         }     
  2612          
  2613     else     
  2614         {     
  2615         INFO_PRINTF1(_L("CData::GetAttributeSet() failed"));     
  2616         }     
  2617              
  2618     CleanupStack::PopAndDestroy(3, headerData);          
  2619          
  2620 __UHEAP_MARKEND;     
  2621       
  2622     return TestStepResult();     
  2623     }     
  2624       
  2625       
  2626 TVerdict CCAFDataStringAttributeStep::doWmdrmTestStepL()     
  2627     {     
  2628     SetTestStepResult(EFail);     
  2629          
  2630     TInt attribVal;     
  2631     GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
  2632          
  2633     TPtrC expectedValue;     
  2634     GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
  2635          
  2636     TInt expectedResult;     
  2637     GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
  2638          
  2639 __UHEAP_MARK;     
  2640     TPtrC header;     
  2641     HBufC8* headerData = NULL;     
  2642          
  2643     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  2644         {     
  2645         headerData = ConvertDes16toHBufC8LC(header);     
  2646         }     
  2647     else     
  2648         {     
  2649         headerData = CreateWmdrmHeaderLC();      
  2650         }     
  2651          
  2652     CContent *content = CContent::NewLC(*headerData);     
  2653     CData *data = content->OpenContentL(EPeek);     
  2654                  
  2655     TBuf <200> value;     
  2656     TInt result = data->GetStringAttribute(attribVal, value);     
  2657     delete data;     
  2658          
  2659     if(result == expectedResult && value == expectedValue)     
  2660         {     
  2661         SetTestStepResult(EPass);     
  2662         }     
  2663     else     
  2664         {     
  2665         INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
  2666         INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
  2667         }     
  2668              
  2669     CleanupStack::PopAndDestroy(2, headerData);          
  2670              
  2671 __UHEAP_MARKEND;     
  2672       
  2673     return TestStepResult();     
  2674     }     
  2675       
  2676       
  2677 TVerdict CCAFDataStringAttributeSetStep::doWmdrmTestStepL()     
  2678     {     
  2679     SetTestStepResult(EFail);     
  2680       
  2681     TInt attribute1;         
  2682     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  2683          
  2684     TInt attribute2;     
  2685     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  2686          
  2687     TPtrC expectedValue1;     
  2688     GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  2689          
  2690     TPtrC expectedValue2;     
  2691     GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  2692          
  2693 __UHEAP_MARK;     
  2694     TPtrC header;     
  2695     HBufC8* headerData = NULL;     
  2696          
  2697     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  2698         {     
  2699         headerData = ConvertDes16toHBufC8LC(header);     
  2700         }     
  2701     else     
  2702         {     
  2703         headerData = CreateWmdrmHeaderLC();      
  2704         }     
  2705          
  2706     CContent *content = CContent::NewLC(*headerData);     
  2707     CData *data = content->OpenContentL(EPeek);     
  2708          
  2709     RStringAttributeSet attributeSet;     
  2710     CleanupClosePushL(attributeSet);     
  2711     attributeSet.AddL(attribute1);     
  2712     attributeSet.AddL(attribute2);     
  2713              
  2714     TInt result = data->GetStringAttributeSet(attributeSet);     
  2715     delete data;     
  2716              
  2717     TBuf <200> value1;     
  2718     TBuf <200> value2;     
  2719     if(result == KErrNone)     
  2720         {     
  2721         TInt result3 = attributeSet.GetValue(attribute1, value1);     
  2722         TInt result4 = attributeSet.GetValue(attribute2, value2);     
  2723                  
  2724         if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
  2725          && result3 == KErrNone && result4 == KErrNone)     
  2726             {     
  2727             SetTestStepResult(EPass);     
  2728             }     
  2729         else     
  2730             {     
  2731             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
  2732             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
  2733             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
  2734             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
  2735             }     
  2736         }     
  2737     else     
  2738         {     
  2739         INFO_PRINTF1(_L("CData::GetStringAttributeSet() failed"));     
  2740         }        
  2741          
  2742     CleanupStack::PopAndDestroy(3, headerData);          
  2743       
  2744 __UHEAP_MARKEND;     
  2745       
  2746     return TestStepResult();     
  2747     }     
  2748       
  2749 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT