sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @internalComponent sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include // unicode builds sl@0: #include sl@0: #include sl@0: #include sl@0: #include // RTest headder sl@0: #include "testcaseroot.h" sl@0: #include "testpolicy.h" sl@0: #include "testcasefactory.h" sl@0: sl@0: sl@0: sl@0: sl@0: CBasicTestPolicy* CBasicTestPolicy::NewL() sl@0: { sl@0: CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CBasicTestPolicy::CBasicTestPolicy() sl@0: : CActive(EPriorityStandard) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: sl@0: void CBasicTestPolicy::ConstructL() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: } sl@0: sl@0: sl@0: CBasicTestPolicy::~CBasicTestPolicy() sl@0: { sl@0: Cancel(); sl@0: if (iTestCase) sl@0: { sl@0: delete iTestCase; sl@0: } sl@0: } sl@0: sl@0: sl@0: /* Because the test policy can be referenced from the test case, parameters to pass to sl@0: the test-case may be stored in this class in future for access on ad-hoc basis as each test sl@0: case desires, without a need to modify all test cases sl@0: */ sl@0: void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId, TRequestStatus* aNotifierStatus) sl@0: { sl@0: LOG_FUNC sl@0: iNotifierStatus = aNotifierStatus; sl@0: // delete previous test run sl@0: if (iTestCase) sl@0: { sl@0: delete iTestCase; sl@0: iTestCase = NULL; sl@0: } sl@0: sl@0: // create the test class sl@0: iTestCase = RTestFactory::CreateTestCaseL(aTestCaseId); sl@0: // configure it sl@0: iTestCase->SetTestPolicy(this); sl@0: sl@0: iTestCase->DisplayTestCaseOptions(); // test preconditions and detail sl@0: sl@0: // run the test-case sl@0: iTestCase->PerformTestL(); sl@0: sl@0: *iNotifierStatus = KRequestPending; sl@0: } sl@0: sl@0: sl@0: void CBasicTestPolicy::DoCancel() sl@0: { sl@0: iTestCase->Cancel(); sl@0: sl@0: User::RequestComplete(iNotifierStatus, KErrCancel); sl@0: } sl@0: sl@0: sl@0: void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode) sl@0: { sl@0: if (KErrNone == aCompletionCode) sl@0: { sl@0: // Note there is no way to pass __FILE__ __LINE__ 'in' to this 'macro' sl@0: test(ETrue); sl@0: } sl@0: else sl@0: { sl@0: test(EFalse); // failed (PANIC here) sl@0: } sl@0: sl@0: if (iNotifierStatus) // will be null if we already signalled earlier sl@0: { sl@0: User::RequestComplete(iNotifierStatus, aCompletionCode); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CBasicTestPolicy::RunL() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CBasicTestPolicy::RunError(TInt /*aError*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: