os/security/crypto/weakcryptospi/test/tcryptospi/src/hashpositiveobjectloadstep.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/crypto/weakcryptospi/test/tcryptospi/src/hashpositiveobjectloadstep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,109 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 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 "hashpositiveobjectloadstep.h"
1.28 +
1.29 +#include <cryptospi/cryptohashapi.h>
1.30 +
1.31 +
1.32 +using namespace CryptoSpi;
1.33 +
1.34 +CHashPositiveObjectLoadStep::~CHashPositiveObjectLoadStep()
1.35 + {
1.36 + }
1.37 +
1.38 +
1.39 +CHashPositiveObjectLoadStep::CHashPositiveObjectLoadStep()
1.40 + {
1.41 + SetTestStepName(KHashPositiveObjectLoadStep);
1.42 + }
1.43 +
1.44 +
1.45 +TVerdict CHashPositiveObjectLoadStep::doTestStepPreambleL()
1.46 + {
1.47 + SetTestStepResult(EPass);
1.48 + return TestStepResult();
1.49 + }
1.50 +
1.51 +
1.52 +TVerdict CHashPositiveObjectLoadStep::doTestStepL()
1.53 + {
1.54 + if (TestStepResult()==EPass)
1.55 + {
1.56 +
1.57 + //Assume faliure, unless all is successful
1.58 + SetTestStepResult(EFail);
1.59 +
1.60 + INFO_PRINTF1(_L("*** Hash - Positive Object Load ***"));
1.61 + INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
1.62 +
1.63 + TVariantPtrC algorithmUid;
1.64 + TVariantPtrC operationModeUid;
1.65 +
1.66 + //Extract the Test Case ID parameter from the specified INI file
1.67 + if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
1.68 + !GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationModeUid))
1.69 + {
1.70 + ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **"));
1.71 + SetTestStepResult(EFail);
1.72 + }
1.73 + else
1.74 + {
1.75 + //Create and intialise a pointer for the Hash implementation object
1.76 + CHash* hashImpl = NULL;
1.77 +
1.78 + INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
1.79 +
1.80 + //Retrieve a Hash factory object
1.81 + TRAPD(err,CHashFactory::CreateHashL(hashImpl,
1.82 + algorithmUid,
1.83 + operationModeUid,
1.84 + NULL,
1.85 + NULL));
1.86 +
1.87 + //If there are no errors (KErrNone) creating the Hash factory object, Pass the Test
1.88 + if(hashImpl && (err == KErrNone))
1.89 + {
1.90 + INFO_PRINTF1(_L("*** Hash - Positive Object Load: PASS ***"));
1.91 + delete hashImpl;
1.92 + SetTestStepResult(EPass);
1.93 + }
1.94 + else
1.95 + {
1.96 + ERR_PRINTF2(_L("*** FAIL: Failed to Create Hash Object - %d ***"), err);
1.97 + SetTestStepResult(EFail);
1.98 + }
1.99 + }
1.100 +
1.101 + INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
1.102 +
1.103 + }
1.104 + return TestStepResult();
1.105 + }
1.106 +
1.107 +
1.108 +TVerdict CHashPositiveObjectLoadStep::doTestStepPostambleL()
1.109 + {
1.110 +
1.111 + return TestStepResult();
1.112 + }