os/security/contentmgmt/cafstreamingsupport/test/tscaf/source/tmultikeystreamdecoders.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Implements the Multiple Key Stream Decoder Test Case
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "tmultikeystreamdecoders.h"
sl@0
    19
sl@0
    20
#include "testprotstrdesc.h"
sl@0
    21
sl@0
    22
using namespace StreamAccess;
sl@0
    23
sl@0
    24
CScafMultiKeyStreamDecoders::CScafMultiKeyStreamDecoders(CScafServer& aParent): CScafStep(aParent)
sl@0
    25
/**
sl@0
    26
 * Constructor
sl@0
    27
 */
sl@0
    28
	{
sl@0
    29
	SetTestStepName(KScafMultiKeyStreamDecoders);
sl@0
    30
	}
sl@0
    31
sl@0
    32
CScafMultiKeyStreamDecoders::~CScafMultiKeyStreamDecoders()
sl@0
    33
/**
sl@0
    34
 * Destructor
sl@0
    35
 */
sl@0
    36
	{
sl@0
    37
	}
sl@0
    38
sl@0
    39
TVerdict CScafMultiKeyStreamDecoders::doTestStepPreambleL()
sl@0
    40
	{
sl@0
    41
	__UHEAP_MARK;
sl@0
    42
	
sl@0
    43
	// Reads the Thread ID
sl@0
    44
	RThread thread;
sl@0
    45
	iThreadId = thread.Id();
sl@0
    46
	thread.Close();
sl@0
    47
	
sl@0
    48
	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
sl@0
    49
	
sl@0
    50
	ReadTestConfigurationL();
sl@0
    51
	
sl@0
    52
	return TestStepResult();
sl@0
    53
	}
sl@0
    54
sl@0
    55
TVerdict CScafMultiKeyStreamDecoders::doTestL()
sl@0
    56
	{
sl@0
    57
	// Assume the test has failed if the test step result hasn't been otherwise set to EPass
sl@0
    58
	SetTestStepResult(EFail);
sl@0
    59
	
sl@0
    60
	// Retrieval of expected values for Key stream Decoder "A"
sl@0
    61
	TExpectedKeyStreamDecoderAttributes expectedAttributesA = iExpectedKeyStreamDecoderData[0];
sl@0
    62
	
sl@0
    63
	// Retrieval of expected values for Key stream Decoder "B"	
sl@0
    64
	TExpectedKeyStreamDecoderAttributes expectedAttributesB = iExpectedKeyStreamDecoderData[1];
sl@0
    65
	
sl@0
    66
	//Create an SDP document object and set the created key stream field object
sl@0
    67
	CSdpDocument* sdpDoc = CreateSdpDocumentLC();
sl@0
    68
	
sl@0
    69
	// Generate the 2 SDP media field objects from the attributes with the INI configuration
sl@0
    70
	CSdpMediaField* sdpA = CreateSdpLC(0);
sl@0
    71
	AddMediaFieldL(*sdpDoc, sdpA);
sl@0
    72
	CleanupStack::Pop(sdpA);
sl@0
    73
	
sl@0
    74
	CSdpMediaField* sdpB = CreateSdpLC(1);
sl@0
    75
	AddMediaFieldL(*sdpDoc, sdpB);
sl@0
    76
	CleanupStack::Pop(sdpB);
sl@0
    77
	
sl@0
    78
	// Generate the 2 protected key stream description objects for each of the key stream decoders. 
sl@0
    79
	HBufC* filePathA;
sl@0
    80
	if(iDecoderConfigurationArray[0]->iPrivateFolderPath.Length())
sl@0
    81
		{
sl@0
    82
		filePathA = GetFullPathLC(iDecoderConfigurationArray[0]->iPrivateFolderPath, KNullDesC);
sl@0
    83
		}
sl@0
    84
	else
sl@0
    85
		{
sl@0
    86
		filePathA = GetFullPathLC(KStaPrivateFolder, KNullDesC);
sl@0
    87
		}
sl@0
    88
	CTestProtectedStreamDesc* protectStreamDescA = CTestProtectedStreamDesc::NewL(*filePathA);
sl@0
    89
	CleanupStack::PopAndDestroy(filePathA);
sl@0
    90
	CleanupStack::PushL(protectStreamDescA);
sl@0
    91
	
sl@0
    92
	HBufC* filePathB;
sl@0
    93
	if(iDecoderConfigurationArray[1]->iPrivateFolderPath.Length())
sl@0
    94
		{
sl@0
    95
		filePathB = GetFullPathLC(iDecoderConfigurationArray[1]->iPrivateFolderPath, KNullDesC);
sl@0
    96
		}
sl@0
    97
	else
sl@0
    98
		{
sl@0
    99
		filePathB = GetFullPathLC(KStaPrivateFolder, KNullDesC);
sl@0
   100
		}
sl@0
   101
	CTestProtectedStreamDesc* protectStreamDescB = CTestProtectedStreamDesc::NewL(*filePathB);
sl@0
   102
	CleanupStack::PopAndDestroy(filePathB);
sl@0
   103
	CleanupStack::PushL(protectStreamDescB);
sl@0
   104
	
sl@0
   105
	/* Create key stream decoder A using the generated protected key stream description
sl@0
   106
	 * and SDP media description A
sl@0
   107
	 */
sl@0
   108
	CKeyStreamDecoder* decoderA = NULL;
sl@0
   109
	
sl@0
   110
	TRAPD(err,decoderA = CKeyStreamDecoder::NewL(*protectStreamDescA, *sdpA, *sdpDoc)); 
sl@0
   111
	
sl@0
   112
	if(!decoderA || err != KErrNone)
sl@0
   113
		{
sl@0
   114
		ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder A - %d ***"),iThreadId,err);
sl@0
   115
		User::Leave(err);
sl@0
   116
		}
sl@0
   117
	
sl@0
   118
	CleanupStack::PushL(decoderA);
sl@0
   119
	
sl@0
   120
	
sl@0
   121
	/* Create key stream decoder B using the generated protected key stream description
sl@0
   122
	 * and SDP media description B
sl@0
   123
	 */
sl@0
   124
	CKeyStreamDecoder* decoderB = NULL;
sl@0
   125
	
sl@0
   126
	TRAP(err,decoderB = CKeyStreamDecoder::NewL(*protectStreamDescB, *sdpB, *sdpDoc)); 
sl@0
   127
	
sl@0
   128
	if(!decoderB || err != KErrNone)
sl@0
   129
		{
sl@0
   130
		ERR_PRINTF3(_L("*** Thread %d: FAIL - Unsuccessful Construction of Key Stream Decoder B - %d ***"),iThreadId,err);
sl@0
   131
		User::Leave(err);
sl@0
   132
		}
sl@0
   133
	
sl@0
   134
	CleanupStack::PushL(decoderB);
sl@0
   135
	
sl@0
   136
		
sl@0
   137
	/* Check that the retrieved attribute values from either key stream decoder
sl@0
   138
	 * match the expected results stated within the configuration file
sl@0
   139
	 */
sl@0
   140
	TBool attributeCheckResult = ETrue;
sl@0
   141
	
sl@0
   142
	
sl@0
   143
	INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder A..."),iThreadId);
sl@0
   144
	if(!CheckKeyStreamDecoderAttributesL(*decoderA, expectedAttributesA))
sl@0
   145
		{
sl@0
   146
		ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder A attributes mismatch expected values ***"),iThreadId);
sl@0
   147
		attributeCheckResult = EFalse;
sl@0
   148
		}
sl@0
   149
	
sl@0
   150
	
sl@0
   151
	INFO_PRINTF2(_L("Thread %d: Checking Attributes for Key Stream Decoder B..."),iThreadId);
sl@0
   152
	if(!CheckKeyStreamDecoderAttributesL(*decoderB, expectedAttributesB))
sl@0
   153
		{
sl@0
   154
		ERR_PRINTF2(_L("*** Thread %d: FAIL - Key Stream Decoder B attributes mismatch expected values ***"),iThreadId);
sl@0
   155
		attributeCheckResult = EFalse;
sl@0
   156
		}
sl@0
   157
	
sl@0
   158
	if(attributeCheckResult)
sl@0
   159
		{
sl@0
   160
		INFO_PRINTF2(_L("*** Thread %d: SUCCESS - Attributes associated with Key Stream Decoders A & B match expected values ***"),iThreadId);
sl@0
   161
		SetTestStepResult(EPass);
sl@0
   162
		}
sl@0
   163
	
sl@0
   164
	CleanupStack::PopAndDestroy(5, sdpDoc); //< decoderB, decoderA, protectStreamDescB, protectStreamDescA, sdpDoc
sl@0
   165
	return TestStepResult();	
sl@0
   166
	}
sl@0
   167
sl@0
   168
TVerdict CScafMultiKeyStreamDecoders::doTestStepPostambleL()
sl@0
   169
	{
sl@0
   170
	iDecoderConfigurationArray.ResetAndDestroy();
sl@0
   171
	iExpectedKeyStreamDecoderData.Close();
sl@0
   172
	
sl@0
   173
	INFO_PRINTF3(_L("Thread %d - HEAP CELLS: %d"),iThreadId,User::CountAllocCells());
sl@0
   174
	__UHEAP_MARKEND;
sl@0
   175
	
sl@0
   176
	return TestStepResult();
sl@0
   177
	}