Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #include <e32std_private.h>
22 #include <u32std.h> // unicode builds
24 #include <e32base_private.h>
26 #include <e32Test.h> // RTest headder
28 #include <e32def_private.h>
29 #include "testcaseroot.h"
30 #include "testcasecontroller.h"
31 #include "testengine.h"
36 CTestCaseController* CTestCaseController::NewL(CTestEngine& aTestEngine,TBool aHostRole)
38 CTestCaseController* self = new (ELeave) CTestCaseController(aTestEngine,aHostRole);
39 CleanupStack::PushL(self);
41 CleanupStack::Pop(self);
46 CTestCaseController::CTestCaseController(CTestEngine& aTestEngine,TBool aHostRole)
47 : CActive(EPriorityStandard),
48 iTestEngine(aTestEngine),
51 // Add to current threads active scheduler
52 CActiveScheduler::Add(this);
56 CTestCaseController::~CTestCaseController()
58 // Cancel any outstanding test cases
64 void CTestCaseController::ConstructL()
68 iTestPolicy = CBasicTestPolicy::NewL();
70 err = iTestEngine.NextTestCaseId(iTestCaseId);
74 test.Next(iTestCaseId);
75 // pass control to the test-policy (which merely instantiates and runs the test)
76 iTestPolicy->RunTestCaseL(iTestCaseId, &iStatus);
77 SetActive(); // when the 1st test finnishes, we drop into our own RunL active processing loop
81 void CTestCaseController::DoCancel()
83 // Cancel the outstanding test case running
84 iTestPolicy->Cancel();
88 void CTestCaseController::RunL()
90 // Retrieve the completion code of the last test case run
91 TInt err(iStatus.Int());
95 test.Printf(_L("<Error> Test case %lS failed\n"),&iTestCaseId);
99 test.Printf(_L("Test case %lS passed\n"),&iTestCaseId);
102 // Find next test to run
103 err = iTestEngine.NextTestCaseId(iTestCaseId);
106 test.Printf(_L("\n")); // ensures blank line between tests
107 test.Printf(_L("\n"));
108 test.Next(iTestCaseId);
110 // run the next test here
111 iTestPolicy->RunTestCaseL(iTestCaseId, &iStatus);
114 else if (err == KErrNotFound)
116 RDebug::Printf("All specified test cases performed");
117 CActiveScheduler::Stop();
121 RDebug::Printf("<Error %d> Unknown error from CTestEngine::NextTestCaseId",err);
127 TInt CTestCaseController::RunError(TInt aError)
134 // Panic the test module