--- a/contentmgmt/referencedrmagent/tcaf/source/Consumerstep.cpp Thu Aug 19 11:38:48 2010 +0300
+++ b/contentmgmt/referencedrmagent/tcaf/source/Consumerstep.cpp Tue Aug 31 17:00:08 2010 +0300
@@ -1818,7 +1818,18 @@
}
TVerdict CCAFDataAttributeStep::doTestStepL()
- {
+ {
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+ TBool wmdrmFlag = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
+
+ if(wmdrmFlag)
+ {
+ TVerdict verdict = doWmdrmTestStepL();
+ return verdict;
+ }
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+
TInt attribute;
TInt value = KErrNone;
TInt expectedValue = KErrNone;
@@ -1864,6 +1875,17 @@
TVerdict CCAFDataAttributeSetStep::doTestStepL()
{
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+ TBool wmdrmFlag = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
+
+ if(wmdrmFlag)
+ {
+ TVerdict verdict = doWmdrmTestStepL();
+ return verdict;
+ }
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+
TInt expectedValue1;
TInt expectedValue2;
TInt value1;
@@ -1929,6 +1951,17 @@
TVerdict CCAFDataStringAttributeStep::doTestStepL()
{
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+ TBool wmdrmFlag = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
+
+ if(wmdrmFlag)
+ {
+ TVerdict verdict = doWmdrmTestStepL();
+ return verdict;
+ }
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+
TInt expectedResult;
TInt attribute;
TPtrC expectedValue;
@@ -1983,6 +2016,17 @@
TVerdict CCAFDataStringAttributeSetStep::doTestStepL()
{
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+ TBool wmdrmFlag = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
+
+ if(wmdrmFlag)
+ {
+ TVerdict verdict = doWmdrmTestStepL();
+ return verdict;
+ }
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+
TPtrC expectedValue1;
TPtrC expectedValue2;
TBuf <200> value1;
@@ -2198,4 +2242,508 @@
iIterationSum += tickCounterValAfterFileOpen - tickCounterValBeforeFileOpen;
}
-
+#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
+
+CWmdrmCAFContentStep::~CWmdrmCAFContentStep()
+ {
+ }
+
+CWmdrmCAFContentStep::CWmdrmCAFContentStep()
+ {
+ SetTestStepName(KWmdrmCAFContentStep);
+ }
+
+
+TVerdict CWmdrmCAFContentStep::doTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TBool protectedVal;
+ GetBoolFromConfig(ConfigSection(),_L("attribValue1"), protectedVal);
+ TBool forwardable;
+ GetBoolFromConfig(ConfigSection(),_L("attribValue2"), forwardable);
+
+ TBool headerDataPresent = ETrue;
+ GetBoolFromConfig(ConfigSection(),_L("headerDataFlag"), headerDataPresent);
+
+ INFO_PRINTF1(_L("Verify CContent APIs for WMDRM content"));
+
+ __UHEAP_MARK;
+
+ CContent* content = NULL;
+
+ // this condition verifies that CContent construction leaves with KErrMissingWmdrmHeaderData,
+ // when no header data is provided.
+ if(!headerDataPresent)
+ {
+ content = CContent::NewL(KNullDesC8());
+ return EPass;
+ }
+
+ // create a dummy header data.
+ HBufC8* headerData = CreateWmdrmHeaderLC();
+
+ // Open a file and retrieve the attributes.
+ // If headerDataPresent is false, the code will never reach here.s
+ content = CContent::NewL(*headerData);
+ CleanupStack::PushL(content);
+ CAttribute* attrs = content->NewAttributeL(ETrue);
+ CleanupStack::PushL(attrs);
+
+ TBool value1 = attrs->ResponseSet().IsSet(EIsProtected);
+ TBool value2 = attrs->ResponseSet().IsSet(EIsForwardable);
+ if(value1 == protectedVal && value2 == forwardable)
+ {
+ SetTestStepResult(EPass);
+ }
+
+ CleanupStack::PopAndDestroy(3, headerData);
+
+ __UHEAP_MARKEND;
+ return TestStepResult();
+ }
+
+
+CWmdrmCAFDataStep::~CWmdrmCAFDataStep()
+ {
+ }
+
+CWmdrmCAFDataStep::CWmdrmCAFDataStep()
+ {
+ SetTestStepName(KWmdrmCAFDataStep);
+ }
+
+TVerdict CWmdrmCAFDataStep::doTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TInt attribute;
+ TInt expectedValue = KErrNone;
+
+ GetIntFromConfig(ConfigSection(),_L("attribute"), attribute);
+ GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
+
+__UHEAP_MARK;
+
+ HBufC8* headerData = CreateWmdrmHeaderLC();
+
+ CContent *content = CContent::NewLC(*headerData);
+ CData *data = content->OpenContentL(EPeek);
+ TInt value = KErrNone;
+ User::LeaveIfError(data->GetAttribute(attribute, value));
+ delete data;
+
+ if(expectedValue == value)
+ {
+ SetTestStepResult(EPass);
+ }
+ else
+ {
+ INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
+ }
+
+ CleanupStack::PopAndDestroy(2, headerData);
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+
+CWmdrmCAFReadStep::~CWmdrmCAFReadStep()
+ {
+ }
+
+CWmdrmCAFReadStep::CWmdrmCAFReadStep()
+ {
+ SetTestStepName(KWmdrmCAFReadStep);
+ }
+
+
+TVerdict CWmdrmCAFReadStep::doTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TBool synchronous = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("synchronous"), synchronous);
+ TBool intent = EFalse;
+ GetBoolFromConfig(ConfigSection(),_L("intent"), intent);
+ TPtrC inputPacket;
+ GetStringFromConfig(ConfigSection(),_L("inputPacket"), inputPacket);
+ TPtrC expectedOutput;
+ GetStringFromConfig(ConfigSection(),_L("outputPacket"), expectedOutput);
+
+__UHEAP_MARK;
+ TPtrC header;
+ HBufC8* headerData = NULL;
+
+ if(GetStringFromConfig(ConfigSection(),_L("header"), header))
+ {
+ headerData = ConvertDes16toHBufC8LC(header);
+ }
+ else
+ {
+ headerData = CreateWmdrmHeaderLC();
+ }
+
+ TInt result = 0;
+ if(!synchronous)
+ {
+ result = TestAsynchronousReadL(*headerData, intent, inputPacket, expectedOutput);
+ }
+ else
+ {
+ result = TestSynchronousReadL(*headerData, intent, inputPacket, expectedOutput);
+ }
+
+ if(result == KErrNone)
+ {
+ SetTestStepResult(EPass);
+ }
+
+ CleanupStack::PopAndDestroy(headerData);
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+TInt CWmdrmCAFReadStep::TestSynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)
+ {
+__UHEAP_MARK;
+ CData* data = NULL;
+ TInt returnVal = KErrGeneral;
+
+ if(aIntent)
+ {
+ data = CData::NewL(aHeaderData, EPeek);
+ }
+ else
+ {
+ data = CData::NewL(aHeaderData);
+ }
+
+ CleanupStack::PushL(data);
+
+ if(aInputPacket.Length() <= 0)
+ {
+ // dummy output buffer.This loop essentially tests the error condition KErrInsufficientDataPacketLength.
+ TBuf8<2> outputBuffer;
+ User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));
+ }
+
+ else
+ {
+ HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);
+ HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());
+ TPtr8 outputPacketPtr = outputPacket->Des();
+
+ User::LeaveIfError(data->Read(*inputPacket, outputPacketPtr));
+ HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);
+ if(expectedOutput->Compare(*outputPacket) == KErrNone)
+ {
+ returnVal = KErrNone;
+ }
+
+ CleanupStack::PopAndDestroy(3, inputPacket);
+ }
+
+ CleanupStack::PopAndDestroy(data);
+__UHEAP_MARKEND;
+
+ return returnVal;
+ }
+
+TInt CWmdrmCAFReadStep::TestAsynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)
+ {
+__UHEAP_MARK;
+ CData* data = NULL;
+ TInt returnVal = KErrGeneral;
+
+ if(aIntent)
+ {
+ data = CData::NewL(aHeaderData, EPeek);
+ }
+ else
+ {
+ data = CData::NewL(aHeaderData);
+ }
+
+ CleanupStack::PushL(data);
+
+ if(aInputPacket.Length() <= 0)
+ {
+ TBuf8<2> outputBuffer;
+ User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));
+ }
+
+ else
+ {
+ HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);
+ HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());
+ TPtr8 outputPacketPtr = outputPacket->Des();
+
+ TRequestStatus status;
+ data->Read(*inputPacket, outputPacketPtr, status);
+ User::WaitForRequest(status);
+
+ if(status.Int() != KErrNone)
+ {
+ CleanupStack::PopAndDestroy(3, data);
+ return status.Int();
+ }
+
+ HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);
+ if(expectedOutput->Compare(*outputPacket) == KErrNone)
+ {
+ returnVal = KErrNone;
+ }
+
+ CleanupStack::PopAndDestroy(3, inputPacket);
+ }
+
+ CleanupStack::PopAndDestroy(data);
+__UHEAP_MARKEND;
+
+ return returnVal;
+ }
+
+TVerdict CCAFDataAttributeStep::doWmdrmTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TInt attribVal;
+ GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);
+
+ TInt expectedValue;
+ GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
+
+__UHEAP_MARK;
+ TPtrC header;
+ HBufC8* headerData = NULL;
+
+ if(GetStringFromConfig(ConfigSection(),_L("header"), header))
+ {
+ headerData = ConvertDes16toHBufC8LC(header);
+ }
+ else
+ {
+ headerData = CreateWmdrmHeaderLC();
+ }
+
+ CContent *content = CContent::NewLC(*headerData);
+ CData *data = content->OpenContentL(EPeek);
+ TInt value;
+ User::LeaveIfError(data->GetAttribute(attribVal, value));
+ delete data;
+
+ if(expectedValue == value)
+ {
+ SetTestStepResult(EPass);
+ }
+ else
+ {
+ INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
+ }
+
+ CleanupStack::PopAndDestroy(2, headerData);
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+
+TVerdict CCAFDataAttributeSetStep::doWmdrmTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TInt attribute1;
+ GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
+
+ TInt attribute2;
+ GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
+
+ TInt expectedValue1;
+ GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
+
+ TInt expectedValue2;
+ GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
+
+__UHEAP_MARK;
+
+ TPtrC header;
+ HBufC8* headerData = NULL;
+
+ if(GetStringFromConfig(ConfigSection(),_L("header"), header))
+ {
+ headerData = ConvertDes16toHBufC8LC(header);
+ }
+ else
+ {
+ headerData = CreateWmdrmHeaderLC();
+ }
+
+ CContent *content = CContent::NewLC(*headerData);
+ CData *data = content->OpenContentL(EPeek);
+
+ RAttributeSet attributeSet;
+ CleanupClosePushL(attributeSet);
+ attributeSet.AddL(attribute1);
+ attributeSet.AddL(attribute2);
+
+ TInt result = data->GetAttributeSet(attributeSet);
+ delete data;
+
+ if(result == KErrNone)
+ {
+ TInt value1;
+ User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
+
+ TInt value2;
+ User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
+
+ if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)
+ {
+ SetTestStepResult(EPass);
+ }
+ else
+ {
+ INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
+ }
+ }
+
+ else
+ {
+ INFO_PRINTF1(_L("CData::GetAttributeSet() failed"));
+ }
+
+ CleanupStack::PopAndDestroy(3, headerData);
+
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+
+TVerdict CCAFDataStringAttributeStep::doWmdrmTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TInt attribVal;
+ GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);
+
+ TPtrC expectedValue;
+ GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
+
+ TInt expectedResult;
+ GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
+
+__UHEAP_MARK;
+ TPtrC header;
+ HBufC8* headerData = NULL;
+
+ if(GetStringFromConfig(ConfigSection(),_L("header"), header))
+ {
+ headerData = ConvertDes16toHBufC8LC(header);
+ }
+ else
+ {
+ headerData = CreateWmdrmHeaderLC();
+ }
+
+ CContent *content = CContent::NewLC(*headerData);
+ CData *data = content->OpenContentL(EPeek);
+
+ TBuf <200> value;
+ TInt result = data->GetStringAttribute(attribVal, value);
+ delete data;
+
+ if(result == expectedResult && value == expectedValue)
+ {
+ SetTestStepResult(EPass);
+ }
+ else
+ {
+ INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
+ INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);
+ }
+
+ CleanupStack::PopAndDestroy(2, headerData);
+
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+
+TVerdict CCAFDataStringAttributeSetStep::doWmdrmTestStepL()
+ {
+ SetTestStepResult(EFail);
+
+ TInt attribute1;
+ GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
+
+ TInt attribute2;
+ GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
+
+ TPtrC expectedValue1;
+ GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
+
+ TPtrC expectedValue2;
+ GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
+
+__UHEAP_MARK;
+ TPtrC header;
+ HBufC8* headerData = NULL;
+
+ if(GetStringFromConfig(ConfigSection(),_L("header"), header))
+ {
+ headerData = ConvertDes16toHBufC8LC(header);
+ }
+ else
+ {
+ headerData = CreateWmdrmHeaderLC();
+ }
+
+ CContent *content = CContent::NewLC(*headerData);
+ CData *data = content->OpenContentL(EPeek);
+
+ RStringAttributeSet attributeSet;
+ CleanupClosePushL(attributeSet);
+ attributeSet.AddL(attribute1);
+ attributeSet.AddL(attribute2);
+
+ TInt result = data->GetStringAttributeSet(attributeSet);
+ delete data;
+
+ TBuf <200> value1;
+ TBuf <200> value2;
+ if(result == KErrNone)
+ {
+ TInt result3 = attributeSet.GetValue(attribute1, value1);
+ TInt result4 = attributeSet.GetValue(attribute2, value2);
+
+ if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2
+ && result3 == KErrNone && result4 == KErrNone)
+ {
+ SetTestStepResult(EPass);
+ }
+ else
+ {
+ INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);
+ INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);
+ INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);
+ INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);
+ }
+ }
+ else
+ {
+ INFO_PRINTF1(_L("CData::GetStringAttributeSet() failed"));
+ }
+
+ CleanupStack::PopAndDestroy(3, headerData);
+
+__UHEAP_MARKEND;
+
+ return TestStepResult();
+ }
+
+#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT