os/security/crypto/weakcryptospi/test/tbigint/tprimevector.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/test/tbigint/tprimevector.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,109 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "tprimevector.h"
    1.23 +#include "t_input.h"
    1.24 +#include <bigint.h>
    1.25 +
    1.26 +CTestAction* CPrimeVector::NewL(RFs& aFs, CConsoleBase& aConsole, 
    1.27 +	Output& aOut, const TTestActionSpec& aTestActionSpec)
    1.28 +	{
    1.29 +	CTestAction* self = CPrimeVector::NewLC(aFs, aConsole,
    1.30 +		aOut, aTestActionSpec);
    1.31 +	CleanupStack::Pop();
    1.32 +	return self;
    1.33 +	}
    1.34 +
    1.35 +CTestAction* CPrimeVector::NewLC(RFs& aFs, CConsoleBase& aConsole, 
    1.36 +	Output& aOut, const TTestActionSpec& aTestActionSpec)
    1.37 +	{
    1.38 +	CPrimeVector* self = new(ELeave) CPrimeVector(aFs, aConsole, aOut);
    1.39 +	CleanupStack::PushL(self);
    1.40 +	self->ConstructL(aTestActionSpec);
    1.41 +	return self;
    1.42 +	}
    1.43 +
    1.44 +CPrimeVector::~CPrimeVector()
    1.45 +	{
    1.46 +	delete iBody;
    1.47 +	delete iPrime;
    1.48 +	}
    1.49 +
    1.50 +CPrimeVector::CPrimeVector(RFs& aFs, CConsoleBase& aConsole, 
    1.51 +	Output& aOut) : CTestAction(aConsole, aOut), iFs(aFs)
    1.52 +	{
    1.53 +	}
    1.54 +
    1.55 +void CPrimeVector::ConstructL(const TTestActionSpec& aTestActionSpec)
    1.56 +	{
    1.57 +	CTestAction::ConstructL(aTestActionSpec);
    1.58 +	iBody = HBufC8::NewL(aTestActionSpec.iActionBody.Length());
    1.59 +	iBody->Des().Copy(aTestActionSpec.iActionBody);
    1.60 +
    1.61 +	iPrime = Input::ParseElementHexL(*iBody, _L8("<prime>"));
    1.62 +	}
    1.63 +
    1.64 +void CPrimeVector::DoPerformPrerequisite(TRequestStatus& aStatus)
    1.65 +	{
    1.66 +	TRequestStatus* status = &aStatus;
    1.67 +	User::RequestComplete(status, KErrNone);
    1.68 +	iActionState = CTestAction::EAction;
    1.69 +	}
    1.70 +
    1.71 +void CPrimeVector::DoPerformPostrequisite(TRequestStatus& aStatus)
    1.72 +	{
    1.73 +	TRequestStatus* status = &aStatus;
    1.74 +	iFinished = ETrue;
    1.75 +	User::RequestComplete(status, KErrNone);
    1.76 +	}
    1.77 +
    1.78 +void CPrimeVector::DoReportAction(void)
    1.79 +	{
    1.80 +	}
    1.81 +
    1.82 +void CPrimeVector::DoCheckResult(TInt /*aError*/)
    1.83 +	{
    1.84 +	iResult = (iResult && iExpectedResult) || (!iResult && !iExpectedResult);
    1.85 +	if (iResult)
    1.86 +		iConsole.Printf(_L("."));
    1.87 +	else
    1.88 +		iConsole.Printf(_L("X"));
    1.89 +	}
    1.90 +
    1.91 +
    1.92 +void CPrimeVector::PerformAction(TRequestStatus& aStatus)
    1.93 +	{
    1.94 +	PerformActionL();
    1.95 +	TRequestStatus* status = &aStatus;
    1.96 +	User::RequestComplete(status, KErrNone);
    1.97 +	iActionState = CTestAction::EPostrequisite;
    1.98 +	}
    1.99 +
   1.100 +void CPrimeVector::PerformActionL(void)
   1.101 +	{
   1.102 +	__UHEAP_MARK;
   1.103 +	iResult = ETrue;
   1.104 +
   1.105 +	RInteger prime = RInteger::NewL(*iPrime);
   1.106 +	CleanupStack::PushL(prime);
   1.107 +	iResult = prime.IsPrimeL();
   1.108 +
   1.109 +	CleanupStack::PopAndDestroy(&prime); 
   1.110 +	__UHEAP_MARKEND;
   1.111 +	}
   1.112 +