os/security/cryptoservices/filebasedcertificateandkeystores/test/tkeystore/t_settime.cpp
First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <unifiedkeystore.h>
21 #include "t_keystore_actions.h"
22 #include "t_keystore_defs.h"
26 /////////////////////////////////////////////////////////////////////////////////
28 /////////////////////////////////////////////////////////////////////////////////
30 CTestAction* CSetTime::NewL(RFs& aFs,
31 CConsoleBase& aConsole,
33 const TTestActionSpec& aTestActionSpec)
35 CTestAction* self = CSetTime::NewLC(aFs, aConsole, aOut, aTestActionSpec);
36 CleanupStack::Pop(self);
40 CTestAction* CSetTime::NewLC(RFs& aFs,
41 CConsoleBase& aConsole,
43 const TTestActionSpec& aTestActionSpec)
45 CSetTime* self = new (ELeave) CSetTime(aFs, aConsole, aOut);
46 CleanupStack::PushL(self);
47 self->ConstructL(aTestActionSpec);
55 CSetTime::CSetTime(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
56 CKeyStoreTestAction(aFs, aConsole, aOut), iState(EMain)
60 void CSetTime::ConstructL(const TTestActionSpec& aTestActionSpec)
62 CKeyStoreTestAction::ConstructL(aTestActionSpec);
64 TPtrC8 data = Input::ParseElement(aTestActionSpec.iActionBody, KHomeTimeStart);
68 void CSetTime::PerformAction(TRequestStatus& aStatus)
74 User::LeaveIfError(User::SetHomeTime(iNewTime));
77 TRequestStatus* status = &aStatus;
78 User::RequestComplete(status, KErrNone);
84 TRequestStatus* status = &aStatus;
85 User::RequestComplete(status, aStatus.Int());
86 if (aStatus == iExpectedResult)
95 iActionState = EPostrequisite;
101 void CSetTime::PerformCancel()
106 void CSetTime::Reset()
111 void CSetTime::DoReportAction()
113 iOut.writeString(_L("Setting time..."));
117 void CSetTime::DoCheckResult(TInt aError)
121 if (aError == KErrNone)
123 _LIT(KSuccessful, "Time set successfully\n");
124 iConsole.Write(KSuccessful);
125 iOut.writeString(KSuccessful);
131 if (aError!=iExpectedResult)
133 _LIT(KFailed, "!!!Set time failure!!!\n");
134 iConsole.Write(KFailed);
135 iOut.writeString(KFailed);
139 _LIT(KFailed, "Set time failed, but expected\n");
140 iConsole.Write(KFailed);
141 iOut.writeString(KFailed);
150 void CSetTime::SetNewTimeL(const TDesC8& aData)
152 HBufC* buf = HBufC::NewLC(aData.Length());
153 TPtr ptr = buf->Des();
155 User::LeaveIfError(iNewTime.Parse(*buf));
156 CleanupStack::PopAndDestroy(buf);