crypto/weakcryptospi/test/tcryptospi/src/symmetriccipherpositiveobjectloadstep.cpp
changeset 8 35751d3474b7
child 49 2f10d260163b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-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 * Example CTestStep derived implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalTechnology
       
    23 */
       
    24 #include "symmetriccipherpositiveobjectloadstep.h"
       
    25 
       
    26 #include "cryptosymmetriccipherapi.h"
       
    27 #include "keys.h"
       
    28 #include "filereader.h"
       
    29 
       
    30 using namespace CryptoSpi;
       
    31 
       
    32 CSymmetricCipherPositiveObjectLoadStep::~CSymmetricCipherPositiveObjectLoadStep()
       
    33 	{
       
    34 	}
       
    35 
       
    36 
       
    37 CSymmetricCipherPositiveObjectLoadStep::CSymmetricCipherPositiveObjectLoadStep()
       
    38 	{
       
    39 	SetTestStepName(KSymmetricCipherPositiveObjectLoadStep);
       
    40 	}
       
    41 
       
    42 
       
    43 TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPreambleL()
       
    44 	{
       
    45 	SetTestStepResult(EPass);
       
    46 	return TestStepResult();
       
    47 	}
       
    48 
       
    49 
       
    50 TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepL()
       
    51 	{
       
    52 
       
    53 	INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load ***"));
       
    54 	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
       
    55 	
       
    56   	if (TestStepResult()==EPass)
       
    57 		{
       
    58 		
       
    59 		//Assume failure, unless all is successful
       
    60 		SetTestStepResult(EFail);
       
    61 		
       
    62 		TVariantPtrC operationMode;
       
    63 		
       
    64 		TBool shouldLoad(EFalse);
       
    65 
       
    66 		// Create a Symmetric Cipher with the values from the ini file	
       
    67 		CryptoSpi::CSymmetricCipher * impl = NULL;	
       
    68 			
       
    69 		CKey* key = NULL;
       
    70 		TRAPD(err, SetupCipherL(ETrue, EFalse, operationMode, impl, key));
       
    71 
       
    72 
       
    73 		if(impl && err==KErrNone)
       
    74 			{
       
    75 			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
       
    76 			delete impl;
       
    77 			delete key;
       
    78 			SetTestStepResult(EPass);
       
    79 			}
       
    80 		else if (!impl && err==KErrNotSupported && 
       
    81 			     GetBoolFromConfig(ConfigSection(),_L("ShouldLoad"), shouldLoad) &&
       
    82 			     shouldLoad == EFalse)
       
    83 			{
       
    84 			INFO_PRINTF1(_L("*** Symmetric Cipher - The object was not loaded which was expected ***"));
       
    85 			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
       
    86 			SetTestStepResult(EPass);
       
    87 			}
       
    88 		else
       
    89 			{
       
    90 			ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Cipher Object - %d ***"), err);
       
    91 			SetTestStepResult(EFail);
       
    92 			}	
       
    93 		}
       
    94 		
       
    95 	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
       
    96 
       
    97 	return TestStepResult();
       
    98 	}
       
    99 
       
   100 
       
   101 TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPostambleL()
       
   102 	{
       
   103 	return TestStepResult();
       
   104 	}