os/security/cryptomgmtlibs/securitytestfw/test/testhandler2/t_message.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21 */
    22 
    23 #include "t_message.h"
    24 #include "t_input.h"
    25 #include "t_testactionspec.h"
    26 #include "t_output.h"
    27 
    28 _LIT8(KMessageStart, "<message>");
    29 _LIT8(KMessageEnd, "</message>");
    30 
    31 CTestActionMessage* CTestActionMessage::NewL(CConsoleBase& aConsole, 
    32 											 Output& aOut,
    33 											 const TTestActionSpec& aTestActionSpec)
    34 	{
    35 	CTestActionMessage* self = CTestActionMessage::NewLC(aConsole, aOut, aTestActionSpec);
    36 	CleanupStack::Pop(self);
    37 	return self;
    38 	}
    39 
    40 CTestActionMessage* CTestActionMessage::NewLC(CConsoleBase& aConsole, 
    41 											  Output& aOut,
    42 											  const TTestActionSpec& aTestActionSpec)
    43 	{
    44 	CTestActionMessage* self = new(ELeave) CTestActionMessage(aConsole, aOut);
    45 	CleanupStack::PushL(self);
    46 	self->ConstructL(aTestActionSpec);
    47 	return self;
    48 	}
    49 
    50 CTestActionMessage::~CTestActionMessage()
    51 	{
    52 	delete iMessage;
    53 	}
    54 
    55 void CTestActionMessage::DoPerformPrerequisite(TRequestStatus& aStatus)
    56 	{
    57 	iActionState = EAction;
    58 	TRequestStatus* status = &aStatus;
    59 	User::RequestComplete(status, KErrNone);
    60 	};
    61 
    62 void CTestActionMessage::PerformAction(TRequestStatus& aStatus)
    63 	{
    64 	TRequestStatus* status = &aStatus;
    65 	User::RequestComplete(status, KErrNone);
    66 	iActionState = EPostrequisite;
    67 	}
    68 
    69 void CTestActionMessage::DoPerformPostrequisite(TRequestStatus& aStatus) 
    70 	{	
    71 	TRequestStatus* status = &aStatus;
    72 	User::RequestComplete(status, KErrNone);
    73 	iFinished = ETrue;
    74 	iResult = ETrue;
    75 	};
    76 
    77 void CTestActionMessage::PerformMessage()
    78 	{
    79 	__ASSERT_DEBUG(EFalse, User::Panic(_L("CTestActionMessage::PerformMessage()"), 1));
    80 	}
    81 
    82 void CTestActionMessage::Reset()
    83 	{
    84 	__ASSERT_DEBUG(EFalse, User::Panic(_L("CTestActionMessage::Reset()"), 1));
    85 	}
    86 
    87 CTestActionMessage::CTestActionMessage(CConsoleBase& aConsole, 
    88 									   Output& aOut)
    89 : CTestAction(aConsole, aOut) 
    90 	{
    91 	}
    92 
    93 void CTestActionMessage::ConstructL(const TTestActionSpec& aTestActionSpec)
    94 	{
    95 	CTestAction::ConstructL(aTestActionSpec);
    96 	TInt pos = 0;
    97 	TInt err = KErrNone;
    98 	HBufC8* aBody = HBufC8::NewLC(aTestActionSpec.iActionBody.Length());
    99 	aBody->Des().Copy(aTestActionSpec.iActionBody);
   100 	TPtrC8 pMessage = Input::ParseElement(*aBody, KMessageStart, KMessageEnd, pos, err);
   101 	User::LeaveIfError(err);
   102 	iMessage = pMessage.AllocL();
   103 	CleanupStack::PopAndDestroy();
   104 	}
   105 
   106 void CTestActionMessage::DoReportAction()
   107 	{
   108 	iOut.writeString(*iMessage);
   109 	iOut.writeNewLine();
   110 	iOut.writeNewLine();
   111 	}
   112 
   113 void CTestActionMessage::DoCheckResult(TInt /*aError*/)
   114 	{
   115 	}