contentmgmt/referencedrmagent/tcaf/source/Contentstep.cpp
changeset 15 da2ae96f639b
child 45 030c4fbc13d7
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     1 /*
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <test/testexecutelog.h>
       
    20 #include <caf/content.h>
       
    21 #include <caf/data.h>
       
    22 #include <caf/attribute.h>
       
    23 #include "cafserver.h"
       
    24 #include "bitset.h"
       
    25 #include "contentstep.h"
       
    26 #include "embeddedobject.h"
       
    27 #include "streamableptrarray.h"
       
    28 #include "attributeset.h"
       
    29 #include "stringattributeset.h"
       
    30 #include <caf/agentfactory.h>
       
    31 
       
    32 using namespace ContentAccess;
       
    33 
       
    34 /* 
       
    35  * Content attribute step
       
    36  *
       
    37  */
       
    38 
       
    39 CCAFContentAttributeStep::~CCAFContentAttributeStep()
       
    40 	{
       
    41 	}
       
    42 
       
    43 CCAFContentAttributeStep::CCAFContentAttributeStep(CCAFServer& aParent) : iParent(aParent)
       
    44 	{
       
    45 	SetTestStepName(KCAFContentAttributeStep);
       
    46 	}
       
    47 
       
    48 TVerdict CCAFContentAttributeStep::doTestStepL()
       
    49 	{
       
    50 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
    51     TBool wmdrmFlag = EFalse;     
       
    52     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
    53          
       
    54     if(wmdrmFlag)     
       
    55         {     
       
    56         TVerdict verdict = doWmdrmTestStepL();     
       
    57         return verdict;     
       
    58         }     
       
    59 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
       
    60 
       
    61 	TInt attribute;
       
    62 	TInt value = KErrNone;
       
    63 	TInt expectedValue;
       
    64 	TInt unresolvedUri = EFalse;
       
    65 	TPtrC uri;
       
    66 	TPtrC uniqueId;
       
    67 
       
    68 	SetTestStepResult(EPass);
       
    69 
       
    70 	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
       
    71 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
    72 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
       
    73 	GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
       
    74 	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
       
    75 	
       
    76 
       
    77 	__UHEAP_MARK;
       
    78 	
       
    79 	// Open using file name
       
    80 	CContent *content = CContent::NewLC(uri);
       
    81 	value = expectedValue+1;
       
    82 	User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
       
    83 	if(expectedValue != value )
       
    84 		{
       
    85 		SetTestStepResult(EFail);
       
    86 		INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
       
    87 		}
       
    88 	CleanupStack::PopAndDestroy(content);		    		
       
    89 	
       
    90 	// Open using file handle
       
    91    	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
       
    92    	if (!unresolvedUri) 
       
    93 		{
       
    94 		RFile file;
       
    95 		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
       
    96 		content = CContent::NewLC(file);
       
    97 		file.Close();
       
    98 		value = expectedValue+1;
       
    99 		User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
       
   100 		if(expectedValue != value)
       
   101 			{
       
   102 			SetTestStepResult(EFail);
       
   103 			INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
       
   104 			}
       
   105 		CleanupStack::PopAndDestroy(content);		    		
       
   106 		}
       
   107 		
       
   108 	__UHEAP_MARKEND;
       
   109 	return TestStepResult();
       
   110 	}
       
   111 
       
   112 /* 
       
   113  * Content attributeset step
       
   114  *
       
   115  */
       
   116 
       
   117 CCAFContentAttributeSetStep::~CCAFContentAttributeSetStep()
       
   118 	{
       
   119 	}
       
   120 
       
   121 CCAFContentAttributeSetStep::CCAFContentAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
       
   122 	{
       
   123 	SetTestStepName(KCAFContentAttributeSetStep);
       
   124 	}
       
   125 
       
   126 TVerdict CCAFContentAttributeSetStep::doTestStepL()
       
   127 	{
       
   128 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   129     TBool wmdrmFlag = EFalse;     
       
   130     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
   131          
       
   132     if(wmdrmFlag)     
       
   133         {     
       
   134         TVerdict verdict = doWmdrmTestStepL();     
       
   135         return verdict;     
       
   136         }     
       
   137 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   138   
       
   139 	TInt value1;
       
   140 	TInt value2;
       
   141 	TInt expectedValue1;
       
   142 	TInt expectedValue2;
       
   143 	TInt attribute1;
       
   144 	TInt attribute2;
       
   145 	TInt result = KErrNone;
       
   146 	TInt unresolvedUri = EFalse;
       
   147 	TPtrC uri;
       
   148 	TPtrC uniqueId;
       
   149 
       
   150 	SetTestStepResult(EPass);
       
   151 
       
   152 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   153 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
       
   154 	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
       
   155 	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
       
   156 	GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
       
   157 	GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
       
   158 	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
       
   159 
       
   160 	__UHEAP_MARK;
       
   161 	// open using filename
       
   162 	CContent *content = CContent::NewLC(uri);
       
   163 	RAttributeSet attributeSet;
       
   164 	CleanupClosePushL(attributeSet);
       
   165 	attributeSet.AddL(attribute1);
       
   166 	attributeSet.AddL(attribute2);
       
   167 
       
   168 	if(uniqueId == KDefaultContentObject())
       
   169 		{
       
   170 		result = content->GetAttributeSet(attributeSet);
       
   171 		}
       
   172 	else
       
   173 		{
       
   174 		result = content->GetAttributeSet(attributeSet, uniqueId);
       
   175 		}
       
   176 	if(result != KErrNone)
       
   177 		{
       
   178 		SetTestStepResult(EFail);
       
   179 		INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
       
   180 		}
       
   181 	
       
   182 	User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
       
   183 	User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
       
   184 	if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
       
   185 		{
       
   186 		SetTestStepResult(EFail);
       
   187 		INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
       
   188 		}
       
   189 	CleanupStack::PopAndDestroy(&attributeSet);		
       
   190 	CleanupStack::PopAndDestroy(content);		
       
   191     		
       
   192    	// Open using file handle
       
   193    	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
       
   194    	if (!unresolvedUri) 
       
   195 		{
       
   196 		RFile file;
       
   197 		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
       
   198 		content = CContent::NewLC(file);
       
   199 		file.Close(); 		
       
   200 	    		
       
   201 		CleanupClosePushL(attributeSet);
       
   202 		attributeSet.AddL(attribute1);
       
   203 		attributeSet.AddL(attribute2);
       
   204 
       
   205 		result = content->GetAttributeSet(attributeSet, uniqueId);
       
   206 		if(result != KErrNone)
       
   207 			{
       
   208 			SetTestStepResult(EFail);
       
   209 			INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
       
   210 			}
       
   211 			
       
   212 		User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
       
   213 		User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
       
   214 		if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
       
   215 			{
       
   216 			SetTestStepResult(EFail);
       
   217 			INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
       
   218 			}
       
   219 		CleanupStack::PopAndDestroy(&attributeSet);		
       
   220 		CleanupStack::PopAndDestroy(content);		
       
   221 	   	}
       
   222 	__UHEAP_MARKEND;
       
   223 	return TestStepResult();
       
   224 	}
       
   225 
       
   226 
       
   227 /* 
       
   228  * Content string attribute step
       
   229  *
       
   230  */
       
   231 
       
   232 CCAFContentStringAttributeStep::~CCAFContentStringAttributeStep()
       
   233 	{
       
   234 	}
       
   235 
       
   236 CCAFContentStringAttributeStep::CCAFContentStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
       
   237 	{
       
   238 	SetTestStepName(KCAFContentStringAttributeStep);
       
   239 	}
       
   240 
       
   241 TVerdict CCAFContentStringAttributeStep::doTestStepL()
       
   242 	{
       
   243 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   244     TBool wmdrmFlag = EFalse;     
       
   245     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
   246          
       
   247     if(wmdrmFlag)     
       
   248         {     
       
   249         TVerdict verdict = doWmdrmTestStepL();     
       
   250         return verdict;     
       
   251         }     
       
   252 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
       
   253 
       
   254 	TInt expectedResult;
       
   255 	TInt attribute;
       
   256 	TInt unresolvedUri = EFalse;
       
   257 	TPtrC expectedValue;
       
   258 	TBuf <200> value;
       
   259 	TInt result = KErrNone;
       
   260 	TPtrC uri;
       
   261 	TPtrC uniqueId;
       
   262 
       
   263 	SetTestStepResult(EPass);
       
   264 
       
   265 	GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
       
   266 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   267 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
       
   268 	GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
       
   269 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   270 	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
       
   271 
       
   272 	__UHEAP_MARK;
       
   273 	
       
   274 	// Open using file name
       
   275 	CContent *content = CContent::NewLC(uri);
       
   276 	
       
   277 	if(uniqueId == KDefaultContentObject())
       
   278 		{
       
   279 		result = content->GetStringAttribute(attribute, value);
       
   280 		}
       
   281 	else
       
   282 		{
       
   283 		result = content->GetStringAttribute(attribute, value, uniqueId);
       
   284 		}
       
   285 	if(result != expectedResult)
       
   286 		{
       
   287 		SetTestStepResult(EFail);
       
   288 		INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
       
   289 		}
       
   290 	if(value != expectedValue)
       
   291 		{
       
   292 		SetTestStepResult(EFail);
       
   293 		INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
       
   294 		}
       
   295 
       
   296 	CleanupStack::PopAndDestroy(content);		
       
   297 
       
   298    	// Open using file handle
       
   299    	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
       
   300    	if (!unresolvedUri) 
       
   301 	   	{
       
   302 		RFile file;
       
   303 		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
       
   304 		content = CContent::NewLC(file);
       
   305 		file.Close(); 		
       
   306 
       
   307 		result = content->GetStringAttribute(attribute, value, uniqueId);
       
   308 		if(result != expectedResult)
       
   309 			{
       
   310 			SetTestStepResult(EFail);
       
   311 			INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
       
   312 			}
       
   313 		else if(value != expectedValue)
       
   314 			{
       
   315 			SetTestStepResult(EFail);
       
   316 			INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
       
   317 			}
       
   318 		CleanupStack::PopAndDestroy(content);		
       
   319 		}		
       
   320 
       
   321     		
       
   322 	__UHEAP_MARKEND;
       
   323 	return TestStepResult();
       
   324 	}
       
   325 
       
   326 /* 
       
   327  * Content StringAttributeSet step
       
   328  *
       
   329  */
       
   330 
       
   331 CCAFContentStringAttributeSetStep::~CCAFContentStringAttributeSetStep()
       
   332 	{
       
   333 	}
       
   334 
       
   335 CCAFContentStringAttributeSetStep::CCAFContentStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
       
   336 	{
       
   337 	SetTestStepName(KCAFContentStringAttributeSetStep);
       
   338 	}
       
   339 
       
   340 TVerdict CCAFContentStringAttributeSetStep::doTestStepL()
       
   341 	{
       
   342 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   343     TBool wmdrmFlag = EFalse;     
       
   344     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
   345          
       
   346     if(wmdrmFlag)     
       
   347         {     
       
   348         TVerdict verdict = doWmdrmTestStepL();     
       
   349         return verdict;     
       
   350         }     
       
   351 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
       
   352 
       
   353 	TPtrC expectedValue1;
       
   354 	TPtrC expectedValue2;
       
   355 	TBuf <200> value1;
       
   356 	TBuf <200> value2;
       
   357 	TInt result1;
       
   358 	TInt result2;
       
   359 	TInt attribute1;
       
   360 	TInt attribute2;
       
   361 	TInt result = KErrNone;
       
   362 	TInt unresolvedUri = EFalse;
       
   363 	TPtrC uri;
       
   364 	TPtrC uniqueId;
       
   365 
       
   366 	SetTestStepResult(EPass);
       
   367 
       
   368 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   369 	GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
       
   370 	GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
       
   371 	GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
       
   372 	GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
       
   373 	GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
       
   374 	GetIntFromConfig(ConfigSection(),_L("result1"),result1);
       
   375 	GetIntFromConfig(ConfigSection(),_L("result2"),result2);
       
   376 	GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
       
   377 
       
   378 	__UHEAP_MARK;
       
   379 	
       
   380 	// Open using file name
       
   381 	CContent *content = CContent::NewLC(uri);
       
   382 	RStringAttributeSet attributeSet;
       
   383 	CleanupClosePushL(attributeSet);
       
   384 	attributeSet.AddL(attribute1);
       
   385 	attributeSet.AddL(attribute2);
       
   386 	
       
   387 	if(uniqueId == KDefaultContentObject())
       
   388 		{
       
   389 		result = content->GetStringAttributeSet(attributeSet);	
       
   390 		}
       
   391 	else
       
   392 		{
       
   393 		result = content->GetStringAttributeSet(attributeSet, uniqueId);
       
   394 		}
       
   395 	if(result != KErrNone)
       
   396 		{
       
   397 		SetTestStepResult(EFail);
       
   398 		INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
       
   399 		}
       
   400 	if(result1 != attributeSet.GetValue(attribute1, value1))
       
   401 		{
       
   402 		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
       
   403 		}
       
   404 	if(result2 != attributeSet.GetValue(attribute2, value2))
       
   405 		{
       
   406 		INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
       
   407 		}
       
   408 	if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
       
   409 		{
       
   410 		SetTestStepResult(EFail);
       
   411 		INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
       
   412 		}
       
   413 	CleanupStack::PopAndDestroy(&attributeSet);		
       
   414 	CleanupStack::PopAndDestroy(content);		
       
   415 	
       
   416     		
       
   417    	// Open using file handle
       
   418    	// cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
       
   419    	if (!unresolvedUri) 
       
   420 		{	
       
   421 		RFile file;
       
   422 		file.Open(iParent.Fs(), uri, EFileShareReadersOnly);		
       
   423 		content = CContent::NewLC(file);
       
   424 		file.Close(); 		
       
   425 
       
   426 		CleanupClosePushL(attributeSet);
       
   427 		attributeSet.AddL(attribute1);
       
   428 		attributeSet.AddL(attribute2);
       
   429 
       
   430 		result = content->GetStringAttributeSet(attributeSet, uniqueId);	
       
   431 			
       
   432 		if(result != KErrNone)
       
   433 			{
       
   434 			SetTestStepResult(EFail);
       
   435 			INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
       
   436 			}
       
   437 
       
   438 		if(result1 != attributeSet.GetValue(attribute1, value1))
       
   439 			{
       
   440 			INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
       
   441 			}
       
   442 		if(result2 != attributeSet.GetValue(attribute2, value2))
       
   443 			{
       
   444 			INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
       
   445 			}
       
   446 		
       
   447 		if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
       
   448 			{
       
   449 			SetTestStepResult(EFail);
       
   450 			INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
       
   451 			}
       
   452 		CleanupStack::PopAndDestroy(&attributeSet);		
       
   453 		CleanupStack::PopAndDestroy(content);		
       
   454 		}
       
   455 	__UHEAP_MARKEND;
       
   456 	return TestStepResult();
       
   457 	}
       
   458 
       
   459 
       
   460 
       
   461 /* 
       
   462  * This step tests the notification functions
       
   463  *
       
   464  */
       
   465 
       
   466 CCAFContentNotifyStep::~CCAFContentNotifyStep()
       
   467 	{
       
   468 	}
       
   469 
       
   470 CCAFContentNotifyStep::CCAFContentNotifyStep(CCAFServer& aParent) : iParent(aParent)
       
   471 	{
       
   472 	SetTestStepName(KCAFContentNotifyStep);
       
   473 	}
       
   474 
       
   475 
       
   476 TVerdict CCAFContentNotifyStep::doTestStepL()
       
   477 	{
       
   478 	TPtrC uri;
       
   479 	TInt result;
       
   480 	TRequestStatus status = KRequestPending;
       
   481 	
       
   482 	TInt Status1;
       
   483 	TInt Cancel1;
       
   484 	TInt Cancel2;
       
   485 	
       
   486 	
       
   487 	SetTestStepResult(EPass);
       
   488 
       
   489 	// Find the file to copy and the expected return code from the INI file
       
   490 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   491 	GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
       
   492 	GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
       
   493 	GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
       
   494 
       
   495 	INFO_PRINTF2(_L("Performing notification tests on %S"), &uri);
       
   496 
       
   497 	__UHEAP_MARK;
       
   498 	CContent *content = CContent::NewLC(uri);
       
   499 	// Wait for rights 
       
   500 	content->NotifyStatusChange(ERightsAvailable, status);
       
   501 	User::WaitForRequest(status);
       
   502 	if(status.Int() != Status1)
       
   503 		{
       
   504 		INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
       
   505 		SetTestStepResult(EFail);
       
   506 		}
       
   507 	result = content->CancelNotifyStatusChange(status);
       
   508 	if(result != Cancel1)
       
   509 		{
       
   510 		INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
       
   511 		SetTestStepResult(EFail);
       
   512 		}
       
   513 	
       
   514 	// Wait for rights expired but cancel before they arrive
       
   515 	content->NotifyStatusChange(ERightsExpired, status);
       
   516 	result = content->CancelNotifyStatusChange(status);
       
   517 	if(result != Cancel2)
       
   518 		{
       
   519 		INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
       
   520 		SetTestStepResult(EFail);
       
   521 		}
       
   522 	
       
   523 	CleanupStack::PopAndDestroy(content);
       
   524 	
       
   525    		
       
   526 	__UHEAP_MARKEND;
       
   527 	return TestStepResult();
       
   528 	}
       
   529 
       
   530 /* 
       
   531  * This step sets a property in the agents
       
   532  *
       
   533  */
       
   534 
       
   535 CCAFContentSetPropertyStep::~CCAFContentSetPropertyStep()
       
   536 	{
       
   537 	}
       
   538 
       
   539 CCAFContentSetPropertyStep::CCAFContentSetPropertyStep(CCAFServer& aParent) : iParent(aParent)
       
   540 	{
       
   541 	SetTestStepName(KCAFContentSetPropertyStep);
       
   542 	}
       
   543 
       
   544 
       
   545 TVerdict CCAFContentSetPropertyStep::doTestStepL()
       
   546 	{
       
   547 	TInt expectedResult;
       
   548 	TInt result;
       
   549 	TPtrC uri;
       
   550 
       
   551 	SetTestStepResult(EFail);
       
   552 
       
   553 	// Find the file to copy and the expected return code from the INI file
       
   554 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   555 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   556 
       
   557 	INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult);
       
   558 
       
   559 	__UHEAP_MARK;
       
   560 
       
   561 	CContent *content = CContent::NewLC(uri);
       
   562 	result = content->SetProperty(EAgentPropertyBufferSize, 100);
       
   563 	CleanupStack::PopAndDestroy(content);
       
   564 	
       
   565 	if(result == expectedResult)
       
   566 		{	
       
   567 		SetTestStepResult(EPass);
       
   568 		}
       
   569 	else 
       
   570 		{
       
   571 		INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result);
       
   572 		}
       
   573     		
       
   574 	__UHEAP_MARKEND;
       
   575 	return TestStepResult();
       
   576 	}
       
   577 
       
   578 
       
   579 /* 
       
   580  * This step asks the agent to display information about a file
       
   581  *
       
   582  */
       
   583 
       
   584 CCAFContentDisplayInfoStep::~CCAFContentDisplayInfoStep()
       
   585 	{
       
   586 	}
       
   587 
       
   588 CCAFContentDisplayInfoStep::CCAFContentDisplayInfoStep(CCAFServer& aParent) : iParent(aParent)
       
   589 	{
       
   590 	SetTestStepName(KCAFContentDisplayInfoStep);
       
   591 	}
       
   592 
       
   593 
       
   594 TVerdict CCAFContentDisplayInfoStep::doTestStepL()
       
   595 	{
       
   596 	TPtrC uri;
       
   597 	TInt expectedResult;
       
   598 	TInt result;
       
   599 
       
   600 	SetTestStepResult(EFail);
       
   601 
       
   602 	// Find the file to copy and the expected return code from the INI file
       
   603 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   604 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   605 
       
   606 	INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult);
       
   607 
       
   608 	__UHEAP_MARK;
       
   609 
       
   610 	CContent *content = CContent::NewLC(uri);
       
   611 	TRAP(result, content->DisplayInfoL(EFileProperties));
       
   612 	CleanupStack::PopAndDestroy(content);
       
   613 	
       
   614 	if(result == expectedResult)
       
   615 		{	
       
   616 		SetTestStepResult(EPass);
       
   617 		}
       
   618 	else 
       
   619 		{
       
   620 		INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result);
       
   621 		}
       
   622     		
       
   623 	__UHEAP_MARKEND;
       
   624 	return TestStepResult();
       
   625 	}
       
   626 
       
   627 /* 
       
   628  * This step attempts to perform an agent specific command
       
   629  *
       
   630  */
       
   631 
       
   632 CCAFContentAgentSpecificStep::~CCAFContentAgentSpecificStep()
       
   633 	{
       
   634 	}
       
   635 
       
   636 CCAFContentAgentSpecificStep::CCAFContentAgentSpecificStep(CCAFServer& aParent) : iParent(aParent)
       
   637 	{
       
   638 	SetTestStepName(KCAFContentAgentSpecificStep);
       
   639 	}
       
   640 
       
   641 
       
   642 TVerdict CCAFContentAgentSpecificStep::doTestStepL()
       
   643 	{
       
   644 	TPtrC input16;
       
   645 	TPtrC output16;
       
   646 	TPtrC uri;
       
   647 	TInt expectedResult;
       
   648 	TInt command;
       
   649 	TInt result;
       
   650 	TBuf8 <100> actualOutput;
       
   651 	TBuf8 <100> output;
       
   652 	TBuf8 <100> input;
       
   653 
       
   654 
       
   655 	SetTestStepResult(EPass);
       
   656 
       
   657 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   658 	GetIntFromConfig(ConfigSection(),_L("command"),command);
       
   659 	GetStringFromConfig(ConfigSection(),_L("input"),input16);
       
   660 	GetStringFromConfig(ConfigSection(),_L("output"),output16);
       
   661 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   662 
       
   663 	input.Copy(input16);
       
   664 	output.Copy(output16);
       
   665 
       
   666 	__UHEAP_MARK;
       
   667 	CContent *content = CContent::NewLC(uri);
       
   668 
       
   669 	INFO_PRINTF1(_L("Running synchronous Agent specific command"));
       
   670 	actualOutput.SetLength(0);
       
   671 	result = content->AgentSpecificCommand(command, input, actualOutput);
       
   672 	if(result != expectedResult)
       
   673 		{	
       
   674 		SetTestStepResult(EFail);
       
   675 		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result);
       
   676 		}
       
   677 	else if(actualOutput != output)
       
   678 		{
       
   679 		SetTestStepResult(EFail);
       
   680 		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
       
   681 		}
       
   682 
       
   683 	INFO_PRINTF1(_L("Running asynchronous Agent specific command"));
       
   684 	TRequestStatus status;
       
   685 	actualOutput.SetLength(0);
       
   686 	content->AgentSpecificCommand(command, input, actualOutput, status);
       
   687 	User::WaitForRequest(status);
       
   688 	if(status.Int() != expectedResult)
       
   689 		{	
       
   690 		SetTestStepResult(EFail);
       
   691 		INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int());
       
   692 		}
       
   693 	else if(actualOutput != output)
       
   694 		{
       
   695 		SetTestStepResult(EFail);
       
   696 		INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
       
   697 		}
       
   698 	
       
   699 	CleanupStack::PopAndDestroy(content);		
       
   700     		
       
   701 	__UHEAP_MARKEND;
       
   702 	return TestStepResult();
       
   703 	}
       
   704 
       
   705 
       
   706 /* 
       
   707  * This step tests the rights request functions
       
   708  *
       
   709  */
       
   710 
       
   711 CCAFContentRequestRightsStep::~CCAFContentRequestRightsStep()
       
   712 	{
       
   713 	}
       
   714 
       
   715 CCAFContentRequestRightsStep::CCAFContentRequestRightsStep(CCAFServer& aParent) : iParent(aParent)
       
   716 	{
       
   717 	SetTestStepName(KCAFContentRequestRightsStep);
       
   718 	}
       
   719 
       
   720 
       
   721 TVerdict CCAFContentRequestRightsStep::doTestStepL()
       
   722 	{
       
   723 	TPtrC uri;
       
   724 	TInt result;
       
   725 	TRequestStatus status = KRequestPending;
       
   726 	
       
   727 	TInt Status1;
       
   728 	TInt Cancel1;
       
   729 	TInt Cancel2;
       
   730 	
       
   731 	
       
   732 	SetTestStepResult(EPass);
       
   733 
       
   734 	// Find the file to copy and the expected return code from the INI file
       
   735 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   736 	GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
       
   737 	GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
       
   738 	GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
       
   739 
       
   740 	INFO_PRINTF2(_L("Performing Request Rights tests on %S"), &uri);
       
   741 
       
   742 	__UHEAP_MARK;
       
   743 	CContent *content = CContent::NewLC(uri);
       
   744 	// Wait for rights 
       
   745 	content->RequestRights(status);
       
   746 	User::WaitForRequest(status);
       
   747 	if(status.Int() != Status1)
       
   748 		{
       
   749 		INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
       
   750 		SetTestStepResult(EFail);
       
   751 		}
       
   752 	result = content->CancelRequestRights(status);
       
   753 	if(result != Cancel1)
       
   754 		{
       
   755 		INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
       
   756 		SetTestStepResult(EFail);
       
   757 		}
       
   758 	
       
   759 	// Wait for rights expired but cancel before they arrive
       
   760 	content->RequestRights(status);
       
   761 	result = content->CancelRequestRights(status);
       
   762 	if(result != Cancel2)
       
   763 		{
       
   764 		INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
       
   765 		SetTestStepResult(EFail);
       
   766 		}
       
   767 	
       
   768 	CleanupStack::PopAndDestroy(content);
       
   769 	
       
   770    		
       
   771 	__UHEAP_MARKEND;
       
   772 	return TestStepResult();
       
   773 	}
       
   774 
       
   775 
       
   776 
       
   777 /* 
       
   778  * This step tests the rights request functions
       
   779  *
       
   780  */
       
   781 
       
   782 CCAFContentEmbeddedObjectsStep::~CCAFContentEmbeddedObjectsStep()
       
   783 	{
       
   784 	}
       
   785 
       
   786 CCAFContentEmbeddedObjectsStep::CCAFContentEmbeddedObjectsStep(CCAFServer& aParent) : iParent(aParent)
       
   787 	{
       
   788 	SetTestStepName(KCAFContentEmbeddedObjectsStep);
       
   789 	}
       
   790 
       
   791 
       
   792 TVerdict CCAFContentEmbeddedObjectsStep::doTestStepL()
       
   793 	{
       
   794 	TPtrC uri;
       
   795 	TInt expectedCount;
       
   796 	TInt expectedResult;
       
   797 	
       
   798 	SetTestStepResult(EPass);
       
   799 
       
   800 	// Find the file to copy and the expected return code from the INI file
       
   801 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   802 	GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
       
   803 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   804 
       
   805 	INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
       
   806 
       
   807 	__UHEAP_MARK;
       
   808 	CContent *content = CContent::NewLC(uri);
       
   809 
       
   810 	RStreamablePtrArray <CEmbeddedObject> array;
       
   811 	CleanupClosePushL(array);
       
   812 
       
   813 	// Wait for rights
       
   814 	TRAPD(result, content->GetEmbeddedObjectsL(array));
       
   815 	if(result != expectedResult)
       
   816 		{
       
   817 		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedResult);
       
   818 		SetTestStepResult(EFail);
       
   819 		}
       
   820 	
       
   821 	if((result == KErrNone) && (array.Count() != expectedCount))
       
   822 			{
       
   823 			INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d objects, expected %d"), array.Count(), expectedCount);
       
   824 			SetTestStepResult(EFail);
       
   825 			}
       
   826 
       
   827 	CleanupStack::PopAndDestroy(&array);	
       
   828 	CleanupStack::PopAndDestroy(content);
       
   829 	
       
   830    		
       
   831 	__UHEAP_MARKEND;
       
   832 	return TestStepResult();
       
   833 	}
       
   834 
       
   835 /* 
       
   836  * This step tests the rights request functions
       
   837  *
       
   838  */
       
   839 
       
   840 CCAFContentEmbeddedObjectTypeStep::~CCAFContentEmbeddedObjectTypeStep()
       
   841 	{
       
   842 	}
       
   843 
       
   844 CCAFContentEmbeddedObjectTypeStep::CCAFContentEmbeddedObjectTypeStep(CCAFServer& aParent) : iParent(aParent)
       
   845 	{
       
   846 	SetTestStepName(KCAFContentEmbeddedObjectTypeStep);
       
   847 	}
       
   848 
       
   849 
       
   850 TVerdict CCAFContentEmbeddedObjectTypeStep::doTestStepL()
       
   851 	{
       
   852 	TPtrC uri;
       
   853 	TInt expectedContent;
       
   854 	TInt expectedContainers;
       
   855 	TInt expectedContainerResult;
       
   856 	TInt expectedContentResult;
       
   857 
       
   858 	SetTestStepResult(EPass);
       
   859 
       
   860 	// Find the file to copy and the expected return code from the INI file
       
   861 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   862 	GetIntFromConfig(ConfigSection(),_L("contentcount"),expectedContent);
       
   863 	GetIntFromConfig(ConfigSection(),_L("containercount"),expectedContainers);
       
   864 	GetIntFromConfig(ConfigSection(),_L("containerresult"),expectedContainerResult);
       
   865 	GetIntFromConfig(ConfigSection(),_L("contentresult"),expectedContentResult);
       
   866 
       
   867 	INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
       
   868 
       
   869 	__UHEAP_MARK;
       
   870 	CContent *content = CContent::NewLC(uri);
       
   871 
       
   872 	RStreamablePtrArray <CEmbeddedObject> array;
       
   873 	CleanupClosePushL(array);
       
   874 
       
   875 	// get embedded objects
       
   876 	TRAPD(result, content->GetEmbeddedObjectsL(array, EContainerObject));
       
   877 
       
   878 	if(result != expectedContainerResult)
       
   879 		{
       
   880 		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContainerResult);
       
   881 		SetTestStepResult(EFail);
       
   882 		}
       
   883 
       
   884 	if((result == KErrNone) && (array.Count() != expectedContainers))
       
   885 		{
       
   886 		INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d container objects, expected %d"), array.Count(), expectedContainers);
       
   887 		SetTestStepResult(EFail);
       
   888 		}
       
   889 
       
   890 	// clear array
       
   891 	array.ResetAndDestroy();
       
   892 	
       
   893 	// get embedded objects
       
   894 	TRAP(result, content->GetEmbeddedObjectsL(array, EContentObject));
       
   895 
       
   896 	if(result != expectedContentResult)
       
   897 		{
       
   898 		INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContentResult);
       
   899 		SetTestStepResult(EFail);
       
   900 		}
       
   901 
       
   902 	if((result == KErrNone) && (array.Count() != expectedContent))
       
   903 		{
       
   904 		INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d content objects, expected %d"), array.Count(), expectedContent);
       
   905 		SetTestStepResult(EFail);
       
   906 		}
       
   907 
       
   908 
       
   909 	CleanupStack::PopAndDestroy(&array);	
       
   910 	CleanupStack::PopAndDestroy(content);
       
   911 	
       
   912    		
       
   913 	__UHEAP_MARKEND;
       
   914 	return TestStepResult();
       
   915 	}
       
   916 
       
   917 /* 
       
   918  * This step tests the rights request functions
       
   919  *
       
   920  */
       
   921 
       
   922 CCAFContentSearchStep::~CCAFContentSearchStep()
       
   923 	{
       
   924 	}
       
   925 
       
   926 CCAFContentSearchStep::CCAFContentSearchStep(CCAFServer& aParent) : iParent(aParent)
       
   927 	{
       
   928 	SetTestStepName(KCAFContentSearchStep);
       
   929 	}
       
   930 
       
   931 
       
   932 TVerdict CCAFContentSearchStep::doTestStepL()
       
   933 	{
       
   934 	TPtrC uri;
       
   935 	TPtrC mimeType16;
       
   936 	TInt result;
       
   937 	TInt expectedCount;
       
   938 	TInt expectedResult;
       
   939 	TBuf8 <255> mimeType8;
       
   940 	
       
   941 	SetTestStepResult(EPass);
       
   942 
       
   943 	// Find the file, mimetype, expected return code and expected count from the INI file
       
   944 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
   945 	GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
       
   946 	GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
       
   947 	GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType16);
       
   948 
       
   949 	mimeType8.Copy(mimeType16);
       
   950 
       
   951 	INFO_PRINTF3(_L("Search for embedded %S objects within %S"), &mimeType16, &uri);
       
   952 
       
   953 	__UHEAP_MARK;
       
   954 	CContent *content = CContent::NewLC(uri);
       
   955 
       
   956 	RStreamablePtrArray <CEmbeddedObject> array;
       
   957 	CleanupClosePushL(array);
       
   958 
       
   959 	// get embedded objects
       
   960 	result = content->Search(array, mimeType8, ETrue);
       
   961 	
       
   962 	if(result != expectedResult)
       
   963 		{
       
   964 		INFO_PRINTF3(_L("Search() return value %d, expected %d"), result, expectedResult);
       
   965 		SetTestStepResult(EFail);
       
   966 		}
       
   967 	
       
   968 	if(array.Count() != expectedCount)
       
   969 		{
       
   970 		INFO_PRINTF3(_L("Search() found %d objects, expected %d"), array.Count(), expectedCount);
       
   971 		SetTestStepResult(EFail);
       
   972 		}
       
   973 
       
   974 	CleanupStack::PopAndDestroy(&array);	
       
   975 	CleanupStack::PopAndDestroy(content);
       
   976 	
       
   977    		
       
   978 	__UHEAP_MARKEND;
       
   979 	return TestStepResult();
       
   980 	}
       
   981 
       
   982 /* 
       
   983  * This step tests the container open/close functions
       
   984  *
       
   985  */
       
   986 
       
   987 CCAFContentContainerStep::~CCAFContentContainerStep()
       
   988 	{
       
   989 	}
       
   990 
       
   991 CCAFContentContainerStep::CCAFContentContainerStep(CCAFServer& aParent) : iParent(aParent)
       
   992 	{
       
   993 	SetTestStepName(KCAFContentContainerStep);
       
   994 	}
       
   995 
       
   996 
       
   997 TVerdict CCAFContentContainerStep::doTestStepL()
       
   998 	{
       
   999 	TPtrC uri;
       
  1000 	TPtrC uniqueId;
       
  1001 	TInt result;
       
  1002 	TInt openResult;
       
  1003 	TInt closeResult;
       
  1004 	
       
  1005 	
       
  1006 	SetTestStepResult(EPass);
       
  1007 
       
  1008 	// Find the file to copy and the expected return code from the INI file
       
  1009 	GetStringFromConfig(ConfigSection(),_L("uri"),uri);
       
  1010 	GetStringFromConfig(ConfigSection(),_L("uniqueId"),uniqueId);
       
  1011 	GetIntFromConfig(ConfigSection(),_L("openResult"),openResult);
       
  1012 	GetIntFromConfig(ConfigSection(),_L("closeResult"),closeResult);
       
  1013 
       
  1014 	INFO_PRINTF2(_L("Opening embedded container within %S"), &uri);
       
  1015 
       
  1016 	__UHEAP_MARK;
       
  1017 	CContent *content = CContent::NewLC(uri);
       
  1018 
       
  1019 	result = content->OpenContainer(uniqueId);
       
  1020 	if(result != openResult)
       
  1021 		{
       
  1022 		SetTestStepResult(EFail);	
       
  1023 		INFO_PRINTF3(_L("OpenContainer() returned %d, expected %d"), result, openResult);
       
  1024 		}
       
  1025 	result = content->CloseContainer();
       
  1026 	if(result != closeResult)
       
  1027 		{
       
  1028 		SetTestStepResult(EFail);	
       
  1029 		INFO_PRINTF3(_L("CloseContainer() returned %d, expected %d"), result, closeResult);
       
  1030 		}
       
  1031 	CleanupStack::PopAndDestroy(content);
       
  1032    		
       
  1033 	__UHEAP_MARKEND;
       
  1034 	return TestStepResult();
       
  1035 	}
       
  1036 
       
  1037 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
  1038       
       
  1039 // The following methods test the various content attribute APIs for WMDRM content.     
       
  1040       
       
  1041 TVerdict CCAFContentAttributeStep::doWmdrmTestStepL()     
       
  1042     {     
       
  1043     SetTestStepResult(EFail);     
       
  1044          
       
  1045     TInt attribVal;     
       
  1046     GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
       
  1047          
       
  1048     TInt expectedValue;     
       
  1049     GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
       
  1050       
       
  1051 __UHEAP_MARK;     
       
  1052     TPtrC header;     
       
  1053     HBufC8* headerData = NULL;     
       
  1054          
       
  1055     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1056         {     
       
  1057         headerData = ConvertDes16toHBufC8LC(header);     
       
  1058         }     
       
  1059     else     
       
  1060         {     
       
  1061         headerData = CreateWmdrmHeaderLC();      
       
  1062         }     
       
  1063              
       
  1064     CContent *content = CContent::NewLC(*headerData);     
       
  1065     TInt value;     
       
  1066     User::LeaveIfError(content->GetAttribute(attribVal, value));     
       
  1067          
       
  1068     if(expectedValue == value)     
       
  1069         {     
       
  1070         SetTestStepResult(EPass);     
       
  1071         }     
       
  1072     else     
       
  1073         {     
       
  1074         INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);     
       
  1075         }     
       
  1076          
       
  1077     CleanupStack::PopAndDestroy(2, headerData);                      
       
  1078 __UHEAP_MARKEND;     
       
  1079       
       
  1080     return TestStepResult();     
       
  1081     }     
       
  1082          
       
  1083       
       
  1084 TVerdict CCAFContentAttributeSetStep::doWmdrmTestStepL()     
       
  1085     {     
       
  1086     SetTestStepResult(EFail);     
       
  1087          
       
  1088     TInt attribute1;     
       
  1089     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
       
  1090          
       
  1091     TInt attribute2;     
       
  1092     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
       
  1093          
       
  1094     TInt expectedValue1;     
       
  1095     GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
       
  1096          
       
  1097     TInt expectedValue2;     
       
  1098     GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
       
  1099       
       
  1100 __UHEAP_MARK;     
       
  1101       
       
  1102     TPtrC header;     
       
  1103     HBufC8* headerData = NULL;     
       
  1104          
       
  1105     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1106         {     
       
  1107         headerData = ConvertDes16toHBufC8LC(header);     
       
  1108         }     
       
  1109     else     
       
  1110         {     
       
  1111         headerData = CreateWmdrmHeaderLC();      
       
  1112         }     
       
  1113          
       
  1114     CContent *content = CContent::NewLC(*headerData);     
       
  1115                      
       
  1116     RAttributeSet attributeSet;     
       
  1117     CleanupClosePushL(attributeSet);     
       
  1118     attributeSet.AddL(attribute1);     
       
  1119     attributeSet.AddL(attribute2);     
       
  1120              
       
  1121     TInt result = content->GetAttributeSet(attributeSet);     
       
  1122     if(result == KErrNone)     
       
  1123         {     
       
  1124         TInt value1;         
       
  1125         User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
       
  1126              
       
  1127         TInt value2;     
       
  1128         User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
       
  1129              
       
  1130         if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
       
  1131             {     
       
  1132             SetTestStepResult(EPass);     
       
  1133             }     
       
  1134         else     
       
  1135             {     
       
  1136             INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));     
       
  1137             }     
       
  1138         }     
       
  1139          
       
  1140     else     
       
  1141         {     
       
  1142         INFO_PRINTF1(_L("CContent::GetAttributeSet() failed"));     
       
  1143         }     
       
  1144              
       
  1145     CleanupStack::PopAndDestroy(3, headerData);          
       
  1146          
       
  1147 __UHEAP_MARKEND;     
       
  1148       
       
  1149     return TestStepResult();     
       
  1150     }     
       
  1151       
       
  1152       
       
  1153 TVerdict CCAFContentStringAttributeStep::doWmdrmTestStepL()     
       
  1154     {     
       
  1155     SetTestStepResult(EFail);     
       
  1156          
       
  1157     TInt attribVal;     
       
  1158     GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
       
  1159          
       
  1160     TPtrC expectedValue;     
       
  1161     GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
       
  1162          
       
  1163     TInt expectedResult;     
       
  1164     GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
       
  1165          
       
  1166 __UHEAP_MARK;     
       
  1167     TPtrC header;     
       
  1168     HBufC8* headerData = NULL;     
       
  1169          
       
  1170     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1171         {     
       
  1172         headerData = ConvertDes16toHBufC8LC(header);     
       
  1173         }     
       
  1174     else     
       
  1175         {     
       
  1176         headerData = CreateWmdrmHeaderLC();      
       
  1177         }     
       
  1178          
       
  1179     CContent *content = CContent::NewLC(*headerData);     
       
  1180                  
       
  1181     TBuf <200> value;     
       
  1182     TInt result = content->GetStringAttribute(attribVal, value);     
       
  1183     if(result == expectedResult && value == expectedValue)     
       
  1184         {     
       
  1185         SetTestStepResult(EPass);     
       
  1186         }     
       
  1187     else     
       
  1188         {     
       
  1189         INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
       
  1190         INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
       
  1191         }     
       
  1192              
       
  1193     CleanupStack::PopAndDestroy(2, headerData);          
       
  1194              
       
  1195 __UHEAP_MARKEND;     
       
  1196       
       
  1197     return TestStepResult();     
       
  1198     }     
       
  1199       
       
  1200       
       
  1201 TVerdict CCAFContentStringAttributeSetStep::doWmdrmTestStepL()     
       
  1202     {     
       
  1203     SetTestStepResult(EFail);     
       
  1204       
       
  1205     TInt attribute1;         
       
  1206     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
       
  1207          
       
  1208     TInt attribute2;     
       
  1209     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
       
  1210          
       
  1211     TPtrC expectedValue1;     
       
  1212     GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
       
  1213          
       
  1214     TPtrC expectedValue2;     
       
  1215     GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
       
  1216          
       
  1217 __UHEAP_MARK;     
       
  1218     TPtrC header;     
       
  1219     HBufC8* headerData = NULL;     
       
  1220          
       
  1221     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1222         {     
       
  1223         headerData = ConvertDes16toHBufC8LC(header);     
       
  1224         }     
       
  1225     else     
       
  1226         {     
       
  1227         headerData = CreateWmdrmHeaderLC();      
       
  1228         }     
       
  1229          
       
  1230     CContent *content = CContent::NewLC(*headerData);     
       
  1231          
       
  1232     RStringAttributeSet attributeSet;     
       
  1233     CleanupClosePushL(attributeSet);     
       
  1234     attributeSet.AddL(attribute1);     
       
  1235     attributeSet.AddL(attribute2);     
       
  1236              
       
  1237     TInt result = content->GetStringAttributeSet(attributeSet);     
       
  1238     TBuf <200> value1;     
       
  1239     TBuf <200> value2;     
       
  1240     if(result == KErrNone)     
       
  1241         {     
       
  1242         TInt result3 = attributeSet.GetValue(attribute1, value1);     
       
  1243         TInt result4 = attributeSet.GetValue(attribute2, value2);     
       
  1244                  
       
  1245         if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
       
  1246          && result3 == KErrNone && result4 == KErrNone)     
       
  1247             {     
       
  1248             SetTestStepResult(EPass);     
       
  1249             }     
       
  1250         else     
       
  1251             {     
       
  1252             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
       
  1253             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
       
  1254             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
       
  1255             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
       
  1256             }     
       
  1257         }     
       
  1258     else     
       
  1259         {     
       
  1260         INFO_PRINTF1(_L("CContent::GetStringAttributeSet() failed"));     
       
  1261         }        
       
  1262          
       
  1263     CleanupStack::PopAndDestroy(3, headerData);          
       
  1264       
       
  1265 __UHEAP_MARKEND;     
       
  1266       
       
  1267     return TestStepResult();     
       
  1268     }     
       
  1269       
       
  1270 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT 
       
  1271