|
1 // Copyright (c) 1995-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 // Automatically test the window server capabilities. |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include "W32STD.H" |
|
20 #include "../SERVER/w32cmd.h" |
|
21 #include <e32svr.h> |
|
22 #include <bacline.h> |
|
23 #include <hal.h> |
|
24 |
|
25 typedef TInt (*TPanicFunction)(TInt aInt,TDes& capability,TInt aExternalGroupId); |
|
26 LOCAL_D const TUint KPanicThreadHeapSize=0x2000; |
|
27 #define EWindowGroupHandle 1234 |
|
28 #define EWindowGroupHandle2 4567 |
|
29 _LIT(KCAPABILITY_ALL,"CAPABILITY_ALL"); |
|
30 _LIT(KCAPABILITY_NONE,"CAPABILITY_NONE"); |
|
31 _LIT(KWRITEDATA_SWEVENT,"WRITEDATA+SWEVENT"); |
|
32 _LIT(KWRITEDATA_POWERMGMT,"WRITEDATA+POWERMGMT"); |
|
33 _LIT(KPOWERMGMT_SWEVENT,"POWERMGMT+SWEVENT"); |
|
34 _LIT(KSetOrdinalPositionPri,"EWsWinOpSetOrdinalPositionPri Capability Check"); |
|
35 _LIT(KSetOrdinalPositionErr,"EWsWinOpSetOrdinalPositionErr Capability Check"); |
|
36 TLogMessageText LogMessageText; |
|
37 |
|
38 //Enum for indicating which capability is checked. |
|
39 enum TTestCapability |
|
40 { |
|
41 EWriteDeviceData, |
|
42 ESwEvent, |
|
43 EPowerMgmt, |
|
44 EDoNotTest, |
|
45 ENoCapReq, |
|
46 EEikSrvSID, |
|
47 ESwEventPri, |
|
48 ENoSwEventPri, |
|
49 ENoSwEventPriSmallOrdinal, |
|
50 ESwEventErr, |
|
51 ENoSwEventErr, |
|
52 ENoSwEventErrSmallOrdinal, |
|
53 }; |
|
54 |
|
55 //Enum for test exit reasons |
|
56 enum TTestState |
|
57 { |
|
58 EWsExitReasonBad, |
|
59 EWsTestNext, |
|
60 EWsTestFinished, |
|
61 }; |
|
62 |
|
63 |
|
64 TTestCapability gTheTestCapability; |
|
65 TInt gTestState=KErrNone; |
|
66 |
|
67 |
|
68 //Panics if EWsExitReasonBad |
|
69 enum TAutoPanics |
|
70 { |
|
71 EAutoPanicPanicFailed, |
|
72 }; |
|
73 |
|
74 //Thread function structure |
|
75 struct SPanicParams |
|
76 { |
|
77 TInt num; |
|
78 TPanicFunction func; |
|
79 TBuf<256> capability; |
|
80 TInt externalGroupId; |
|
81 }; |
|
82 |
|
83 class CTestBase |
|
84 { |
|
85 public: |
|
86 CTestBase(); |
|
87 ~CTestBase(); |
|
88 void ConstructL(const TDes* aCapabilityTest); |
|
89 TInt TestWsPanicL(TPanicFunction aFunction, TInt aInt, const TDes& aCommandLine); |
|
90 void UpdateLogsL(); |
|
91 private : |
|
92 TInt TestPanicL(SPanicParams* aPtr); |
|
93 TInt LaunchPanicThread(RThread& aThread, SPanicParams* aPtr); |
|
94 void Test(TInt aCondition); |
|
95 private : |
|
96 TInt iThreadNumber; |
|
97 RWsSession iWs; |
|
98 TBuf<256> iCapabilityTest; |
|
99 TInt iTestCount; |
|
100 TInt iTestPass; |
|
101 }; |
|
102 |
|
103 //RWsSession derived class to test the EWservMessShutdown message |
|
104 class RShellWsSession : public RWsSession |
|
105 { |
|
106 public: |
|
107 void ShutDown(); |
|
108 }; |
|
109 |
|
110 void RShellWsSession::ShutDown() |
|
111 { |
|
112 SendReceive(EWservMessShutdown,TIpcArgs(EWservShutdownCheck)); |
|
113 } |
|
114 |
|
115 LOCAL_C TInt PanicThreadFunc(TAny* aPtr) |
|
116 { |
|
117 CTrapCleanup* CleanUpStack=CTrapCleanup::New(); |
|
118 SPanicParams* ptr=(SPanicParams*)aPtr; |
|
119 TInt ret; |
|
120 TRAP(ret,ret=(*ptr->func)(ptr->num,ptr->capability,ptr->externalGroupId)); |
|
121 delete CleanUpStack; |
|
122 if (ret==EWsExitReasonBad) |
|
123 { |
|
124 User::Panic(_L("Auto"),EAutoPanicPanicFailed); |
|
125 } |
|
126 return(ret); |
|
127 } |
|
128 |
|
129 CTestBase::CTestBase() |
|
130 { |
|
131 } |
|
132 |
|
133 CTestBase::~CTestBase() |
|
134 { |
|
135 iWs.Close(); |
|
136 } |
|
137 |
|
138 void CTestBase::ConstructL(const TDes* aCapabilityTest) |
|
139 { |
|
140 iTestCount=iTestPass=0; |
|
141 iWs.Connect(); |
|
142 TLex lex(*aCapabilityTest); |
|
143 TPtrC capability = lex.NextToken(); |
|
144 iCapabilityTest.Append(capability); |
|
145 } |
|
146 |
|
147 TInt CTestBase::LaunchPanicThread(RThread& aThread, SPanicParams* aPtr) |
|
148 { |
|
149 TBuf<32> threadName; |
|
150 _LIT(KPanicThread, "AutoPanicThread%d"); |
|
151 threadName.AppendFormat(KPanicThread,iThreadNumber++); |
|
152 return(aThread.Create(threadName,PanicThreadFunc,KDefaultStackSize,KPanicThreadHeapSize,KPanicThreadHeapSize,aPtr,EOwnerThread)); |
|
153 } |
|
154 |
|
155 TInt CTestBase::TestPanicL(SPanicParams* aPtr) |
|
156 { |
|
157 RThread thread; |
|
158 TRequestStatus stat; |
|
159 TInt err=LaunchPanicThread(thread, aPtr); |
|
160 if (err==KErrAlreadyExists) |
|
161 { |
|
162 // wait for kernel to clear up old threads |
|
163 // and have several attempts at starting the thread |
|
164 // if unsuccessful the first time |
|
165 for (TInt i=0;i<3;i++) |
|
166 { |
|
167 User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs |
|
168 err=LaunchPanicThread(thread, aPtr); |
|
169 if (err!=KErrAlreadyExists) |
|
170 { |
|
171 break; |
|
172 } |
|
173 } |
|
174 } |
|
175 User::LeaveIfError(err); |
|
176 thread.Logon(stat); |
|
177 User::SetJustInTime(EFalse); |
|
178 thread.Resume(); |
|
179 User::WaitForRequest(stat); |
|
180 User::SetJustInTime(ETrue); |
|
181 TInt threadExit=thread.ExitReason(); |
|
182 if (threadExit!=EWsTestFinished) |
|
183 { |
|
184 if (gTheTestCapability==ENoCapReq) |
|
185 { |
|
186 Test(threadExit==KErrNone); |
|
187 } |
|
188 else if(gTheTestCapability==EEikSrvSID) |
|
189 { |
|
190 Test(threadExit==KErrPermissionDenied); |
|
191 } |
|
192 else if(!iCapabilityTest.Compare(KCAPABILITY_ALL)) |
|
193 { |
|
194 if(gTheTestCapability!=EDoNotTest) |
|
195 { |
|
196 iTestCount++; |
|
197 if(gTheTestCapability==ESwEventPri) |
|
198 { |
|
199 Test(threadExit==KPasswordWindowGroupPriority); |
|
200 } |
|
201 else |
|
202 { |
|
203 Test(threadExit==KErrNone); |
|
204 } |
|
205 } |
|
206 } |
|
207 else if(!iCapabilityTest.Compare(KCAPABILITY_NONE)) |
|
208 { |
|
209 if(gTheTestCapability!=EDoNotTest) |
|
210 { |
|
211 iTestCount++; |
|
212 if((gTheTestCapability==ENoSwEventPriSmallOrdinal)||(gTheTestCapability==ENoSwEventPri)) |
|
213 { |
|
214 Test(threadExit==KPasswordWindowGroupPriority-1); |
|
215 } |
|
216 else if(gTheTestCapability==ENoSwEventErrSmallOrdinal) |
|
217 { |
|
218 Test(threadExit==KErrNone); |
|
219 } |
|
220 else if(gTheTestCapability==ENoSwEventErr) |
|
221 { |
|
222 Test(threadExit==KErrPermissionDenied); |
|
223 } |
|
224 else |
|
225 { |
|
226 Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); |
|
227 } |
|
228 } |
|
229 } |
|
230 else if(!iCapabilityTest.Compare(KWRITEDATA_SWEVENT)) |
|
231 { |
|
232 if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==ESwEvent) |
|
233 { |
|
234 iTestCount++; |
|
235 Test(threadExit==KErrNone); |
|
236 } |
|
237 if(gTheTestCapability==EPowerMgmt) |
|
238 { |
|
239 iTestCount++; |
|
240 Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); |
|
241 } |
|
242 } |
|
243 else if(!iCapabilityTest.Compare(KWRITEDATA_POWERMGMT)) |
|
244 { |
|
245 if(gTheTestCapability==EWriteDeviceData || gTheTestCapability==EPowerMgmt) |
|
246 { |
|
247 iTestCount++; |
|
248 Test(threadExit==KErrNone); |
|
249 } |
|
250 if(gTheTestCapability==ESwEvent) |
|
251 { |
|
252 iTestCount++; |
|
253 Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); |
|
254 } |
|
255 } |
|
256 else if(!iCapabilityTest.Compare(KPOWERMGMT_SWEVENT)) |
|
257 { |
|
258 if(gTheTestCapability==EPowerMgmt || gTheTestCapability==ESwEvent) |
|
259 { |
|
260 iTestCount++; |
|
261 Test(threadExit==KErrNone); |
|
262 } |
|
263 if(gTheTestCapability==EWriteDeviceData) |
|
264 { |
|
265 iTestCount++; |
|
266 Test((threadExit==EWservPanicPermissionDenied)||(threadExit==KErrPermissionDenied)); |
|
267 } |
|
268 } |
|
269 } |
|
270 thread.Close(); |
|
271 return(threadExit); |
|
272 } |
|
273 |
|
274 TInt CTestBase::TestWsPanicL(TPanicFunction aFunction,TInt aTestNo, const TDes& aCommandLine) |
|
275 { |
|
276 TLex lex(aCommandLine); |
|
277 TPtrC capability = lex.NextToken(); |
|
278 TPtrC idstr = lex.NextToken(); |
|
279 lex = idstr; |
|
280 TInt id = 0; |
|
281 lex.Val(id); |
|
282 |
|
283 SPanicParams params; |
|
284 params.num=aTestNo; |
|
285 params.func=aFunction; |
|
286 params.capability.Copy(capability); |
|
287 params.externalGroupId = id; |
|
288 return TestPanicL(¶ms); |
|
289 } |
|
290 |
|
291 void CTestBase::Test(TInt aCondition) |
|
292 { |
|
293 if(!aCondition) |
|
294 { |
|
295 TLogMessageText buf; |
|
296 _LIT(Fail,"AUTO Failed in Capability Test : "); |
|
297 buf.Append(Fail); |
|
298 buf.Append(iCapabilityTest); |
|
299 iWs.LogMessage(buf); |
|
300 iWs.Flush(); |
|
301 } |
|
302 else |
|
303 { |
|
304 iTestPass++; |
|
305 } |
|
306 } |
|
307 |
|
308 void CTestBase::UpdateLogsL() |
|
309 { |
|
310 TBuf<256> testResult; |
|
311 RFs fileSession; |
|
312 RFile resultFile; |
|
313 User::LeaveIfError(fileSession.Connect()); |
|
314 CleanupClosePushL(fileSession); |
|
315 resultFile.Replace(fileSession,_L("C:\\DATA\\TestResult.Dat"),EFileWrite); |
|
316 CleanupClosePushL(resultFile); |
|
317 TFileText fileText; |
|
318 fileText.Set(resultFile); |
|
319 testResult.Num(iTestCount); |
|
320 fileText.Write(testResult); |
|
321 testResult.Num(iTestPass); |
|
322 fileText.Write(testResult); |
|
323 resultFile.Close(); |
|
324 fileSession.Close(); |
|
325 CleanupStack::PopAndDestroy(&resultFile); |
|
326 CleanupStack::PopAndDestroy(&fileSession); |
|
327 } |
|
328 |
|
329 TInt TestCapability(TInt aTest, TDes& aCapability, TInt aExternalGroupId) |
|
330 { |
|
331 _LIT(KDllName,"CLICK"); |
|
332 RWsSession ws; |
|
333 ws.Connect(); |
|
334 CleanupClosePushL(ws); |
|
335 RWindowGroup gr1(ws); |
|
336 RWindowGroup gr2(ws); |
|
337 gr1.Construct(EWindowGroupHandle,EFalse); |
|
338 gr2.Construct(EWindowGroupHandle2,EFalse); |
|
339 CleanupClosePushL(gr1); |
|
340 CleanupClosePushL(gr2); |
|
341 TWsEvent event; |
|
342 RSoundPlugIn click1(ws); |
|
343 CWsScreenDevice *screenDevice; |
|
344 TRawEvent rawEvent; |
|
345 CPalette* defPalette=CPalette::NewDefaultL(EColor256); |
|
346 TInt ret=KErrNone; |
|
347 switch(aTest) |
|
348 { |
|
349 case 0: |
|
350 // ws.LogMessage(_L("EWsClOpSetKeyboardRepeatRate Capability Check")); |
|
351 gTheTestCapability=EWriteDeviceData; |
|
352 ret=ws.SetKeyboardRepeatRate(TTimeIntervalMicroSeconds32(1000000), TTimeIntervalMicroSeconds32(500000)); |
|
353 ws.Flush(); |
|
354 break; |
|
355 case 1: |
|
356 // ws.LogMessage(_L("EWsClOpSetDoubleClick Capability Check")); |
|
357 gTheTestCapability=EWriteDeviceData; |
|
358 ret=ws.SetDoubleClick(TTimeIntervalMicroSeconds32(900000),10); |
|
359 ws.Flush(); |
|
360 break; |
|
361 case 2: |
|
362 // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (external group) Capability Check")); |
|
363 gTheTestCapability=ESwEvent; |
|
364 event.SetType(EEventModifiersChanged); |
|
365 ret=ws.SendEventToWindowGroup(aExternalGroupId,event); |
|
366 break; |
|
367 case 3: |
|
368 // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroup Capability Check")); |
|
369 gTheTestCapability=ESwEvent; |
|
370 event.SetType(EEventModifiersChanged); |
|
371 ret=ws.SendEventToAllWindowGroups(event); |
|
372 break; |
|
373 case 4: |
|
374 // ws.LogMessage(_L("EWsClOpSendEventToAllWindowGroupPriority Capability Check")); |
|
375 gTheTestCapability=ESwEvent; |
|
376 event.SetType(EEventModifiersChanged); |
|
377 gr1.SetOrdinalPosition(0,1); |
|
378 ret=ws.SendEventToAllWindowGroups(gr1.OrdinalPriority(),event); |
|
379 break; |
|
380 case 5: |
|
381 // ws.LogMessage(_L("EWsClOpSendEventToOneWindowGroupPerClient Capability Check")); |
|
382 gTheTestCapability=ESwEvent; |
|
383 event.SetType(EEventModifiersChanged); |
|
384 ret=ws.SendEventToOneWindowGroupsPerClient(event); |
|
385 break; |
|
386 case 6: |
|
387 // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (external group) Capability Check")); |
|
388 gTheTestCapability=ESwEvent; |
|
389 ret=ws.SendMessageToWindowGroup(aExternalGroupId,TUid::Uid(123),_L8("SomeParams")); |
|
390 break; |
|
391 case 7: |
|
392 // ws.LogMessage(_L("EWsClOpClaimSystemPointerCursorList Capability Check")); |
|
393 gTheTestCapability=EWriteDeviceData; |
|
394 ret=ws.ClaimSystemPointerCursorList(); |
|
395 //This may return KErrInUse if succeeds. |
|
396 if(ret==KErrInUse) |
|
397 { |
|
398 ret=KErrNone; |
|
399 } |
|
400 break; |
|
401 case 8: |
|
402 // ws.LogMessage(_L("EWsClOpSetClientCursorMode Capability Check")); |
|
403 gTheTestCapability=EWriteDeviceData; |
|
404 ret=ws.SetClientCursorMode(EPointerCursorNone); |
|
405 ws.Flush(); |
|
406 break; |
|
407 case 9: |
|
408 //Check only if capability is not defined,since the windowgroup is not focused. |
|
409 if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) |
|
410 { |
|
411 // ws.LogMessage(_L("EWsClOpSetPointerCursorPosition Capability Check")); |
|
412 gTheTestCapability=EWriteDeviceData; |
|
413 ret=ws.SetPointerCursorPosition(TPoint(60,20)); |
|
414 ws.Flush(); |
|
415 } |
|
416 else |
|
417 { |
|
418 gTheTestCapability=EDoNotTest; |
|
419 } |
|
420 break; |
|
421 case 10: |
|
422 // ws.LogMessage(_L("EWsClOpSetModifierState Capability Check")); |
|
423 gTheTestCapability=EWriteDeviceData; |
|
424 ret=ws.SetModifierState(EModifierCapsLock,ETurnOnModifier); |
|
425 ret=ws.SetModifierState(EModifierCapsLock,ETurnOffModifier); |
|
426 ws.Flush(); |
|
427 break; |
|
428 case 11: |
|
429 { |
|
430 // ws.LogMessage(_L("EWsClOpRawEvent Capability Check")); |
|
431 gTheTestCapability=ESwEvent; |
|
432 rawEvent.Set(TRawEvent::EActive); |
|
433 ws.SimulateRawEvent(rawEvent); |
|
434 ws.Flush(); |
|
435 } |
|
436 break; |
|
437 case 12: |
|
438 { |
|
439 // ws.LogMessage(_L("EWsClOpKeyEvent Capability Check")); |
|
440 gTheTestCapability=ESwEvent; |
|
441 TKeyEvent keyEvent; |
|
442 keyEvent.iCode='J'; |
|
443 keyEvent.iScanCode=0; |
|
444 keyEvent.iModifiers=EModifierAutorepeatable; |
|
445 keyEvent.iRepeats=0; |
|
446 ws.SimulateKeyEvent(keyEvent); |
|
447 ws.Flush(); |
|
448 } |
|
449 break; |
|
450 case 13: |
|
451 // ws.LogMessage(_L("EWsClOpSendOffEventsToShell Capability Check")); |
|
452 gTheTestCapability=EPowerMgmt; |
|
453 ret=ws.RequestOffEvents(EFalse); |
|
454 break; |
|
455 case 14: |
|
456 // ws.LogMessage(_L("EWsClOpSetFaded Capability Check")); |
|
457 gTheTestCapability=EWriteDeviceData; |
|
458 ret=ws.SetSystemFaded(EFalse); |
|
459 break; |
|
460 case 15: |
|
461 //Since there is some problem in running the EWsClOpNoFlickerFree |
|
462 //code this test is not run if WriteDeviceData capability is defined. |
|
463 // ws.LogMessage(_L("EWsClOpNoFlickerFree Capability Check")); |
|
464 if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KWRITEDATA_SWEVENT)) |
|
465 { |
|
466 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); |
|
467 gTheTestCapability=EWriteDeviceData; |
|
468 TInt err; |
|
469 if ((err=screen->Construct(0))!=KErrNone) |
|
470 { |
|
471 delete screen; |
|
472 User::Leave(err); |
|
473 } |
|
474 ws.TestWrite(ws.WsHandle(), EWsClOpNoFlickerFree, NULL, 0); |
|
475 ws.Flush(); |
|
476 delete screen; |
|
477 } |
|
478 else |
|
479 { |
|
480 gTheTestCapability=EDoNotTest; |
|
481 } |
|
482 break; |
|
483 case 16: |
|
484 // ws.LogMessage(_L("EWsClOpSetFocusScreen Capability Check")); |
|
485 gTheTestCapability=EWriteDeviceData; |
|
486 ret=ws.SetFocusScreen(0); |
|
487 break; |
|
488 case 17: |
|
489 { |
|
490 //Check only if capability is not defined. Otherwise it will shut down the shell. |
|
491 if(aCapability.Compare(KCAPABILITY_ALL)&&aCapability.Compare(KWRITEDATA_POWERMGMT)&&aCapability.Compare(KPOWERMGMT_SWEVENT)) |
|
492 { |
|
493 // ws.LogMessage(_L("EWservMessShutdown Capability Check")); |
|
494 gTheTestCapability=EPowerMgmt; |
|
495 RShellWsSession wsShell; |
|
496 wsShell.Connect(); |
|
497 wsShell.ShutDown(); |
|
498 } |
|
499 else |
|
500 { |
|
501 gTheTestCapability=EDoNotTest; |
|
502 } |
|
503 break; |
|
504 } |
|
505 case 18: |
|
506 // ws.LogMessage(_L("EWsWinOpCaptureKey Capability Check")); |
|
507 gTheTestCapability=ESwEvent; |
|
508 ret=gr2.CaptureKey('a',EModifierFunc,EModifierFunc); |
|
509 //If the function succeeds capability check,the ret value is handle identifying the capture key. |
|
510 if(ret>0) |
|
511 { |
|
512 ret=KErrNone; |
|
513 } |
|
514 break; |
|
515 case 19: |
|
516 // ws.LogMessage(_L("EWsWinOpCaptureKeyUpsAndDowns Capability Check")); |
|
517 gTheTestCapability=ESwEvent; |
|
518 ret=gr2.CaptureKeyUpAndDowns('a',0,0); |
|
519 //If the function succeeds capability check,the ret value is handle identifying the capture key. |
|
520 if(ret>0) |
|
521 { |
|
522 ret=KErrNone; |
|
523 } |
|
524 break; |
|
525 case 20: |
|
526 // ws.LogMessage(_L("EWsWinOpCaptureLongKey Capability Check")); |
|
527 gTheTestCapability=ESwEvent; |
|
528 ret=gr2.CaptureLongKey(EKeyEscape,'e',0,0,2,ELongCaptureNormal|ELongCaptureRepeatEvents); |
|
529 //If the function succeeds capability check,the ret value is handle identifying the capture key. |
|
530 if(ret>0) |
|
531 { |
|
532 ret=KErrNone; |
|
533 } |
|
534 break; |
|
535 case 21: |
|
536 // ws.LogMessage(_L("EWsClickOpLoad Capability Check")); |
|
537 gTheTestCapability=EWriteDeviceData; |
|
538 click1.Construct(); |
|
539 CleanupClosePushL(click1); |
|
540 ret=click1.Load(KDllName); |
|
541 CleanupStack::PopAndDestroy(&click1); |
|
542 break; |
|
543 case 22: |
|
544 // ws.LogMessage(_L("EWsClickOpUnLoad Capability Check")); |
|
545 gTheTestCapability=EWriteDeviceData; |
|
546 click1.Construct(); |
|
547 ret=click1.Unload(); |
|
548 break; |
|
549 case 23: |
|
550 // ws.LogMessage(_L("EWsSdOpSetScreenMode Capability Check")); |
|
551 gTheTestCapability=EWriteDeviceData; |
|
552 screenDevice=new(ELeave) CWsScreenDevice(ws); |
|
553 CleanupStack::PushL(screenDevice); |
|
554 screenDevice->Construct(0); |
|
555 screenDevice->SetScreenMode(0); |
|
556 CleanupStack::PopAndDestroy(screenDevice); |
|
557 break; |
|
558 case 24: |
|
559 // ws.LogMessage(_L("EWsSdOpSetScreenModeEnforcement Capability Check")); |
|
560 gTheTestCapability=EWriteDeviceData; |
|
561 screenDevice=new(ELeave) CWsScreenDevice(ws); |
|
562 CleanupStack::PushL(screenDevice); |
|
563 screenDevice->Construct(0); |
|
564 screenDevice->SetScreenModeEnforcement(ESizeEnforcementNone); |
|
565 ws.Flush(); |
|
566 CleanupStack::PopAndDestroy(screenDevice); |
|
567 break; |
|
568 case 25: |
|
569 { |
|
570 // ws.LogMessage(_L("EWsSdOpSetPalette Capability Check")); |
|
571 gTheTestCapability=EWriteDeviceData; |
|
572 screenDevice=new(ELeave) CWsScreenDevice(ws); |
|
573 CleanupStack::PushL(screenDevice); |
|
574 screenDevice->Construct(0); |
|
575 ret=screenDevice->SetCustomPalette(defPalette); |
|
576 //Returns KErrNotSupported if succeeds capability check. |
|
577 if(ret==KErrNotSupported) |
|
578 { |
|
579 ret=KErrNone; |
|
580 } |
|
581 CleanupStack::PopAndDestroy(screenDevice); |
|
582 } |
|
583 break; |
|
584 case 26: |
|
585 { |
|
586 //Checking the capability for SetHotKeys |
|
587 // ws.LogMessage(_L("EWsClOpSetHotKey Capability Check")); |
|
588 gTheTestCapability=ESwEvent; |
|
589 ret=ws.SetHotKey(EHotKeyEnableLogging,'e',EModifierFunc|EModifierCtrl|EModifierShift,0); |
|
590 ws.Flush(); |
|
591 } |
|
592 break; |
|
593 case 27: |
|
594 { |
|
595 //Checking the capability for ClearHotKeys |
|
596 // ws.LogMessage(_L("EWsClOpClearHotKeys Capability Check")); |
|
597 gTheTestCapability=ESwEvent; |
|
598 ret=ws.ClearHotKeys(EHotKeyEnableLogging); |
|
599 ws.Flush(); |
|
600 } |
|
601 break; |
|
602 case 28: |
|
603 // ws.LogMessage(_L("EWsClOpSendEventToWindowGroup (own group) Capability Check")); |
|
604 gTheTestCapability=ENoCapReq; |
|
605 event.SetType(EEventModifiersChanged); |
|
606 ret=ws.SendEventToWindowGroup(gr1.Identifier(),event); |
|
607 break; |
|
608 case 29: |
|
609 // ws.LogMessage(_L("EWsClOpSendMessageToWindowGroup (own group) Capability Check")); |
|
610 gTheTestCapability=ENoCapReq; |
|
611 ret=ws.SendMessageToWindowGroup(gr1.Identifier(),TUid::Uid(123),_L8("SomeParams")); |
|
612 break; |
|
613 case 30: |
|
614 // ws.LogMessage(_L("EWsClOpSetBackLight Capability Check")); |
|
615 gTheTestCapability=EEikSrvSID; |
|
616 screenDevice=new(ELeave) CWsScreenDevice(ws); |
|
617 CleanupStack::PushL(screenDevice); |
|
618 screenDevice->Construct(0); |
|
619 ret=screenDevice->SetBackLight(ETrue); //Always returns KErrPermissionDenied. |
|
620 CleanupStack::PopAndDestroy(screenDevice); |
|
621 break; |
|
622 case 31: |
|
623 { |
|
624 TBool test=EFalse; |
|
625 if(!aCapability.Compare(KCAPABILITY_ALL)) |
|
626 { |
|
627 gTheTestCapability=ESwEventPri; |
|
628 test=ETrue; |
|
629 } |
|
630 else if(!aCapability.Compare(KCAPABILITY_NONE)) |
|
631 { |
|
632 gTheTestCapability=ENoSwEventPri; |
|
633 test=ETrue; |
|
634 } |
|
635 else |
|
636 { |
|
637 gTheTestCapability=EDoNotTest; |
|
638 } |
|
639 if(test) |
|
640 { |
|
641 LogMessageText.Format(KSetOrdinalPositionPri); |
|
642 ws.LogMessage(LogMessageText); |
|
643 gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority); |
|
644 ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); |
|
645 } |
|
646 } |
|
647 break; |
|
648 case 32: |
|
649 if(!aCapability.Compare(KCAPABILITY_NONE)) |
|
650 { |
|
651 LogMessageText.Format(KSetOrdinalPositionPri); |
|
652 ws.LogMessage(LogMessageText); |
|
653 gTheTestCapability=ENoSwEventPriSmallOrdinal; |
|
654 gr1.SetOrdinalPosition(0,KPasswordWindowGroupPriority-1); |
|
655 ret=ws.GetWindowGroupOrdinalPriority(gr1.Identifier()); |
|
656 } |
|
657 else |
|
658 { |
|
659 gTheTestCapability=EDoNotTest; |
|
660 } |
|
661 break; |
|
662 case 33: |
|
663 { |
|
664 TBool test=EFalse; |
|
665 if(!aCapability.Compare(KCAPABILITY_ALL)) |
|
666 { |
|
667 gTheTestCapability=ESwEventErr; |
|
668 test=ETrue; |
|
669 } |
|
670 else if(!aCapability.Compare(KCAPABILITY_NONE)) |
|
671 { |
|
672 gTheTestCapability=ENoSwEventErr; |
|
673 test=ETrue; |
|
674 } |
|
675 else |
|
676 { |
|
677 gTheTestCapability=EDoNotTest; |
|
678 } |
|
679 if(test) |
|
680 { |
|
681 LogMessageText.Format(KSetOrdinalPositionErr); |
|
682 ws.LogMessage(LogMessageText); |
|
683 ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority); |
|
684 } |
|
685 } |
|
686 break; |
|
687 case 34: |
|
688 if(!aCapability.Compare(KCAPABILITY_NONE)) |
|
689 { |
|
690 LogMessageText.Format(KSetOrdinalPositionErr); |
|
691 ws.LogMessage(LogMessageText); |
|
692 gTheTestCapability=ENoSwEventErrSmallOrdinal; |
|
693 ret=gr1.SetOrdinalPositionErr(0,KPasswordWindowGroupPriority-1); |
|
694 } |
|
695 else |
|
696 { |
|
697 gTheTestCapability=EDoNotTest; |
|
698 } |
|
699 break; |
|
700 case 35: |
|
701 // EWsClOpSetCloseProximityThresholds Capability Check |
|
702 gTheTestCapability=EWriteDeviceData; |
|
703 ret=ws.SetCloseProximityThresholds(-20, -50); |
|
704 ws.SetCloseProximityThresholds(KMaxTInt, KMinTInt); |
|
705 break; |
|
706 case 36: |
|
707 // EWsClOpSetHighPressureThresholds Capability Check |
|
708 gTheTestCapability=EWriteDeviceData; |
|
709 ret=ws.SetHighPressureThresholds(4000, 2000); |
|
710 ws.SetHighPressureThresholds(KMaxTInt, KMinTInt); |
|
711 break; |
|
712 default: |
|
713 ret=gTestState=EWsTestFinished; |
|
714 } |
|
715 CleanupStack::PopAndDestroy(&gr2); |
|
716 CleanupStack::PopAndDestroy(&gr1); |
|
717 CleanupStack::PopAndDestroy(&ws); |
|
718 return ret; |
|
719 } |
|
720 |
|
721 void MainL() |
|
722 { |
|
723 TBuf<256> commandLine; |
|
724 User::CommandLine(commandLine); |
|
725 CTestBase testBase; |
|
726 testBase.ConstructL(&commandLine); |
|
727 TInt ii=0; |
|
728 while(gTestState!=EWsTestFinished) |
|
729 testBase.TestWsPanicL(&TestCapability,ii++,commandLine) ; |
|
730 // testBase.UpdateLogsL(); |
|
731 } |
|
732 |
|
733 GLDEF_C TInt E32Main() |
|
734 { |
|
735 __UHEAP_MARK; |
|
736 CTrapCleanup* cleanUpStack=CTrapCleanup::New(); |
|
737 if(cleanUpStack==NULL) |
|
738 { |
|
739 return KErrNoMemory; |
|
740 } |
|
741 TRAP_IGNORE(MainL()) |
|
742 delete cleanUpStack; |
|
743 __UHEAP_MARKEND; |
|
744 return(KErrNone); |
|
745 } |