os/security/contentmgmt/referencedrmagent/tcaf/source/CafutilsStep.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/CafutilsStep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,950 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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 <s32mem.h>
    1.24 +#include <caf/caf.h>
    1.25 +#include <caf/rightsinfo.h>
    1.26 +#include <caf/manager.h>
    1.27 +#include <caf/supplieroutputfile.h>
    1.28 +#include "cafserver.h"
    1.29 +#include "CafUtilsStep.h"
    1.30 +
    1.31 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    1.32 +#include "refcafhelper.h"
    1.33 +#include <caf/cafhelper.h>     
    1.34 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
    1.35 +
    1.36 +using namespace ContentAccess;
    1.37 +
    1.38 +
    1.39 +CCafCDirStreamStep::~CCafCDirStreamStep()
    1.40 +	{
    1.41 +	}
    1.42 +
    1.43 +CCafCDirStreamStep::CCafCDirStreamStep(CCAFServer& aParent) : iParent(aParent)
    1.44 +	{
    1.45 +	SetTestStepName(KCAFCDirStreamStep);
    1.46 +	}
    1.47 +
    1.48 +
    1.49 +TVerdict CCafCDirStreamStep::doTestStepL()
    1.50 +	{
    1.51 +	SetTestStepResult(EPass);
    1.52 +
    1.53 +	_LIT(KTcafDir, "C:\\tcaf\\");
    1.54 +	
    1.55 +	INFO_PRINTF1(_L("CDirStreamable test"));
    1.56 +	
    1.57 +
    1.58 +	__UHEAP_MARK;
    1.59 +	
    1.60 +	CManager *manager = CManager::NewLC();
    1.61 +	
    1.62 +	CDir *fileList = NULL;
    1.63 +	User::LeaveIfError(manager->GetDir(KTcafDir(),KNullUid, ESortByName, fileList));
    1.64 +	
    1.65 +	CDirStreamable *newFileList = CDirStreamable::NewL(*fileList);
    1.66 +	delete fileList;
    1.67 +	
    1.68 +	// Create a buffer
    1.69 +	CBufFlat* buf = CBufFlat::NewL(50);
    1.70 +	CleanupStack::PushL(buf);
    1.71 +	
    1.72 +	// create write stream
    1.73 +	RBufWriteStream writeStream(*buf);
    1.74 +	CleanupClosePushL(writeStream);
    1.75 +
    1.76 +	// write the directory to the stream
    1.77 +	newFileList->ExternalizeL(writeStream);
    1.78 +	CleanupStack::PopAndDestroy(&writeStream);
    1.79 +
    1.80 +	// create read stream
    1.81 +	RBufReadStream readStream(*buf);
    1.82 +	CleanupClosePushL(readStream);
    1.83 +
    1.84 +	// construct a new CDirStreamable from the stream
    1.85 +	CDirStreamable *streamDir = CDirStreamable::NewL(readStream);
    1.86 +	CleanupStack::PopAndDestroy(&readStream);
    1.87 +	
    1.88 +	for(TInt i = 0; i < newFileList->Count(); i++)
    1.89 +		{
    1.90 +		if((*newFileList)[i].iName != (*streamDir)[i].iName)
    1.91 +			{
    1.92 +			SetTestStepResult(EFail);
    1.93 +			}
    1.94 +		if((*newFileList)[i].iType != (*streamDir)[i].iType)
    1.95 +			{
    1.96 +			SetTestStepResult(EFail);
    1.97 +			}
    1.98 +		}
    1.99 +	
   1.100 +	CleanupStack::PopAndDestroy(buf);
   1.101 +	
   1.102 +	delete newFileList;
   1.103 +	delete streamDir;
   1.104 +	CleanupStack::PopAndDestroy(manager);
   1.105 +	
   1.106 +	__UHEAP_MARKEND;
   1.107 +
   1.108 +	return TestStepResult();
   1.109 +	}
   1.110 +
   1.111 +CCafRAttributeSetStreamStep::~CCafRAttributeSetStreamStep()
   1.112 +	{
   1.113 +	}
   1.114 +
   1.115 +CCafRAttributeSetStreamStep::CCafRAttributeSetStreamStep(CCAFServer& aParent) : iParent(aParent)
   1.116 +	{
   1.117 +	SetTestStepName(KCAFRAttributeSetStreamStep);
   1.118 +	}
   1.119 +
   1.120 +
   1.121 +TVerdict CCafRAttributeSetStreamStep::doTestStepL()
   1.122 +	{
   1.123 +	SetTestStepResult(EPass);
   1.124 +	
   1.125 +	INFO_PRINTF1(_L("CRAttributeSet streaming test"));
   1.126 +	
   1.127 +	__UHEAP_MARK;
   1.128 +	
   1.129 +
   1.130 +	RAttributeSet aSet;
   1.131 +	CleanupClosePushL(aSet);
   1.132 +	aSet.AddL(EIsProtected);
   1.133 +	aSet.AddL(EIsForwardable);
   1.134 +	aSet.AddL(EIsForwardable);
   1.135 +	
   1.136 +	aSet.SetValue(EIsProtected, (TInt) ETrue, KErrNone);
   1.137 +	aSet.SetValue(EIsForwardable, (TInt) EFalse, KErrNone);
   1.138 +		
   1.139 +	// Create a buffer
   1.140 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.141 +	CleanupStack::PushL(buf);
   1.142 +	
   1.143 +	// create write stream
   1.144 +	RBufWriteStream writeStream(*buf);
   1.145 +	CleanupClosePushL(writeStream);
   1.146 +
   1.147 +	// write the directory to the stream
   1.148 +	aSet.ExternalizeL(writeStream);
   1.149 +	CleanupStack::PopAndDestroy(&writeStream);
   1.150 +
   1.151 +	// create read stream
   1.152 +	RBufReadStream readStream(*buf);
   1.153 +	CleanupClosePushL(readStream);
   1.154 +
   1.155 +	// construct a new CDirStreamable from the stream
   1.156 +	RAttributeSet bSet;
   1.157 +	CleanupClosePushL(bSet);
   1.158 +	bSet.InternalizeL(readStream);
   1.159 +		
   1.160 +	TInt valueA, valueB;
   1.161 +	if(aSet.Count() != bSet.Count())
   1.162 +		{
   1.163 +		SetTestStepResult(EFail);
   1.164 +		}
   1.165 +	
   1.166 +	for(TInt i = 0; i < aSet.Count(); i++)
   1.167 +		{
   1.168 +		valueA = -1;
   1.169 +		valueB = -1;
   1.170 +		if(aSet.GetValue(aSet[i],valueA) != bSet.GetValue(aSet[i],valueB))
   1.171 +			{
   1.172 +			SetTestStepResult(EFail);
   1.173 +			}
   1.174 +			
   1.175 +		if(valueA != valueB)
   1.176 +			{
   1.177 +			SetTestStepResult(EFail);
   1.178 +			}
   1.179 +		}
   1.180 +	
   1.181 +	CleanupStack::PopAndDestroy(&bSet);
   1.182 +	CleanupStack::PopAndDestroy(&readStream);
   1.183 +	CleanupStack::PopAndDestroy(buf);
   1.184 +	CleanupStack::PopAndDestroy(&aSet);
   1.185 +	
   1.186 +	__UHEAP_MARKEND;
   1.187 +
   1.188 +	return TestStepResult();
   1.189 +	}
   1.190 +
   1.191 +
   1.192 +CCafRStringAttributeSetStreamStep::~CCafRStringAttributeSetStreamStep()
   1.193 +	{
   1.194 +	}
   1.195 +
   1.196 +CCafRStringAttributeSetStreamStep::CCafRStringAttributeSetStreamStep(CCAFServer& aParent) : iParent(aParent)
   1.197 +	{
   1.198 +	SetTestStepName(KCAFRStringAttributeSetStreamStep);
   1.199 +	}
   1.200 +
   1.201 +
   1.202 +TVerdict CCafRStringAttributeSetStreamStep::doTestStepL()
   1.203 +	{
   1.204 +	SetTestStepResult(EPass);
   1.205 +	
   1.206 +	INFO_PRINTF1(_L("CRStringAttributeSet streaming test"));
   1.207 +	
   1.208 +	_LIT(KMimeType,"mime/type");
   1.209 +
   1.210 +	__UHEAP_MARK;
   1.211 +	
   1.212 +	RStringAttributeSet aSet;
   1.213 +	CleanupClosePushL(aSet);
   1.214 +	aSet.AddL(EMimeType);
   1.215 +	aSet.AddL(EDescription);
   1.216 +	
   1.217 +	// Set some values, normally be done by the agent
   1.218 +	aSet.SetValue(EMimeType, KMimeType(), KErrNone);	
   1.219 +	aSet.SetValue(EDescription, KNullDesC(), KErrNotSupported);	
   1.220 +	
   1.221 +	// Create a buffer
   1.222 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.223 +	CleanupStack::PushL(buf);
   1.224 +	
   1.225 +	// create write stream
   1.226 +	RBufWriteStream writeStream(*buf);
   1.227 +	CleanupClosePushL(writeStream);
   1.228 +
   1.229 +	// write the directory to the stream
   1.230 +	aSet.ExternalizeL(writeStream);
   1.231 +	CleanupStack::PopAndDestroy(&writeStream);
   1.232 +
   1.233 +	// create read stream
   1.234 +	RBufReadStream readStream(*buf);
   1.235 +	CleanupClosePushL(readStream);
   1.236 +
   1.237 +	// construct a new CDirStreamable from the stream
   1.238 +	RStringAttributeSet bSet;
   1.239 +	CleanupClosePushL(bSet);
   1.240 +	bSet.InternalizeL(readStream);
   1.241 +		
   1.242 +	TBuf <1024> valueA;
   1.243 +	TBuf <1024> valueB;
   1.244 +	if(aSet.Count() != bSet.Count())
   1.245 +		{
   1.246 +		SetTestStepResult(EFail);
   1.247 +		}
   1.248 +	
   1.249 +	for(TInt i = 0; i < aSet.Count(); i++)
   1.250 +		{
   1.251 +		valueA.SetLength(0);
   1.252 +		valueB.SetLength(0);
   1.253 +		if(aSet.GetValue(aSet[i],valueA) != bSet.GetValue(aSet[i],valueB))
   1.254 +			{
   1.255 +			SetTestStepResult(EFail);
   1.256 +			}
   1.257 +			
   1.258 +		if(valueA != valueB)
   1.259 +			{
   1.260 +			SetTestStepResult(EFail);
   1.261 +			}
   1.262 +		}
   1.263 +	
   1.264 +	CleanupStack::PopAndDestroy(&bSet);
   1.265 +	CleanupStack::PopAndDestroy(&readStream);
   1.266 +	CleanupStack::PopAndDestroy(buf);
   1.267 +	CleanupStack::PopAndDestroy(&aSet);
   1.268 +	
   1.269 +	__UHEAP_MARKEND;
   1.270 +
   1.271 +	return TestStepResult();
   1.272 +	}
   1.273 +
   1.274 +
   1.275 +
   1.276 +CCafSupplierOutputFileStreamStep::~CCafSupplierOutputFileStreamStep()
   1.277 +	{
   1.278 +	}
   1.279 +
   1.280 +CCafSupplierOutputFileStreamStep::CCafSupplierOutputFileStreamStep(CCAFServer& aParent) : iParent(aParent)
   1.281 +	{
   1.282 +	SetTestStepName(KCAFSupplierOutputFileStreamStep);
   1.283 +	}
   1.284 +
   1.285 +
   1.286 +TVerdict CCafSupplierOutputFileStreamStep::doTestStepL()
   1.287 +	{
   1.288 +	SetTestStepResult(EPass);
   1.289 +
   1.290 +	_LIT(KDummyName, "C:\\tcaf\\supplieroutputfile.txt");
   1.291 +	_LIT8(KDummyType, "something//caf");
   1.292 +	
   1.293 +	INFO_PRINTF1(_L("CSupplierOutputFile test"));
   1.294 +	
   1.295 +
   1.296 +	__UHEAP_MARK;
   1.297 +	
   1.298 +	CSupplierOutputFile *outputFile = CSupplierOutputFile::NewL(KDummyName(), EContent, KDummyType());
   1.299 +	
   1.300 +	// Create a buffer
   1.301 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.302 +	CleanupStack::PushL(buf);
   1.303 +	
   1.304 +	// create write stream
   1.305 +	RBufWriteStream writeStream(*buf);
   1.306 +	CleanupClosePushL(writeStream);
   1.307 +
   1.308 +	// write the directory to the stream
   1.309 +	outputFile->ExternalizeL(writeStream);
   1.310 +	CleanupStack::PopAndDestroy(&writeStream);
   1.311 +
   1.312 +	// create read stream
   1.313 +	RBufReadStream readStream(*buf);
   1.314 +	CleanupClosePushL(readStream);
   1.315 +
   1.316 +	// construct a new CSupplierOutputFile from the stream
   1.317 +	CSupplierOutputFile *outputFile2= CSupplierOutputFile::NewL(readStream);
   1.318 +	CleanupStack::PopAndDestroy(&readStream);
   1.319 +	
   1.320 +	if(outputFile->FileName() != outputFile2->FileName())
   1.321 +			{
   1.322 +			SetTestStepResult(EFail);
   1.323 +			}
   1.324 +	if(outputFile->OutputType() != outputFile2->OutputType())
   1.325 +			{
   1.326 +			SetTestStepResult(EFail);
   1.327 +			}
   1.328 +	if(outputFile->MimeTypeL() != outputFile2->MimeTypeL())
   1.329 +			{
   1.330 +			SetTestStepResult(EFail);
   1.331 +			}
   1.332 +	
   1.333 +	CleanupStack::PopAndDestroy(buf);
   1.334 +	
   1.335 +	delete outputFile;
   1.336 +	delete outputFile2;
   1.337 +	
   1.338 +	__UHEAP_MARKEND;
   1.339 +
   1.340 +	return TestStepResult();
   1.341 +	}
   1.342 +
   1.343 +CCafMetaDataArrayStep::~CCafMetaDataArrayStep()
   1.344 +	{
   1.345 +	}
   1.346 +
   1.347 +CCafMetaDataArrayStep::CCafMetaDataArrayStep(CCAFServer& aParent) : iParent(aParent)
   1.348 +	{
   1.349 +	SetTestStepName(KCAFMetaDataArrayStep);
   1.350 +	}
   1.351 +
   1.352 +
   1.353 +TVerdict CCafMetaDataArrayStep::doTestStepL()
   1.354 +	{
   1.355 +	SetTestStepResult(EPass);
   1.356 +
   1.357 +	_LIT(KTest1, "Cat");
   1.358 +	_LIT(KValue1, "Sat");
   1.359 +
   1.360 +	_LIT8(KTest2, "Mellow");
   1.361 +	_LIT8(KValue2, "Yellow");
   1.362 +
   1.363 +	_LIT8(KTest3, "Tree");
   1.364 +	_LIT8(KValue3, "House");
   1.365 +
   1.366 +	
   1.367 +	INFO_PRINTF1(_L("CMetaDataArray test"));
   1.368 +	
   1.369 +
   1.370 +	__UHEAP_MARK;
   1.371 +	
   1.372 +	CMetaDataArray *array = CMetaDataArray::NewLC();
   1.373 +	array->AddL(KTest1(), KValue1());
   1.374 +	array->AddL(KTest2(), KValue2());
   1.375 +	array->AddL(KTest3(), KValue3());
   1.376 +	
   1.377 +	// Create a buffer
   1.378 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.379 +	CleanupStack::PushL(buf);
   1.380 +	
   1.381 +	// create write stream
   1.382 +	RBufWriteStream writeStream(*buf);
   1.383 +	CleanupClosePushL(writeStream);
   1.384 +
   1.385 +	// write the directory to the stream
   1.386 +	array->ExternalizeL(writeStream);
   1.387 +	CleanupStack::PopAndDestroy(&writeStream);
   1.388 +
   1.389 +	// create read stream
   1.390 +	RBufReadStream readStream(*buf);
   1.391 +	CleanupClosePushL(readStream);
   1.392 +
   1.393 +	// construct a new CSupplierOutputFile from the stream
   1.394 +	CMetaDataArray *array2= CMetaDataArray::NewL(readStream);
   1.395 +	CleanupStack::PopAndDestroy(&readStream);
   1.396 +	
   1.397 +	
   1.398 +	if(array->Count() != array2->Count() || (*array)[0].Field() != KTest1() || (*array)[1].Data8() != KValue2())
   1.399 +			{
   1.400 +			SetTestStepResult(EFail);
   1.401 +			}
   1.402 +	for(TInt i = 0; i < array->Count(); i++)
   1.403 +		{
   1.404 +		const CMetaData &a = (*array)[i];
   1.405 +		const CMetaData &b = (*array2)[i];
   1.406 +		if(a.Field() != b.Field())
   1.407 +			{
   1.408 +			SetTestStepResult(EFail);
   1.409 +			}
   1.410 +		if(a.Field8() != b.Field8())
   1.411 +			{
   1.412 +			SetTestStepResult(EFail);
   1.413 +			}
   1.414 +		if(a.Data() != b.Data())
   1.415 +			{
   1.416 +			SetTestStepResult(EFail);
   1.417 +			}
   1.418 +		if(a.Data8() != b.Data8())
   1.419 +			{
   1.420 +			SetTestStepResult(EFail);
   1.421 +			}
   1.422 +		}
   1.423 +	
   1.424 +	delete array2;
   1.425 +		
   1.426 +	CleanupStack::PopAndDestroy(buf);
   1.427 +	CleanupStack::PopAndDestroy(array);
   1.428 +	
   1.429 +	__UHEAP_MARKEND;
   1.430 +
   1.431 +	return TestStepResult();
   1.432 +	}
   1.433 +
   1.434 +
   1.435 +CCafEmbeddedObjectStep::~CCafEmbeddedObjectStep()
   1.436 +	{
   1.437 +	}
   1.438 +
   1.439 +CCafEmbeddedObjectStep::CCafEmbeddedObjectStep(CCAFServer& aParent) : iParent(aParent)
   1.440 +	{
   1.441 +	SetTestStepName(KCAFEmbeddedObjectStep);
   1.442 +	}
   1.443 +
   1.444 +
   1.445 +TVerdict CCafEmbeddedObjectStep::doTestStepL()
   1.446 +	{
   1.447 +	SetTestStepResult(EPass);
   1.448 +
   1.449 +	_LIT(KTestUniqueId, "The UniqueId");
   1.450 +	_LIT(KTestName, "The Name");
   1.451 +
   1.452 +	_LIT8(KTestMimeType, "The mime type");
   1.453 +
   1.454 +	
   1.455 +	INFO_PRINTF1(_L("CEmbeddedObject test"));
   1.456 +	
   1.457 +
   1.458 +	__UHEAP_MARK;
   1.459 +	
   1.460 +	CEmbeddedObject *aObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject);
   1.461 +	
   1.462 +	// Create a buffer
   1.463 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.464 +	CleanupStack::PushL(buf);
   1.465 +	
   1.466 +	// create write stream
   1.467 +	RBufWriteStream writeStream(*buf);
   1.468 +	CleanupClosePushL(writeStream);
   1.469 +
   1.470 +	// write the directory to the stream
   1.471 +	aObject->ExternalizeL(writeStream);
   1.472 +	CleanupStack::PopAndDestroy(&writeStream);
   1.473 +
   1.474 +	// create read stream
   1.475 +	RBufReadStream readStream(*buf);
   1.476 +	CleanupClosePushL(readStream);
   1.477 +
   1.478 +	// construct a new CSupplierOutputFile from the stream
   1.479 +	CEmbeddedObject *bObject= CEmbeddedObject::NewL(readStream);
   1.480 +	CleanupStack::PopAndDestroy(&readStream);
   1.481 +	
   1.482 +	
   1.483 +	if(aObject->UniqueId() != bObject->UniqueId())
   1.484 +			{
   1.485 +			SetTestStepResult(EFail);
   1.486 +			}
   1.487 +			
   1.488 +	if(aObject->Name() != bObject->Name())
   1.489 +			{
   1.490 +			SetTestStepResult(EFail);
   1.491 +			}			
   1.492 +	if(aObject->Type() != bObject->Type())
   1.493 +			{
   1.494 +			SetTestStepResult(EFail);
   1.495 +			}			
   1.496 +	if(aObject->MimeType() != bObject->MimeType())
   1.497 +			{
   1.498 +			SetTestStepResult(EFail);
   1.499 +			}			
   1.500 +	
   1.501 +	CleanupStack::PopAndDestroy(buf);
   1.502 +	delete aObject;
   1.503 +	delete bObject;
   1.504 +	
   1.505 +	__UHEAP_MARKEND;
   1.506 +
   1.507 +	return TestStepResult();
   1.508 +	}
   1.509 +
   1.510 +CCafVirtualPathStep::~CCafVirtualPathStep()
   1.511 +	{
   1.512 +	}
   1.513 +
   1.514 +CCafVirtualPathStep::CCafVirtualPathStep(CCAFServer& aParent) : iParent(aParent)
   1.515 +	{
   1.516 +	SetTestStepName(KCAFVirtualPathStep);
   1.517 +	}
   1.518 +
   1.519 +
   1.520 +TVerdict CCafVirtualPathStep::doTestStepL()
   1.521 +	{
   1.522 +	SetTestStepResult(EPass);
   1.523 +	INFO_PRINTF1(_L("CVirtualPath test"));
   1.524 +	_LIT(KTestUniqueId, "The UniqueId");
   1.525 +	_LIT(KTestUri, "A URI");
   1.526 +	_LIT(KSection,"virtualpath");
   1.527 +	_LIT(KDefaultUniqueID,"DEFAULT");
   1.528 +	TPtrC uri;
   1.529 +	TPtrC uniqueID;
   1.530 +	TPtrC combined;
   1.531 +	TPtrC expecteduniqueid;
   1.532 +	TPtrC expecteduri;
   1.533 +	__UHEAP_MARK;
   1.534 +	
   1.535 +	/* test the creation of TVirtualPathPtr and CVirtualPath objects and check if they contain
   1.536 +	 * the expected URI and UniqueID values.
   1.537 +	 */
   1.538 +	TInt i;
   1.539 +	for(i = 0;i<6;i++)
   1.540 +		{
   1.541 +		TBuf<13> sectionName(KSection);
   1.542 +		sectionName.AppendNum(i);
   1.543 +		GetStringFromConfig(sectionName,_L("uri"),uri);
   1.544 +		GetStringFromConfig(sectionName,_L("uniqueID"),uniqueID);
   1.545 +		GetStringFromConfig(sectionName,_L("combined"),combined);
   1.546 +		GetStringFromConfig(sectionName,_L("expecteduri"),expecteduri);
   1.547 +		GetStringFromConfig(sectionName,_L("expecteduniqueid"),expecteduniqueid);
   1.548 +		// Test the TVirtualPathPtr API
   1.549 +		TVirtualPathPtr vPath(uri,uniqueID);
   1.550 +		if(vPath.URI()!=expecteduri)
   1.551 +			{
   1.552 +			INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI());
   1.553 +			SetTestStepResult(EFail);
   1.554 +			}
   1.555 +		if(vPath.UniqueId()!=expecteduniqueid)
   1.556 +			{
   1.557 +			INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed uniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId());
   1.558 +			SetTestStepResult(EFail);
   1.559 +			}
   1.560 +		vPath=TVirtualPathPtr(combined);
   1.561 +		if(vPath.URI()!=expecteduri)
   1.562 +			{
   1.563 +			INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed Uri() for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI());
   1.564 +			SetTestStepResult(EFail);
   1.565 +			}
   1.566 +		if(vPath.UniqueId()!=expecteduniqueid)
   1.567 +			{
   1.568 +			INFO_PRINTF4(_L("TVirtualPathPtr(aCombinedUriUniqueId) failed UniqueID() for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId());
   1.569 +			SetTestStepResult(EFail);
   1.570 +			}
   1.571 +		vPath=combined;
   1.572 +		if(vPath.URI()!=expecteduri)
   1.573 +			{
   1.574 +			INFO_PRINTF4(_L("TVirtualPathPtr operator = failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI());
   1.575 +			SetTestStepResult(EFail);
   1.576 +			}
   1.577 +		if(vPath.UniqueId()!=expecteduniqueid)
   1.578 +			{
   1.579 +			INFO_PRINTF4(_L("TVirtualPathPtr operator = UniqueId for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId());
   1.580 +			SetTestStepResult(EFail);
   1.581 +			}
   1.582 +		// Test the CVirtualPath API
   1.583 +		CVirtualPath* heapPath = CVirtualPath::NewL(uri,uniqueID);
   1.584 +		if(heapPath->URI()!=expecteduri)
   1.585 +			{
   1.586 +			INFO_PRINTF4(_L("TCVirtualPath::NewL(uri,uniqueID) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&heapPath->URI());
   1.587 +			SetTestStepResult(EFail);
   1.588 +			}
   1.589 +		if(heapPath->UniqueId()!=expecteduniqueid)
   1.590 +			{
   1.591 +			INFO_PRINTF4(_L("CVirtualPath::NewL(uri,uniqueID) failed UniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&heapPath->UniqueId());;
   1.592 +			SetTestStepResult(EFail);
   1.593 +			}
   1.594 +		if(heapPath->GetCombinedUriUniqueId()!=combined)
   1.595 +			{
   1.596 +			INFO_PRINTF4(_L("CVirtualPath::NewL(uri,uniqueID) failed GetCombinedUriUniqueId() for %S\nExpected %S\nGot %S"),&combined,&combined,&heapPath->GetCombinedUriUniqueId());
   1.597 +			SetTestStepResult(EFail);
   1.598 +			}
   1.599 +		delete heapPath;
   1.600 +		heapPath=NULL;
   1.601 +		
   1.602 +		heapPath = CVirtualPath::NewL(combined);
   1.603 +		if(heapPath->URI()!=expecteduri)
   1.604 +			{
   1.605 +			INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&heapPath->URI());
   1.606 +			SetTestStepResult(EFail);
   1.607 +			}
   1.608 +		if(heapPath->UniqueId()!=expecteduniqueid)
   1.609 +			{
   1.610 +			INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed UniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&heapPath->UniqueId());
   1.611 +			SetTestStepResult(EFail);
   1.612 +			}
   1.613 +		if(heapPath->GetCombinedUriUniqueId()!=combined)
   1.614 +			{
   1.615 +			INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed GetCombinedUriUniqueId() for %S\nExpected %S\nGot %S"),&combined,&combined,&heapPath->GetCombinedUriUniqueId());
   1.616 +			SetTestStepResult(EFail);
   1.617 +			}
   1.618 +		delete heapPath;
   1.619 +		heapPath=NULL;
   1.620 +		}
   1.621 +
   1.622 +
   1.623 +	CVirtualPath *aPath= CVirtualPath::NewL(KTestUri(), KTestUniqueId());
   1.624 +	
   1.625 +	// Create a buffer
   1.626 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.627 +	CleanupStack::PushL(buf);
   1.628 +	
   1.629 +	// create write stream
   1.630 +	RBufWriteStream writeStream(*buf);
   1.631 +	CleanupClosePushL(writeStream);
   1.632 +
   1.633 +	// write the directory to the stream
   1.634 +	aPath->ExternalizeL(writeStream);
   1.635 +	CleanupStack::PopAndDestroy(&writeStream);
   1.636 +
   1.637 +	// create read stream
   1.638 +	RBufReadStream readStream(*buf);
   1.639 +	CleanupClosePushL(readStream);
   1.640 +
   1.641 +	// construct a new CSupplierOutputFile from the stream
   1.642 +	CVirtualPath *bPath= CVirtualPath::NewL(readStream);
   1.643 +	CleanupStack::PopAndDestroy(&readStream);
   1.644 +	
   1.645 +	
   1.646 +	if(aPath->UniqueId() != bPath->UniqueId())
   1.647 +			{
   1.648 +			SetTestStepResult(EFail);
   1.649 +			}
   1.650 +			
   1.651 +	if(aPath->URI() != bPath->URI())
   1.652 +			{
   1.653 +			SetTestStepResult(EFail);
   1.654 +			}			
   1.655 +
   1.656 +	// Test that if a uniqueID of length greater than ContentAccess::KMaxCafUniqueId
   1.657 +	// is given then it will not treat it as a valid uniqueID
   1.658 +	HBufC* longUID = HBufC::NewLC(aPath->UniqueId().Length() * 100+aPath->URI().Length()+1);
   1.659 +	longUID->Des().Append(aPath->URI());
   1.660 +	longUID->Des().Append(KCafVirtualPathSeparator);
   1.661 +	// create a very long concatenated URI and UniqueID
   1.662 +	for ( i = 0; i < 100; ++i )
   1.663 +		{
   1.664 +		longUID->Des().Append(aPath->UniqueId());
   1.665 +		}
   1.666 +	// create a TVirtualPathPtr with the concatenated URI and UniqueID
   1.667 +	TVirtualPathPtr longPath(longUID->Des());
   1.668 +	// check if the expected URI and UniqueID are stored
   1.669 +	if(longPath.URI()!=longUID->Des())
   1.670 +		{
   1.671 +		SetTestStepResult(EFail);
   1.672 +		}
   1.673 +	if(longPath.UniqueId()!=KDefaultUniqueID)
   1.674 +		{
   1.675 +		SetTestStepResult(EFail);
   1.676 +		}
   1.677 +		
   1.678 +	CleanupStack::PopAndDestroy(longUID);
   1.679 +	CleanupStack::PopAndDestroy(buf);
   1.680 +	delete aPath;
   1.681 +	delete bPath;
   1.682 +	
   1.683 +	
   1.684 +	__UHEAP_MARKEND;
   1.685 +
   1.686 +	return TestStepResult();
   1.687 +	}
   1.688 +
   1.689 +
   1.690 +
   1.691 +CCafRightsInfoStep::~CCafRightsInfoStep()
   1.692 +	{
   1.693 +	}
   1.694 +
   1.695 +CCafRightsInfoStep::CCafRightsInfoStep(CCAFServer& aParent) : iParent(aParent)
   1.696 +	{
   1.697 +	SetTestStepName(KCAFRightsInfoStep);
   1.698 +	}
   1.699 +
   1.700 +
   1.701 +TVerdict CCafRightsInfoStep::doTestStepL()
   1.702 +	{
   1.703 +	SetTestStepResult(EPass);
   1.704 +
   1.705 +	_LIT(KTestUniqueId, "The UniqueId");
   1.706 +	_LIT(KTestDescription, "A Description");
   1.707 +
   1.708 +	INFO_PRINTF1(_L("CRightsInfo test"));
   1.709 +	
   1.710 +
   1.711 +	__UHEAP_MARK;
   1.712 +	
   1.713 +	CRightsInfo *aRights= CRightsInfo::NewL(KTestDescription(), KTestUniqueId(), ERightsTypeConsumable, ERightsStatusNone);
   1.714 +	
   1.715 +	
   1.716 +	// Create a buffer
   1.717 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.718 +	CleanupStack::PushL(buf);
   1.719 +	
   1.720 +	// create write stream
   1.721 +	RBufWriteStream writeStream(*buf);
   1.722 +	CleanupClosePushL(writeStream);
   1.723 +
   1.724 +	// write the directory to the stream
   1.725 +	aRights->ExternalizeL(writeStream);
   1.726 +	CleanupStack::PopAndDestroy(&writeStream);
   1.727 +
   1.728 +	// create read stream
   1.729 +	RBufReadStream readStream(*buf);
   1.730 +	CleanupClosePushL(readStream);
   1.731 +
   1.732 +	// construct a new CSupplierOutputFile from the stream
   1.733 +	CRightsInfo *bRights= CRightsInfo::NewL(readStream);
   1.734 +	CleanupStack::PopAndDestroy(&readStream);
   1.735 +	
   1.736 +	
   1.737 +	if(aRights->UniqueId() != bRights->UniqueId())
   1.738 +			{
   1.739 +			SetTestStepResult(EFail);
   1.740 +			}
   1.741 +			
   1.742 +	if(aRights->Description() != bRights->Description())
   1.743 +			{
   1.744 +			SetTestStepResult(EFail);
   1.745 +			}			
   1.746 +
   1.747 +	if(aRights->RightsType() != bRights->RightsType())
   1.748 +			{
   1.749 +			SetTestStepResult(EFail);
   1.750 +			}			
   1.751 +
   1.752 +	if(aRights->RightsStatus() != bRights->RightsStatus())
   1.753 +			{
   1.754 +			SetTestStepResult(EFail);
   1.755 +			}			
   1.756 +	
   1.757 +	CleanupStack::PopAndDestroy(buf);
   1.758 +	delete aRights;
   1.759 +	delete bRights;
   1.760 +	
   1.761 +	__UHEAP_MARKEND;
   1.762 +
   1.763 +	return TestStepResult();
   1.764 +	}
   1.765 +
   1.766 +
   1.767 +
   1.768 +CCafStreamablePtrArrayStep::~CCafStreamablePtrArrayStep()
   1.769 +	{
   1.770 +	}
   1.771 +
   1.772 +CCafStreamablePtrArrayStep::CCafStreamablePtrArrayStep(CCAFServer& aParent) : iParent(aParent)
   1.773 +	{
   1.774 +	SetTestStepName(KCAFStreamablePtrArrayStep);
   1.775 +	}
   1.776 +
   1.777 +
   1.778 +TVerdict CCafStreamablePtrArrayStep::doTestStepL()
   1.779 +	{
   1.780 +	SetTestStepResult(EPass);
   1.781 +
   1.782 +	_LIT(KTestUniqueId, "The UniqueId");
   1.783 +	_LIT(KTestName, "The Name");
   1.784 +	_LIT8(KTestMimeType, "The mime type");
   1.785 +
   1.786 +	INFO_PRINTF1(_L("StreamablePtrArray test"));
   1.787 +	
   1.788 +	__UHEAP_MARK;
   1.789 +	
   1.790 +	RStreamablePtrArray <CEmbeddedObject> array;
   1.791 +	
   1.792 +	CEmbeddedObject *aObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject);
   1.793 +	CEmbeddedObject *bObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject);
   1.794 +	CEmbeddedObject *cObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject);
   1.795 +	
   1.796 +	array.AppendL(aObject);
   1.797 +	array.AppendL(bObject);
   1.798 +	array.AppendL(cObject);
   1.799 +	
   1.800 +
   1.801 +	// Create a buffer
   1.802 +	CBufFlat* buf = CBufFlat::NewL(50);
   1.803 +	CleanupStack::PushL(buf);
   1.804 +	
   1.805 +	// create write stream
   1.806 +	RBufWriteStream writeStream(*buf);
   1.807 +	CleanupClosePushL(writeStream);
   1.808 +
   1.809 +	// write the directory to the stream
   1.810 +	array.ExternalizeL(writeStream);
   1.811 +	CleanupStack::PopAndDestroy(&writeStream);
   1.812 +
   1.813 +	// create read stream
   1.814 +	RBufReadStream readStream(*buf);
   1.815 +	CleanupClosePushL(readStream);
   1.816 +
   1.817 +	// construct a new CSupplierOutputFile from the stream
   1.818 +	RStreamablePtrArray <CEmbeddedObject> bArray;
   1.819 +	bArray.InternalizeL(readStream);
   1.820 +	CleanupStack::PopAndDestroy(&readStream);
   1.821 +	
   1.822 +	if(array.Count() != bArray.Count())
   1.823 +			{
   1.824 +			SetTestStepResult(EFail);
   1.825 +			}
   1.826 +			
   1.827 +	for(TInt i=0; i < array.Count(); i++)
   1.828 +		{
   1.829 +		if(array[i]->UniqueId() != bArray[i]->UniqueId())
   1.830 +			{
   1.831 +			SetTestStepResult(EFail);
   1.832 +			}
   1.833 +			
   1.834 +		if(array[i]->Name() != bArray[i]->Name())
   1.835 +			{
   1.836 +			SetTestStepResult(EFail);
   1.837 +			}			
   1.838 +		}
   1.839 +	
   1.840 +	CleanupStack::PopAndDestroy(buf);
   1.841 +	array.Close();
   1.842 +	bArray.Close();
   1.843 +	
   1.844 +	__UHEAP_MARKEND;
   1.845 +
   1.846 +	return TestStepResult();
   1.847 +	}
   1.848 +
   1.849 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   1.850 +
   1.851 +CCafHelperStep::~CCafHelperStep()
   1.852 +    {     
   1.853 +    }     
   1.854 +  
   1.855 +CCafHelperStep::CCafHelperStep()
   1.856 +    {     
   1.857 +    SetTestStepName(KCAFHelperStep);     
   1.858 +    }     
   1.859 +      
   1.860 +      
   1.861 +TVerdict CCafHelperStep::doTestStepL()     
   1.862 +    {     
   1.863 +    SetTestStepResult(EFail);     
   1.864 +__UHEAP_MARK;     
   1.865 +         
   1.866 +    TInt result;     
   1.867 +         
   1.868 +    TInt error;     
   1.869 +    GetIntFromConfig(ConfigSection(),_L("error"),error);     
   1.870 +         
   1.871 +    TInt expectedValue;     
   1.872 +    GetIntFromConfig(ConfigSection(),_L("expected"),expectedValue);     
   1.873 +         
   1.874 +    // fileheader case.     
   1.875 +    TPtrC uri;     
   1.876 +    if (!GetStringFromConfig(ConfigSection(), _L("uri"), uri))     
   1.877 +        {     
   1.878 +        INFO_PRINTF1(_L("CCafHelper test : HeaderData case."));     
   1.879 +        result = TestHeaderDataCaseL(error);     
   1.880 +        }     
   1.881 +             
   1.882 +    else     
   1.883 +        {     
   1.884 +        TBool isFileName = EFalse;     
   1.885 +        GetBoolFromConfig(ConfigSection(),_L("flag"),isFileName);     
   1.886 +             
   1.887 +        // filehandle case     
   1.888 +        if(isFileName == EFalse)     
   1.889 +            {     
   1.890 +            INFO_PRINTF1(_L("CCafHelper test : FileHandle case."));     
   1.891 +            result = TestFileHandleCaseL(error, uri);     
   1.892 +            }     
   1.893 +             
   1.894 +        // filename case.     
   1.895 +        else     
   1.896 +            {     
   1.897 +            INFO_PRINTF1(_L("CCafHelper test : FileName case."));     
   1.898 +         
   1.899 +            CCAFHelper* helperObj = CCAFHelper::NewL();     
   1.900 +            CleanupStack::PushL(helperObj);     
   1.901 +             
   1.902 +            result = (*helperObj)().HandleCAFErrorL(error, uri);     
   1.903 +            CleanupStack::PopAndDestroy(helperObj);     
   1.904 +            }        
   1.905 +        }     
   1.906 +         
   1.907 +    if(result == expectedValue)     
   1.908 +        {     
   1.909 +        SetTestStepResult(EPass);     
   1.910 +        }     
   1.911 +             
   1.912 +__UHEAP_MARKEND;     
   1.913 +             
   1.914 +    return TestStepResult();     
   1.915 +    }     
   1.916 +         
   1.917 +TInt CCafHelperStep::TestFileHandleCaseL(TInt aError, const TDesC& aFileName)     
   1.918 +    {     
   1.919 +__UHEAP_MARK;     
   1.920 +    RFs fs;     
   1.921 +    RFile fileHandle;     
   1.922 +    User::LeaveIfError(fs.Connect());     
   1.923 +    CleanupClosePushL(fs);     
   1.924 +    User::LeaveIfError(fileHandle.Open(fs, aFileName, EFileRead));     
   1.925 +    CleanupClosePushL(fileHandle);     
   1.926 +         
   1.927 +    CCAFHelper* helperObj = CCAFHelper::NewL();     
   1.928 +    CleanupStack::PushL(helperObj);     
   1.929 +    TInt result = (*helperObj)().HandleCAFErrorL(aError, fileHandle);     
   1.930 +    CleanupStack::PopAndDestroy(3, &fs);     
   1.931 +__UHEAP_MARKEND;     
   1.932 +      
   1.933 +    return result;     
   1.934 +    }     
   1.935 +         
   1.936 +TInt CCafHelperStep::TestHeaderDataCaseL(TInt aError)     
   1.937 +    {     
   1.938 +    _LIT8(KFileHeaderData,"W\0R\0M\0H\0E\0A\0D\0E\0R\0");     
   1.939 +      
   1.940 +__UHEAP_MARK;        
   1.941 +    CCAFHelper* helperObj = CCAFHelper::NewL();     
   1.942 +    CleanupStack::PushL(helperObj);     
   1.943 +         
   1.944 +    TInt result = (*helperObj)().HandleCAFErrorL(aError, KFileHeaderData);     
   1.945 +    CleanupStack::PopAndDestroy(helperObj);     
   1.946 +__UHEAP_MARKEND;     
   1.947 +      
   1.948 +    return result;     
   1.949 +    }     
   1.950 +         
   1.951 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
   1.952 +
   1.953 +