Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\power\d_lddpowerseqtest.cpp
15 // LDD for testing the power up and down sequence
19 #include <kernel/kernel.h>
20 #include <kernel/kpower.h>
21 #include "d_lddpowerseqtest.h"
24 _LIT(KLitPower1,"PowerSeqTest1");
25 _LIT(KLitPower2,"PowerSeqTest2");
28 // Variables to store asynchronous status request and time count user variables address.
30 TRequestStatus *aStatus_up1;
31 TRequestStatus *aStatus_up2;
32 TRequestStatus *aStatus_down1;
33 TRequestStatus *aStatus_down2;
34 TUint *time_power1down;
35 TUint *time_power2down;
45 class DTest1PowerHandler : public DPowerHandler
51 void PowerDown(TPowerState);
57 class DTest2PowerHandler : public DPowerHandler
62 void PowerDown(TPowerState);
65 class DTestFactory : public DLogicalDevice
72 virtual TInt Install(); //overriding pure virtual
73 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
74 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
77 class DTest1 : public DLogicalChannelBase
79 // Test logical channel
85 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
86 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
87 DTest1PowerHandler power1;
88 DTest2PowerHandler power2;
93 DECLARE_STANDARD_LDD()
95 return new DTestFactory;
101 DTestFactory::DTestFactory()
106 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
109 // Create new channel
112 return aChannel?KErrNone:KErrNoMemory;
115 TInt DTestFactory::Install()
117 // Install the LDD - overriding pure virtual
120 return SetName(&KLddName);
123 void DTestFactory::GetCaps(TDes8& /*aDes*/) const
125 // Get capabilities - overriding pure virtual
130 TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
135 //try to remove a handler that hasn't been added yet - should not cause any problems
150 //try to remove a handler twice - should not cause any problems
154 TInt DTest1::Request(TInt aReqNo, TAny* a1, TAny* a2)
157 // Store status requests and time stamp variable for each power up and power down
162 // 'Request' functions...
163 TRequestStatus* s = (TRequestStatus*)a1;
165 kumemget32(args,a2,sizeof(args)); // get user side arguments
169 case RLddTest1::EPOWERDOWN_POWER1:
171 time_power1down = (TUint*)args[0];
174 case RLddTest1::EPOWERDOWN_POWER2:
176 time_power2down = (TUint*)args[0];
179 case RLddTest1::EPOWERUP_POWER1:
181 time_power1up = (TUint*)args[0];
184 case RLddTest1::EPOWERUP_POWER2:
186 time_power2up = (TUint*)args[0];
192 // 'Control' functions...
196 case RLddTest1::ESET_SLEEPTIME:
197 sleepTime = (TUint)a1;
205 DTest1PowerHandler::DTest1PowerHandler():DPowerHandler(KLitPower1)
208 // Power handler1 constructor
212 DTest2PowerHandler::DTest2PowerHandler():DPowerHandler(KLitPower2)
215 // Power handler2 constructor
220 void DTest1PowerHandler::PowerUp()
223 // Sleep for sometime to get different tick counts for comparision.
224 // Copy the tick count to user variable and complete the request
226 NKern::Sleep(sleepTime);
228 TUint temp = NKern::TickCount();
229 kumemput(time_power1up, (const TUint *)&temp, sizeof(temp));
231 Kern::RequestComplete(aStatus_up1, KErrNone);
237 void DTest2PowerHandler::PowerUp()
240 // Copy the tick count to user variable and complete the request
243 TUint temp = NKern::TickCount();
244 kumemput(time_power2up, (const TUint *)&temp, sizeof(temp));
246 Kern::RequestComplete(aStatus_up2, KErrNone);
251 void DTest1PowerHandler::PowerDown(TPowerState /*aState*/)
254 // Copy the tick count to user variable and complete the request
257 TUint temp = NKern::TickCount();
258 kumemput(time_power1down, (const TUint *)&temp, sizeof(temp));
260 Kern::RequestComplete(aStatus_down1, KErrNone);
265 void DTest2PowerHandler::PowerDown(TPowerState /*aState*/)
268 // Sleep for sometime to get different tick counts for comparision.
269 // Copy the tick count to user variable and complete the request
272 NKern::Sleep(sleepTime);
274 TUint temp = NKern::TickCount();
275 kumemput(time_power2down, (const TUint *)&temp, sizeof(temp));
277 Kern::RequestComplete(aStatus_down2, KErrNone);