os/security/contentmgmt/referencedrmagent/tcaf/source/Consumerstep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/referencedrmagent/tcaf/source/Consumerstep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2749 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <test/testexecutelog.h>
    1.23 +#include <caf/content.h>
    1.24 +#include <caf/data.h>
    1.25 +#include <caf/attribute.h>
    1.26 +#include "cafserver.h"
    1.27 +#include "bitset.h"
    1.28 +#include "Consumerstep.h"
    1.29 +#include "attributeset.h"
    1.30 +#include "stringattributeset.h"
    1.31 +#include <caf/virtualpath.h>
    1.32 +#include <e32hal.h>
    1.33 +#include <hal.h>
    1.34 +
    1.35 +using namespace ContentAccess;
    1.36 +
    1.37 +const TInt KCafTestMaxDataTypeLength = 255;
    1.38 +const TInt KCafTestSecToMS = 1000;
    1.39 +
    1.40 +_LIT(KCDataThreadSemaphore, "CData_Thread_Test");
    1.41 +
    1.42 +/* 
    1.43 + * Step1 compares an agent 'size' call with that obtained by RFile
    1.44 + *
    1.45 + */
    1.46 +
    1.47 +CCAFSizeStep::~CCAFSizeStep()
    1.48 +	{
    1.49 +	}
    1.50 +
    1.51 +CCAFSizeStep::CCAFSizeStep(CCAFServer& aParent)
    1.52 +: iParent(aParent)
    1.53 +	{
    1.54 +	SetTestStepName(KCAFSizeStep);
    1.55 +	}
    1.56 +
    1.57 +TVerdict CCAFSizeStep::doTestStepL()
    1.58 +	{
    1.59 +	__UHEAP_MARK;
    1.60 +	
    1.61 +	SetTestStepResult(EInconclusive);
    1.62 +	
    1.63 +	INFO_PRINTF1(_L("Basic Open Content Test"));
    1.64 +	
    1.65 +	TPtrC uri1;
    1.66 +	TPtrC uri2;
    1.67 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
    1.68 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
    1.69 +
    1.70 +	INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
    1.71 +	CContent* content = CContent::NewLC(uri1);
    1.72 +	INFO_PRINTF1(_L("Creating CData object from content"));
    1.73 +
    1.74 +	CData* data = content->OpenContentL(EPeek);
    1.75 +	CleanupStack::PushL(data);
    1.76 +
    1.77 +	TInt size = 0;
    1.78 +	data->DataSizeL(size);
    1.79 +	INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %d"),size);
    1.80 +	CleanupStack::PopAndDestroy(data);
    1.81 +	CleanupStack::PopAndDestroy(content);
    1.82 +
    1.83 +	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
    1.84 +	TInt size1 = 0;
    1.85 +	
    1.86 +	TBool withoutIntent;
    1.87 +	if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
    1.88 +		{
    1.89 +		INFO_PRINTF1(_L("With Intent"));
    1.90 +		data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);			
    1.91 +		}
    1.92 +	else
    1.93 +		{
    1.94 +		INFO_PRINTF1(_L("Without Intent"));
    1.95 +		data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
    1.96 +		data->SetProperty(EAgentPropertyAgentUI, 0);
    1.97 +		User::LeaveIfError(data->EvaluateIntent(EPeek));		
    1.98 +		}
    1.99 +	
   1.100 +	CleanupStack::PushL(data);
   1.101 +	data->DataSizeL(size1);
   1.102 +	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
   1.103 +	CleanupStack::PopAndDestroy(data);
   1.104 +
   1.105 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   1.106 +	RFile file;
   1.107 +	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
   1.108 +
   1.109 +	TInt size2;
   1.110 +	file.Size(size2);
   1.111 +	file.Close();
   1.112 +
   1.113 +	INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
   1.114 +
   1.115 +	if(size == size2 && size == size1)
   1.116 +		{
   1.117 +		SetTestStepResult(EPass);
   1.118 +		}
   1.119 +	else
   1.120 +		{
   1.121 +		SetTestStepResult(EFail);
   1.122 +		}
   1.123 +	
   1.124 +	__UHEAP_MARKEND;
   1.125 +	return TestStepResult();
   1.126 +	}
   1.127 +
   1.128 +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   1.129 +/* 
   1.130 + * This is the 64bit version of CCAFSizeStep
   1.131 + */
   1.132 +
   1.133 +CCAFSizeStep64::~CCAFSizeStep64()
   1.134 +	{
   1.135 +	}
   1.136 +
   1.137 +CCAFSizeStep64::CCAFSizeStep64(CCAFServer& aParent)
   1.138 +: iParent(aParent)
   1.139 +	{
   1.140 +	SetTestStepName(KCAFSizeStep);
   1.141 +	}
   1.142 +
   1.143 +TVerdict CCAFSizeStep64::doTestStepL()
   1.144 +	{
   1.145 +	__UHEAP_MARK;
   1.146 +	
   1.147 +	SetTestStepResult(EInconclusive);
   1.148 +	
   1.149 +	INFO_PRINTF1(_L("Basic Open Content Test"));
   1.150 +	
   1.151 +	TPtrC uri1;
   1.152 +	TPtrC uri2;
   1.153 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   1.154 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   1.155 +
   1.156 +	INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
   1.157 +	CContent* content = CContent::NewLC(uri1);
   1.158 +	INFO_PRINTF1(_L("Creating CData object from content"));
   1.159 +
   1.160 +	CData* data = content->OpenContentL(EPeek);
   1.161 +	CleanupStack::PushL(data);
   1.162 +
   1.163 +	TInt64 size = 0;
   1.164 +	data->DataSize64L(size);
   1.165 +	INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %Ld"),size);
   1.166 +	CleanupStack::PopAndDestroy(data);
   1.167 +	CleanupStack::PopAndDestroy(content);
   1.168 +
   1.169 +	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
   1.170 +	TInt64 size1 = 0;
   1.171 +	
   1.172 +	TBool withoutIntent;
   1.173 +	if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
   1.174 +		{
   1.175 +		INFO_PRINTF1(_L("With Intent"));
   1.176 +		data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);			
   1.177 +		}
   1.178 +	else
   1.179 +		{
   1.180 +		INFO_PRINTF1(_L("Without Intent"));
   1.181 +		data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
   1.182 +		data->SetProperty(EAgentPropertyAgentUI, 0);
   1.183 +		User::LeaveIfError(data->EvaluateIntent(EPeek));		
   1.184 +		}
   1.185 +	
   1.186 +	CleanupStack::PushL(data);
   1.187 +	data->DataSize64L(size1);
   1.188 +	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %Ld"),size1);
   1.189 +	CleanupStack::PopAndDestroy(data);
   1.190 +
   1.191 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   1.192 +	RFile64 file;
   1.193 +	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
   1.194 +
   1.195 +	TInt64 size2;
   1.196 +	file.Size(size2);
   1.197 +	file.Close();
   1.198 +
   1.199 +	INFO_PRINTF2(_L("Size of content from f32: %Ld"),size2);
   1.200 +
   1.201 +	if(size == size2 && size == size1)
   1.202 +		{
   1.203 +		SetTestStepResult(EPass);
   1.204 +		}
   1.205 +	else
   1.206 +		{
   1.207 +		SetTestStepResult(EFail);
   1.208 +		}
   1.209 +	
   1.210 +	__UHEAP_MARKEND;
   1.211 +	return TestStepResult();
   1.212 +	}
   1.213 +#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   1.214 +
   1.215 +/*
   1.216 + * This step compares a seek and read using CAF with that using RFile
   1.217 + *
   1.218 + */
   1.219 +
   1.220 +CCAFSeekReadStep::~CCAFSeekReadStep()
   1.221 +	{
   1.222 +	}
   1.223 +
   1.224 +CCAFSeekReadStep::CCAFSeekReadStep(CCAFServer& aParent)
   1.225 +: iParent(aParent)
   1.226 +	{
   1.227 +	SetTestStepName(KCAFSeekReadStep);
   1.228 +	}
   1.229 +
   1.230 +void CCAFSeekReadStep::StandardCheckReturnValue(TInt aReturnValue)
   1.231 +	{
   1.232 +	if (aReturnValue != KErrNone)
   1.233 +		{
   1.234 +		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
   1.235 +		SetTestStepResult(EFail);
   1.236 +		}	
   1.237 +	}
   1.238 +TVerdict CCAFSeekReadStep::doTestStepL()
   1.239 +	{
   1.240 +	SetTestStepResult(EInconclusive);
   1.241 +	
   1.242 +	TBuf8<2> buf1;
   1.243 +	TBuf8<2> buf2;
   1.244 +	TRequestStatus status;
   1.245 +
   1.246 +	__UHEAP_MARK;
   1.247 +	INFO_PRINTF1(_L("Basic Open Content Test"));
   1.248 +	
   1.249 +	TPtrC uri1;
   1.250 +	TPtrC uri2;
   1.251 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   1.252 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   1.253 +
   1.254 +	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
   1.255 +	CContent* content = CContent::NewLC(uri1);
   1.256 +
   1.257 +	INFO_PRINTF1(_L("Creating data object from content"));
   1.258 +	CData* data = content->OpenContentL(EPeek);
   1.259 +	
   1.260 +	// don't need CContent any more
   1.261 +	CleanupStack::PopAndDestroy(content);
   1.262 +	CleanupStack::PushL(data);
   1.263 +
   1.264 +	// Now, open the same file using RFile
   1.265 +	RFile file;
   1.266 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   1.267 +	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
   1.268 +	CleanupClosePushL(file);
   1.269 +
   1.270 +	TInt size = 0;
   1.271 +	file.Size(size);
   1.272 +	INFO_PRINTF2(_L("Size of content from f32: %d"),size);
   1.273 +	
   1.274 +	// Seek and read from start using both CAF and RFile
   1.275 +	TInt pos1 = size/4;
   1.276 +	data->Seek(ESeekStart, pos1);
   1.277 +	TInt pos2 = size/4;
   1.278 +	file.Seek(ESeekStart, pos2);
   1.279 +	data->Read(buf1);
   1.280 +	file.Read(buf2);
   1.281 +	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
   1.282 +	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
   1.283 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
   1.284 +		{
   1.285 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.286 +		SetTestStepResult(EFail);
   1.287 +		}
   1.288 +
   1.289 +	// set the location within the file then retrieve the current location within the file
   1.290 +	pos1=0;
   1.291 +	pos2=0;
   1.292 +	data->Seek(ESeekCurrent, pos1);
   1.293 +	file.Seek(ESeekCurrent, pos2);
   1.294 +
   1.295 +	INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
   1.296 +	INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
   1.297 +
   1.298 +	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
   1.299 +		{
   1.300 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.301 +		SetTestStepResult(EFail);
   1.302 +		}
   1.303 +
   1.304 +	// Seek and read from current using both CAF and RFile
   1.305 +	pos1 = size/4;
   1.306 +	data->Seek(ESeekCurrent, pos1);
   1.307 +	pos2 = size/4;
   1.308 +	file.Seek(ESeekCurrent, pos2);
   1.309 +	data->Read(buf1);
   1.310 +	file.Read(buf2);
   1.311 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
   1.312 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
   1.313 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
   1.314 +		{
   1.315 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.316 +		SetTestStepResult(EFail);
   1.317 +		}
   1.318 +
   1.319 +	// Seek and read from end using both CAF and RFile
   1.320 +	pos1 = -size/4;
   1.321 +	data->Seek(ESeekEnd, pos1);
   1.322 +	pos2 = -size/4;
   1.323 +	file.Seek(ESeekEnd, pos2);
   1.324 +	data->Read(buf1);
   1.325 +	file.Read(buf2);
   1.326 +	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
   1.327 +	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
   1.328 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
   1.329 +		{
   1.330 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.331 +		SetTestStepResult(EFail);
   1.332 +		}
   1.333 +
   1.334 +	// Test other overloaded forms of CData::Read
   1.335 +
   1.336 +	// Read only 1 byte using both CAF and RFile
   1.337 +	pos1 = size/4;
   1.338 +	data->Seek(ESeekStart, pos1);
   1.339 +	pos2 = size/4;
   1.340 +	file.Seek(ESeekStart, pos2);
   1.341 +	data->Read(buf1,1);
   1.342 +	file.Read(buf2,1);
   1.343 +	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
   1.344 +	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
   1.345 +	
   1.346 +	pos1=0;
   1.347 +	pos2=0;
   1.348 +	data->Seek(ESeekCurrent, pos1);
   1.349 +	file.Seek(ESeekCurrent,pos2);
   1.350 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.351 +		{
   1.352 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.353 +		SetTestStepResult(EFail);
   1.354 +		}
   1.355 +
   1.356 +	// Read asynchronously using both CAF and RFile
   1.357 +	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
   1.358 +	pos1 = size/4;
   1.359 +	data->Seek(ESeekStart, pos1);
   1.360 +	pos2 = size/4;
   1.361 +	file.Seek(ESeekStart, pos2);
   1.362 +	status = KRequestPending;
   1.363 +	data->Read(buf1,status);
   1.364 +	User::WaitForRequest(status);
   1.365 +	status = KRequestPending;
   1.366 +	file.Read(buf2,status);
   1.367 +	User::WaitForRequest(status);
   1.368 +	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
   1.369 +	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
   1.370 +
   1.371 +	pos1=0;
   1.372 +	pos2=0;
   1.373 +	data->Seek(ESeekCurrent, pos1);
   1.374 +	file.Seek(ESeekCurrent,pos2);
   1.375 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.376 +		{
   1.377 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.378 +		SetTestStepResult(EFail);
   1.379 +		}
   1.380 +
   1.381 +	// Read only 1 byte asynchronously using both CAF and RFile
   1.382 +	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
   1.383 +	pos1 = size/4;
   1.384 +	data->Seek(ESeekStart, pos1);
   1.385 +	pos2 = size/4;
   1.386 +	file.Seek(ESeekStart, pos2);
   1.387 +	status = KRequestPending;
   1.388 +	data->Read(buf1,1,status);
   1.389 +	User::WaitForRequest(status);
   1.390 +	status = KRequestPending;
   1.391 +	file.Read(buf2,1, status);
   1.392 +	User::WaitForRequest(status);
   1.393 +	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.394 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.395 +
   1.396 +	pos1=0;
   1.397 +	pos2=0;
   1.398 +	data->Seek(ESeekCurrent, pos1);
   1.399 +	file.Seek(ESeekCurrent,pos2);
   1.400 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.401 +		{
   1.402 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.403 +		SetTestStepResult(EFail);
   1.404 +		}
   1.405 +
   1.406 +	// read past EOF
   1.407 +	pos1 = size+1;
   1.408 +	pos2 = size+1;
   1.409 +	data->Seek(ESeekStart, pos1);
   1.410 +	file.Seek(ESeekStart, pos2);
   1.411 +	data->Read(buf1);
   1.412 +	file.Read(buf2);
   1.413 +
   1.414 +	if(buf1.Length() != 0 || buf1.Length() != 0)
   1.415 +		{
   1.416 +		INFO_PRINTF1(_L("ERROR data read past EOF"));
   1.417 +		SetTestStepResult(EFail);
   1.418 +		}
   1.419 +
   1.420 +	
   1.421 +	// Read asynchronously supplying an offset using both CAF and RFile
   1.422 +	TInt err;
   1.423 +	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
   1.424 +	pos1 = size/4;
   1.425 +	pos2 = size/4;
   1.426 +	status = KRequestPending;
   1.427 +	err = data->Read(pos1,buf1,1,status);
   1.428 +	
   1.429 +	StandardCheckReturnValue(err);
   1.430 +	
   1.431 +	User::WaitForRequest(status);
   1.432 +	status = KRequestPending;
   1.433 +	file.Read(pos2, buf2,1, status);
   1.434 +	User::WaitForRequest(status);
   1.435 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.436 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.437 +
   1.438 +	pos1=0;
   1.439 +	pos2=0;
   1.440 +	data->Seek(ESeekCurrent, pos1);
   1.441 +	file.Seek(ESeekCurrent,pos2);
   1.442 +	if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.443 +		{
   1.444 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.445 +		SetTestStepResult(EFail);
   1.446 +		}
   1.447 +		
   1.448 +	// Check asynchronous cancellation
   1.449 +	err = 0;
   1.450 +	INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));	
   1.451 +	pos1 = size/4;
   1.452 +	pos2 = size/4;
   1.453 +	status = KRequestPending;
   1.454 +	err = data->Read(pos1,buf1,1,status);
   1.455 +	StandardCheckReturnValue(err);
   1.456 +	data->ReadCancel(status);
   1.457 +	User::WaitForRequest(status);
   1.458 +	TRequestStatus status2(KRequestPending);
   1.459 +	file.Read(pos2, buf2,1, status2);	
   1.460 +	file.ReadCancel();
   1.461 +	User::WaitForRequest(status2);	
   1.462 +	INFO_PRINTF3(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
   1.463 +	INFO_PRINTF3(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());	
   1.464 +	if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.465 +		{
   1.466 +		INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
   1.467 +		SetTestStepResult(EFail);
   1.468 +		}
   1.469 +		
   1.470 +	// read past EOF
   1.471 +	pos1 = size+1;
   1.472 +	pos2 = size+1;
   1.473 +	status = KRequestPending;
   1.474 +	data->Read(pos1,buf1,1,status);
   1.475 +	StandardCheckReturnValue(err);
   1.476 +	User::WaitForRequest(status);
   1.477 +	status = KRequestPending;
   1.478 +	file.Read(pos2,buf2,1,status);
   1.479 +	User::WaitForRequest(status);
   1.480 +	
   1.481 +	if(buf1.Length() != 0 || buf1.Length() != 0)
   1.482 +		{
   1.483 +		INFO_PRINTF1(_L("ERROR data read past EOF"));
   1.484 +		SetTestStepResult(EFail);
   1.485 +		}
   1.486 +		
   1.487 +	// read over the length of the buffer
   1.488 +	INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
   1.489 +	pos1 = size/4;
   1.490 +	pos2 = size/4;
   1.491 +	status = KRequestPending;
   1.492 +	err = data->Read(pos1,buf1,5,status);
   1.493 +	StandardCheckReturnValue(err);
   1.494 +	User::WaitForRequest(status);
   1.495 +	if(status.Int()!=KErrOverflow)
   1.496 +		{
   1.497 +		INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
   1.498 +		SetTestStepResult(EFail);
   1.499 +		}
   1.500 +	status = KRequestPending;
   1.501 +	file.Read(pos2, buf2,5, status);
   1.502 +	User::WaitForRequest(status);
   1.503 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.504 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.505 +
   1.506 +	if (buf1 !=buf2 ||  buf1.Length() != buf2.Length())
   1.507 +		{
   1.508 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.509 +		SetTestStepResult(EFail);
   1.510 +		}
   1.511 +	// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
   1.512 +	INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
   1.513 +	pos1 = -1;
   1.514 +	status = KRequestPending;
   1.515 +	err = data->Read(pos1,buf1,5,status);
   1.516 +	if(err!=KErrArgument)
   1.517 +		{
   1.518 +		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
   1.519 +		SetTestStepResult(EFail);
   1.520 +		}
   1.521 +		
   1.522 +	// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
   1.523 +	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
   1.524 +	TBuf8<256> buf3;
   1.525 +	TBuf8<256> buf4;
   1.526 +	pos1 = 0;
   1.527 +	pos2 = 0;
   1.528 +	status = KRequestPending;
   1.529 +	err = data->Read(pos1,buf3,size+1,status);
   1.530 +	StandardCheckReturnValue(err);
   1.531 +	User::WaitForRequest(status);
   1.532 +	status = KRequestPending;
   1.533 +	file.Read(pos2, buf4,size+1, status);
   1.534 +	User::WaitForRequest(status);
   1.535 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   1.536 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   1.537 +
   1.538 +	pos1=0;
   1.539 +	pos2=0;
   1.540 +	data->Seek(ESeekCurrent, pos1);
   1.541 +	file.Seek(ESeekCurrent,pos2);
   1.542 +	if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size || 
   1.543 +									pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
   1.544 +		{
   1.545 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.546 +		SetTestStepResult(EFail);
   1.547 +		}
   1.548 +
   1.549 +	// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
   1.550 +	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
   1.551 +	pos1 = size/4;
   1.552 +	pos2 = size/4;
   1.553 +	status = KRequestPending;
   1.554 +	err = data->Read(pos1,buf3,size+1,status);
   1.555 +	StandardCheckReturnValue(err);
   1.556 +	User::WaitForRequest(status);
   1.557 +	status = KRequestPending;
   1.558 +	file.Read(pos2, buf4,size+1, status);
   1.559 +	User::WaitForRequest(status);
   1.560 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   1.561 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   1.562 +
   1.563 +	pos1=0;
   1.564 +	pos2=0;
   1.565 +	data->Seek(ESeekCurrent, pos1);
   1.566 +	file.Seek(ESeekCurrent,pos2);
   1.567 +	if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
   1.568 +		{
   1.569 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.570 +		SetTestStepResult(EFail);
   1.571 +		}	
   1.572 +		
   1.573 +	CleanupStack::PopAndDestroy(2, data);
   1.574 +
   1.575 +	__UHEAP_MARKEND;
   1.576 +
   1.577 +	if (TestStepResult() != EFail)
   1.578 +		{
   1.579 +		SetTestStepResult(EPass);
   1.580 +		}
   1.581 +
   1.582 +	return TestStepResult();
   1.583 +	}
   1.584 +
   1.585 +
   1.586 +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   1.587 +/*
   1.588 + * This is the 64bit version of CCAFSeekReadStep. 
   1.589 +*/
   1.590 +
   1.591 +CCAFSeekReadStep64::~CCAFSeekReadStep64()
   1.592 +	{
   1.593 +	}
   1.594 +
   1.595 +CCAFSeekReadStep64::CCAFSeekReadStep64(CCAFServer& aParent)
   1.596 +: iParent(aParent)
   1.597 +	{
   1.598 +	SetTestStepName(KCAFSeekReadStep);
   1.599 +	}
   1.600 +
   1.601 +void CCAFSeekReadStep64::StandardCheckReturnValue(TInt aReturnValue)
   1.602 +	{
   1.603 +	if (aReturnValue != KErrNone)
   1.604 +		{
   1.605 +		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
   1.606 +		SetTestStepResult(EFail);
   1.607 +		}	
   1.608 +	}
   1.609 +TVerdict CCAFSeekReadStep64::doTestStepL()
   1.610 +	{
   1.611 +	SetTestStepResult(EInconclusive);
   1.612 +	
   1.613 +	TBuf8<2> buf1;
   1.614 +	TBuf8<2> buf2;
   1.615 +	TRequestStatus status;
   1.616 +
   1.617 +	__UHEAP_MARK;
   1.618 +	INFO_PRINTF1(_L("Basic Open Content Test"));
   1.619 +	
   1.620 +	TPtrC uri1;
   1.621 +	TPtrC uri2;
   1.622 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
   1.623 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
   1.624 +
   1.625 +	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
   1.626 +	CContent* content = CContent::NewLC(uri1);
   1.627 +
   1.628 +	INFO_PRINTF1(_L("Creating data object from content"));
   1.629 +	CData* data = content->OpenContentL(EPeek);
   1.630 +	
   1.631 +	// don't need CContent any more
   1.632 +	CleanupStack::PopAndDestroy(content);
   1.633 +	CleanupStack::PushL(data);
   1.634 +
   1.635 +	// Now, open the same file using RFile
   1.636 +	RFile64 file;
   1.637 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
   1.638 +	User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
   1.639 +	CleanupClosePushL(file);
   1.640 +
   1.641 +	TInt64 size = 0;
   1.642 +	file.Size(size);
   1.643 +	INFO_PRINTF2(_L("Size of content from f32: %Ld"),size);
   1.644 +	
   1.645 +	// Seek and read from start using both CAF and RFile
   1.646 +	TInt64 pos1 = size/4;
   1.647 +	data->Seek64(ESeekStart, pos1);
   1.648 +	//pos2 needs to be modified to TInt64 when file server supports 64bit
   1.649 +	TInt64 pos2 = size/4;
   1.650 +	file.Seek(ESeekStart, pos2);
   1.651 +	data->Read(buf1);
   1.652 +	file.Read(buf2);
   1.653 +	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %Ld"), pos1);
   1.654 +	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %Ld"), pos2);
   1.655 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
   1.656 +		{
   1.657 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.658 +		SetTestStepResult(EFail);
   1.659 +		}
   1.660 +
   1.661 +	// set the location within the file then retrieve the current location within the file
   1.662 +	pos1=0;
   1.663 +	pos2=0;
   1.664 +	data->Seek64(ESeekCurrent, pos1);
   1.665 +	file.Seek(ESeekCurrent, pos2);
   1.666 +
   1.667 +	INFO_PRINTF2(_L("Current position using CData: %Ld"), pos1);
   1.668 +	INFO_PRINTF2(_L("Current position using RFile: %Ld"), pos2);
   1.669 +
   1.670 +	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
   1.671 +		{
   1.672 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.673 +		SetTestStepResult(EFail);
   1.674 +		}
   1.675 +
   1.676 +	// Seek and read from current using both CAF and RFile
   1.677 +	pos1 = size/4;
   1.678 +	data->Seek64(ESeekCurrent, pos1);
   1.679 +	pos2 = size/4;
   1.680 +	file.Seek(ESeekCurrent, pos2);
   1.681 +	data->Read(buf1);
   1.682 +	file.Read(buf2);
   1.683 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %Ld"), pos1);
   1.684 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %Ld"), pos2);
   1.685 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
   1.686 +		{
   1.687 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.688 +		SetTestStepResult(EFail);
   1.689 +		}
   1.690 +
   1.691 +	// Seek and read from end using both CAF and RFile
   1.692 +	pos1 = -size/4;
   1.693 +	data->Seek64(ESeekEnd, pos1);
   1.694 +	pos2 = -size/4;
   1.695 +	file.Seek(ESeekEnd, pos2);
   1.696 +	data->Read(buf1);
   1.697 +	file.Read(buf2);
   1.698 +	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %Ld"), pos1);
   1.699 +	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %Ld"), pos2);
   1.700 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
   1.701 +		{
   1.702 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.703 +		SetTestStepResult(EFail);
   1.704 +		}
   1.705 +
   1.706 +	// Test other overloaded forms of CData::Read
   1.707 +
   1.708 +	// Read only 1 byte using both CAF and RFile
   1.709 +	pos1 = size/4;
   1.710 +	data->Seek64(ESeekStart, pos1);
   1.711 +	pos2 = size/4;
   1.712 +	file.Seek(ESeekStart, pos2);
   1.713 +	data->Read(buf1,1);
   1.714 +	file.Read(buf2,1);
   1.715 +	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
   1.716 +	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
   1.717 +	
   1.718 +	pos1=0;
   1.719 +	pos2=0;
   1.720 +	data->Seek64(ESeekCurrent, pos1);
   1.721 +	file.Seek(ESeekCurrent,pos2);
   1.722 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.723 +		{
   1.724 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.725 +		SetTestStepResult(EFail);
   1.726 +		}
   1.727 +
   1.728 +	// Read asynchronously using both CAF and RFile
   1.729 +	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
   1.730 +	pos1 = size/4;
   1.731 +	data->Seek64(ESeekStart, pos1);
   1.732 +	pos2 = size/4;
   1.733 +	file.Seek(ESeekStart, pos2);
   1.734 +	status = KRequestPending;
   1.735 +	data->Read(buf1,status);
   1.736 +	User::WaitForRequest(status);
   1.737 +	status = KRequestPending;
   1.738 +	file.Read(buf2,status);
   1.739 +	User::WaitForRequest(status);
   1.740 +	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
   1.741 +	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
   1.742 +
   1.743 +	pos1=0;
   1.744 +	pos2=0;
   1.745 +	data->Seek64(ESeekCurrent, pos1);
   1.746 +	file.Seek(ESeekCurrent,pos2);
   1.747 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.748 +		{
   1.749 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.750 +		SetTestStepResult(EFail);
   1.751 +		}
   1.752 +
   1.753 +	// Read only 1 byte asynchronously using both CAF and RFile
   1.754 +	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
   1.755 +	pos1 = size/4;
   1.756 +	data->Seek64(ESeekStart, pos1);
   1.757 +	pos2 = size/4;
   1.758 +	file.Seek(ESeekStart, pos2);
   1.759 +	status = KRequestPending;
   1.760 +	data->Read(buf1,1,status);
   1.761 +	User::WaitForRequest(status);
   1.762 +	status = KRequestPending;
   1.763 +	file.Read(buf2,1, status);
   1.764 +	User::WaitForRequest(status);
   1.765 +	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.766 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.767 +
   1.768 +	pos1=0;
   1.769 +	pos2=0;
   1.770 +	data->Seek64(ESeekCurrent, pos1);
   1.771 +	file.Seek(ESeekCurrent,pos2);
   1.772 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.773 +		{
   1.774 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.775 +		SetTestStepResult(EFail);
   1.776 +		}
   1.777 +
   1.778 +	// read past EOF
   1.779 +	pos1 = size+1;
   1.780 +	pos2 = size+1;
   1.781 +	data->Seek64(ESeekStart, pos1);
   1.782 +	file.Seek(ESeekStart, pos2);
   1.783 +	data->Read(buf1);
   1.784 +	file.Read(buf2);
   1.785 +
   1.786 +	if(buf1.Length() != 0 || buf1.Length() != 0)
   1.787 +		{
   1.788 +		INFO_PRINTF1(_L("ERROR data read past EOF"));
   1.789 +		SetTestStepResult(EFail);
   1.790 +		}
   1.791 +
   1.792 +	
   1.793 +	// Read asynchronously supplying an offset using both CAF and RFile
   1.794 +	TInt err;
   1.795 +	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
   1.796 +	pos1 = size/4;
   1.797 +	pos2 = size/4;
   1.798 +	status = KRequestPending;
   1.799 +	err = data->Read(pos1,buf1,1,status);
   1.800 +	
   1.801 +	StandardCheckReturnValue(err);
   1.802 +	
   1.803 +	User::WaitForRequest(status);
   1.804 +	status = KRequestPending;
   1.805 +	file.Read(pos2, buf2,1, status);
   1.806 +	User::WaitForRequest(status);
   1.807 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.808 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.809 +
   1.810 +	pos1=0;
   1.811 +	pos2=0;
   1.812 +	data->Seek64(ESeekCurrent, pos1);
   1.813 +	file.Seek(ESeekCurrent,pos2);
   1.814 +	if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.815 +		{
   1.816 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.817 +		SetTestStepResult(EFail);
   1.818 +		}
   1.819 +		
   1.820 +	// Check asynchronous cancellation
   1.821 +	err = 0;
   1.822 +	INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));	
   1.823 +	pos1 = size/4;
   1.824 +	pos2 = size/4;
   1.825 +	status = KRequestPending;
   1.826 +	err = data->Read(pos1,buf1,1,status);
   1.827 +	StandardCheckReturnValue(err);
   1.828 +	data->ReadCancel(status);
   1.829 +	User::WaitForRequest(status);
   1.830 +	TRequestStatus status2(KRequestPending);
   1.831 +	file.Read(pos2, buf2,1, status2);	
   1.832 +	file.ReadCancel();
   1.833 +	User::WaitForRequest(status2);	
   1.834 +	INFO_PRINTF3(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
   1.835 +	INFO_PRINTF3(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());	
   1.836 +	if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
   1.837 +		{
   1.838 +		INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
   1.839 +		SetTestStepResult(EFail);
   1.840 +		}
   1.841 +		
   1.842 +	// read past EOF
   1.843 +	pos1 = size+1;
   1.844 +	pos2 = size+1;
   1.845 +	status = KRequestPending;
   1.846 +	data->Read(pos1,buf1,1,status);
   1.847 +	StandardCheckReturnValue(err);
   1.848 +	User::WaitForRequest(status);
   1.849 +	status = KRequestPending;
   1.850 +	file.Read(pos2,buf2,1,status);
   1.851 +	User::WaitForRequest(status);
   1.852 +	
   1.853 +	if(buf1.Length() != 0 || buf1.Length() != 0)
   1.854 +		{
   1.855 +		INFO_PRINTF1(_L("ERROR data read past EOF"));
   1.856 +		SetTestStepResult(EFail);
   1.857 +		}
   1.858 +		
   1.859 +	// read over the length of the buffer
   1.860 +	INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
   1.861 +	pos1 = size/4;
   1.862 +	pos2 = size/4;
   1.863 +	status = KRequestPending;
   1.864 +	err = data->Read(pos1,buf1,5,status);
   1.865 +	StandardCheckReturnValue(err);
   1.866 +	User::WaitForRequest(status);
   1.867 +	if(status.Int()!=KErrOverflow)
   1.868 +		{
   1.869 +		INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
   1.870 +		SetTestStepResult(EFail);
   1.871 +		}
   1.872 +	status = KRequestPending;
   1.873 +	file.Read(pos2, buf2,5, status);
   1.874 +	User::WaitForRequest(status);
   1.875 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
   1.876 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
   1.877 +
   1.878 +	if (buf1 !=buf2 ||  buf1.Length() != buf2.Length())
   1.879 +		{
   1.880 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.881 +		SetTestStepResult(EFail);
   1.882 +		}
   1.883 +	// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
   1.884 +	INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
   1.885 +	pos1 = -1;
   1.886 +	status = KRequestPending;
   1.887 +	err = data->Read(pos1,buf1,5,status);
   1.888 +	if(err!=KErrArgument)
   1.889 +		{
   1.890 +		INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
   1.891 +		SetTestStepResult(EFail);
   1.892 +		}
   1.893 +		
   1.894 +	// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
   1.895 +	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
   1.896 +	TBuf8<256> buf3;
   1.897 +	TBuf8<256> buf4;
   1.898 +	pos1 = 0;
   1.899 +	pos2 = 0;
   1.900 +	status = KRequestPending;
   1.901 +	err = data->Read(pos1,buf3,size+1,status);
   1.902 +	StandardCheckReturnValue(err);
   1.903 +	User::WaitForRequest(status);
   1.904 +	status = KRequestPending;
   1.905 +	file.Read(pos2, buf4,size+1, status);
   1.906 +	User::WaitForRequest(status);
   1.907 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   1.908 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   1.909 +
   1.910 +	pos1=0;
   1.911 +	pos2=0;
   1.912 +	data->Seek64(ESeekCurrent, pos1);
   1.913 +	file.Seek(ESeekCurrent,pos2);
   1.914 +	if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size || 
   1.915 +									pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
   1.916 +		{
   1.917 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.918 +		SetTestStepResult(EFail);
   1.919 +		}
   1.920 +
   1.921 +	// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
   1.922 +	INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
   1.923 +	pos1 = size/4;
   1.924 +	pos2 = size/4;
   1.925 +	status = KRequestPending;
   1.926 +	err = data->Read(pos1,buf3,size+1,status);
   1.927 +	StandardCheckReturnValue(err);
   1.928 +	User::WaitForRequest(status);
   1.929 +	status = KRequestPending;
   1.930 +	file.Read(pos2, buf4,size+1, status);
   1.931 +	User::WaitForRequest(status);
   1.932 +	INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
   1.933 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
   1.934 +
   1.935 +	pos1=0;
   1.936 +	pos2=0;
   1.937 +	data->Seek64(ESeekCurrent, pos1);
   1.938 +	file.Seek(ESeekCurrent,pos2);
   1.939 +	if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
   1.940 +		{
   1.941 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
   1.942 +		SetTestStepResult(EFail);
   1.943 +		}	
   1.944 +	
   1.945 +	CleanupStack::PopAndDestroy(2, data);
   1.946 +	
   1.947 +	__UHEAP_MARKEND;
   1.948 +	
   1.949 +	if (TestStepResult() != EFail)
   1.950 +		{
   1.951 +		SetTestStepResult(EPass);
   1.952 +		}
   1.953 +
   1.954 +	return TestStepResult();
   1.955 +	}
   1.956 +
   1.957 +#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   1.958 +/*
   1.959 + * This step retrieves the attributes of a file using the CAF framework
   1.960 + *
   1.961 + */
   1.962 +
   1.963 +CCAFAttributesStep::~CCAFAttributesStep()
   1.964 +	{
   1.965 +	}
   1.966 +
   1.967 +CCAFAttributesStep::CCAFAttributesStep(CCAFServer& aParent) : iParent(aParent)
   1.968 +	{
   1.969 +	SetTestStepName(KCAFAttributesStep);
   1.970 +	}
   1.971 +
   1.972 +
   1.973 +TVerdict CCAFAttributesStep::doTestStepL()
   1.974 +	{
   1.975 +	CContent *content;
   1.976 +	CAttribute *attrs; 
   1.977 +	TPtrC fileName;
   1.978 +	TBool Protected;
   1.979 +	TBool Forwardable;
   1.980 +	
   1.981 +	
   1.982 +	TBool Value;
   1.983 +
   1.984 +	SetTestStepResult(EFail);
   1.985 +
   1.986 +	GetStringFromConfig(ConfigSection(),_L("filename"),fileName);
   1.987 +	GetBoolFromConfig(ConfigSection(),_L("Protected"),Protected);
   1.988 +	GetBoolFromConfig(ConfigSection(),_L("Forwardable"),Forwardable);
   1.989 +
   1.990 +
   1.991 +	INFO_PRINTF2(_L("Check attributes of file: %S"), &fileName);	
   1.992 +
   1.993 +	__UHEAP_MARK;
   1.994 +
   1.995 +	// Open a file and retrieve the attributes
   1.996 +	content = CContent::NewLC(fileName);
   1.997 +	attrs = content->NewAttributeL(ETrue);
   1.998 +	CleanupStack::PushL(attrs);
   1.999 +
  1.1000 +	// Assume all the attributes are what we expect them to be
  1.1001 +	SetTestStepResult(EPass);
  1.1002 +
  1.1003 +	Value = attrs->ResponseSet().IsSet(EIsProtected);
  1.1004 +	if(Value != Protected)
  1.1005 +		{
  1.1006 +		SetTestStepResult(EFail);
  1.1007 +		Protected ? INFO_PRINTF1(_L("File is Protected")) : INFO_PRINTF1(_L("File is not Protected"));
  1.1008 +		}
  1.1009 +
  1.1010 +	Value = attrs->ResponseSet().IsSet(EIsForwardable);
  1.1011 +	if(Value != Forwardable)
  1.1012 +		{
  1.1013 +		SetTestStepResult(EFail);
  1.1014 +		Forwardable ? INFO_PRINTF1(_L("File is Forwardable")) : INFO_PRINTF1(_L("File is not Forwardable"));
  1.1015 +		}
  1.1016 +
  1.1017 +	CleanupStack::PopAndDestroy(2, content); 
  1.1018 +
  1.1019 +	__UHEAP_MARKEND;
  1.1020 +	return TestStepResult();
  1.1021 +	}
  1.1022 +
  1.1023 +
  1.1024 +/*
  1.1025 + * This step retrieves the string attributes of a file using the CAF framework
  1.1026 + *
  1.1027 + */
  1.1028 +
  1.1029 +CCAFStringAttributesStep::~CCAFStringAttributesStep()
  1.1030 +	{
  1.1031 +	}
  1.1032 +
  1.1033 +CCAFStringAttributesStep::CCAFStringAttributesStep(CCAFServer& aParent) : iParent(aParent)
  1.1034 +	{
  1.1035 +	SetTestStepName(KCAFStringAttributesStep);
  1.1036 +	}
  1.1037 +
  1.1038 +
  1.1039 +TVerdict CCAFStringAttributesStep::doTestStepL()
  1.1040 +	{
  1.1041 +	TInt expectedResult;
  1.1042 +	TInt attribute;
  1.1043 +	TPtrC expectedValue;
  1.1044 +	TBuf <256> value; //this will be used to test KErrOverFlow when transactionid is 257char long.
  1.1045 +	TInt result = KErrNone;
  1.1046 +	TPtrC uri;
  1.1047 +	TPtrC uniqueId;
  1.1048 +
  1.1049 +	SetTestStepResult(EPass);
  1.1050 +
  1.1051 +	GetIntFromConfig(ConfigSection(),_L("stringattribute"),attribute);
  1.1052 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.1053 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1.1054 +	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
  1.1055 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
  1.1056 +
  1.1057 +	__UHEAP_MARK;
  1.1058 +	CContent *content = CContent::NewLC(uri);
  1.1059 +	CData *data = content->OpenContentL(EPeek, uniqueId);
  1.1060 +	result = data->GetStringAttribute(attribute, value);
  1.1061 +	delete data;
  1.1062 +	if(result != expectedResult)
  1.1063 +		{
  1.1064 +		SetTestStepResult(EFail);
  1.1065 +		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
  1.1066 +		}
  1.1067 +	if(value != expectedValue)
  1.1068 +		{
  1.1069 +		SetTestStepResult(EFail);
  1.1070 +		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
  1.1071 +		}
  1.1072 +
  1.1073 +	CleanupStack::PopAndDestroy(content);		
  1.1074 +    		
  1.1075 +	__UHEAP_MARKEND;
  1.1076 +	return TestStepResult();
  1.1077 +
  1.1078 +	}
  1.1079 +
  1.1080 +
  1.1081 +
  1.1082 +
  1.1083 +/* 
  1.1084 + * Step reads from a CData from multiple threads
  1.1085 + *
  1.1086 + */
  1.1087 +
  1.1088 +CCAFMultiThreadCDataStep::~CCAFMultiThreadCDataStep()
  1.1089 +	{
  1.1090 +	}
  1.1091 +
  1.1092 +CCAFMultiThreadCDataStep::CCAFMultiThreadCDataStep(CCAFServer& aParent)
  1.1093 +: iParent(aParent)
  1.1094 +	{
  1.1095 +	SetTestStepName(KCAFMultiThreadCDataStep);
  1.1096 +	}
  1.1097 +
  1.1098 +TVerdict CCAFMultiThreadCDataStep::doTestStepL()
  1.1099 +	{
  1.1100 +	TBuf8<2> buf;
  1.1101 +
  1.1102 +	__UHEAP_MARK;
  1.1103 +	_LIT(KCDataThread,"CData_Thread");
  1.1104 +
  1.1105 +	SetTestStepResult(EInconclusive);
  1.1106 +	
  1.1107 +	INFO_PRINTF1(_L("Multi Thread CData Test"));
  1.1108 +	
  1.1109 +	TPtrC uri;
  1.1110 +	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1.1111 +
  1.1112 +	INFO_PRINTF1(_L("Creating data object from content"));
  1.1113 +	CContent* content = CContent::NewLC(uri);
  1.1114 +	CData* data = content->OpenContentL(EPeek);
  1.1115 +	CleanupStack::PushL(data);
  1.1116 +
  1.1117 +	TInt size, pos;
  1.1118 +
  1.1119 +	// Create a mutex for communication between our thread and the new thread
  1.1120 +	RSemaphore threadSemaphore;
  1.1121 +	threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
  1.1122 +	threadSemaphore.Wait(); 
  1.1123 +
  1.1124 +	// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future 
  1.1125 +	RThread readerThread;
  1.1126 +	User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
  1.1127 +	
  1.1128 +	// request notification of thread completion
  1.1129 +	TRequestStatus stat;
  1.1130 +	readerThread.Logon(stat);
  1.1131 +	readerThread.Resume();	
  1.1132 +	
  1.1133 +	data->DataSizeL(size);
  1.1134 +	pos = size/2;
  1.1135 +	data->Seek(ESeekStart,pos);
  1.1136 +	data->Read(buf);
  1.1137 +
  1.1138 +	threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
  1.1139 +	threadSemaphore.Signal(); // finished with semaphore
  1.1140 +	threadSemaphore.Close(); // so close
  1.1141 +
  1.1142 +	User::WaitForRequest(stat); // wait for thread to finish
  1.1143 +	TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
  1.1144 +	User::LeaveIfError(error);
  1.1145 +	readerThread.Close();  // close the thread
  1.1146 +	
  1.1147 +	CleanupStack::PopAndDestroy(data);
  1.1148 +	CleanupStack::PopAndDestroy(content);
  1.1149 +
  1.1150 +	__UHEAP_MARKEND;
  1.1151 +	
  1.1152 +	SetTestStepResult(EPass);
  1.1153 +	return TestStepResult();
  1.1154 +	}
  1.1155 +
  1.1156 +TInt CCAFMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
  1.1157 +	{
  1.1158 +	TBuf8 <2> buf;
  1.1159 +	CData *data = reinterpret_cast <CData *> (aPtr);
  1.1160 +
  1.1161 +	// create a trap handler
  1.1162 +	CTrapCleanup* cleanup = CTrapCleanup::New();
  1.1163 +
  1.1164 +	RSemaphore threadSemaphore;
  1.1165 +	threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
  1.1166 +
  1.1167 +	data->Read(buf);
  1.1168 +	threadSemaphore.Signal(); // allow original thread to continue
  1.1169 +	threadSemaphore.Close();
  1.1170 +	
  1.1171 +	delete cleanup;
  1.1172 +	return KErrNone;
  1.1173 +	}
  1.1174 +
  1.1175 +
  1.1176 +/* 
  1.1177 + * Obtains the mime type from a CData
  1.1178 + *
  1.1179 + */
  1.1180 +
  1.1181 +CCAFMimeTypeCDataStep::~CCAFMimeTypeCDataStep()
  1.1182 +	{
  1.1183 +	}
  1.1184 +
  1.1185 +CCAFMimeTypeCDataStep::CCAFMimeTypeCDataStep(CCAFServer& aParent)
  1.1186 +: iParent(aParent)
  1.1187 +	{
  1.1188 +	SetTestStepName(KCAFMimeTypeCDataStep);
  1.1189 +	}
  1.1190 +
  1.1191 +TVerdict CCAFMimeTypeCDataStep::doTestStepL()
  1.1192 +	{
  1.1193 +	__UHEAP_MARK;
  1.1194 +
  1.1195 +
  1.1196 +	SetTestStepResult(EFail);
  1.1197 +	
  1.1198 +	INFO_PRINTF1(_L("CData MimeType Test"));
  1.1199 +	
  1.1200 +	TPtrC uri;
  1.1201 +	TPtrC expectedMimeType;
  1.1202 +	TBool mimeTypeKnown=EFalse;
  1.1203 +
  1.1204 +	// Load INI parameters
  1.1205 +	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1.1206 +	GetStringFromConfig(ConfigSection(),_L("ContentMimeType"),expectedMimeType);
  1.1207 +	GetBoolFromConfig(ConfigSection(),_L("Known"),mimeTypeKnown);
  1.1208 +
  1.1209 +	// convert to Des8
  1.1210 +	HBufC8 *expected = ConvertDes16toHBufC8LC(expectedMimeType);
  1.1211 +
  1.1212 +	// Create CContent and CData
  1.1213 +	INFO_PRINTF1(_L("Creating data object from content"));
  1.1214 +	CContent* content = CContent::NewLC(uri);
  1.1215 +	CData* data = content->OpenContentL(EPeek);
  1.1216 +	CleanupStack::PushL(data);
  1.1217 +
  1.1218 +	// Get mime type from CData
  1.1219 +	INFO_PRINTF1(_L("Checking mime type"));
  1.1220 +	HBufC8 *buffer = HBufC8::NewLC(KCafTestMaxDataTypeLength);
  1.1221 +	TPtr8 ptr = buffer->Des();
  1.1222 +	TBool r = data->GetMimeTypeL(ptr);
  1.1223 +
  1.1224 +	// check if result matches expected result
  1.1225 +	if(r == mimeTypeKnown && *buffer == *expected)
  1.1226 +		{
  1.1227 +		SetTestStepResult(EPass);
  1.1228 +		}
  1.1229 +
  1.1230 +	CleanupStack::PopAndDestroy(4,expected);
  1.1231 +	__UHEAP_MARKEND;
  1.1232 +	return TestStepResult();
  1.1233 +	}
  1.1234 +
  1.1235 +	/*
  1.1236 + * This step tests file sharing modes
  1.1237 + *
  1.1238 + */
  1.1239 +
  1.1240 +CCAFShareModeStep::~CCAFShareModeStep()
  1.1241 +	{
  1.1242 +	}
  1.1243 +
  1.1244 +CCAFShareModeStep::CCAFShareModeStep(CCAFServer& aParent) : iParent(aParent)
  1.1245 +	{
  1.1246 +	SetTestStepName(KCAFShareModeStep);
  1.1247 +	}
  1.1248 +
  1.1249 +
  1.1250 +TVerdict CCAFShareModeStep::doTestStepL()
  1.1251 +	{
  1.1252 +	TVerdict verdict = EFail;
  1.1253 +	TRAPD(err, verdict = doShareModeStepL());
  1.1254 +	if(err != KErrNone)
  1.1255 +		{
  1.1256 +		if(err != KErrInUse)
  1.1257 +			{
  1.1258 +			User::Leave(err);
  1.1259 +			}
  1.1260 +		else
  1.1261 +			{
  1.1262 +			User::Leave(KErrGeneral);
  1.1263 +			}
  1.1264 +		}
  1.1265 +	return verdict;	
  1.1266 +	}
  1.1267 +
  1.1268 +TVerdict CCAFShareModeStep::doShareModeStepL()	
  1.1269 +	{
  1.1270 +	CAttribute *attr = NULL;
  1.1271 +	RFile file;	
  1.1272 +	RFs fs;
  1.1273 +	TPtrC fileName;
  1.1274 +	TInt err = 0;
  1.1275 +	
  1.1276 +	SetTestStepResult(EPass);
  1.1277 +
  1.1278 +	GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
  1.1279 +
  1.1280 +	// This function works if I step through everything but fails
  1.1281 +	// when run or step over the TRAP
  1.1282 +//	User::Leave(KErrGeneral);
  1.1283 +	
  1.1284 +
  1.1285 +	__UHEAP_MARK;
  1.1286 +	
  1.1287 +	INFO_PRINTF2(_L("Creating Content object for file: %S"), &fileName);	
  1.1288 +	CContent* content= CContent::NewL(fileName);	
  1.1289 +	CData *data = NULL;
  1.1290 +	
  1.1291 +	fs.Connect();
  1.1292 +	CleanupClosePushL(fs);
  1.1293 +
  1.1294 +
  1.1295 +	INFO_PRINTF1(_L("Testing EContentShareReadOnly"));	
  1.1296 +	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOnly | EFileRead | EFileStream));
  1.1297 +	CleanupClosePushL(file);
  1.1298 +	data = content->OpenContentL(EPeek);
  1.1299 +	delete data;
  1.1300 +	data = NULL;
  1.1301 +	data = content->OpenContentL(EPeek, EContentShareReadOnly);
  1.1302 +	delete data;
  1.1303 +	data = NULL;
  1.1304 +	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadWrite));
  1.1305 +	delete data;
  1.1306 +	data = NULL;
  1.1307 +	
  1.1308 +	// We can open read-write because CAF never writes.
  1.1309 +	
  1.1310 +	if(err != KErrNone)
  1.1311 +		{
  1.1312 +		SetTestStepResult(EFail);
  1.1313 +		}
  1.1314 +	
  1.1315 +	// However, exclusive mode should be impossible.
  1.1316 +	
  1.1317 +	TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
  1.1318 +	delete data;
  1.1319 +	data = NULL;
  1.1320 +	if(err != KErrInUse)
  1.1321 +		{
  1.1322 +		SetTestStepResult(EFail);
  1.1323 +		}
  1.1324 +	CleanupStack::PopAndDestroy(&file); 
  1.1325 +	delete content;
  1.1326 +
  1.1327 +	
  1.1328 +	INFO_PRINTF1(_L("Testing EContentShareReadWrite"));	
  1.1329 +	content = CContent::NewL(fileName, EContentShareReadWrite);
  1.1330 +	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileStream));
  1.1331 +	CleanupClosePushL(file);
  1.1332 +	data = content->OpenContentL(EPeek, EContentShareReadWrite);
  1.1333 +	delete data;
  1.1334 +	data = NULL;
  1.1335 +	
  1.1336 +	// We should be able to open read-only
  1.1337 +	
  1.1338 +	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
  1.1339 +	delete data;
  1.1340 +	data = NULL;
  1.1341 +	if(err != KErrNone)
  1.1342 +		{
  1.1343 +		SetTestStepResult(EFail);
  1.1344 +		}
  1.1345 +		
  1.1346 +	// but not share exclusive
  1.1347 +		
  1.1348 +	TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
  1.1349 +	delete data;
  1.1350 +	data = NULL;
  1.1351 +	if(err != KErrInUse)
  1.1352 +		{
  1.1353 +		SetTestStepResult(EFail);
  1.1354 +		}
  1.1355 +	CleanupStack::PopAndDestroy(&file);
  1.1356 +	
  1.1357 +	
  1.1358 +	// Reopen the file with write attributes, and make sure ReadOnly becomes impossible 
  1.1359 +	User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileWrite | EFileStream));
  1.1360 +	CleanupClosePushL(file);
  1.1361 +	
  1.1362 +	TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
  1.1363 +	delete data;
  1.1364 +	data = NULL;
  1.1365 +	if(err != KErrInUse)
  1.1366 +		{
  1.1367 +		SetTestStepResult(EFail);
  1.1368 +		}
  1.1369 +	
  1.1370 +	CleanupStack::PopAndDestroy(&file);
  1.1371 +	delete content;
  1.1372 +	
  1.1373 +	
  1.1374 +	INFO_PRINTF1(_L("Testing EContentShareExclusive"));	
  1.1375 +	User::LeaveIfError(file.Open(fs, fileName, EFileShareExclusive | EFileRead | EFileStream));
  1.1376 +	CleanupClosePushL(file);
  1.1377 +	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadOnly));
  1.1378 +	delete data;
  1.1379 +	data = NULL;
  1.1380 +	if(err != KErrInUse)
  1.1381 +		{
  1.1382 +		SetTestStepResult(EFail);
  1.1383 +		}
  1.1384 +	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadWrite));
  1.1385 +	delete data;
  1.1386 +	data = NULL;
  1.1387 +	if(err != KErrInUse)
  1.1388 +		{
  1.1389 +		SetTestStepResult(EFail);
  1.1390 +		}
  1.1391 +	TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareExclusive));
  1.1392 +	delete data;
  1.1393 +	data = NULL;
  1.1394 +	if(err != KErrInUse)
  1.1395 +		{
  1.1396 +		SetTestStepResult(EFail);
  1.1397 +		}
  1.1398 +	CleanupStack::PopAndDestroy(&file); 
  1.1399 +	
  1.1400 +	INFO_PRINTF1(_L("Testing CContent::NewAttributeL"));	
  1.1401 +	content = CContent::NewL(fileName, EContentShareReadWrite);
  1.1402 +	User::LeaveIfError(file.Open(fs, fileName, EFileShareAny | EFileRead | EFileStream));
  1.1403 +	CleanupClosePushL(file);
  1.1404 +	attr = content->NewAttributeL(ETrue,EContentShareReadWrite);
  1.1405 +	delete attr;
  1.1406 +	attr = NULL;
  1.1407 +	TRAP(err, attr = content->NewAttributeL(ETrue));
  1.1408 +	delete attr;
  1.1409 +	attr = NULL;
  1.1410 +	if(err != KErrInUse)
  1.1411 +		{
  1.1412 +		SetTestStepResult(EFail);
  1.1413 +		}
  1.1414 +	CleanupStack::PopAndDestroy(2, &fs); // fs, file
  1.1415 +	delete content;
  1.1416 +
  1.1417 +	__UHEAP_MARKEND;
  1.1418 +	return TestStepResult();
  1.1419 +	}
  1.1420 +
  1.1421 +CCAFHandleSizeStep::CCAFHandleSizeStep(CCAFServer& aParent)
  1.1422 +:iParent(aParent)
  1.1423 +{
  1.1424 +	SetTestStepName(KCAFHandleSizeStep);	
  1.1425 +}
  1.1426 +
  1.1427 +CCAFHandleSizeStep::~CCAFHandleSizeStep()
  1.1428 +{
  1.1429 +	
  1.1430 +	
  1.1431 +}	
  1.1432 +
  1.1433 +TVerdict CCAFHandleSizeStep::doTestStepL()
  1.1434 +	{
  1.1435 +	__UHEAP_MARK;
  1.1436 +	
  1.1437 +	SetTestStepResult(EInconclusive);
  1.1438 +	
  1.1439 +	INFO_PRINTF1(_L("Basic Open Content Test"));
  1.1440 +	
  1.1441 +	TPtrC uri1;
  1.1442 +	TPtrC uri2;
  1.1443 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
  1.1444 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
  1.1445 +
  1.1446 +	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
  1.1447 +	
  1.1448 +	RFile file1;
  1.1449 +	User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead));	
  1.1450 +	CleanupClosePushL(file1);	
  1.1451 +		
  1.1452 +	CContent* content = CContent::NewLC(file1);
  1.1453 +
  1.1454 +	INFO_PRINTF1(_L("Creating data object from content"));
  1.1455 +
  1.1456 +	CData* data = content->OpenContentL(EPeek);
  1.1457 +	CleanupStack::PushL(data);
  1.1458 +
  1.1459 +	TInt size = 0;
  1.1460 +	data->DataSizeL(size);
  1.1461 +	INFO_PRINTF2(_L("Size of content from caf: %d"),size);
  1.1462 +	CleanupStack::PopAndDestroy(data);
  1.1463 +	CleanupStack::PopAndDestroy(content);
  1.1464 +	
  1.1465 +	TInt pos = 0;
  1.1466 +	file1.Seek(ESeekStart, pos);
  1.1467 +
  1.1468 +	INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
  1.1469 +	TInt size1 = 0;
  1.1470 +	data = CData::NewL(file1, KDefaultContentObject(), EPeek);
  1.1471 +	CleanupStack::PushL(data);
  1.1472 +	data->DataSizeL(size1);
  1.1473 +	INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
  1.1474 +	CleanupStack::PopAndDestroy(data);
  1.1475 +	CleanupStack::PopAndDestroy(&file1);
  1.1476 +	
  1.1477 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
  1.1478 +	RFile file2;
  1.1479 +	User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead));
  1.1480 +	
  1.1481 +	TInt size2;
  1.1482 +	file2.Size(size2);
  1.1483 +	file2.Close();
  1.1484 +
  1.1485 +	INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
  1.1486 +
  1.1487 +	if(size == size2 && size1 == size2)
  1.1488 +		{
  1.1489 +		SetTestStepResult(EPass);
  1.1490 +		}
  1.1491 +	else
  1.1492 +		{
  1.1493 +		SetTestStepResult(EFail);
  1.1494 +		}
  1.1495 +	
  1.1496 +	__UHEAP_MARKEND;
  1.1497 +	return TestStepResult();
  1.1498 +	}
  1.1499 +
  1.1500 +
  1.1501 +CCAFHandleSeekReadStep::~CCAFHandleSeekReadStep()
  1.1502 +{
  1.1503 +	
  1.1504 +}
  1.1505 +
  1.1506 +CCAFHandleSeekReadStep::CCAFHandleSeekReadStep(CCAFServer& aParent)
  1.1507 +: iParent(aParent)
  1.1508 +	{
  1.1509 +	SetTestStepName(KCAFHandleSeekReadStep);
  1.1510 +	}
  1.1511 +	
  1.1512 +TVerdict CCAFHandleSeekReadStep::doTestStepL()
  1.1513 +	{
  1.1514 +	SetTestStepResult(EInconclusive);
  1.1515 +	
  1.1516 +	TBuf8<2> buf1;
  1.1517 +	TBuf8<2> buf2;
  1.1518 +	TRequestStatus status;
  1.1519 +
  1.1520 +	__UHEAP_MARK;
  1.1521 +	INFO_PRINTF1(_L("Basic Open Content Test"));
  1.1522 +	
  1.1523 +	TPtrC uri1;
  1.1524 +	TPtrC uri2;
  1.1525 +	GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
  1.1526 +	GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
  1.1527 +
  1.1528 +	INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
  1.1529 +	RFile file1;
  1.1530 +	User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead | EFileShareReadersOnly));	
  1.1531 +	CleanupClosePushL(file1);		
  1.1532 +	CContent* content = CContent::NewLC(file1);
  1.1533 +
  1.1534 +	INFO_PRINTF1(_L("Creating data object from content"));
  1.1535 +	CData* data = content->OpenContentL(EPeek);
  1.1536 +	CleanupStack::PushL(data);
  1.1537 +
  1.1538 +	// Now, open the same file using RFile
  1.1539 +	RFile file2;
  1.1540 +	INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
  1.1541 +	//User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
  1.1542 +	TInt res = file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly);
  1.1543 +	CleanupClosePushL(file2);
  1.1544 +
  1.1545 +	TInt size = 0;
  1.1546 +	file2.Size(size);
  1.1547 +	INFO_PRINTF2(_L("Size of content from f32: %d"),size);
  1.1548 +	
  1.1549 +	// Seek and read from start using both CAF and RFile
  1.1550 +	TInt pos1 = size/4;
  1.1551 +	data->Seek(ESeekStart, pos1);
  1.1552 +	TInt pos2 = size/4;
  1.1553 +	file2.Seek(ESeekStart, pos2);
  1.1554 +	data->Read(buf1);
  1.1555 +	file2.Read(buf2);
  1.1556 +	INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
  1.1557 +	INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
  1.1558 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
  1.1559 +		{
  1.1560 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1561 +		SetTestStepResult(EFail);
  1.1562 +		}
  1.1563 +
  1.1564 +	// set the location within the file then retrieve the current location within the file
  1.1565 +	pos1=0;
  1.1566 +	pos2=0;
  1.1567 +	data->Seek(ESeekCurrent, pos1);
  1.1568 +	file2.Seek(ESeekCurrent, pos2);
  1.1569 +
  1.1570 +	INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
  1.1571 +	INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
  1.1572 +
  1.1573 +	if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
  1.1574 +		{
  1.1575 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1576 +		SetTestStepResult(EFail);
  1.1577 +		}
  1.1578 +
  1.1579 +	// Seek and read from current using both CAF and RFile
  1.1580 +	pos1 = size/4;
  1.1581 +	data->Seek(ESeekCurrent, pos1);
  1.1582 +	pos2 = size/4;
  1.1583 +	file2.Seek(ESeekCurrent, pos2);
  1.1584 +	data->Read(buf1);
  1.1585 +	file2.Read(buf2);
  1.1586 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
  1.1587 +	INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
  1.1588 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
  1.1589 +		{
  1.1590 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1591 +		SetTestStepResult(EFail);
  1.1592 +		}
  1.1593 +
  1.1594 +	// Seek and read from end using both CAF and RFile
  1.1595 +	pos1 = -size/4;
  1.1596 +	data->Seek(ESeekEnd, pos1);
  1.1597 +	pos2 = -size/4;
  1.1598 +	file2.Seek(ESeekEnd, pos2);
  1.1599 +	data->Read(buf1);
  1.1600 +	file2.Read(buf2);
  1.1601 +	INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
  1.1602 +	INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
  1.1603 +	if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
  1.1604 +		{
  1.1605 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1606 +		SetTestStepResult(EFail);
  1.1607 +		}
  1.1608 +
  1.1609 +	// Test other overloaded forms of CData::Read
  1.1610 +
  1.1611 +	// Read only 1 byte using both CAF and RFile
  1.1612 +	pos1 = size/4;
  1.1613 +	data->Seek(ESeekStart, pos1);
  1.1614 +	pos2 = size/4;
  1.1615 +	file2.Seek(ESeekStart, pos2);
  1.1616 +	data->Read(buf1,1);
  1.1617 +	file2.Read(buf2,1);
  1.1618 +	INFO_PRINTF2(_L("Data Length from  CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
  1.1619 +	INFO_PRINTF2(_L("Data Length from  RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
  1.1620 +	
  1.1621 +	pos1=0;
  1.1622 +	pos2=0;
  1.1623 +	data->Seek(ESeekCurrent, pos1);
  1.1624 +	file2.Seek(ESeekCurrent,pos2);
  1.1625 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1.1626 +		{
  1.1627 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1628 +		SetTestStepResult(EFail);
  1.1629 +		}
  1.1630 +
  1.1631 +	// Read asynchronously using both CAF and RFile
  1.1632 +	INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
  1.1633 +	pos1 = size/4;
  1.1634 +	data->Seek(ESeekStart, pos1);
  1.1635 +	pos2 = size/4;
  1.1636 +	file2.Seek(ESeekStart, pos2);
  1.1637 +	status = KRequestPending;
  1.1638 +	data->Read(buf1,status);
  1.1639 +	User::WaitForRequest(status);
  1.1640 +	status = KRequestPending;
  1.1641 +	file2.Read(buf2,status);
  1.1642 +	User::WaitForRequest(status);
  1.1643 +	INFO_PRINTF2(_L("Data length from  CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
  1.1644 +	INFO_PRINTF2(_L("Data length from  RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
  1.1645 +
  1.1646 +	pos1=0;
  1.1647 +	pos2=0;
  1.1648 +	data->Seek(ESeekCurrent, pos1);
  1.1649 +	file2.Seek(ESeekCurrent,pos2);
  1.1650 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1.1651 +		{
  1.1652 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1653 +		SetTestStepResult(EFail);
  1.1654 +		}
  1.1655 +
  1.1656 +	// Read only 1 byte asynchronously using both CAF and RFile
  1.1657 +	INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
  1.1658 +	pos1 = size/4;
  1.1659 +	data->Seek(ESeekStart, pos1);
  1.1660 +	pos2 = size/4;
  1.1661 +	file2.Seek(ESeekStart, pos2);
  1.1662 +	status = KRequestPending;
  1.1663 +	data->Read(buf1,1,status);
  1.1664 +	User::WaitForRequest(status);
  1.1665 +	status = KRequestPending;
  1.1666 +	file2.Read(buf2,1, status);
  1.1667 +	User::WaitForRequest(status);
  1.1668 +	INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
  1.1669 +	INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
  1.1670 +
  1.1671 +	pos1=0;
  1.1672 +	pos2=0;
  1.1673 +	data->Seek(ESeekCurrent, pos1);
  1.1674 +	file2.Seek(ESeekCurrent,pos2);
  1.1675 +	if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
  1.1676 +		{
  1.1677 +		INFO_PRINTF1(_L("ERROR buffers or position do not match"));
  1.1678 +		SetTestStepResult(EFail);
  1.1679 +		}
  1.1680 +
  1.1681 +	// read past EOF
  1.1682 +	pos1 = size+1;
  1.1683 +	pos2 = size+1;
  1.1684 +	data->Seek(ESeekStart, pos1);
  1.1685 +	file2.Seek(ESeekStart, pos2);
  1.1686 +	data->Read(buf1);
  1.1687 +	file2.Read(buf2);
  1.1688 +
  1.1689 +	if(buf1.Length() != 0 || buf1.Length() != 0)
  1.1690 +		{
  1.1691 +		INFO_PRINTF1(_L("ERROR data read past EOF"));
  1.1692 +		SetTestStepResult(EFail);
  1.1693 +		}
  1.1694 +	
  1.1695 +	CleanupStack::PopAndDestroy(4);
  1.1696 +
  1.1697 +	__UHEAP_MARKEND;
  1.1698 +
  1.1699 +	if (TestStepResult() != EFail)
  1.1700 +		{
  1.1701 +		SetTestStepResult(EPass);
  1.1702 +		}
  1.1703 +
  1.1704 +	return TestStepResult();
  1.1705 +	}
  1.1706 +
  1.1707 +/* 
  1.1708 + * Step reads from a CData from multiple threads using RFile handle
  1.1709 + *
  1.1710 + */
  1.1711 + 
  1.1712 +CCAFHandleMultiThreadCDataStep::~CCAFHandleMultiThreadCDataStep()
  1.1713 + {
  1.1714 +  	
  1.1715 + }
  1.1716 +   
  1.1717 + CCAFHandleMultiThreadCDataStep::CCAFHandleMultiThreadCDataStep(CCAFServer& aParent)
  1.1718 + :iParent(aParent)
  1.1719 + {
  1.1720 + 	
  1.1721 + 	SetTestStepName(KCAFHandleMultiThreadCDataStep);
  1.1722 + }
  1.1723 + 
  1.1724 +TVerdict CCAFHandleMultiThreadCDataStep::doTestStepL()
  1.1725 +	 {
  1.1726 +	TBuf8<2> buf;
  1.1727 +
  1.1728 +	__UHEAP_MARK;
  1.1729 +	_LIT(KCDataThread,"CData_Thread");
  1.1730 +
  1.1731 +	SetTestStepResult(EInconclusive);
  1.1732 +	
  1.1733 +	INFO_PRINTF1(_L("Multi Thread CData Test using RFile Handle"));
  1.1734 +	
  1.1735 +	TPtrC uri;
  1.1736 +	GetStringFromConfig(ConfigSection(),_L("URI"),uri);
  1.1737 +
  1.1738 +	INFO_PRINTF1(_L("Creating data object from content"));
  1.1739 +	RFile file;
  1.1740 +	User::LeaveIfError(file.Open(iParent.Fs(), uri, EFileRead));	
  1.1741 +		
  1.1742 +	CleanupClosePushL(file);
  1.1743 +		
  1.1744 +	CContent* content = CContent::NewLC(file);
  1.1745 +	CData* data = content->OpenContentL(EPeek);
  1.1746 +	CleanupStack::PushL(data);
  1.1747 +
  1.1748 +	TInt size, pos;
  1.1749 +
  1.1750 +	// Create a mutex for communication between our thread and the new thread
  1.1751 +	RSemaphore threadSemaphore;
  1.1752 +	threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
  1.1753 +	threadSemaphore.Wait(); 
  1.1754 +
  1.1755 +	// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future 
  1.1756 +	RThread readerThread;
  1.1757 +	User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
  1.1758 +	
  1.1759 +	// request notification of thread completion
  1.1760 +	TRequestStatus stat;
  1.1761 +	readerThread.Logon(stat);
  1.1762 +	readerThread.Resume();	
  1.1763 +	
  1.1764 +
  1.1765 +	data->DataSizeL(size);
  1.1766 +	pos = size/2;
  1.1767 +	data->Seek(ESeekStart,pos);
  1.1768 +	data->Read(buf);
  1.1769 +
  1.1770 +	threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
  1.1771 +	threadSemaphore.Signal(); // finished with semaphore
  1.1772 +	threadSemaphore.Close(); // so close
  1.1773 +
  1.1774 +	User::WaitForRequest(stat); // wait for thread to finish
  1.1775 +	TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
  1.1776 +	User::LeaveIfError(error);
  1.1777 +	readerThread.Close();  // close the thread
  1.1778 +	
  1.1779 +	CleanupStack::PopAndDestroy(data);
  1.1780 +	CleanupStack::PopAndDestroy(content);
  1.1781 +	CleanupStack::PopAndDestroy(&file); //file
  1.1782 +	
  1.1783 +
  1.1784 +	__UHEAP_MARKEND;
  1.1785 +	
  1.1786 +	SetTestStepResult(EPass);
  1.1787 +	return TestStepResult();	
  1.1788 +}
  1.1789 +
  1.1790 +TInt CCAFHandleMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
  1.1791 +	{
  1.1792 +	TBuf8 <2> buf;
  1.1793 +	CData *data = reinterpret_cast <CData *> (aPtr);
  1.1794 +
  1.1795 +	// create a trap handler
  1.1796 +	CTrapCleanup* cleanup = CTrapCleanup::New();
  1.1797 +
  1.1798 +	RSemaphore threadSemaphore;
  1.1799 +	threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
  1.1800 +
  1.1801 +	data->Read(buf);
  1.1802 +	threadSemaphore.Signal(); // allow original thread to continue
  1.1803 +	threadSemaphore.Close();
  1.1804 +	
  1.1805 +	delete cleanup;
  1.1806 +	return KErrNone;
  1.1807 +	}
  1.1808 +
  1.1809 +/* 
  1.1810 + * Data attribute step
  1.1811 + *
  1.1812 + */
  1.1813 +
  1.1814 +CCAFDataAttributeStep::~CCAFDataAttributeStep()
  1.1815 +	{
  1.1816 +	}
  1.1817 +
  1.1818 +CCAFDataAttributeStep::CCAFDataAttributeStep(CCAFServer& aParent) : iParent(aParent)
  1.1819 +	{
  1.1820 +	SetTestStepName(KCAFDataAttributeStep);
  1.1821 +	}
  1.1822 +
  1.1823 +TVerdict CCAFDataAttributeStep::doTestStepL()
  1.1824 +	{
  1.1825 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.1826 +    TBool wmdrmFlag = EFalse;     
  1.1827 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1.1828 +         
  1.1829 +    if(wmdrmFlag)     
  1.1830 +        {     
  1.1831 +        TVerdict verdict = doWmdrmTestStepL();     
  1.1832 +        return verdict;     
  1.1833 +        }     
  1.1834 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.1835 +  
  1.1836 +	TInt attribute;
  1.1837 +	TInt value = KErrNone;
  1.1838 +	TInt expectedValue = KErrNone;
  1.1839 +	TPtrC uri;
  1.1840 +	TPtrC uniqueId;
  1.1841 +
  1.1842 +	SetTestStepResult(EPass);
  1.1843 +
  1.1844 +	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
  1.1845 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.1846 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1.1847 +	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
  1.1848 +
  1.1849 +	__UHEAP_MARK;
  1.1850 +	CContent *content = CContent::NewLC(uri);
  1.1851 +	CData *data = content->OpenContentL(EPeek, uniqueId);
  1.1852 +	User::LeaveIfError(data->GetAttribute(attribute, value));
  1.1853 +	delete data;
  1.1854 +	if(expectedValue != value)
  1.1855 +		{
  1.1856 +		SetTestStepResult(EFail);
  1.1857 +		INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
  1.1858 +		}
  1.1859 +	
  1.1860 +	CleanupStack::PopAndDestroy(content);		    		
  1.1861 +	__UHEAP_MARKEND;
  1.1862 +	return TestStepResult();
  1.1863 +	}
  1.1864 +
  1.1865 +/* 
  1.1866 + * Data attributeset step
  1.1867 + *
  1.1868 + */
  1.1869 +
  1.1870 +CCAFDataAttributeSetStep::~CCAFDataAttributeSetStep()
  1.1871 +	{
  1.1872 +	}
  1.1873 +
  1.1874 +CCAFDataAttributeSetStep::CCAFDataAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
  1.1875 +	{
  1.1876 +	SetTestStepName(KCAFDataAttributeSetStep);
  1.1877 +	}
  1.1878 +
  1.1879 +TVerdict CCAFDataAttributeSetStep::doTestStepL()
  1.1880 +	{
  1.1881 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.1882 +    TBool wmdrmFlag = EFalse;     
  1.1883 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1.1884 +         
  1.1885 +    if(wmdrmFlag)     
  1.1886 +        {     
  1.1887 +        TVerdict verdict = doWmdrmTestStepL();     
  1.1888 +        return verdict;     
  1.1889 +        }     
  1.1890 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
  1.1891 +
  1.1892 +	TInt expectedValue1;
  1.1893 +	TInt expectedValue2;
  1.1894 +	TInt value1;
  1.1895 +	TInt value2;
  1.1896 +	TInt attribute1;
  1.1897 +	TInt attribute2;
  1.1898 +	TInt result = KErrNone;
  1.1899 +	TPtrC uri;
  1.1900 +	TPtrC uniqueId;
  1.1901 +
  1.1902 +	SetTestStepResult(EPass);
  1.1903 +
  1.1904 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.1905 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1.1906 +	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
  1.1907 +	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
  1.1908 +	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
  1.1909 +	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
  1.1910 +
  1.1911 +	__UHEAP_MARK;
  1.1912 +	CContent *content = CContent::NewLC(uri);
  1.1913 +	RAttributeSet attributeSet;
  1.1914 +	CleanupClosePushL(attributeSet);
  1.1915 +	attributeSet.AddL(attribute1);
  1.1916 +	attributeSet.AddL(attribute2);
  1.1917 +
  1.1918 +	CData *data = content->OpenContentL(EPeek, uniqueId);
  1.1919 +	result = data->GetAttributeSet(attributeSet);
  1.1920 +	delete data;
  1.1921 +	if(result != KErrNone)
  1.1922 +		{
  1.1923 +		SetTestStepResult(EFail);
  1.1924 +		INFO_PRINTF1(_L("CData::GetAttribute() failed"));
  1.1925 +		}
  1.1926 +	User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
  1.1927 +	User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
  1.1928 +	if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
  1.1929 +		{
  1.1930 +		SetTestStepResult(EFail);
  1.1931 +		INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
  1.1932 +		}
  1.1933 +	CleanupStack::PopAndDestroy(&attributeSet);		
  1.1934 +	CleanupStack::PopAndDestroy(content);		
  1.1935 +    		
  1.1936 +	__UHEAP_MARKEND;
  1.1937 +	return TestStepResult();
  1.1938 +	}
  1.1939 +
  1.1940 +
  1.1941 +/* 
  1.1942 + * Data string attribute step
  1.1943 + *
  1.1944 + */
  1.1945 +
  1.1946 +CCAFDataStringAttributeStep::~CCAFDataStringAttributeStep()
  1.1947 +	{
  1.1948 +	}
  1.1949 +
  1.1950 +CCAFDataStringAttributeStep::CCAFDataStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
  1.1951 +	{
  1.1952 +	SetTestStepName(KCAFDataStringAttributeStep);
  1.1953 +	}
  1.1954 +
  1.1955 +TVerdict CCAFDataStringAttributeStep::doTestStepL()
  1.1956 +	{
  1.1957 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.1958 +    TBool wmdrmFlag = EFalse;     
  1.1959 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1.1960 +         
  1.1961 +    if(wmdrmFlag)     
  1.1962 +        {     
  1.1963 +        TVerdict verdict = doWmdrmTestStepL();     
  1.1964 +        return verdict;     
  1.1965 +        }     
  1.1966 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
  1.1967 +
  1.1968 +	TInt expectedResult;
  1.1969 +	TInt attribute;
  1.1970 +	TPtrC expectedValue;
  1.1971 +	TBuf <200> value;
  1.1972 +	TInt result = KErrNone;
  1.1973 +	TPtrC uri;
  1.1974 +	TPtrC uniqueId;
  1.1975 +
  1.1976 +	SetTestStepResult(EPass);
  1.1977 +
  1.1978 +	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
  1.1979 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.1980 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1.1981 +	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
  1.1982 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
  1.1983 +
  1.1984 +	__UHEAP_MARK;
  1.1985 +	CContent *content = CContent::NewLC(uri);
  1.1986 +	CData *data = content->OpenContentL(EPeek, uniqueId);
  1.1987 +	result = data->GetStringAttribute(attribute, value);
  1.1988 +	delete data;
  1.1989 +	if(result != expectedResult)
  1.1990 +		{
  1.1991 +		SetTestStepResult(EFail);
  1.1992 +		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
  1.1993 +		}
  1.1994 +	if(value != expectedValue)
  1.1995 +		{
  1.1996 +		SetTestStepResult(EFail);
  1.1997 +		INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
  1.1998 +		}
  1.1999 +
  1.2000 +	CleanupStack::PopAndDestroy(content);		
  1.2001 +    		
  1.2002 +	__UHEAP_MARKEND;
  1.2003 +	return TestStepResult();
  1.2004 +	}
  1.2005 +
  1.2006 +/* 
  1.2007 + * Data StringAttributeSet step
  1.2008 + *
  1.2009 + */
  1.2010 +
  1.2011 +CCAFDataStringAttributeSetStep::~CCAFDataStringAttributeSetStep()
  1.2012 +	{
  1.2013 +	}
  1.2014 +
  1.2015 +CCAFDataStringAttributeSetStep::CCAFDataStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
  1.2016 +	{
  1.2017 +	SetTestStepName(KCAFDataStringAttributeSetStep);
  1.2018 +	}
  1.2019 +
  1.2020 +TVerdict CCAFDataStringAttributeSetStep::doTestStepL()
  1.2021 +	{
  1.2022 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.2023 +    TBool wmdrmFlag = EFalse;     
  1.2024 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
  1.2025 +         
  1.2026 +    if(wmdrmFlag)     
  1.2027 +        {     
  1.2028 +        TVerdict verdict = doWmdrmTestStepL();     
  1.2029 +        return verdict;     
  1.2030 +        }     
  1.2031 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.2032 +  
  1.2033 +	TPtrC expectedValue1;
  1.2034 +	TPtrC expectedValue2;
  1.2035 +	TBuf <200> value1;
  1.2036 +	TBuf <200> value2;
  1.2037 +	TInt attribute1;
  1.2038 +	TInt attribute2;
  1.2039 +	TInt result = KErrNone;
  1.2040 +	TInt result1;
  1.2041 +	TInt result2;
  1.2042 +	TPtrC uri;
  1.2043 +	TPtrC uniqueId;
  1.2044 +
  1.2045 +	SetTestStepResult(EPass);
  1.2046 +
  1.2047 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.2048 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
  1.2049 +	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
  1.2050 +	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
  1.2051 +	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
  1.2052 +	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
  1.2053 +	GetIntFromConfig(ConfigSection(),_L("result1"),result1);
  1.2054 +	GetIntFromConfig(ConfigSection(),_L("result2"),result2);
  1.2055 +
  1.2056 +	__UHEAP_MARK;
  1.2057 +	CContent *content = CContent::NewLC(uri);
  1.2058 +	RStringAttributeSet attributeSet;
  1.2059 +	CleanupClosePushL(attributeSet);
  1.2060 +	attributeSet.AddL(attribute1);
  1.2061 +	attributeSet.AddL(attribute2);
  1.2062 +	
  1.2063 +	CData *data = content->OpenContentL(EPeek, uniqueId);
  1.2064 +	result = data->GetStringAttributeSet(attributeSet);
  1.2065 +	delete data;
  1.2066 +	if(result != KErrNone)
  1.2067 +		{
  1.2068 +		SetTestStepResult(EFail);
  1.2069 +		INFO_PRINTF1(_L("CData::GetAttribute() failed"));
  1.2070 +		}
  1.2071 +	if(result1 != attributeSet.GetValue(attribute1, value1))
  1.2072 +		{
  1.2073 +		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
  1.2074 +		}
  1.2075 +	if(result2 != attributeSet.GetValue(attribute2, value2))
  1.2076 +		{
  1.2077 +		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
  1.2078 +		}
  1.2079 +	if( value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
  1.2080 +		{
  1.2081 +		SetTestStepResult(EFail);
  1.2082 +		INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
  1.2083 +		}
  1.2084 +	CleanupStack::PopAndDestroy(&attributeSet);		
  1.2085 +	CleanupStack::PopAndDestroy(content);		
  1.2086 +	
  1.2087 +    		
  1.2088 +	__UHEAP_MARKEND;
  1.2089 +	return TestStepResult();
  1.2090 +	}
  1.2091 +
  1.2092 +
  1.2093 +CCAFExecuteIntentStep::~CCAFExecuteIntentStep()
  1.2094 +	{
  1.2095 +	}
  1.2096 +
  1.2097 +CCAFExecuteIntentStep::CCAFExecuteIntentStep(CCAFServer& aParent)
  1.2098 +: iParent(aParent)
  1.2099 +	{
  1.2100 +	SetTestStepName(KCAFSizeStep);
  1.2101 +	}
  1.2102 +
  1.2103 +TVerdict CCAFExecuteIntentStep::doTestStepL()
  1.2104 +	{
  1.2105 +	__UHEAP_MARK;
  1.2106 +	
  1.2107 +	SetTestStepResult(EInconclusive);
  1.2108 +	
  1.2109 +	INFO_PRINTF1(_L("Execute Intent Test"));
  1.2110 +	
  1.2111 +	TPtrC fileName;
  1.2112 +	TPtrC uniqueId;
  1.2113 +	TInt intent = EPeek;
  1.2114 +	TInt expectedResult = KErrNone;
  1.2115 +	
  1.2116 +	GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
  1.2117 +	GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueId);
  1.2118 +	GetIntFromConfig(ConfigSection(),_L("Intent"),intent);
  1.2119 +	GetIntFromConfig(ConfigSection(),_L("ExpectedResult"),expectedResult);
  1.2120 +	
  1.2121 +	INFO_PRINTF3(_L("Creating CData object with filename: %S, UniqueId: %S"), &fileName, &uniqueId);
  1.2122 +	
  1.2123 +	CData* data = NULL;
  1.2124 +	
  1.2125 +	TRAPD(err, data = CData::NewL(TVirtualPathPtr(fileName, uniqueId),static_cast<TIntent>(intent), EContentShareReadOnly));
  1.2126 +	
  1.2127 +	if(err != expectedResult)
  1.2128 +		{
  1.2129 +		INFO_PRINTF2(_L("Unexpected result, EvaluateIntent() returned %d"), err);
  1.2130 +		}
  1.2131 +	else
  1.2132 +		{
  1.2133 +		SetTestStepResult(EPass);
  1.2134 +		if(err == KErrNone)
  1.2135 +			{
  1.2136 +			err = data->ExecuteIntent(static_cast<TIntent>(intent));
  1.2137 +			if(err == KErrNone)
  1.2138 +				{
  1.2139 +				TBuf8 <128> buffer;
  1.2140 +				TInt length = 128;
  1.2141 +			
  1.2142 +				// read the entire content object
  1.2143 +				while(err == KErrNone && length > 0)
  1.2144 +					{
  1.2145 +					err = data->Read(buffer);
  1.2146 +					length = buffer.Length();
  1.2147 +					}
  1.2148 +				if(err != KErrEof && err != KErrNone)
  1.2149 +					{
  1.2150 +					INFO_PRINTF2(_L("Unexpected error while reading content object: %d"), err);
  1.2151 +					SetTestStepResult(EFail);
  1.2152 +					}
  1.2153 +				}
  1.2154 +			else
  1.2155 +				{
  1.2156 +				INFO_PRINTF2(_L("Unexpected error, EvaluteIntent succeeded but ExecuteIntent failed with error: %d"), err);
  1.2157 +				SetTestStepResult(EFail);
  1.2158 +				}
  1.2159 +			}
  1.2160 +		}
  1.2161 +		
  1.2162 +	delete data;
  1.2163 +	
  1.2164 +	__UHEAP_MARKEND;
  1.2165 +	return TestStepResult();
  1.2166 +	}
  1.2167 +
  1.2168 +/* 
  1.2169 + * DRM File Open Performance Test Step
  1.2170 + *
  1.2171 + */
  1.2172 +
  1.2173 +CCAFDRMFileOpenPerformanceTest::~CCAFDRMFileOpenPerformanceTest()
  1.2174 +	{
  1.2175 +	iIterationSum = 0;
  1.2176 +	}
  1.2177 +
  1.2178 +CCAFDRMFileOpenPerformanceTest::CCAFDRMFileOpenPerformanceTest(CCAFServer& aParent) : iParent(aParent)
  1.2179 +	{
  1.2180 +	SetTestStepName(KCAFDRMFileOpenPerformanceStep);
  1.2181 +	}
  1.2182 +
  1.2183 +TVerdict CCAFDRMFileOpenPerformanceTest::doTestStepL()
  1.2184 +	{
  1.2185 +	__UHEAP_MARK;
  1.2186 +
  1.2187 +	INFO_PRINTF1(_L("DRM File Open Performance Test"));
  1.2188 +	
  1.2189 +	TPtrC inputFileName;
  1.2190 +	TInt maxValue = 0 ,iterCount = 0;
  1.2191 +
  1.2192 +	GetStringFromConfig(ConfigSection(),_L("FileName"),inputFileName);
  1.2193 +	GetIntFromConfig(ConfigSection(),_L("IterationCount"),iterCount);
  1.2194 +	GetIntFromConfig(ConfigSection(),_L("MaxTimeLimitInMS"),maxValue);
  1.2195 +		
  1.2196 +	iIterationSum=0;
  1.2197 +	// iterated iterCount times to get the average time taken to open the file.
  1.2198 +	for (TInt i = 0; i < iterCount; ++i)
  1.2199 +		{
  1.2200 +		OpenAndReadFileContentL(inputFileName);
  1.2201 +		}
  1.2202 +		
  1.2203 +	TInt tickPeriod;
  1.2204 +	HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
  1.2205 +	TInt nTickPeriodMS = tickPeriod / KCafTestSecToMS;
  1.2206 +
  1.2207 +	TInt avgTimeForFileOpen = (iIterationSum * nTickPeriodMS) / iterCount;
  1.2208 +	if((avgTimeForFileOpen > maxValue))
  1.2209 +		{
  1.2210 +		INFO_PRINTF1(_L("Performance Test failed."));
  1.2211 +		SetTestStepResult(EFail);
  1.2212 +		}
  1.2213 +
  1.2214 +	INFO_PRINTF2(_L("Expected maximum time to open DRM file in millisecs is : %d"), maxValue);
  1.2215 +	INFO_PRINTF2(_L("Obtained time in millisecs is: %d"), avgTimeForFileOpen);
  1.2216 +	
  1.2217 +	__UHEAP_MARKEND;
  1.2218 +	
  1.2219 +	return TestStepResult();
  1.2220 +	}
  1.2221 +	
  1.2222 +void CCAFDRMFileOpenPerformanceTest::OpenAndReadFileContentL(const TDesC& aFileName)
  1.2223 +	{
  1.2224 +	TPtrC uniqueIdentifier;
  1.2225 +
  1.2226 +	GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueIdentifier);
  1.2227 +	CContent *content = CContent::NewLC(aFileName);
  1.2228 +	CData *data = NULL;
  1.2229 +	TUint32 tickCounterValBeforeFileOpen, tickCounterValAfterFileOpen;
  1.2230 +	if(uniqueIdentifier.Length() > 0)
  1.2231 +		{
  1.2232 +		tickCounterValBeforeFileOpen = User::NTickCount();
  1.2233 +		data = content->OpenContentL(EPeek,uniqueIdentifier);
  1.2234 +		tickCounterValAfterFileOpen = User::NTickCount();
  1.2235 +		}
  1.2236 +	else
  1.2237 +		{
  1.2238 +		tickCounterValBeforeFileOpen = User::NTickCount();
  1.2239 +		data = content->OpenContentL(EPeek);
  1.2240 +		tickCounterValAfterFileOpen = User::NTickCount();
  1.2241 +		}
  1.2242 +	delete data;
  1.2243 +	// finished with Data object
  1.2244 +	CleanupStack::PopAndDestroy(content);	
  1.2245 +	iIterationSum += tickCounterValAfterFileOpen - tickCounterValBeforeFileOpen;
  1.2246 +	}
  1.2247 +	
  1.2248 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
  1.2249 +      
  1.2250 +CWmdrmCAFContentStep::~CWmdrmCAFContentStep()     
  1.2251 +    {     
  1.2252 +    }     
  1.2253 +      
  1.2254 +CWmdrmCAFContentStep::CWmdrmCAFContentStep()     
  1.2255 +    {     
  1.2256 +    SetTestStepName(KWmdrmCAFContentStep);     
  1.2257 +    }     
  1.2258 +      
  1.2259 +      
  1.2260 +TVerdict CWmdrmCAFContentStep::doTestStepL()     
  1.2261 +    {     
  1.2262 +    SetTestStepResult(EFail);     
  1.2263 +    
  1.2264 +    TBool protectedVal;
  1.2265 +    GetBoolFromConfig(ConfigSection(),_L("attribValue1"), protectedVal);     
  1.2266 +    TBool forwardable;     
  1.2267 +    GetBoolFromConfig(ConfigSection(),_L("attribValue2"), forwardable);     
  1.2268 +         
  1.2269 +    TBool headerDataPresent = ETrue;     
  1.2270 +    GetBoolFromConfig(ConfigSection(),_L("headerDataFlag"), headerDataPresent);     
  1.2271 +         
  1.2272 +    INFO_PRINTF1(_L("Verify CContent APIs for WMDRM content"));      
  1.2273 +         
  1.2274 +    __UHEAP_MARK;     
  1.2275 +         
  1.2276 +    CContent* content = NULL;     
  1.2277 +         
  1.2278 +    // this condition verifies that CContent construction leaves with KErrMissingWmdrmHeaderData,     
  1.2279 +    // when no header data is provided.     
  1.2280 +    if(!headerDataPresent)     
  1.2281 +        {     
  1.2282 +        content = CContent::NewL(KNullDesC8());     
  1.2283 +        return EPass;     
  1.2284 +        }     
  1.2285 +         
  1.2286 +    // create a dummy header data.     
  1.2287 +    HBufC8* headerData = CreateWmdrmHeaderLC();     
  1.2288 +         
  1.2289 +    // Open a file and retrieve the attributes.     
  1.2290 +    // If headerDataPresent is false, the code will never reach here.s     
  1.2291 +    content = CContent::NewL(*headerData);     
  1.2292 +    CleanupStack::PushL(content);     
  1.2293 +    CAttribute* attrs = content->NewAttributeL(ETrue);     
  1.2294 +    CleanupStack::PushL(attrs);     
  1.2295 +      
  1.2296 +    TBool value1 = attrs->ResponseSet().IsSet(EIsProtected);     
  1.2297 +    TBool value2 = attrs->ResponseSet().IsSet(EIsForwardable);     
  1.2298 +    if(value1 == protectedVal && value2 == forwardable)     
  1.2299 +        {     
  1.2300 +        SetTestStepResult(EPass);     
  1.2301 +        }     
  1.2302 +      
  1.2303 +    CleanupStack::PopAndDestroy(3, headerData);      
  1.2304 +      
  1.2305 +    __UHEAP_MARKEND;     
  1.2306 +    return TestStepResult();     
  1.2307 +    }     
  1.2308 +      
  1.2309 +      
  1.2310 +CWmdrmCAFDataStep::~CWmdrmCAFDataStep()     
  1.2311 +    {     
  1.2312 +    }     
  1.2313 +      
  1.2314 +CWmdrmCAFDataStep::CWmdrmCAFDataStep()     
  1.2315 +    {     
  1.2316 +    SetTestStepName(KWmdrmCAFDataStep);     
  1.2317 +    }     
  1.2318 +      
  1.2319 +TVerdict CWmdrmCAFDataStep::doTestStepL()     
  1.2320 +    {     
  1.2321 +    SetTestStepResult(EFail);     
  1.2322 +         
  1.2323 +    TInt attribute;     
  1.2324 +    TInt expectedValue = KErrNone;     
  1.2325 +      
  1.2326 +    GetIntFromConfig(ConfigSection(),_L("attribute"), attribute);     
  1.2327 +    GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
  1.2328 +         
  1.2329 +__UHEAP_MARK;     
  1.2330 +      
  1.2331 +    HBufC8* headerData = CreateWmdrmHeaderLC();     
  1.2332 +         
  1.2333 +    CContent *content = CContent::NewLC(*headerData);     
  1.2334 +    CData *data = content->OpenContentL(EPeek);     
  1.2335 +    TInt value = KErrNone;     
  1.2336 +    User::LeaveIfError(data->GetAttribute(attribute, value));     
  1.2337 +    delete data;     
  1.2338 +         
  1.2339 +    if(expectedValue == value)     
  1.2340 +        {     
  1.2341 +        SetTestStepResult(EPass);     
  1.2342 +        }     
  1.2343 +    else     
  1.2344 +        {     
  1.2345 +        INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);        
  1.2346 +        }     
  1.2347 +         
  1.2348 +    CleanupStack::PopAndDestroy(2, headerData);                      
  1.2349 +__UHEAP_MARKEND;     
  1.2350 +         
  1.2351 +    return TestStepResult();     
  1.2352 +    }     
  1.2353 +      
  1.2354 +      
  1.2355 +CWmdrmCAFReadStep::~CWmdrmCAFReadStep()     
  1.2356 +    {     
  1.2357 +    }     
  1.2358 +      
  1.2359 +CWmdrmCAFReadStep::CWmdrmCAFReadStep()     
  1.2360 +    {     
  1.2361 +    SetTestStepName(KWmdrmCAFReadStep);     
  1.2362 +    }     
  1.2363 +      
  1.2364 +      
  1.2365 +TVerdict CWmdrmCAFReadStep::doTestStepL()     
  1.2366 +    {     
  1.2367 +    SetTestStepResult(EFail);     
  1.2368 +         
  1.2369 +    TBool synchronous = EFalse;     
  1.2370 +    GetBoolFromConfig(ConfigSection(),_L("synchronous"), synchronous);     
  1.2371 +    TBool intent = EFalse;     
  1.2372 +    GetBoolFromConfig(ConfigSection(),_L("intent"), intent);     
  1.2373 +    TPtrC inputPacket;     
  1.2374 +    GetStringFromConfig(ConfigSection(),_L("inputPacket"), inputPacket);     
  1.2375 +    TPtrC expectedOutput;     
  1.2376 +    GetStringFromConfig(ConfigSection(),_L("outputPacket"), expectedOutput);     
  1.2377 +         
  1.2378 +__UHEAP_MARK;     
  1.2379 +    TPtrC header;     
  1.2380 +    HBufC8* headerData = NULL;     
  1.2381 +         
  1.2382 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.2383 +        {     
  1.2384 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.2385 +        }     
  1.2386 +    else     
  1.2387 +        {     
  1.2388 +        headerData = CreateWmdrmHeaderLC();      
  1.2389 +        }     
  1.2390 +         
  1.2391 +    TInt result = 0;     
  1.2392 +    if(!synchronous)     
  1.2393 +        {     
  1.2394 +        result = TestAsynchronousReadL(*headerData, intent, inputPacket, expectedOutput);     
  1.2395 +        }     
  1.2396 +    else     
  1.2397 +        {     
  1.2398 +        result = TestSynchronousReadL(*headerData, intent, inputPacket, expectedOutput);     
  1.2399 +        }     
  1.2400 +      
  1.2401 +    if(result == KErrNone)     
  1.2402 +        {     
  1.2403 +        SetTestStepResult(EPass);     
  1.2404 +        }     
  1.2405 +             
  1.2406 +    CleanupStack::PopAndDestroy(headerData);     
  1.2407 +__UHEAP_MARKEND;     
  1.2408 +      
  1.2409 +    return TestStepResult();     
  1.2410 +    }     
  1.2411 +         
  1.2412 +TInt CWmdrmCAFReadStep::TestSynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)     
  1.2413 +    {     
  1.2414 +__UHEAP_MARK;     
  1.2415 +    CData* data = NULL;     
  1.2416 +    TInt returnVal = KErrGeneral;     
  1.2417 +         
  1.2418 +    if(aIntent)     
  1.2419 +        {     
  1.2420 +        data = CData::NewL(aHeaderData, EPeek);     
  1.2421 +        }     
  1.2422 +    else     
  1.2423 +        {     
  1.2424 +        data = CData::NewL(aHeaderData);     
  1.2425 +        }     
  1.2426 +         
  1.2427 +    CleanupStack::PushL(data);     
  1.2428 +         
  1.2429 +    if(aInputPacket.Length() <= 0)     
  1.2430 +        {     
  1.2431 +        // dummy output buffer.This loop essentially tests the error condition KErrInsufficientDataPacketLength.     
  1.2432 +        TBuf8<2> outputBuffer;     
  1.2433 +        User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));     
  1.2434 +        }     
  1.2435 +             
  1.2436 +    else     
  1.2437 +        {     
  1.2438 +        HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);     
  1.2439 +        HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());     
  1.2440 +        TPtr8 outputPacketPtr = outputPacket->Des();     
  1.2441 +         
  1.2442 +        User::LeaveIfError(data->Read(*inputPacket, outputPacketPtr));     
  1.2443 +        HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);     
  1.2444 +        if(expectedOutput->Compare(*outputPacket) == KErrNone)     
  1.2445 +            {     
  1.2446 +            returnVal = KErrNone;        
  1.2447 +            }     
  1.2448 +         
  1.2449 +        CleanupStack::PopAndDestroy(3, inputPacket);         
  1.2450 +        }     
  1.2451 +         
  1.2452 +    CleanupStack::PopAndDestroy(data);     
  1.2453 +__UHEAP_MARKEND;     
  1.2454 +         
  1.2455 +    return returnVal;     
  1.2456 +    }     
  1.2457 +         
  1.2458 +TInt CWmdrmCAFReadStep::TestAsynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)     
  1.2459 +    {     
  1.2460 +__UHEAP_MARK;     
  1.2461 +    CData* data = NULL;     
  1.2462 +    TInt returnVal = KErrGeneral;     
  1.2463 +         
  1.2464 +    if(aIntent)     
  1.2465 +        {     
  1.2466 +        data = CData::NewL(aHeaderData, EPeek);     
  1.2467 +        }     
  1.2468 +    else     
  1.2469 +        {     
  1.2470 +        data = CData::NewL(aHeaderData);     
  1.2471 +        }     
  1.2472 +         
  1.2473 +    CleanupStack::PushL(data);     
  1.2474 +         
  1.2475 +    if(aInputPacket.Length() <= 0)     
  1.2476 +        {     
  1.2477 +        TBuf8<2> outputBuffer;     
  1.2478 +        User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));     
  1.2479 +        }     
  1.2480 +             
  1.2481 +    else     
  1.2482 +        {     
  1.2483 +        HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);     
  1.2484 +        HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());     
  1.2485 +        TPtr8 outputPacketPtr = outputPacket->Des();     
  1.2486 +         
  1.2487 +        TRequestStatus status;     
  1.2488 +        data->Read(*inputPacket, outputPacketPtr, status);     
  1.2489 +        User::WaitForRequest(status);     
  1.2490 +         
  1.2491 +        if(status.Int() != KErrNone)     
  1.2492 +            {     
  1.2493 +            CleanupStack::PopAndDestroy(3, data);     
  1.2494 +            return status.Int();     
  1.2495 +            }     
  1.2496 +             
  1.2497 +        HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);     
  1.2498 +        if(expectedOutput->Compare(*outputPacket) == KErrNone)     
  1.2499 +            {     
  1.2500 +            returnVal = KErrNone;     
  1.2501 +            }     
  1.2502 +         
  1.2503 +        CleanupStack::PopAndDestroy(3, inputPacket);     
  1.2504 +        }     
  1.2505 +         
  1.2506 +    CleanupStack::PopAndDestroy(data);     
  1.2507 +__UHEAP_MARKEND;     
  1.2508 +         
  1.2509 +    return returnVal;     
  1.2510 +    }     
  1.2511 +         
  1.2512 +TVerdict CCAFDataAttributeStep::doWmdrmTestStepL()     
  1.2513 +    {     
  1.2514 +    SetTestStepResult(EFail);     
  1.2515 +         
  1.2516 +    TInt attribVal;     
  1.2517 +    GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
  1.2518 +         
  1.2519 +    TInt expectedValue;     
  1.2520 +    GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
  1.2521 +      
  1.2522 +__UHEAP_MARK;     
  1.2523 +    TPtrC header;     
  1.2524 +    HBufC8* headerData = NULL;     
  1.2525 +         
  1.2526 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.2527 +        {     
  1.2528 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.2529 +        }     
  1.2530 +    else     
  1.2531 +        {     
  1.2532 +        headerData = CreateWmdrmHeaderLC();      
  1.2533 +        }     
  1.2534 +             
  1.2535 +    CContent *content = CContent::NewLC(*headerData);     
  1.2536 +    CData *data = content->OpenContentL(EPeek);     
  1.2537 +    TInt value;     
  1.2538 +    User::LeaveIfError(data->GetAttribute(attribVal, value));     
  1.2539 +    delete data;     
  1.2540 +         
  1.2541 +    if(expectedValue == value)     
  1.2542 +        {     
  1.2543 +        SetTestStepResult(EPass);     
  1.2544 +        }     
  1.2545 +    else     
  1.2546 +        {     
  1.2547 +        INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);        
  1.2548 +        }     
  1.2549 +         
  1.2550 +    CleanupStack::PopAndDestroy(2, headerData);                      
  1.2551 +__UHEAP_MARKEND;     
  1.2552 +      
  1.2553 +    return TestStepResult();     
  1.2554 +    }     
  1.2555 +         
  1.2556 +      
  1.2557 +TVerdict CCAFDataAttributeSetStep::doWmdrmTestStepL()     
  1.2558 +    {     
  1.2559 +    SetTestStepResult(EFail);     
  1.2560 +         
  1.2561 +    TInt attribute1;     
  1.2562 +    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  1.2563 +         
  1.2564 +    TInt attribute2;     
  1.2565 +    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  1.2566 +         
  1.2567 +    TInt expectedValue1;     
  1.2568 +    GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  1.2569 +         
  1.2570 +    TInt expectedValue2;     
  1.2571 +    GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  1.2572 +      
  1.2573 +__UHEAP_MARK;     
  1.2574 +      
  1.2575 +    TPtrC header;     
  1.2576 +    HBufC8* headerData = NULL;     
  1.2577 +         
  1.2578 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.2579 +        {     
  1.2580 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.2581 +        }     
  1.2582 +    else     
  1.2583 +        {     
  1.2584 +        headerData = CreateWmdrmHeaderLC();      
  1.2585 +        }     
  1.2586 +         
  1.2587 +    CContent *content = CContent::NewLC(*headerData);     
  1.2588 +    CData *data = content->OpenContentL(EPeek);     
  1.2589 +                     
  1.2590 +    RAttributeSet attributeSet;     
  1.2591 +    CleanupClosePushL(attributeSet);     
  1.2592 +    attributeSet.AddL(attribute1);     
  1.2593 +    attributeSet.AddL(attribute2);     
  1.2594 +             
  1.2595 +    TInt result = data->GetAttributeSet(attributeSet);     
  1.2596 +    delete data;     
  1.2597 +         
  1.2598 +    if(result == KErrNone)     
  1.2599 +        {     
  1.2600 +        TInt value1;         
  1.2601 +        User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
  1.2602 +             
  1.2603 +        TInt value2;     
  1.2604 +        User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
  1.2605 +             
  1.2606 +        if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
  1.2607 +            {     
  1.2608 +            SetTestStepResult(EPass);     
  1.2609 +            }     
  1.2610 +        else     
  1.2611 +            {     
  1.2612 +            INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));     
  1.2613 +            }     
  1.2614 +        }     
  1.2615 +         
  1.2616 +    else     
  1.2617 +        {     
  1.2618 +        INFO_PRINTF1(_L("CData::GetAttributeSet() failed"));     
  1.2619 +        }     
  1.2620 +             
  1.2621 +    CleanupStack::PopAndDestroy(3, headerData);          
  1.2622 +         
  1.2623 +__UHEAP_MARKEND;     
  1.2624 +      
  1.2625 +    return TestStepResult();     
  1.2626 +    }     
  1.2627 +      
  1.2628 +      
  1.2629 +TVerdict CCAFDataStringAttributeStep::doWmdrmTestStepL()     
  1.2630 +    {     
  1.2631 +    SetTestStepResult(EFail);     
  1.2632 +         
  1.2633 +    TInt attribVal;     
  1.2634 +    GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
  1.2635 +         
  1.2636 +    TPtrC expectedValue;     
  1.2637 +    GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
  1.2638 +         
  1.2639 +    TInt expectedResult;     
  1.2640 +    GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
  1.2641 +         
  1.2642 +__UHEAP_MARK;     
  1.2643 +    TPtrC header;     
  1.2644 +    HBufC8* headerData = NULL;     
  1.2645 +         
  1.2646 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.2647 +        {     
  1.2648 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.2649 +        }     
  1.2650 +    else     
  1.2651 +        {     
  1.2652 +        headerData = CreateWmdrmHeaderLC();      
  1.2653 +        }     
  1.2654 +         
  1.2655 +    CContent *content = CContent::NewLC(*headerData);     
  1.2656 +    CData *data = content->OpenContentL(EPeek);     
  1.2657 +                 
  1.2658 +    TBuf <200> value;     
  1.2659 +    TInt result = data->GetStringAttribute(attribVal, value);     
  1.2660 +    delete data;     
  1.2661 +         
  1.2662 +    if(result == expectedResult && value == expectedValue)     
  1.2663 +        {     
  1.2664 +        SetTestStepResult(EPass);     
  1.2665 +        }     
  1.2666 +    else     
  1.2667 +        {     
  1.2668 +        INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
  1.2669 +        INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
  1.2670 +        }     
  1.2671 +             
  1.2672 +    CleanupStack::PopAndDestroy(2, headerData);          
  1.2673 +             
  1.2674 +__UHEAP_MARKEND;     
  1.2675 +      
  1.2676 +    return TestStepResult();     
  1.2677 +    }     
  1.2678 +      
  1.2679 +      
  1.2680 +TVerdict CCAFDataStringAttributeSetStep::doWmdrmTestStepL()     
  1.2681 +    {     
  1.2682 +    SetTestStepResult(EFail);     
  1.2683 +      
  1.2684 +    TInt attribute1;         
  1.2685 +    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  1.2686 +         
  1.2687 +    TInt attribute2;     
  1.2688 +    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  1.2689 +         
  1.2690 +    TPtrC expectedValue1;     
  1.2691 +    GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  1.2692 +         
  1.2693 +    TPtrC expectedValue2;     
  1.2694 +    GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  1.2695 +         
  1.2696 +__UHEAP_MARK;     
  1.2697 +    TPtrC header;     
  1.2698 +    HBufC8* headerData = NULL;     
  1.2699 +         
  1.2700 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.2701 +        {     
  1.2702 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.2703 +        }     
  1.2704 +    else     
  1.2705 +        {     
  1.2706 +        headerData = CreateWmdrmHeaderLC();      
  1.2707 +        }     
  1.2708 +         
  1.2709 +    CContent *content = CContent::NewLC(*headerData);     
  1.2710 +    CData *data = content->OpenContentL(EPeek);     
  1.2711 +         
  1.2712 +    RStringAttributeSet attributeSet;     
  1.2713 +    CleanupClosePushL(attributeSet);     
  1.2714 +    attributeSet.AddL(attribute1);     
  1.2715 +    attributeSet.AddL(attribute2);     
  1.2716 +             
  1.2717 +    TInt result = data->GetStringAttributeSet(attributeSet);     
  1.2718 +    delete data;     
  1.2719 +             
  1.2720 +    TBuf <200> value1;     
  1.2721 +    TBuf <200> value2;     
  1.2722 +    if(result == KErrNone)     
  1.2723 +        {     
  1.2724 +        TInt result3 = attributeSet.GetValue(attribute1, value1);     
  1.2725 +        TInt result4 = attributeSet.GetValue(attribute2, value2);     
  1.2726 +                 
  1.2727 +        if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
  1.2728 +         && result3 == KErrNone && result4 == KErrNone)     
  1.2729 +            {     
  1.2730 +            SetTestStepResult(EPass);     
  1.2731 +            }     
  1.2732 +        else     
  1.2733 +            {     
  1.2734 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
  1.2735 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
  1.2736 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
  1.2737 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
  1.2738 +            }     
  1.2739 +        }     
  1.2740 +    else     
  1.2741 +        {     
  1.2742 +        INFO_PRINTF1(_L("CData::GetStringAttributeSet() failed"));     
  1.2743 +        }        
  1.2744 +         
  1.2745 +    CleanupStack::PopAndDestroy(3, headerData);          
  1.2746 +      
  1.2747 +__UHEAP_MARKEND;     
  1.2748 +      
  1.2749 +    return TestStepResult();     
  1.2750 +    }     
  1.2751 +      
  1.2752 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT