os/security/contentmgmt/referencedrmagent/tcaf/source/Contentstep.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/Contentstep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1271 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2010 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 "contentstep.h"
    1.29 +#include "EmbeddedObject.h"
    1.30 +#include "StreamablePtrArray.h"
    1.31 +#include "attributeset.h"
    1.32 +#include "stringattributeset.h"
    1.33 +#include <caf/agentfactory.h>
    1.34 +
    1.35 +using namespace ContentAccess;
    1.36 +
    1.37 +/* 
    1.38 + * Content attribute step
    1.39 + *
    1.40 + */
    1.41 +
    1.42 +CCAFContentAttributeStep::~CCAFContentAttributeStep()
    1.43 +	{
    1.44 +	}
    1.45 +
    1.46 +CCAFContentAttributeStep::CCAFContentAttributeStep(CCAFServer& aParent) : iParent(aParent)
    1.47 +	{
    1.48 +	SetTestStepName(KCAFContentAttributeStep);
    1.49 +	}
    1.50 +
    1.51 +TVerdict CCAFContentAttributeStep::doTestStepL()
    1.52 +	{
    1.53 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
    1.54 +    TBool wmdrmFlag = EFalse;     
    1.55 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
    1.56 +         
    1.57 +    if(wmdrmFlag)     
    1.58 +        {     
    1.59 +        TVerdict verdict = doWmdrmTestStepL();     
    1.60 +        return verdict;     
    1.61 +        }     
    1.62 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
    1.63 +
    1.64 +	TInt attribute;
    1.65 +	TInt value = KErrNone;
    1.66 +	TInt expectedValue;
    1.67 +	TInt unresolvedUri = EFalse;
    1.68 +	TPtrC uri;
    1.69 +	TPtrC uniqueId;
    1.70 +
    1.71 +	SetTestStepResult(EPass);
    1.72 +
    1.73 +	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
    1.74 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
    1.75 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
    1.76 +	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
    1.77 +	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
    1.78 +	
    1.79 +
    1.80 +	__UHEAP_MARK;
    1.81 +	
    1.82 +	// Open using file name
    1.83 +	CContent *content = CContent::NewLC(uri);
    1.84 +	value = expectedValue+1;
    1.85 +	User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
    1.86 +	if(expectedValue != value )
    1.87 +		{
    1.88 +		SetTestStepResult(EFail);
    1.89 +		INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
    1.90 +		}
    1.91 +	CleanupStack::PopAndDestroy(content);		    		
    1.92 +	
    1.93 +	// Open using file handle
    1.94 +   	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
    1.95 +   	if (!unresolvedUri) 
    1.96 +		{
    1.97 +		RFile file;
    1.98 +		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
    1.99 +		content = CContent::NewLC(file);
   1.100 +		file.Close();
   1.101 +		value = expectedValue+1;
   1.102 +		User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
   1.103 +		if(expectedValue != value)
   1.104 +			{
   1.105 +			SetTestStepResult(EFail);
   1.106 +			INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
   1.107 +			}
   1.108 +		CleanupStack::PopAndDestroy(content);		    		
   1.109 +		}
   1.110 +		
   1.111 +	__UHEAP_MARKEND;
   1.112 +	return TestStepResult();
   1.113 +	}
   1.114 +
   1.115 +/* 
   1.116 + * Content attributeset step
   1.117 + *
   1.118 + */
   1.119 +
   1.120 +CCAFContentAttributeSetStep::~CCAFContentAttributeSetStep()
   1.121 +	{
   1.122 +	}
   1.123 +
   1.124 +CCAFContentAttributeSetStep::CCAFContentAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
   1.125 +	{
   1.126 +	SetTestStepName(KCAFContentAttributeSetStep);
   1.127 +	}
   1.128 +
   1.129 +TVerdict CCAFContentAttributeSetStep::doTestStepL()
   1.130 +	{
   1.131 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
   1.132 +    TBool wmdrmFlag = EFalse;     
   1.133 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
   1.134 +         
   1.135 +    if(wmdrmFlag)     
   1.136 +        {     
   1.137 +        TVerdict verdict = doWmdrmTestStepL();     
   1.138 +        return verdict;     
   1.139 +        }     
   1.140 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
   1.141 +  
   1.142 +	TInt value1;
   1.143 +	TInt value2;
   1.144 +	TInt expectedValue1;
   1.145 +	TInt expectedValue2;
   1.146 +	TInt attribute1;
   1.147 +	TInt attribute2;
   1.148 +	TInt result = KErrNone;
   1.149 +	TInt unresolvedUri = EFalse;
   1.150 +	TPtrC uri;
   1.151 +	TPtrC uniqueId;
   1.152 +
   1.153 +	SetTestStepResult(EPass);
   1.154 +
   1.155 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.156 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
   1.157 +	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
   1.158 +	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
   1.159 +	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
   1.160 +	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
   1.161 +	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
   1.162 +
   1.163 +	__UHEAP_MARK;
   1.164 +	// open using filename
   1.165 +	CContent *content = CContent::NewLC(uri);
   1.166 +	RAttributeSet attributeSet;
   1.167 +	CleanupClosePushL(attributeSet);
   1.168 +	attributeSet.AddL(attribute1);
   1.169 +	attributeSet.AddL(attribute2);
   1.170 +
   1.171 +	if(uniqueId == KDefaultContentObject())
   1.172 +		{
   1.173 +		result = content->GetAttributeSet(attributeSet);
   1.174 +		}
   1.175 +	else
   1.176 +		{
   1.177 +		result = content->GetAttributeSet(attributeSet, uniqueId);
   1.178 +		}
   1.179 +	if(result != KErrNone)
   1.180 +		{
   1.181 +		SetTestStepResult(EFail);
   1.182 +		INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
   1.183 +		}
   1.184 +	
   1.185 +	User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
   1.186 +	User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
   1.187 +	if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
   1.188 +		{
   1.189 +		SetTestStepResult(EFail);
   1.190 +		INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
   1.191 +		}
   1.192 +	CleanupStack::PopAndDestroy(&attributeSet);		
   1.193 +	CleanupStack::PopAndDestroy(content);		
   1.194 +    		
   1.195 +   	// Open using file handle
   1.196 +   	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
   1.197 +   	if (!unresolvedUri) 
   1.198 +		{
   1.199 +		RFile file;
   1.200 +		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
   1.201 +		content = CContent::NewLC(file);
   1.202 +		file.Close(); 		
   1.203 +	    		
   1.204 +		CleanupClosePushL(attributeSet);
   1.205 +		attributeSet.AddL(attribute1);
   1.206 +		attributeSet.AddL(attribute2);
   1.207 +
   1.208 +		result = content->GetAttributeSet(attributeSet, uniqueId);
   1.209 +		if(result != KErrNone)
   1.210 +			{
   1.211 +			SetTestStepResult(EFail);
   1.212 +			INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
   1.213 +			}
   1.214 +			
   1.215 +		User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
   1.216 +		User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
   1.217 +		if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
   1.218 +			{
   1.219 +			SetTestStepResult(EFail);
   1.220 +			INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
   1.221 +			}
   1.222 +		CleanupStack::PopAndDestroy(&attributeSet);		
   1.223 +		CleanupStack::PopAndDestroy(content);		
   1.224 +	   	}
   1.225 +	__UHEAP_MARKEND;
   1.226 +	return TestStepResult();
   1.227 +	}
   1.228 +
   1.229 +
   1.230 +/* 
   1.231 + * Content string attribute step
   1.232 + *
   1.233 + */
   1.234 +
   1.235 +CCAFContentStringAttributeStep::~CCAFContentStringAttributeStep()
   1.236 +	{
   1.237 +	}
   1.238 +
   1.239 +CCAFContentStringAttributeStep::CCAFContentStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
   1.240 +	{
   1.241 +	SetTestStepName(KCAFContentStringAttributeStep);
   1.242 +	}
   1.243 +
   1.244 +TVerdict CCAFContentStringAttributeStep::doTestStepL()
   1.245 +	{
   1.246 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
   1.247 +    TBool wmdrmFlag = EFalse;     
   1.248 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
   1.249 +         
   1.250 +    if(wmdrmFlag)     
   1.251 +        {     
   1.252 +        TVerdict verdict = doWmdrmTestStepL();     
   1.253 +        return verdict;     
   1.254 +        }     
   1.255 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
   1.256 +
   1.257 +	TInt expectedResult;
   1.258 +	TInt attribute;
   1.259 +	TInt unresolvedUri = EFalse;
   1.260 +	TPtrC expectedValue;
   1.261 +	TBuf <200> value;
   1.262 +	TInt result = KErrNone;
   1.263 +	TPtrC uri;
   1.264 +	TPtrC uniqueId;
   1.265 +
   1.266 +	SetTestStepResult(EPass);
   1.267 +
   1.268 +	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
   1.269 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.270 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
   1.271 +	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
   1.272 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.273 +	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
   1.274 +
   1.275 +	__UHEAP_MARK;
   1.276 +	
   1.277 +	// Open using file name
   1.278 +	CContent *content = CContent::NewLC(uri);
   1.279 +	
   1.280 +	if(uniqueId == KDefaultContentObject())
   1.281 +		{
   1.282 +		result = content->GetStringAttribute(attribute, value);
   1.283 +		}
   1.284 +	else
   1.285 +		{
   1.286 +		result = content->GetStringAttribute(attribute, value, uniqueId);
   1.287 +		}
   1.288 +	if(result != expectedResult)
   1.289 +		{
   1.290 +		SetTestStepResult(EFail);
   1.291 +		INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
   1.292 +		}
   1.293 +	if(value != expectedValue)
   1.294 +		{
   1.295 +		SetTestStepResult(EFail);
   1.296 +		INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
   1.297 +		}
   1.298 +
   1.299 +	CleanupStack::PopAndDestroy(content);		
   1.300 +
   1.301 +   	// Open using file handle
   1.302 +   	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
   1.303 +   	if (!unresolvedUri) 
   1.304 +	   	{
   1.305 +		RFile file;
   1.306 +		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
   1.307 +		content = CContent::NewLC(file);
   1.308 +		file.Close(); 		
   1.309 +
   1.310 +		result = content->GetStringAttribute(attribute, value, uniqueId);
   1.311 +		if(result != expectedResult)
   1.312 +			{
   1.313 +			SetTestStepResult(EFail);
   1.314 +			INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
   1.315 +			}
   1.316 +		else if(value != expectedValue)
   1.317 +			{
   1.318 +			SetTestStepResult(EFail);
   1.319 +			INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
   1.320 +			}
   1.321 +		CleanupStack::PopAndDestroy(content);		
   1.322 +		}		
   1.323 +
   1.324 +    		
   1.325 +	__UHEAP_MARKEND;
   1.326 +	return TestStepResult();
   1.327 +	}
   1.328 +
   1.329 +/* 
   1.330 + * Content StringAttributeSet step
   1.331 + *
   1.332 + */
   1.333 +
   1.334 +CCAFContentStringAttributeSetStep::~CCAFContentStringAttributeSetStep()
   1.335 +	{
   1.336 +	}
   1.337 +
   1.338 +CCAFContentStringAttributeSetStep::CCAFContentStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
   1.339 +	{
   1.340 +	SetTestStepName(KCAFContentStringAttributeSetStep);
   1.341 +	}
   1.342 +
   1.343 +TVerdict CCAFContentStringAttributeSetStep::doTestStepL()
   1.344 +	{
   1.345 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
   1.346 +    TBool wmdrmFlag = EFalse;     
   1.347 +    GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
   1.348 +         
   1.349 +    if(wmdrmFlag)     
   1.350 +        {     
   1.351 +        TVerdict verdict = doWmdrmTestStepL();     
   1.352 +        return verdict;     
   1.353 +        }     
   1.354 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
   1.355 +
   1.356 +	TPtrC expectedValue1;
   1.357 +	TPtrC expectedValue2;
   1.358 +	TBuf <200> value1;
   1.359 +	TBuf <200> value2;
   1.360 +	TInt result1;
   1.361 +	TInt result2;
   1.362 +	TInt attribute1;
   1.363 +	TInt attribute2;
   1.364 +	TInt result = KErrNone;
   1.365 +	TInt unresolvedUri = EFalse;
   1.366 +	TPtrC uri;
   1.367 +	TPtrC uniqueId;
   1.368 +
   1.369 +	SetTestStepResult(EPass);
   1.370 +
   1.371 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.372 +	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
   1.373 +	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
   1.374 +	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
   1.375 +	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
   1.376 +	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
   1.377 +	GetIntFromConfig(ConfigSection(),_L("result1"),result1);
   1.378 +	GetIntFromConfig(ConfigSection(),_L("result2"),result2);
   1.379 +	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
   1.380 +
   1.381 +	__UHEAP_MARK;
   1.382 +	
   1.383 +	// Open using file name
   1.384 +	CContent *content = CContent::NewLC(uri);
   1.385 +	RStringAttributeSet attributeSet;
   1.386 +	CleanupClosePushL(attributeSet);
   1.387 +	attributeSet.AddL(attribute1);
   1.388 +	attributeSet.AddL(attribute2);
   1.389 +	
   1.390 +	if(uniqueId == KDefaultContentObject())
   1.391 +		{
   1.392 +		result = content->GetStringAttributeSet(attributeSet);	
   1.393 +		}
   1.394 +	else
   1.395 +		{
   1.396 +		result = content->GetStringAttributeSet(attributeSet, uniqueId);
   1.397 +		}
   1.398 +	if(result != KErrNone)
   1.399 +		{
   1.400 +		SetTestStepResult(EFail);
   1.401 +		INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
   1.402 +		}
   1.403 +	if(result1 != attributeSet.GetValue(attribute1, value1))
   1.404 +		{
   1.405 +		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
   1.406 +		}
   1.407 +	if(result2 != attributeSet.GetValue(attribute2, value2))
   1.408 +		{
   1.409 +		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
   1.410 +		}
   1.411 +	if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
   1.412 +		{
   1.413 +		SetTestStepResult(EFail);
   1.414 +		INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
   1.415 +		}
   1.416 +	CleanupStack::PopAndDestroy(&attributeSet);		
   1.417 +	CleanupStack::PopAndDestroy(content);		
   1.418 +	
   1.419 +    		
   1.420 +   	// Open using file handle
   1.421 +   	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
   1.422 +   	if (!unresolvedUri) 
   1.423 +		{	
   1.424 +		RFile file;
   1.425 +		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
   1.426 +		content = CContent::NewLC(file);
   1.427 +		file.Close(); 		
   1.428 +
   1.429 +		CleanupClosePushL(attributeSet);
   1.430 +		attributeSet.AddL(attribute1);
   1.431 +		attributeSet.AddL(attribute2);
   1.432 +
   1.433 +		result = content->GetStringAttributeSet(attributeSet, uniqueId);	
   1.434 +			
   1.435 +		if(result != KErrNone)
   1.436 +			{
   1.437 +			SetTestStepResult(EFail);
   1.438 +			INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
   1.439 +			}
   1.440 +
   1.441 +		if(result1 != attributeSet.GetValue(attribute1, value1))
   1.442 +			{
   1.443 +			INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
   1.444 +			}
   1.445 +		if(result2 != attributeSet.GetValue(attribute2, value2))
   1.446 +			{
   1.447 +			INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
   1.448 +			}
   1.449 +		
   1.450 +		if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
   1.451 +			{
   1.452 +			SetTestStepResult(EFail);
   1.453 +			INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
   1.454 +			}
   1.455 +		CleanupStack::PopAndDestroy(&attributeSet);		
   1.456 +		CleanupStack::PopAndDestroy(content);		
   1.457 +		}
   1.458 +	__UHEAP_MARKEND;
   1.459 +	return TestStepResult();
   1.460 +	}
   1.461 +
   1.462 +
   1.463 +
   1.464 +/* 
   1.465 + * This step tests the notification functions
   1.466 + *
   1.467 + */
   1.468 +
   1.469 +CCAFContentNotifyStep::~CCAFContentNotifyStep()
   1.470 +	{
   1.471 +	}
   1.472 +
   1.473 +CCAFContentNotifyStep::CCAFContentNotifyStep(CCAFServer& aParent) : iParent(aParent)
   1.474 +	{
   1.475 +	SetTestStepName(KCAFContentNotifyStep);
   1.476 +	}
   1.477 +
   1.478 +
   1.479 +TVerdict CCAFContentNotifyStep::doTestStepL()
   1.480 +	{
   1.481 +	TPtrC uri;
   1.482 +	TInt result;
   1.483 +	TRequestStatus status = KRequestPending;
   1.484 +	
   1.485 +	TInt Status1;
   1.486 +	TInt Cancel1;
   1.487 +	TInt Cancel2;
   1.488 +	
   1.489 +	
   1.490 +	SetTestStepResult(EPass);
   1.491 +
   1.492 +	// Find the file to copy and the expected return code from the INI file
   1.493 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.494 +	GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
   1.495 +	GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
   1.496 +	GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
   1.497 +
   1.498 +	INFO_PRINTF2(_L("Performing notification tests on %S"), &uri);
   1.499 +
   1.500 +	__UHEAP_MARK;
   1.501 +	CContent *content = CContent::NewLC(uri);
   1.502 +	// Wait for rights 
   1.503 +	content->NotifyStatusChange(ERightsAvailable, status);
   1.504 +	User::WaitForRequest(status);
   1.505 +	if(status.Int() != Status1)
   1.506 +		{
   1.507 +		INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
   1.508 +		SetTestStepResult(EFail);
   1.509 +		}
   1.510 +	result = content->CancelNotifyStatusChange(status);
   1.511 +	if(result != Cancel1)
   1.512 +		{
   1.513 +		INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
   1.514 +		SetTestStepResult(EFail);
   1.515 +		}
   1.516 +	
   1.517 +	// Wait for rights expired but cancel before they arrive
   1.518 +	content->NotifyStatusChange(ERightsExpired, status);
   1.519 +	result = content->CancelNotifyStatusChange(status);
   1.520 +	if(result != Cancel2)
   1.521 +		{
   1.522 +		INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
   1.523 +		SetTestStepResult(EFail);
   1.524 +		}
   1.525 +	
   1.526 +	CleanupStack::PopAndDestroy(content);
   1.527 +	
   1.528 +   		
   1.529 +	__UHEAP_MARKEND;
   1.530 +	return TestStepResult();
   1.531 +	}
   1.532 +
   1.533 +/* 
   1.534 + * This step sets a property in the agents
   1.535 + *
   1.536 + */
   1.537 +
   1.538 +CCAFContentSetPropertyStep::~CCAFContentSetPropertyStep()
   1.539 +	{
   1.540 +	}
   1.541 +
   1.542 +CCAFContentSetPropertyStep::CCAFContentSetPropertyStep(CCAFServer& aParent) : iParent(aParent)
   1.543 +	{
   1.544 +	SetTestStepName(KCAFContentSetPropertyStep);
   1.545 +	}
   1.546 +
   1.547 +
   1.548 +TVerdict CCAFContentSetPropertyStep::doTestStepL()
   1.549 +	{
   1.550 +	TInt expectedResult;
   1.551 +	TInt result;
   1.552 +	TPtrC uri;
   1.553 +
   1.554 +	SetTestStepResult(EFail);
   1.555 +
   1.556 +	// Find the file to copy and the expected return code from the INI file
   1.557 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.558 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.559 +
   1.560 +	INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult);
   1.561 +
   1.562 +	__UHEAP_MARK;
   1.563 +
   1.564 +	CContent *content = CContent::NewLC(uri);
   1.565 +	result = content->SetProperty(EAgentPropertyBufferSize, 100);
   1.566 +	CleanupStack::PopAndDestroy(content);
   1.567 +	
   1.568 +	if(result == expectedResult)
   1.569 +		{	
   1.570 +		SetTestStepResult(EPass);
   1.571 +		}
   1.572 +	else 
   1.573 +		{
   1.574 +		INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result);
   1.575 +		}
   1.576 +    		
   1.577 +	__UHEAP_MARKEND;
   1.578 +	return TestStepResult();
   1.579 +	}
   1.580 +
   1.581 +
   1.582 +/* 
   1.583 + * This step asks the agent to display information about a file
   1.584 + *
   1.585 + */
   1.586 +
   1.587 +CCAFContentDisplayInfoStep::~CCAFContentDisplayInfoStep()
   1.588 +	{
   1.589 +	}
   1.590 +
   1.591 +CCAFContentDisplayInfoStep::CCAFContentDisplayInfoStep(CCAFServer& aParent) : iParent(aParent)
   1.592 +	{
   1.593 +	SetTestStepName(KCAFContentDisplayInfoStep);
   1.594 +	}
   1.595 +
   1.596 +
   1.597 +TVerdict CCAFContentDisplayInfoStep::doTestStepL()
   1.598 +	{
   1.599 +	TPtrC uri;
   1.600 +	TInt expectedResult;
   1.601 +	TInt result;
   1.602 +
   1.603 +	SetTestStepResult(EFail);
   1.604 +
   1.605 +	// Find the file to copy and the expected return code from the INI file
   1.606 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.607 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.608 +
   1.609 +	INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult);
   1.610 +
   1.611 +	__UHEAP_MARK;
   1.612 +
   1.613 +	CContent *content = CContent::NewLC(uri);
   1.614 +	TRAP(result, content->DisplayInfoL(EFileProperties));
   1.615 +	CleanupStack::PopAndDestroy(content);
   1.616 +	
   1.617 +	if(result == expectedResult)
   1.618 +		{	
   1.619 +		SetTestStepResult(EPass);
   1.620 +		}
   1.621 +	else 
   1.622 +		{
   1.623 +		INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result);
   1.624 +		}
   1.625 +    		
   1.626 +	__UHEAP_MARKEND;
   1.627 +	return TestStepResult();
   1.628 +	}
   1.629 +
   1.630 +/* 
   1.631 + * This step attempts to perform an agent specific command
   1.632 + *
   1.633 + */
   1.634 +
   1.635 +CCAFContentAgentSpecificStep::~CCAFContentAgentSpecificStep()
   1.636 +	{
   1.637 +	}
   1.638 +
   1.639 +CCAFContentAgentSpecificStep::CCAFContentAgentSpecificStep(CCAFServer& aParent) : iParent(aParent)
   1.640 +	{
   1.641 +	SetTestStepName(KCAFContentAgentSpecificStep);
   1.642 +	}
   1.643 +
   1.644 +
   1.645 +TVerdict CCAFContentAgentSpecificStep::doTestStepL()
   1.646 +	{
   1.647 +	TPtrC input16;
   1.648 +	TPtrC output16;
   1.649 +	TPtrC uri;
   1.650 +	TInt expectedResult;
   1.651 +	TInt command;
   1.652 +	TInt result;
   1.653 +	TBuf8 <100> actualOutput;
   1.654 +	TBuf8 <100> output;
   1.655 +	TBuf8 <100> input;
   1.656 +
   1.657 +
   1.658 +	SetTestStepResult(EPass);
   1.659 +
   1.660 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.661 +	GetIntFromConfig(ConfigSection(),_L("command"),command);
   1.662 +	GetStringFromConfig(ConfigSection(),_L("input"),input16);
   1.663 +	GetStringFromConfig(ConfigSection(),_L("output"),output16);
   1.664 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.665 +
   1.666 +	input.Copy(input16);
   1.667 +	output.Copy(output16);
   1.668 +
   1.669 +	__UHEAP_MARK;
   1.670 +	CContent *content = CContent::NewLC(uri);
   1.671 +
   1.672 +	INFO_PRINTF1(_L("Running synchronous Agent specific command"));
   1.673 +	actualOutput.SetLength(0);
   1.674 +	result = content->AgentSpecificCommand(command, input, actualOutput);
   1.675 +	if(result != expectedResult)
   1.676 +		{	
   1.677 +		SetTestStepResult(EFail);
   1.678 +		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result);
   1.679 +		}
   1.680 +	else if(actualOutput != output)
   1.681 +		{
   1.682 +		SetTestStepResult(EFail);
   1.683 +		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
   1.684 +		}
   1.685 +
   1.686 +	INFO_PRINTF1(_L("Running asynchronous Agent specific command"));
   1.687 +	TRequestStatus status;
   1.688 +	actualOutput.SetLength(0);
   1.689 +	content->AgentSpecificCommand(command, input, actualOutput, status);
   1.690 +	User::WaitForRequest(status);
   1.691 +	if(status.Int() != expectedResult)
   1.692 +		{	
   1.693 +		SetTestStepResult(EFail);
   1.694 +		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int());
   1.695 +		}
   1.696 +	else if(actualOutput != output)
   1.697 +		{
   1.698 +		SetTestStepResult(EFail);
   1.699 +		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
   1.700 +		}
   1.701 +	
   1.702 +	CleanupStack::PopAndDestroy(content);		
   1.703 +    		
   1.704 +	__UHEAP_MARKEND;
   1.705 +	return TestStepResult();
   1.706 +	}
   1.707 +
   1.708 +
   1.709 +/* 
   1.710 + * This step tests the rights request functions
   1.711 + *
   1.712 + */
   1.713 +
   1.714 +CCAFContentRequestRightsStep::~CCAFContentRequestRightsStep()
   1.715 +	{
   1.716 +	}
   1.717 +
   1.718 +CCAFContentRequestRightsStep::CCAFContentRequestRightsStep(CCAFServer& aParent) : iParent(aParent)
   1.719 +	{
   1.720 +	SetTestStepName(KCAFContentRequestRightsStep);
   1.721 +	}
   1.722 +
   1.723 +
   1.724 +TVerdict CCAFContentRequestRightsStep::doTestStepL()
   1.725 +	{
   1.726 +	TPtrC uri;
   1.727 +	TInt result;
   1.728 +	TRequestStatus status = KRequestPending;
   1.729 +	
   1.730 +	TInt Status1;
   1.731 +	TInt Cancel1;
   1.732 +	TInt Cancel2;
   1.733 +	
   1.734 +	
   1.735 +	SetTestStepResult(EPass);
   1.736 +
   1.737 +	// Find the file to copy and the expected return code from the INI file
   1.738 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.739 +	GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
   1.740 +	GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
   1.741 +	GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
   1.742 +
   1.743 +	INFO_PRINTF2(_L("Performing Request Rights tests on %S"), &uri);
   1.744 +
   1.745 +	__UHEAP_MARK;
   1.746 +	CContent *content = CContent::NewLC(uri);
   1.747 +	// Wait for rights 
   1.748 +	content->RequestRights(status);
   1.749 +	User::WaitForRequest(status);
   1.750 +	if(status.Int() != Status1)
   1.751 +		{
   1.752 +		INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
   1.753 +		SetTestStepResult(EFail);
   1.754 +		}
   1.755 +	result = content->CancelRequestRights(status);
   1.756 +	if(result != Cancel1)
   1.757 +		{
   1.758 +		INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
   1.759 +		SetTestStepResult(EFail);
   1.760 +		}
   1.761 +	
   1.762 +	// Wait for rights expired but cancel before they arrive
   1.763 +	content->RequestRights(status);
   1.764 +	result = content->CancelRequestRights(status);
   1.765 +	if(result != Cancel2)
   1.766 +		{
   1.767 +		INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
   1.768 +		SetTestStepResult(EFail);
   1.769 +		}
   1.770 +	
   1.771 +	CleanupStack::PopAndDestroy(content);
   1.772 +	
   1.773 +   		
   1.774 +	__UHEAP_MARKEND;
   1.775 +	return TestStepResult();
   1.776 +	}
   1.777 +
   1.778 +
   1.779 +
   1.780 +/* 
   1.781 + * This step tests the rights request functions
   1.782 + *
   1.783 + */
   1.784 +
   1.785 +CCAFContentEmbeddedObjectsStep::~CCAFContentEmbeddedObjectsStep()
   1.786 +	{
   1.787 +	}
   1.788 +
   1.789 +CCAFContentEmbeddedObjectsStep::CCAFContentEmbeddedObjectsStep(CCAFServer& aParent) : iParent(aParent)
   1.790 +	{
   1.791 +	SetTestStepName(KCAFContentEmbeddedObjectsStep);
   1.792 +	}
   1.793 +
   1.794 +
   1.795 +TVerdict CCAFContentEmbeddedObjectsStep::doTestStepL()
   1.796 +	{
   1.797 +	TPtrC uri;
   1.798 +	TInt expectedCount;
   1.799 +	TInt expectedResult;
   1.800 +	
   1.801 +	SetTestStepResult(EPass);
   1.802 +
   1.803 +	// Find the file to copy and the expected return code from the INI file
   1.804 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.805 +	GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
   1.806 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.807 +
   1.808 +	INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
   1.809 +
   1.810 +	__UHEAP_MARK;
   1.811 +	CContent *content = CContent::NewLC(uri);
   1.812 +
   1.813 +	RStreamablePtrArray <CEmbeddedObject> array;
   1.814 +	CleanupClosePushL(array);
   1.815 +
   1.816 +	// Wait for rights
   1.817 +	TRAPD(result, content->GetEmbeddedObjectsL(array));
   1.818 +	if(result != expectedResult)
   1.819 +		{
   1.820 +		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedResult);
   1.821 +		SetTestStepResult(EFail);
   1.822 +		}
   1.823 +	
   1.824 +	if((result == KErrNone) && (array.Count() != expectedCount))
   1.825 +			{
   1.826 +			INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d objects, expected %d"), array.Count(), expectedCount);
   1.827 +			SetTestStepResult(EFail);
   1.828 +			}
   1.829 +
   1.830 +	CleanupStack::PopAndDestroy(&array);	
   1.831 +	CleanupStack::PopAndDestroy(content);
   1.832 +	
   1.833 +   		
   1.834 +	__UHEAP_MARKEND;
   1.835 +	return TestStepResult();
   1.836 +	}
   1.837 +
   1.838 +/* 
   1.839 + * This step tests the rights request functions
   1.840 + *
   1.841 + */
   1.842 +
   1.843 +CCAFContentEmbeddedObjectTypeStep::~CCAFContentEmbeddedObjectTypeStep()
   1.844 +	{
   1.845 +	}
   1.846 +
   1.847 +CCAFContentEmbeddedObjectTypeStep::CCAFContentEmbeddedObjectTypeStep(CCAFServer& aParent) : iParent(aParent)
   1.848 +	{
   1.849 +	SetTestStepName(KCAFContentEmbeddedObjectTypeStep);
   1.850 +	}
   1.851 +
   1.852 +
   1.853 +TVerdict CCAFContentEmbeddedObjectTypeStep::doTestStepL()
   1.854 +	{
   1.855 +	TPtrC uri;
   1.856 +	TInt expectedContent;
   1.857 +	TInt expectedContainers;
   1.858 +	TInt expectedContainerResult;
   1.859 +	TInt expectedContentResult;
   1.860 +
   1.861 +	SetTestStepResult(EPass);
   1.862 +
   1.863 +	// Find the file to copy and the expected return code from the INI file
   1.864 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.865 +	GetIntFromConfig(ConfigSection(),_L("contentcount"),expectedContent);
   1.866 +	GetIntFromConfig(ConfigSection(),_L("containercount"),expectedContainers);
   1.867 +	GetIntFromConfig(ConfigSection(),_L("containerresult"),expectedContainerResult);
   1.868 +	GetIntFromConfig(ConfigSection(),_L("contentresult"),expectedContentResult);
   1.869 +
   1.870 +	INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
   1.871 +
   1.872 +	__UHEAP_MARK;
   1.873 +	CContent *content = CContent::NewLC(uri);
   1.874 +
   1.875 +	RStreamablePtrArray <CEmbeddedObject> array;
   1.876 +	CleanupClosePushL(array);
   1.877 +
   1.878 +	// get embedded objects
   1.879 +	TRAPD(result, content->GetEmbeddedObjectsL(array, EContainerObject));
   1.880 +
   1.881 +	if(result != expectedContainerResult)
   1.882 +		{
   1.883 +		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContainerResult);
   1.884 +		SetTestStepResult(EFail);
   1.885 +		}
   1.886 +
   1.887 +	if((result == KErrNone) && (array.Count() != expectedContainers))
   1.888 +		{
   1.889 +		INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d container objects, expected %d"), array.Count(), expectedContainers);
   1.890 +		SetTestStepResult(EFail);
   1.891 +		}
   1.892 +
   1.893 +	// clear array
   1.894 +	array.ResetAndDestroy();
   1.895 +	
   1.896 +	// get embedded objects
   1.897 +	TRAP(result, content->GetEmbeddedObjectsL(array, EContentObject));
   1.898 +
   1.899 +	if(result != expectedContentResult)
   1.900 +		{
   1.901 +		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContentResult);
   1.902 +		SetTestStepResult(EFail);
   1.903 +		}
   1.904 +
   1.905 +	if((result == KErrNone) && (array.Count() != expectedContent))
   1.906 +		{
   1.907 +		INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d content objects, expected %d"), array.Count(), expectedContent);
   1.908 +		SetTestStepResult(EFail);
   1.909 +		}
   1.910 +
   1.911 +
   1.912 +	CleanupStack::PopAndDestroy(&array);	
   1.913 +	CleanupStack::PopAndDestroy(content);
   1.914 +	
   1.915 +   		
   1.916 +	__UHEAP_MARKEND;
   1.917 +	return TestStepResult();
   1.918 +	}
   1.919 +
   1.920 +/* 
   1.921 + * This step tests the rights request functions
   1.922 + *
   1.923 + */
   1.924 +
   1.925 +CCAFContentSearchStep::~CCAFContentSearchStep()
   1.926 +	{
   1.927 +	}
   1.928 +
   1.929 +CCAFContentSearchStep::CCAFContentSearchStep(CCAFServer& aParent) : iParent(aParent)
   1.930 +	{
   1.931 +	SetTestStepName(KCAFContentSearchStep);
   1.932 +	}
   1.933 +
   1.934 +
   1.935 +TVerdict CCAFContentSearchStep::doTestStepL()
   1.936 +	{
   1.937 +	TPtrC uri;
   1.938 +	TPtrC mimeType16;
   1.939 +	TInt result;
   1.940 +	TInt expectedCount;
   1.941 +	TInt expectedResult;
   1.942 +	TBuf8 <255> mimeType8;
   1.943 +	
   1.944 +	SetTestStepResult(EPass);
   1.945 +
   1.946 +	// Find the file, mimetype, expected return code and expected count from the INI file
   1.947 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
   1.948 +	GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
   1.949 +	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
   1.950 +	GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType16);
   1.951 +
   1.952 +	mimeType8.Copy(mimeType16);
   1.953 +
   1.954 +	INFO_PRINTF3(_L("Search for embedded %S objects within %S"), &mimeType16, &uri);
   1.955 +
   1.956 +	__UHEAP_MARK;
   1.957 +	CContent *content = CContent::NewLC(uri);
   1.958 +
   1.959 +	RStreamablePtrArray <CEmbeddedObject> array;
   1.960 +	CleanupClosePushL(array);
   1.961 +
   1.962 +	// get embedded objects
   1.963 +	result = content->Search(array, mimeType8, ETrue);
   1.964 +	
   1.965 +	if(result != expectedResult)
   1.966 +		{
   1.967 +		INFO_PRINTF3(_L("Search() return value %d, expected %d"), result, expectedResult);
   1.968 +		SetTestStepResult(EFail);
   1.969 +		}
   1.970 +	
   1.971 +	if(array.Count() != expectedCount)
   1.972 +		{
   1.973 +		INFO_PRINTF3(_L("Search() found %d objects, expected %d"), array.Count(), expectedCount);
   1.974 +		SetTestStepResult(EFail);
   1.975 +		}
   1.976 +
   1.977 +	CleanupStack::PopAndDestroy(&array);	
   1.978 +	CleanupStack::PopAndDestroy(content);
   1.979 +	
   1.980 +   		
   1.981 +	__UHEAP_MARKEND;
   1.982 +	return TestStepResult();
   1.983 +	}
   1.984 +
   1.985 +/* 
   1.986 + * This step tests the container open/close functions
   1.987 + *
   1.988 + */
   1.989 +
   1.990 +CCAFContentContainerStep::~CCAFContentContainerStep()
   1.991 +	{
   1.992 +	}
   1.993 +
   1.994 +CCAFContentContainerStep::CCAFContentContainerStep(CCAFServer& aParent) : iParent(aParent)
   1.995 +	{
   1.996 +	SetTestStepName(KCAFContentContainerStep);
   1.997 +	}
   1.998 +
   1.999 +
  1.1000 +TVerdict CCAFContentContainerStep::doTestStepL()
  1.1001 +	{
  1.1002 +	TPtrC uri;
  1.1003 +	TPtrC uniqueId;
  1.1004 +	TInt result;
  1.1005 +	TInt openResult;
  1.1006 +	TInt closeResult;
  1.1007 +	
  1.1008 +	
  1.1009 +	SetTestStepResult(EPass);
  1.1010 +
  1.1011 +	// Find the file to copy and the expected return code from the INI file
  1.1012 +	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
  1.1013 +	GetStringFromConfig(ConfigSection(),_L("uniqueId"),uniqueId);
  1.1014 +	GetIntFromConfig(ConfigSection(),_L("openResult"),openResult);
  1.1015 +	GetIntFromConfig(ConfigSection(),_L("closeResult"),closeResult);
  1.1016 +
  1.1017 +	INFO_PRINTF2(_L("Opening embedded container within %S"), &uri);
  1.1018 +
  1.1019 +	__UHEAP_MARK;
  1.1020 +	CContent *content = CContent::NewLC(uri);
  1.1021 +
  1.1022 +	result = content->OpenContainer(uniqueId);
  1.1023 +	if(result != openResult)
  1.1024 +		{
  1.1025 +		SetTestStepResult(EFail);	
  1.1026 +		INFO_PRINTF3(_L("OpenContainer() returned %d, expected %d"), result, openResult);
  1.1027 +		}
  1.1028 +	result = content->CloseContainer();
  1.1029 +	if(result != closeResult)
  1.1030 +		{
  1.1031 +		SetTestStepResult(EFail);	
  1.1032 +		INFO_PRINTF3(_L("CloseContainer() returned %d, expected %d"), result, closeResult);
  1.1033 +		}
  1.1034 +	CleanupStack::PopAndDestroy(content);
  1.1035 +   		
  1.1036 +	__UHEAP_MARKEND;
  1.1037 +	return TestStepResult();
  1.1038 +	}
  1.1039 +
  1.1040 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
  1.1041 +      
  1.1042 +// The following methods test the various content attribute APIs for WMDRM content.     
  1.1043 +      
  1.1044 +TVerdict CCAFContentAttributeStep::doWmdrmTestStepL()     
  1.1045 +    {     
  1.1046 +    SetTestStepResult(EFail);     
  1.1047 +         
  1.1048 +    TInt attribVal;     
  1.1049 +    GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
  1.1050 +         
  1.1051 +    TInt expectedValue;     
  1.1052 +    GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
  1.1053 +      
  1.1054 +__UHEAP_MARK;     
  1.1055 +    TPtrC header;     
  1.1056 +    HBufC8* headerData = NULL;     
  1.1057 +         
  1.1058 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.1059 +        {     
  1.1060 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.1061 +        }     
  1.1062 +    else     
  1.1063 +        {     
  1.1064 +        headerData = CreateWmdrmHeaderLC();      
  1.1065 +        }     
  1.1066 +             
  1.1067 +    CContent *content = CContent::NewLC(*headerData);     
  1.1068 +    TInt value;     
  1.1069 +    User::LeaveIfError(content->GetAttribute(attribVal, value));     
  1.1070 +         
  1.1071 +    if(expectedValue == value)     
  1.1072 +        {     
  1.1073 +        SetTestStepResult(EPass);     
  1.1074 +        }     
  1.1075 +    else     
  1.1076 +        {     
  1.1077 +        INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);     
  1.1078 +        }     
  1.1079 +         
  1.1080 +    CleanupStack::PopAndDestroy(2, headerData);                      
  1.1081 +__UHEAP_MARKEND;     
  1.1082 +      
  1.1083 +    return TestStepResult();     
  1.1084 +    }     
  1.1085 +         
  1.1086 +      
  1.1087 +TVerdict CCAFContentAttributeSetStep::doWmdrmTestStepL()     
  1.1088 +    {     
  1.1089 +    SetTestStepResult(EFail);     
  1.1090 +         
  1.1091 +    TInt attribute1;     
  1.1092 +    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  1.1093 +         
  1.1094 +    TInt attribute2;     
  1.1095 +    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  1.1096 +         
  1.1097 +    TInt expectedValue1;     
  1.1098 +    GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  1.1099 +         
  1.1100 +    TInt expectedValue2;     
  1.1101 +    GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  1.1102 +      
  1.1103 +__UHEAP_MARK;     
  1.1104 +      
  1.1105 +    TPtrC header;     
  1.1106 +    HBufC8* headerData = NULL;     
  1.1107 +         
  1.1108 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.1109 +        {     
  1.1110 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.1111 +        }     
  1.1112 +    else     
  1.1113 +        {     
  1.1114 +        headerData = CreateWmdrmHeaderLC();      
  1.1115 +        }     
  1.1116 +         
  1.1117 +    CContent *content = CContent::NewLC(*headerData);     
  1.1118 +                     
  1.1119 +    RAttributeSet attributeSet;     
  1.1120 +    CleanupClosePushL(attributeSet);     
  1.1121 +    attributeSet.AddL(attribute1);     
  1.1122 +    attributeSet.AddL(attribute2);     
  1.1123 +             
  1.1124 +    TInt result = content->GetAttributeSet(attributeSet);     
  1.1125 +    if(result == KErrNone)     
  1.1126 +        {     
  1.1127 +        TInt value1;         
  1.1128 +        User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
  1.1129 +             
  1.1130 +        TInt value2;     
  1.1131 +        User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
  1.1132 +             
  1.1133 +        if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
  1.1134 +            {     
  1.1135 +            SetTestStepResult(EPass);     
  1.1136 +            }     
  1.1137 +        else     
  1.1138 +            {     
  1.1139 +            INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));     
  1.1140 +            }     
  1.1141 +        }     
  1.1142 +         
  1.1143 +    else     
  1.1144 +        {     
  1.1145 +        INFO_PRINTF1(_L("CContent::GetAttributeSet() failed"));     
  1.1146 +        }     
  1.1147 +             
  1.1148 +    CleanupStack::PopAndDestroy(3, headerData);          
  1.1149 +         
  1.1150 +__UHEAP_MARKEND;     
  1.1151 +      
  1.1152 +    return TestStepResult();     
  1.1153 +    }     
  1.1154 +      
  1.1155 +      
  1.1156 +TVerdict CCAFContentStringAttributeStep::doWmdrmTestStepL()     
  1.1157 +    {     
  1.1158 +    SetTestStepResult(EFail);     
  1.1159 +         
  1.1160 +    TInt attribVal;     
  1.1161 +    GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
  1.1162 +         
  1.1163 +    TPtrC expectedValue;     
  1.1164 +    GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
  1.1165 +         
  1.1166 +    TInt expectedResult;     
  1.1167 +    GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
  1.1168 +         
  1.1169 +__UHEAP_MARK;     
  1.1170 +    TPtrC header;     
  1.1171 +    HBufC8* headerData = NULL;     
  1.1172 +         
  1.1173 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.1174 +        {     
  1.1175 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.1176 +        }     
  1.1177 +    else     
  1.1178 +        {     
  1.1179 +        headerData = CreateWmdrmHeaderLC();      
  1.1180 +        }     
  1.1181 +         
  1.1182 +    CContent *content = CContent::NewLC(*headerData);     
  1.1183 +                 
  1.1184 +    TBuf <200> value;     
  1.1185 +    TInt result = content->GetStringAttribute(attribVal, value);     
  1.1186 +    if(result == expectedResult && value == expectedValue)     
  1.1187 +        {     
  1.1188 +        SetTestStepResult(EPass);     
  1.1189 +        }     
  1.1190 +    else     
  1.1191 +        {     
  1.1192 +        INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
  1.1193 +        INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
  1.1194 +        }     
  1.1195 +             
  1.1196 +    CleanupStack::PopAndDestroy(2, headerData);          
  1.1197 +             
  1.1198 +__UHEAP_MARKEND;     
  1.1199 +      
  1.1200 +    return TestStepResult();     
  1.1201 +    }     
  1.1202 +      
  1.1203 +      
  1.1204 +TVerdict CCAFContentStringAttributeSetStep::doWmdrmTestStepL()     
  1.1205 +    {     
  1.1206 +    SetTestStepResult(EFail);     
  1.1207 +      
  1.1208 +    TInt attribute1;         
  1.1209 +    GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
  1.1210 +         
  1.1211 +    TInt attribute2;     
  1.1212 +    GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
  1.1213 +         
  1.1214 +    TPtrC expectedValue1;     
  1.1215 +    GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
  1.1216 +         
  1.1217 +    TPtrC expectedValue2;     
  1.1218 +    GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
  1.1219 +         
  1.1220 +__UHEAP_MARK;     
  1.1221 +    TPtrC header;     
  1.1222 +    HBufC8* headerData = NULL;     
  1.1223 +         
  1.1224 +    if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
  1.1225 +        {     
  1.1226 +        headerData = ConvertDes16toHBufC8LC(header);     
  1.1227 +        }     
  1.1228 +    else     
  1.1229 +        {     
  1.1230 +        headerData = CreateWmdrmHeaderLC();      
  1.1231 +        }     
  1.1232 +         
  1.1233 +    CContent *content = CContent::NewLC(*headerData);     
  1.1234 +         
  1.1235 +    RStringAttributeSet attributeSet;     
  1.1236 +    CleanupClosePushL(attributeSet);     
  1.1237 +    attributeSet.AddL(attribute1);     
  1.1238 +    attributeSet.AddL(attribute2);     
  1.1239 +             
  1.1240 +    TInt result = content->GetStringAttributeSet(attributeSet);     
  1.1241 +    TBuf <200> value1;     
  1.1242 +    TBuf <200> value2;     
  1.1243 +    if(result == KErrNone)     
  1.1244 +        {     
  1.1245 +        TInt result3 = attributeSet.GetValue(attribute1, value1);     
  1.1246 +        TInt result4 = attributeSet.GetValue(attribute2, value2);     
  1.1247 +                 
  1.1248 +        if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
  1.1249 +         && result3 == KErrNone && result4 == KErrNone)     
  1.1250 +            {     
  1.1251 +            SetTestStepResult(EPass);     
  1.1252 +            }     
  1.1253 +        else     
  1.1254 +            {     
  1.1255 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
  1.1256 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
  1.1257 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
  1.1258 +            INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
  1.1259 +            }     
  1.1260 +        }     
  1.1261 +    else     
  1.1262 +        {     
  1.1263 +        INFO_PRINTF1(_L("CContent::GetStringAttributeSet() failed"));     
  1.1264 +        }        
  1.1265 +         
  1.1266 +    CleanupStack::PopAndDestroy(3, headerData);          
  1.1267 +      
  1.1268 +__UHEAP_MARKEND;     
  1.1269 +      
  1.1270 +    return TestStepResult();     
  1.1271 +    }     
  1.1272 +      
  1.1273 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
  1.1274 +