os/security/crypto/weakcryptospi/test/tcryptospi/src/symmetriccipherpositiveobjectloadstep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/test/tcryptospi/src/symmetriccipherpositiveobjectloadstep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,104 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-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 +* Example CTestStep derived implementation
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalTechnology
    1.26 +*/
    1.27 +#include "symmetriccipherpositiveobjectloadstep.h"
    1.28 +
    1.29 +#include <cryptospi/cryptosymmetriccipherapi.h>
    1.30 +#include <cryptospi/keys.h>
    1.31 +#include "filereader.h"
    1.32 +
    1.33 +using namespace CryptoSpi;
    1.34 +
    1.35 +CSymmetricCipherPositiveObjectLoadStep::~CSymmetricCipherPositiveObjectLoadStep()
    1.36 +	{
    1.37 +	}
    1.38 +
    1.39 +
    1.40 +CSymmetricCipherPositiveObjectLoadStep::CSymmetricCipherPositiveObjectLoadStep()
    1.41 +	{
    1.42 +	SetTestStepName(KSymmetricCipherPositiveObjectLoadStep);
    1.43 +	}
    1.44 +
    1.45 +
    1.46 +TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPreambleL()
    1.47 +	{
    1.48 +	SetTestStepResult(EPass);
    1.49 +	return TestStepResult();
    1.50 +	}
    1.51 +
    1.52 +
    1.53 +TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepL()
    1.54 +	{
    1.55 +
    1.56 +	INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load ***"));
    1.57 +	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
    1.58 +	
    1.59 +  	if (TestStepResult()==EPass)
    1.60 +		{
    1.61 +		
    1.62 +		//Assume failure, unless all is successful
    1.63 +		SetTestStepResult(EFail);
    1.64 +		
    1.65 +		TVariantPtrC operationMode;
    1.66 +		
    1.67 +		TBool shouldLoad(EFalse);
    1.68 +
    1.69 +		// Create a Symmetric Cipher with the values from the ini file	
    1.70 +		CryptoSpi::CSymmetricCipher * impl = NULL;	
    1.71 +			
    1.72 +		CKey* key = NULL;
    1.73 +		TRAPD(err, SetupCipherL(ETrue, EFalse, operationMode, impl, key));
    1.74 +
    1.75 +
    1.76 +		if(impl && err==KErrNone)
    1.77 +			{
    1.78 +			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
    1.79 +			delete impl;
    1.80 +			delete key;
    1.81 +			SetTestStepResult(EPass);
    1.82 +			}
    1.83 +		else if (!impl && err==KErrNotSupported && 
    1.84 +			     GetBoolFromConfig(ConfigSection(),_L("ShouldLoad"), shouldLoad) &&
    1.85 +			     shouldLoad == EFalse)
    1.86 +			{
    1.87 +			INFO_PRINTF1(_L("*** Symmetric Cipher - The object was not loaded which was expected ***"));
    1.88 +			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
    1.89 +			SetTestStepResult(EPass);
    1.90 +			}
    1.91 +		else
    1.92 +			{
    1.93 +			ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Cipher Object - %d ***"), err);
    1.94 +			SetTestStepResult(EFail);
    1.95 +			}	
    1.96 +		}
    1.97 +		
    1.98 +	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
    1.99 +
   1.100 +	return TestStepResult();
   1.101 +	}
   1.102 +
   1.103 +
   1.104 +TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPostambleL()
   1.105 +	{
   1.106 +	return TestStepResult();
   1.107 +	}