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.
20 #include <e32std_private.h>
21 #include <u32std.h> // unicode builds
23 #include <e32base_private.h>
25 #include <e32Test.h> // RTest headder
26 #include "testcaseroot.h"
27 #include "testcasewd.h"
28 #include "testcasefactory.h"
29 #include "exampletestcase.h"
33 // the name below is used to add a pointer to our construction method to a pointer MAP in
35 _LIT(KTestCaseId,"EXAMPLETESTCASE");
37 // UNcomment the next line to add the test to the catalog(factory)
38 const TTestCaseFactoryReceipt<CExampleTestCase> CExampleTestCase::iFactoryReceipt(KTestCaseId);
40 CExampleTestCase* CExampleTestCase::NewL(TBool aHost)
43 CExampleTestCase* self = new (ELeave) CExampleTestCase(aHost);
44 CleanupStack::PushL(self);
46 CleanupStack::Pop(self);
51 CExampleTestCase::CExampleTestCase(TBool aHost)
52 : CTestCaseRoot(KTestCaseId, aHost)
58 void CExampleTestCase::ConstructL()
62 iWDTimer = CTestCaseWatchdog::NewL();
66 CExampleTestCase::~CExampleTestCase()
75 void CExampleTestCase::ExecuteTestCaseL()
78 iCaseStep = EFirstStep;
81 CActiveScheduler::Add(this);
82 // run our root RunL()
87 void CExampleTestCase::DescribePreconditions()
89 test.Printf(_L("This is an example test, there is nothing to do beforehand.\n"));
92 void CExampleTestCase::DoCancel()
99 void CExampleTestCase::ProcessKey(TKeyCode &aKey)
100 { // the default implementation does this already, but we will store the key here again anyway
101 iKeyCodeInput = aKey;
105 void CExampleTestCase::FuncA(CTestCaseRoot *pThis)
107 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis);
108 // cancel any pending call, and then complete our active obj with a timeout value
109 test.Printf(_L("@@@ FuncA cancel a keyboard Read() @@@\n"));
111 p->iConsole->ReadCancel();
115 void CExampleTestCase::FuncB(CTestCaseRoot *pThis)
117 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis);
118 // cancel any pending call, and then complete our active obj with a timeout value
119 test.Printf(_L("@@@ FuncB cancel a 'B' keyboard Read() @@@\n"));
122 p->iConsole->ReadCancel();
124 TRequestStatus* s = &p->iStatus;
125 p->iStatus = KRequestPending;
128 User::RequestComplete(s, KTestCaseWatchdogTO);
133 // handle event completion
134 void CExampleTestCase::RunStepL()
138 // Obtain the completion code for this CActive obj.
139 TInt completionCode(iStatus.Int());
140 RDebug::Printf("Example test iStatus compl.=%d\n", completionCode);
141 //test.Printf(_L("Example test iStatus compl.=%d\n"), completionCode);
146 iCaseStep=ESecondStep;
147 test.Printf(_L("Test step 1\n"));
152 iCaseStep=EThirdStep;
153 test.Printf(_L("Test step 2\n"));
154 test.Printf(_L("(this test step uses Keyboard)\n"));
155 test.Printf(_L("Press ANY key once you have removed the 'A' connector...\n"));
157 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncA);
160 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput);
162 iCaseStep=EFourthStep;
163 test.Printf(_L("Test step 3\n"));
164 test.Printf(_L("(this test step uses Keyboard)\n"));
165 test.Printf(_L("Press <SPACE> key once you have removed the 'A' connector...\n"));
167 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncB);
171 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput);
172 test.Printf(_L("Test step 4\n"));
175 iCaseStep=EFifthStep;
176 if (' ' != iKeyCodeInput)
179 iCaseStep=EThirdStep;
184 iCaseStep=ESixthStep;
185 test.Printf(_L("Test step 5\n"));
186 test.Printf(_L("(this test uses a delay)\n"));
187 iTimer.After(iStatus, 500000);
192 test.Printf(_L("Test step 6(%d)\n"), completionCode);
194 iConsole->ReadCancel();
201 iCaseStep=ESecondStep;
202 test.Printf(_L("LAST step7 code (%d)\n"), completionCode);
203 TestPolicy().SignalTestComplete(KErrNone);
208 //test.Printf(_L("<Error> unknown test step"));
210 TestFailed(KErrCorrupt, _L("unknown test step"));