Update contrib.
2 * Copyright (c) 1998-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 "t_testaction.h"
23 #include "t_testactionspec.h"
24 #include "tScriptSetup.h"
25 #include "t_testhandler.h"
27 EXPORT_C CTestAction::~CTestAction()
32 EXPORT_C void CTestAction::PerformPrerequisite(TRequestStatus& aStatus)
34 DoPerformPrerequisite(aStatus);
37 EXPORT_C void CTestAction::PerformPostrequisite(TRequestStatus& aStatus)
39 DoPerformPostrequisite(aStatus);
42 EXPORT_C void CTestAction::AfterOOMFailure()
46 TBool CTestAction::Finished()
51 EXPORT_C void CTestAction::ReportAction()
53 iOut.writeString(*iNameInfo);
58 EXPORT_C void CTestAction::CheckResult(TInt aError)
61 // DoCheckResult must update iResult
62 //iResult = (iResult && iExpectedResult) || (!iResult && !iExpectedResult);
63 DoCheckResult(aError);
65 if (iKnownFailure) // Expecting an error because of known
66 iResult = ETrue; // defect current deferred etc
68 iOut.writeString(_L("\tStatus : "));
69 iOut.writeError(aError);
70 iOut.writeString(_L(" ("));
71 iOut.writeNum(aError);
72 iOut.writeString(_L(")"));
74 iOut.writeString(_L("\tTest outcome : "));
77 iOut.writeString(_L("PASSED"));
81 iOut.writeString(_L("FAILED"));
87 EXPORT_C void CTestAction::PerformCancel()
91 EXPORT_C void CTestAction::Reset()
95 EXPORT_C CTestAction::CTestAction(CConsoleBase& aConsole,
97 : iFinished(EFalse), iKnownFailure(EFalse), iConsole(aConsole), iOut(aOut)
101 EXPORT_C void CTestAction::ConstructL(const TTestActionSpec& aTestActionSpec)
103 iNameInfo = aTestActionSpec.iActionName.AllocL();
105 iTefScript = aTestActionSpec.iTefScript;
107 TRAPD(err, iExpectedResult = Input::ParseElementBoolL(
108 aTestActionSpec.iActionResult, _L8("<result>")) );
109 if(err == KErrArgument)
111 //if there is no <result> field or it has invalid text then we assume
112 //it's a "normal" test. ie it must be true to pass.
113 iExpectedResult = ETrue;
115 else if(err != KErrNone)
120 // If there's a known defect because of deferred defects etc, the script
121 // will flag it. We record as much here and, when result is returned, check
122 // against known failure and adjust result accordingly. This should only be
123 // used for reported defects that have been deferred etc rather than as a
124 // workaround for test failures. The failure will be reported in a separate
125 // part of the log file so it's not overlooked entirely.
127 _LIT8(KTrue, "ETrue");
128 // _LIT8(KFalse, "EFalse");
133 TPtrC8 knownFailure = Input::ParseElement(aTestActionSpec.iActionBody, KKnownDefectStart, KKnownDefectEnd, pos, err);
134 if (knownFailure.Compare(KTrue)==0)
135 iKnownFailure = ETrue;
136 else // Assume if it's not true it's false or not there which == false
137 iKnownFailure = EFalse;
141 EXPORT_C void CTestAction::DoPerformPrerequisite(TRequestStatus& aStatus)
143 iActionState = EAction;
144 TRequestStatus* status = &aStatus;
145 User::RequestComplete(status, KErrNone);
148 EXPORT_C void CTestAction::DoPerformPostrequisite(TRequestStatus& aStatus)
150 TRequestStatus* status = &aStatus;
151 // pass on any error from peform action
152 User::RequestComplete(status, aStatus.Int());
156 EXPORT_C void CTestAction::FailTestNow(TRequestStatus& aStatus)
158 iActionState=EPostrequisite;
160 TRequestStatus* status = &aStatus;
161 User::RequestComplete(status, KErrNone);
165 EXPORT_C CTestAction::TScriptError CTestAction::ScriptError(void)
167 return(iScriptError);
170 EXPORT_C void CTestAction::SetScriptError(const TScriptError &aScriptError, const TDesC& aError)
172 iScriptError = aScriptError;
173 aScriptErrorDescription.Copy(aError);
176 EXPORT_C void CTestAction::ScriptError(TDes& aError)
178 aError.Copy(aScriptErrorDescription);
181 void CTestAction::SetTestHandler(CTestHandler& aTestHandler)
183 iTestHandler = &aTestHandler;
186 EXPORT_C CBase* CTestAction::SharedData() const
188 ASSERT(iTestHandler);
189 return iTestHandler->SharedData();
192 EXPORT_C void CTestAction::SetSharedData(CBase* aData)
194 ASSERT(iTestHandler);
195 iTestHandler->SetSharedData(aData);
198 EXPORT_C void CTestAction::ResetState()