0
|
1 |
// Copyright (c) 2006-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\power\d_lddpowerseqtest.cpp
|
|
15 |
// LDD for testing the power up and down sequence
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include <kernel/kernel.h>
|
|
20 |
#include <kernel/kpower.h>
|
|
21 |
#include "d_lddpowerseqtest.h"
|
|
22 |
|
|
23 |
|
|
24 |
_LIT(KLitPower1,"PowerSeqTest1");
|
|
25 |
_LIT(KLitPower2,"PowerSeqTest2");
|
|
26 |
|
|
27 |
//
|
|
28 |
// Variables to store asynchronous status request and time count user variables address.
|
|
29 |
//
|
|
30 |
TRequestStatus *aStatus_up1;
|
|
31 |
TRequestStatus *aStatus_up2;
|
|
32 |
TRequestStatus *aStatus_down1;
|
|
33 |
TRequestStatus *aStatus_down2;
|
|
34 |
TUint *time_power1down;
|
|
35 |
TUint *time_power2down;
|
|
36 |
TUint *time_power1up;
|
|
37 |
TUint *time_power2up;
|
|
38 |
TUint sleepTime;
|
|
39 |
|
|
40 |
|
|
41 |
class DTest1;
|
|
42 |
//
|
|
43 |
// Power handler1
|
|
44 |
//
|
|
45 |
class DTest1PowerHandler : public DPowerHandler
|
|
46 |
{
|
|
47 |
public:
|
|
48 |
DTest1PowerHandler();
|
|
49 |
|
|
50 |
void PowerUp();
|
|
51 |
void PowerDown(TPowerState);
|
|
52 |
};
|
|
53 |
|
|
54 |
//
|
|
55 |
// Power handler2
|
|
56 |
//
|
|
57 |
class DTest2PowerHandler : public DPowerHandler
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
DTest2PowerHandler();
|
|
61 |
void PowerUp();
|
|
62 |
void PowerDown(TPowerState);
|
280
|
63 |
void ActDead();
|
|
64 |
private:
|
|
65 |
TBool iActDead;
|
0
|
66 |
};
|
|
67 |
|
|
68 |
class DTestFactory : public DLogicalDevice
|
|
69 |
//
|
|
70 |
// Test LDD factory
|
|
71 |
//
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
DTestFactory();
|
|
75 |
virtual TInt Install(); //overriding pure virtual
|
|
76 |
virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
|
|
77 |
virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
|
|
78 |
};
|
|
79 |
|
|
80 |
class DTest1 : public DLogicalChannelBase
|
|
81 |
//
|
|
82 |
// Test logical channel
|
|
83 |
//
|
|
84 |
{
|
|
85 |
public:
|
|
86 |
virtual ~DTest1();
|
|
87 |
protected:
|
|
88 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
|
89 |
virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
|
|
90 |
DTest1PowerHandler power1;
|
|
91 |
DTest2PowerHandler power2;
|
280
|
92 |
private:
|
|
93 |
TUint iPslShutdownTimeoutMsBackup;
|
0
|
94 |
};
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
DECLARE_STANDARD_LDD()
|
|
99 |
{
|
|
100 |
return new DTestFactory;
|
|
101 |
}
|
|
102 |
|
|
103 |
//
|
|
104 |
// Constructor
|
|
105 |
//
|
|
106 |
DTestFactory::DTestFactory()
|
|
107 |
{
|
|
108 |
|
|
109 |
}
|
|
110 |
|
|
111 |
TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
|
|
112 |
{
|
|
113 |
//
|
|
114 |
// Create new channel
|
|
115 |
//
|
|
116 |
aChannel=new DTest1;
|
|
117 |
return aChannel?KErrNone:KErrNoMemory;
|
|
118 |
}
|
|
119 |
|
|
120 |
TInt DTestFactory::Install()
|
|
121 |
//
|
|
122 |
// Install the LDD - overriding pure virtual
|
|
123 |
//
|
|
124 |
{
|
|
125 |
return SetName(&KLddName);
|
|
126 |
}
|
|
127 |
|
|
128 |
void DTestFactory::GetCaps(TDes8& /*aDes*/) const
|
|
129 |
//
|
|
130 |
// Get capabilities - overriding pure virtual
|
|
131 |
//
|
|
132 |
{
|
|
133 |
}
|
|
134 |
|
|
135 |
TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
|
136 |
//
|
|
137 |
// Create channel
|
|
138 |
//
|
|
139 |
{
|
|
140 |
//try to remove a handler that hasn't been added yet - should not cause any problems
|
|
141 |
power1.Remove();
|
|
142 |
//Add power handlers
|
|
143 |
power2.Add();
|
|
144 |
power1.Add();
|
|
145 |
return KErrNone;
|
|
146 |
}
|
|
147 |
|
|
148 |
DTest1::~DTest1()
|
|
149 |
//
|
|
150 |
// Destructor
|
|
151 |
//
|
|
152 |
{
|
|
153 |
power1.Remove();
|
|
154 |
power2.Remove();
|
|
155 |
//try to remove a handler twice - should not cause any problems
|
|
156 |
power2.Remove();
|
280
|
157 |
((DTestPowerManager*)(Kern::PowerModel()))->iPslShutdownTimeoutMs = iPslShutdownTimeoutMsBackup;
|
0
|
158 |
}
|
|
159 |
|
|
160 |
TInt DTest1::Request(TInt aReqNo, TAny* a1, TAny* a2)
|
|
161 |
{
|
|
162 |
//
|
|
163 |
// Store status requests and time stamp variable for each power up and power down
|
|
164 |
//
|
|
165 |
|
|
166 |
if(aReqNo<0)
|
|
167 |
{
|
|
168 |
// 'Request' functions...
|
|
169 |
TRequestStatus* s = (TRequestStatus*)a1;
|
|
170 |
TAny* args[2];
|
|
171 |
kumemget32(args,a2,sizeof(args)); // get user side arguments
|
|
172 |
|
|
173 |
switch(~aReqNo)
|
|
174 |
{
|
|
175 |
case RLddTest1::EPOWERDOWN_POWER1:
|
|
176 |
aStatus_down1 = s;
|
|
177 |
time_power1down = (TUint*)args[0];
|
|
178 |
break;
|
|
179 |
|
|
180 |
case RLddTest1::EPOWERDOWN_POWER2:
|
|
181 |
aStatus_down2 = s;
|
|
182 |
time_power2down = (TUint*)args[0];
|
|
183 |
break;
|
|
184 |
|
|
185 |
case RLddTest1::EPOWERUP_POWER1:
|
|
186 |
aStatus_up1 = s;
|
|
187 |
time_power1up = (TUint*)args[0];
|
|
188 |
break;
|
|
189 |
|
|
190 |
case RLddTest1::EPOWERUP_POWER2:
|
|
191 |
aStatus_up2 = s;
|
|
192 |
time_power2up = (TUint*)args[0];
|
|
193 |
break;
|
|
194 |
}
|
|
195 |
}
|
|
196 |
else
|
|
197 |
{
|
|
198 |
// 'Control' functions...
|
|
199 |
switch(aReqNo)
|
|
200 |
{
|
280
|
201 |
|
0
|
202 |
// DoControl
|
|
203 |
case RLddTest1::ESET_SLEEPTIME:
|
|
204 |
sleepTime = (TUint)a1;
|
|
205 |
break;
|
280
|
206 |
case RLddTest1::EPOWER_ACTDEAD_POWER2:
|
|
207 |
power2.ActDead();
|
|
208 |
break;
|
|
209 |
case RLddTest1::EPOWER_ESETPOWERDOWNTIMEOUT:
|
|
210 |
iPslShutdownTimeoutMsBackup = ((DTestPowerManager*)(Kern::PowerModel()))->iPslShutdownTimeoutMs;
|
|
211 |
((DTestPowerManager*)(Kern::PowerModel()))->iPslShutdownTimeoutMs = (TUint)a1;
|
|
212 |
break;
|
0
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
return KErrNone;
|
|
217 |
}
|
|
218 |
|
|
219 |
DTest1PowerHandler::DTest1PowerHandler():DPowerHandler(KLitPower1)
|
|
220 |
{
|
|
221 |
//
|
|
222 |
// Power handler1 constructor
|
|
223 |
//
|
|
224 |
}
|
|
225 |
|
280
|
226 |
DTest2PowerHandler::DTest2PowerHandler():DPowerHandler(KLitPower2), iActDead(EFalse)
|
0
|
227 |
{
|
|
228 |
//
|
|
229 |
// Power handler2 constructor
|
|
230 |
//
|
|
231 |
}
|
|
232 |
|
|
233 |
|
|
234 |
void DTest1PowerHandler::PowerUp()
|
|
235 |
{
|
|
236 |
//
|
|
237 |
// Sleep for sometime to get different tick counts for comparision.
|
|
238 |
// Copy the tick count to user variable and complete the request
|
|
239 |
//
|
|
240 |
NKern::Sleep(sleepTime);
|
|
241 |
|
|
242 |
TUint temp = NKern::TickCount();
|
|
243 |
kumemput(time_power1up, (const TUint *)&temp, sizeof(temp));
|
|
244 |
|
|
245 |
Kern::RequestComplete(aStatus_up1, KErrNone);
|
|
246 |
|
|
247 |
PowerUpDone();
|
|
248 |
|
|
249 |
}
|
|
250 |
|
|
251 |
void DTest2PowerHandler::PowerUp()
|
|
252 |
{
|
|
253 |
//
|
|
254 |
// Copy the tick count to user variable and complete the request
|
|
255 |
//
|
|
256 |
|
|
257 |
TUint temp = NKern::TickCount();
|
|
258 |
kumemput(time_power2up, (const TUint *)&temp, sizeof(temp));
|
|
259 |
|
|
260 |
Kern::RequestComplete(aStatus_up2, KErrNone);
|
|
261 |
|
|
262 |
PowerUpDone();
|
|
263 |
}
|
|
264 |
|
|
265 |
void DTest1PowerHandler::PowerDown(TPowerState /*aState*/)
|
|
266 |
{
|
|
267 |
//
|
|
268 |
// Copy the tick count to user variable and complete the request
|
|
269 |
//
|
|
270 |
|
|
271 |
TUint temp = NKern::TickCount();
|
|
272 |
kumemput(time_power1down, (const TUint *)&temp, sizeof(temp));
|
|
273 |
|
|
274 |
Kern::RequestComplete(aStatus_down1, KErrNone);
|
|
275 |
|
|
276 |
PowerDownDone();
|
|
277 |
}
|
|
278 |
|
|
279 |
void DTest2PowerHandler::PowerDown(TPowerState /*aState*/)
|
|
280 |
{
|
|
281 |
//
|
|
282 |
// Sleep for sometime to get different tick counts for comparision.
|
|
283 |
// Copy the tick count to user variable and complete the request
|
|
284 |
//
|
|
285 |
|
|
286 |
NKern::Sleep(sleepTime);
|
|
287 |
|
|
288 |
TUint temp = NKern::TickCount();
|
|
289 |
kumemput(time_power2down, (const TUint *)&temp, sizeof(temp));
|
|
290 |
|
|
291 |
Kern::RequestComplete(aStatus_down2, KErrNone);
|
|
292 |
|
280
|
293 |
if(!iActDead)
|
|
294 |
{
|
|
295 |
PowerDownDone();
|
|
296 |
}
|
0
|
297 |
}
|
280
|
298 |
|
|
299 |
void DTest2PowerHandler::ActDead()
|
|
300 |
{
|
|
301 |
iActDead = ETrue;
|
|
302 |
}
|
|
303 |
|