|
1 // Copyright (c) 2010 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\resmanus\d_resmanusbtrace.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <kernel/kernel.h> |
|
19 #include <drivers/resource.h> |
|
20 #include <drivers/resourcecontrol.h> |
|
21 #include <drivers/resmanus_trace.h> |
|
22 #include <drivers/resourcecontrol_trace.h> |
|
23 #include "d_resmanusbtraceconst.h" |
|
24 #include "d_resmanusbtrace.h" |
|
25 |
|
26 class DTestFactory : public DLogicalDevice |
|
27 // |
|
28 // Test LDD factory |
|
29 // |
|
30 { |
|
31 public: |
|
32 DTestFactory(); |
|
33 virtual TInt Install(); //overriding pure virtual |
|
34 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual |
|
35 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual |
|
36 }; |
|
37 |
|
38 class DTest1 : public DLogicalChannelBase |
|
39 // |
|
40 // Test logical channel |
|
41 // |
|
42 { |
|
43 public: |
|
44 virtual ~DTest1(); |
|
45 protected: |
|
46 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
47 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
48 |
|
49 private: |
|
50 TInt DoSendLog(TLogInfo* aInfo); |
|
51 TInt ClientHandle() { return KClientHandle; } |
|
52 }; |
|
53 |
|
54 |
|
55 |
|
56 DECLARE_STANDARD_LDD() |
|
57 { |
|
58 return new DTestFactory; |
|
59 } |
|
60 |
|
61 // |
|
62 // Constructor |
|
63 // |
|
64 DTestFactory::DTestFactory() |
|
65 { |
|
66 |
|
67 } |
|
68 |
|
69 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
70 { |
|
71 // |
|
72 // Create new channel |
|
73 // |
|
74 aChannel=new DTest1; |
|
75 return aChannel?KErrNone:KErrNoMemory; |
|
76 } |
|
77 |
|
78 TInt DTestFactory::Install() |
|
79 // |
|
80 // Install the LDD - overriding pure virtual |
|
81 // |
|
82 { |
|
83 return SetName(&KLddName); |
|
84 } |
|
85 |
|
86 void DTestFactory::GetCaps(TDes8& /*aDes*/) const |
|
87 // |
|
88 // Get capabilities - overriding pure virtual |
|
89 // |
|
90 { |
|
91 } |
|
92 |
|
93 TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
94 // |
|
95 // Create channel |
|
96 // |
|
97 { |
|
98 return KErrNone; |
|
99 } |
|
100 |
|
101 DTest1::~DTest1() |
|
102 // |
|
103 // Destructor |
|
104 // |
|
105 { |
|
106 } |
|
107 |
|
108 TInt DTest1::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) |
|
109 { |
|
110 |
|
111 // 'Control' functions... |
|
112 switch(aReqNo) |
|
113 { |
|
114 // DoControl |
|
115 case RLddTest1::ECONTROL_SENDLOG: |
|
116 TLogInfo info; |
|
117 DoSendLog(&info); |
|
118 Kern::ThreadRawWrite(&Kern::CurrentThread(), a1, &info, sizeof(info)); |
|
119 break; |
|
120 } |
|
121 |
|
122 return KErrNone; |
|
123 } |
|
124 |
|
125 class TestResource |
|
126 { |
|
127 public: |
|
128 TestResource(const TDesC8& aName, TInt aDefaultLevel) |
|
129 { |
|
130 iName = (HBuf8*)&aName; |
|
131 iDefaultLevel = aDefaultLevel; |
|
132 } |
|
133 HBuf* iName; |
|
134 TInt iDefaultLevel; |
|
135 TInt iResourceId; |
|
136 }; |
|
137 |
|
138 struct TestClient |
|
139 { |
|
140 TDes8* iName; |
|
141 TInt iClientId; |
|
142 }; |
|
143 |
|
144 struct TestCallback |
|
145 { |
|
146 TInt iResourceId; |
|
147 TInt iClientId; |
|
148 }; |
|
149 |
|
150 struct TestNotification |
|
151 { |
|
152 TestCallback iCallback; |
|
153 }; |
|
154 |
|
155 class TestRequest |
|
156 { |
|
157 public: |
|
158 TInt ResourceId() {return iResourceId;} |
|
159 TInt ClientId() {return iClientId;} |
|
160 TInt Level() {return iLevel;} |
|
161 TInt iResourceId; |
|
162 TInt iClientId; |
|
163 TInt iLevel; |
|
164 }; |
|
165 |
|
166 TInt DTest1::DoSendLog(TLogInfo* aInfo) |
|
167 { |
|
168 TInt r = KErrNoMemory; |
|
169 |
|
170 TInt iClient = (TInt) KClient; |
|
171 TBuf<80> Buffer; |
|
172 TDes8* iUserNameUsed = &Buffer; |
|
173 Buffer.Append(KCLIENTNAME); |
|
174 Kern::Printf("PRM_US_OPEN_CHANNEL_START_TRACE"); |
|
175 PRM_US_OPEN_CHANNEL_START_TRACE |
|
176 |
|
177 Kern::Printf("PRM_US_OPEN_CHANNEL_END_TRACE %x", (TInt)ClientHandle()); |
|
178 PRM_US_OPEN_CHANNEL_END_TRACE |
|
179 |
|
180 TUint8 stateRes[3] = {KStatsRes1, KStatsRes2, KStatsRes3}; |
|
181 Kern::Printf("PRM_US_REGISTER_CLIENT_START_TRACE"); |
|
182 PRM_US_REGISTER_CLIENT_START_TRACE |
|
183 |
|
184 Kern::Printf("PRM_US_REGISTER_CLIENT_END_TRACE"); |
|
185 PRM_US_REGISTER_CLIENT_END_TRACE |
|
186 |
|
187 Kern::Printf("PRM_US_DEREGISTER_CLIENT_START_TRACE"); |
|
188 PRM_US_DEREGISTER_CLIENT_START_TRACE |
|
189 |
|
190 Kern::Printf("PRM_US_DEREGISTER_CLIENT_END_TRACE"); |
|
191 PRM_US_DEREGISTER_CLIENT_END_TRACE |
|
192 |
|
193 TUint resourceId = KResourceId; |
|
194 Kern::Printf("PRM_US_GET_RESOURCE_STATE_START_TRACE"); |
|
195 PRM_US_GET_RESOURCE_STATE_START_TRACE |
|
196 |
|
197 TUint aResourceId = KResourceId; |
|
198 TUint aLevel = KLevel; |
|
199 TUint aClient = KClient; |
|
200 TUint aResult = KResult; |
|
201 Kern::Printf("PRM_US_GET_RESOURCE_STATE_END_TRACE"); |
|
202 PRM_US_GET_RESOURCE_STATE_END_TRACE |
|
203 |
|
204 TUint newState = KLevel; |
|
205 Kern::Printf("PRM_US_SET_RESOURCE_STATE_START_TRACE"); |
|
206 PRM_US_SET_RESOURCE_STATE_START_TRACE |
|
207 |
|
208 Kern::Printf("PRM_US_SET_RESOURCE_STATE_END_TRACE"); |
|
209 PRM_US_SET_RESOURCE_STATE_END_TRACE |
|
210 |
|
211 Kern::Printf("PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE"); |
|
212 PRM_US_CANCEL_GET_RESOURCE_STATE_START_TRACE |
|
213 |
|
214 Kern::Printf("PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE"); |
|
215 PRM_US_CANCEL_GET_RESOURCE_STATE_END_TRACE |
|
216 |
|
217 Kern::Printf("PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE"); |
|
218 PRM_US_CANCEL_SET_RESOURCE_STATE_START_TRACE |
|
219 |
|
220 Kern::Printf("PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE"); |
|
221 PRM_US_CANCEL_SET_RESOURCE_STATE_END_TRACE |
|
222 |
|
223 TPowerResourceInfoV01 ResourceInfo; |
|
224 TPowerResourceInfoV01* pResInfo = &ResourceInfo; |
|
225 TestResource Resource(KRESOURCENAME, KDefaultLevel); |
|
226 TestResource* pR = &Resource; |
|
227 pResInfo->iMinLevel = KMinLevel; |
|
228 pResInfo->iMaxLevel = KMaxLevel; |
|
229 pResInfo->iDefaultLevel = KDefaultLevel; |
|
230 TUint resCount = KResCount; |
|
231 Kern::Printf("PRM_REGISTER_RESOURCE_TRACE"); |
|
232 PRM_REGISTER_RESOURCE_TRACE |
|
233 |
|
234 TUint aClientId = KClientId; |
|
235 TBuf8<80> ClientName(KCLIENTNAME); |
|
236 SPowerResourceClient ResourceClient; |
|
237 SPowerResourceClient* pC = &ResourceClient; |
|
238 pC->iName = &ClientName; |
|
239 Kern::Printf("PRM_CLIENT_REGISTER_TRACE"); |
|
240 PRM_CLIENT_REGISTER_TRACE |
|
241 |
|
242 Kern::Printf("PRM_CLIENT_DEREGISTER_TRACE"); |
|
243 PRM_CLIENT_DEREGISTER_TRACE |
|
244 |
|
245 TInt aNewState = KLevel; |
|
246 pC->iClientId = KClientId; |
|
247 Kern::Printf("PRM_CLIENT_CHANGE_STATE_START_TRACE"); |
|
248 PRM_CLIENT_CHANGE_STATE_START_TRACE |
|
249 |
|
250 pC->iClientId = KClientId; |
|
251 Kern::Printf("PRM_CLIENT_CHANGE_STATE_END_TRACE"); |
|
252 PRM_CLIENT_CHANGE_STATE_END_TRACE |
|
253 |
|
254 TestNotification aN; |
|
255 TestNotification* pN = &aN; |
|
256 pN->iCallback.iResourceId = KResourceId; |
|
257 |
|
258 Kern::Printf("PRM_POSTNOTIFICATION_REGISTER_TRACE"); |
|
259 PRM_POSTNOTIFICATION_REGISTER_TRACE |
|
260 |
|
261 Kern::Printf("PRM_POSTNOTIFICATION_DEREGISTER_TRACE"); |
|
262 PRM_POSTNOTIFICATION_DEREGISTER_TRACE |
|
263 |
|
264 Kern::Printf("PRM_POSTNOTIFICATION_SENT_TRACE"); |
|
265 PRM_POSTNOTIFICATION_SENT_TRACE |
|
266 |
|
267 TestCallback* pCb = &(pN->iCallback); |
|
268 pCb->iClientId = KClientId; |
|
269 Kern::Printf("PRM_CALLBACK_COMPLETION_TRACE"); |
|
270 PRM_CALLBACK_COMPLETION_TRACE |
|
271 |
|
272 TInt size = KSize; |
|
273 PRM_MEMORY_USAGE_TRACE |
|
274 |
|
275 TestRequest aRequest; |
|
276 aRequest.iClientId = KClientId; |
|
277 aRequest.iResourceId = KResourceId; |
|
278 |
|
279 TDesC8* iName = iUserNameUsed; |
|
280 Kern::Printf("PRM_PSL_RESOURCE_GET_STATE_START_TRACE"); |
|
281 PRM_PSL_RESOURCE_GET_STATE_START_TRACE |
|
282 |
|
283 Kern::Printf("PRM_RESOURCE_GET_STATE_START_TRACE"); |
|
284 PRM_RESOURCE_GET_STATE_START_TRACE |
|
285 |
|
286 TInt retVal = KRetVal; |
|
287 TInt iCurLevel = KLevel; |
|
288 TInt aState = KLevel; |
|
289 Kern::Printf("PRM_PSL_RESOURCE_GET_STATE_END_TRACE"); |
|
290 PRM_PSL_RESOURCE_GET_STATE_END_TRACE |
|
291 |
|
292 Kern::Printf("PRM_RESOURCE_GET_STATE_END_TRACE"); |
|
293 PRM_RESOURCE_GET_STATE_END_TRACE |
|
294 |
|
295 Kern::Printf("PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE"); |
|
296 PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE |
|
297 |
|
298 aRequest.iLevel = KLevel; |
|
299 Kern::Printf("PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE"); |
|
300 PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE |
|
301 |
|
302 Kern::Printf("PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE"); |
|
303 PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE |
|
304 |
|
305 TInt iDefaultLevel = KDefaultLevel; |
|
306 TInt iFlags = KFlags; |
|
307 TInt iMinLevel = KMinLevel; |
|
308 TInt iMaxLevel = KMaxLevel; |
|
309 TInt aReason = KErrNoMemory; |
|
310 Kern::Printf("PRM_PSL_RESOURCE_CREATE_TRACE"); |
|
311 PRM_PSL_RESOURCE_CREATE_TRACE |
|
312 |
|
313 Kern::Printf("PRM_BOOTING_TRACE"); |
|
314 PRM_BOOTING_TRACE |
|
315 |
|
316 TestResource* aPDRes = &Resource; |
|
317 aPDRes->iResourceId = KResourceId; |
|
318 TestClient Client; |
|
319 TestClient* aClientPtr = &Client; |
|
320 aClientPtr->iName = &ClientName; |
|
321 aClientPtr->iClientId = KClientId; |
|
322 Kern::Printf("PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE"); |
|
323 PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE |
|
324 |
|
325 TestResource* pDR = &Resource; |
|
326 TInt level = KLevel; |
|
327 Kern::Printf("PRM_REGISTER_DYNAMIC_RESOURCE_TRACE"); |
|
328 PRM_REGISTER_DYNAMIC_RESOURCE_TRACE |
|
329 |
|
330 Kern::Printf("PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE"); |
|
331 PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE |
|
332 |
|
333 TestResource* pR1 = &Resource; |
|
334 TestResource* pR2 = &Resource; |
|
335 Kern::Printf("PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE"); |
|
336 PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE |
|
337 |
|
338 TestResource* pDR1 = &Resource; |
|
339 TestResource* pDR2 = &Resource; |
|
340 Kern::Printf("PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE"); |
|
341 PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE |
|
342 |
|
343 aInfo->iPR = &Resource; |
|
344 aInfo->iPC = &ResourceClient; |
|
345 aInfo->iPN = pN; |
|
346 aInfo->iPCb = pCb; |
|
347 aInfo->iPClient = &Client; |
|
348 aInfo->iPCallback = &(pN->iCallback); |
|
349 |
|
350 return KErrNone; |
|
351 } |