|
1 // Copyright (c) 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 "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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 |
|
23 #include "te_conestepbase.h" |
|
24 |
|
25 |
|
26 _LIT(KTestStepThread, "TestStepConeThread"); |
|
27 |
|
28 |
|
29 TVerdict CTe_ConeStepBase::doTestStepPreambleL() |
|
30 { |
|
31 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL(); |
|
32 |
|
33 TESTNOERRORL(iConeThread.Create(KTestStepThread, CTe_ConeStepBase::ConeThreadFunction, |
|
34 KDefaultStackSize, NULL, this)); |
|
35 |
|
36 iInitUISemaphore.CreateLocal(0); |
|
37 iConeThread.Resume(); // start the cone thread |
|
38 |
|
39 // wait for InitUIL() method to finish, that means test can start now |
|
40 iInitUISemaphore.Wait(); |
|
41 |
|
42 return TestStepResult(); |
|
43 } |
|
44 |
|
45 TVerdict CTe_ConeStepBase::doTestStepPostambleL() |
|
46 { |
|
47 iProfiler->FreeResultsMemory(); // cleanup memory in the baseclass (otherwise heaptest panics) |
|
48 |
|
49 iConeThread.RequestComplete(iTestCompletionStatus, KErrNone); // informs conestopper |
|
50 |
|
51 TRequestStatus status; |
|
52 iConeThread.Rendezvous(status); // asynchronous, completes amongst others when thread terminates |
|
53 User::WaitForRequest(status); // waits for Rendevous() to finish |
|
54 iConeThread.Close(); |
|
55 iInitUISemaphore.Close(); |
|
56 |
|
57 return CTe_graphicsperformanceSuiteStepBase::doTestStepPostambleL(); |
|
58 } |
|
59 |
|
60 |
|
61 /** |
|
62 * Starts the CONE thread. |
|
63 */ |
|
64 TInt CTe_ConeStepBase::ConeThreadFunction(TAny* aParams) |
|
65 { |
|
66 CTe_ConeStepBase* testStep = static_cast<CTe_ConeStepBase*>(aParams); |
|
67 return testStep->StartControlEnvironment(); |
|
68 } |
|
69 |
|
70 CCoeEnv* CTe_ConeStepBase::ConstructControlEnvironment() |
|
71 { |
|
72 CEikonEnv* eikonEnv = new CEikonEnv(); |
|
73 if (eikonEnv) |
|
74 { |
|
75 TRAPD(err, eikonEnv->ConstructL()); |
|
76 if (err != KErrNone) |
|
77 { |
|
78 delete eikonEnv; |
|
79 return NULL; |
|
80 } |
|
81 } |
|
82 return eikonEnv; |
|
83 } |
|
84 |
|
85 TInt CTe_ConeStepBase::StartControlEnvironment() |
|
86 { |
|
87 TInt err = KErrNoMemory; |
|
88 CConeThreadStopper* stopper = new CConeThreadStopper(*this); |
|
89 if (stopper) |
|
90 { |
|
91 CCoeEnv* coeEnv = ConstructControlEnvironment(); |
|
92 if (coeEnv) |
|
93 { |
|
94 TRAP(err, InitUIL(coeEnv)); |
|
95 if (err == KErrNone) |
|
96 { |
|
97 stopper->Start(iTestCompletionStatus); |
|
98 iInitUISemaphore.Signal(); |
|
99 coeEnv->ExecuteD(); // runs until its terminated by the CConeThreadStopper |
|
100 coeEnv = NULL; |
|
101 } |
|
102 delete coeEnv; |
|
103 } |
|
104 delete stopper; |
|
105 } |
|
106 if (err != KErrNone) |
|
107 { |
|
108 SetTestStepResult(EAbort); |
|
109 iInitUISemaphore.Signal(); // also signal if an error occurs, otherwise test would be blocked |
|
110 } |
|
111 return err; |
|
112 } |
|
113 |
|
114 |
|
115 void CTe_ConeStepBase::StopControlEnvironment() |
|
116 { |
|
117 CActiveScheduler::Stop(); |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 CConeThreadStopper::CConeThreadStopper(CTe_ConeStepBase& aTestStep) : |
|
123 CActive(EPriorityStandard), iTestStep(aTestStep) |
|
124 { |
|
125 // empty |
|
126 } |
|
127 |
|
128 CConeThreadStopper::~CConeThreadStopper() |
|
129 { |
|
130 Cancel(); |
|
131 } |
|
132 |
|
133 void CConeThreadStopper::Start(TRequestStatus *&aStopStatus) |
|
134 { |
|
135 CActiveScheduler::Add(this); |
|
136 aStopStatus = &iStatus; |
|
137 iStatus = KRequestPending; |
|
138 SetActive(); |
|
139 } |
|
140 |
|
141 void CConeThreadStopper::DoCancel() |
|
142 { |
|
143 // empty |
|
144 } |
|
145 |
|
146 void CConeThreadStopper::RunL() |
|
147 { |
|
148 iTestStep.StopControlEnvironment(); // stops the active scheduler of the CONE thread |
|
149 } |
|
150 |