|
1 // Copyright (c) 1996-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 // Testing key event, capturing keys and hot keys |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 |
|
25 #include "TKEY.H" |
|
26 |
|
27 #define LOGGING 1 //Uncomment this when there is a fail so that you get more logging |
|
28 |
|
29 GLDEF_D ClientToKill *SecondClient=NULL; |
|
30 |
|
31 GLDEF_C CTClient *CreateClientToKillL() |
|
32 { |
|
33 return(SecondClient=new(ELeave) ClientToKill()); |
|
34 } |
|
35 |
|
36 GLDEF_C TInt ProcToKill(TAny *aScreenNumber) |
|
37 { |
|
38 TInt ret=KErrNone; |
|
39 ret=TestLibStartUp(CreateClientToKillL,(TInt)aScreenNumber); |
|
40 return(ret); |
|
41 } |
|
42 |
|
43 CVisibleGroup::CVisibleGroup(TInt aScreenNo): iScreenNo(aScreenNo) |
|
44 {} |
|
45 |
|
46 void CVisibleGroup::ConstructL() |
|
47 { |
|
48 User::LeaveIfError(iWs.Connect()); |
|
49 iScr=new(ELeave) CWsScreenDevice(iWs); |
|
50 User::LeaveIfError(iScr->Construct(iScreenNo)); |
|
51 iScr->SetAppScreenMode(iMode); |
|
52 iGroup=RWindowGroup(iWs); |
|
53 User::LeaveIfError(iGroup.Construct(NULL,ETrue)); |
|
54 TInt id=TheClient->iGroup->GroupWin()->Identifier(); |
|
55 iGroup.SetOwningWindowGroup(id); |
|
56 #if defined(LOGGING) |
|
57 TLogMessageText buf; |
|
58 _LIT(KIds,"Window Group Id: Main=%d, 2nd Client=%d"); |
|
59 buf.Format(KIds,id,iGroup.Identifier()); |
|
60 iWs.LogMessage(buf); |
|
61 #endif |
|
62 iWs.Flush(); |
|
63 } |
|
64 |
|
65 CVisibleGroup::~CVisibleGroup() |
|
66 { |
|
67 iGroup.Close(); |
|
68 delete iScr; |
|
69 iWs.Close(); |
|
70 } |
|
71 |
|
72 void CVisibleGroup::SetMode(TInt aMode) |
|
73 { |
|
74 iMode=aMode; |
|
75 iScr->SetAppScreenMode(iMode); |
|
76 iWs.Flush(); |
|
77 } |
|
78 |
|
79 ClientToKill::ClientToKill() |
|
80 {} |
|
81 |
|
82 void ClientToKill::ConstructL() |
|
83 { |
|
84 CTClient::ConstructL(); |
|
85 RSemaphore sem; |
|
86 sem.OpenGlobal(KSemaphoreName); |
|
87 |
|
88 iGroup=new(ELeave) TestWindowGroup(this); |
|
89 iGroup->ConstructL(); |
|
90 |
|
91 iScreen->SetScreenMode(0); |
|
92 TSize screenSize=iScreen->SizeInPixels(); |
|
93 |
|
94 TInt winWidth=3*screenSize.iWidth/4; |
|
95 TInt winHeight=3*screenSize.iHeight/4; |
|
96 iTestWin=new(ELeave) TestWindow(); |
|
97 iTestWin->SetUpL(TPoint((screenSize.iWidth+4)/8,(screenSize.iHeight+4)/8),TSize(winWidth,winHeight),iGroup,*iGc); |
|
98 |
|
99 #if defined(LOGGING) |
|
100 TLogMessageText buf; |
|
101 _LIT(KId,"Window Group Id in 2nd Process=%d"); |
|
102 buf.Format(KId,iGroup->GroupWin()->Identifier()); |
|
103 LogMessage(buf); |
|
104 #endif |
|
105 sem.Signal(); // Signal thread fully initialised |
|
106 sem.Close(); |
|
107 } |
|
108 |
|
109 ClientToKill::~ClientToKill() |
|
110 { |
|
111 delete iTestWin; |
|
112 } |
|
113 |
|
114 |
|
115 // CTKey |
|
116 |
|
117 CTKey::CTKey(CTestStep* aStep) : CTWsGraphicsBase(aStep) |
|
118 { |
|
119 } |
|
120 |
|
121 |
|
122 |
|
123 void CTKey::ConstructL() |
|
124 { |
|
125 iSem.CreateGlobal(KSemaphoreName,0,KOwnerType); |
|
126 iVisibleGroup=new(ELeave) CVisibleGroup(iTest->iScreenNumber); |
|
127 iVisibleGroup->ConstructL(); |
|
128 } |
|
129 |
|
130 CTKey::~CTKey() |
|
131 { |
|
132 delete iVisibleGroup; |
|
133 iSem.Close(); |
|
134 // Set focus back to this screen as it went to primary screen when iVisibleGroup was destroyed |
|
135 // Wserv focus handling made focus screen switch to another screen if there is no |
|
136 // focusable window group on that particular screen. |
|
137 TheClient->iWs.SetFocusScreen(iTest->iScreenNumber); |
|
138 } |
|
139 |
|
140 void CTKey::SendKey(TInt aScanCode) |
|
141 { |
|
142 TKeyEvent keyEvent; |
|
143 keyEvent.iCode=aScanCode; |
|
144 keyEvent.iScanCode=aScanCode; |
|
145 keyEvent.iModifiers=0; |
|
146 keyEvent.iRepeats=0; |
|
147 TheClient->iWs.SimulateKeyEvent(keyEvent); |
|
148 TheClient->iWs.Flush(); |
|
149 } |
|
150 |
|
151 void CTKey::SendUpDown(TInt aScanCode) |
|
152 { |
|
153 TRawEvent rawEvent; |
|
154 rawEvent.Set(TRawEvent::EKeyDown,aScanCode); |
|
155 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
156 rawEvent.Set(TRawEvent::EKeyUp,aScanCode); |
|
157 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
158 } |
|
159 |
|
160 void CTKey::SendCtrlAltShift(TRawEvent::TType aType) |
|
161 { |
|
162 TRawEvent rawEvent; |
|
163 rawEvent.Set(aType,EStdKeyLeftFunc); |
|
164 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
165 rawEvent.Set(aType,EStdKeyLeftCtrl); |
|
166 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
167 rawEvent.Set(aType,EStdKeyLeftShift); |
|
168 TheClient->iWs.SimulateRawEvent(rawEvent); |
|
169 } |
|
170 |
|
171 void CTKey::SendCtrlAltShift(TInt aScanCode) |
|
172 { |
|
173 SendCtrlAltShift(TRawEvent::EKeyDown); |
|
174 SendUpDown(aScanCode); |
|
175 SendCtrlAltShift(TRawEvent::EKeyUp); |
|
176 TheClient->iWs.Flush(); |
|
177 } |
|
178 |
|
179 void CTKey::LogWindowGroupIds() |
|
180 { |
|
181 CArrayFixFlat<TInt>* idList=new(ELeave) CArrayFixFlat<TInt>(5); |
|
182 if (!idList) |
|
183 return; |
|
184 TheClient->iWs.WindowGroupList(0,idList); |
|
185 TLogMessageText buf; |
|
186 _LIT(KWinGp,"Window Group Id's: %d"); |
|
187 _LIT(KId,", %d"); |
|
188 TInt ii=0; |
|
189 buf.Format(KWinGp,(*idList)[ii]); |
|
190 while (++ii<idList->Count()) |
|
191 buf.AppendFormat(KId,(*idList)[ii]); |
|
192 LOG_MESSAGE(buf); |
|
193 delete idList; |
|
194 } |
|
195 |
|
196 void CTKey::SetHotKey(THotKey aType, TUint aKeyCode) |
|
197 { |
|
198 TheClient->iWs.SetHotKey(aType,aKeyCode-'A'+1,EFuncCtrlShift,EFuncCtrlShift); |
|
199 } |
|
200 |
|
201 void CTKey::KeyOfOrientation() |
|
202 { |
|
203 TInt numScreenModes = TheClient->iScreen->NumScreenModes(); |
|
204 TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); |
|
205 if(numScreenModes >= 2) |
|
206 { |
|
207 //1 possible rotation of 180deg found in wsini.ini screenmode 8 |
|
208 iVisibleGroup->SetMode(numScreenModes-1); |
|
209 TheClient->iScreen->SetScreenMode(numScreenModes-1); |
|
210 SendCtrlAltShift('O'); |
|
211 TheClient->iWs.Flush(); |
|
212 //1 possible rotation of 90deg found in wsini.ini screenmode 7 |
|
213 iVisibleGroup->SetMode(numScreenModes-2); |
|
214 TheClient->iScreen->SetScreenMode(numScreenModes-2); |
|
215 SendCtrlAltShift('O'); |
|
216 TheClient->iWs.Flush(); |
|
217 //reset to original screenmode |
|
218 iVisibleGroup->SetMode(originalScreenMode); |
|
219 TheClient->iScreen->SetScreenMode(originalScreenMode); |
|
220 } |
|
221 else |
|
222 { |
|
223 TEST(numScreenModes>2); |
|
224 INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); |
|
225 } |
|
226 TPixelsAndRotation originalSizeAndRotation; |
|
227 TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),originalSizeAndRotation); |
|
228 SendCtrlAltShift('O'); |
|
229 TheClient->iWs.Flush(); |
|
230 TPixelsAndRotation sizeAndRotation; |
|
231 TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); |
|
232 TEST(sizeAndRotation.iRotation!=originalSizeAndRotation.iRotation); |
|
233 if (sizeAndRotation.iRotation==originalSizeAndRotation.iRotation) |
|
234 INFO_PRINTF3(_L("iRotation - Not Expected: %d, Actual: %d"), originalSizeAndRotation.iRotation, sizeAndRotation.iRotation); |
|
235 SendCtrlAltShift('O'); |
|
236 TheClient->iWs.Flush(); |
|
237 } |
|
238 |
|
239 void CTKey::CycleDisplaySize() |
|
240 { |
|
241 // The test does nothing if there is only one possible screen mode -> return |
|
242 TInt numScreenModes = TheClient->iScreen->NumScreenModes(); |
|
243 if (numScreenModes<2) |
|
244 { |
|
245 TEST(numScreenModes>2); |
|
246 INFO_PRINTF2(_L("numScreenModes - Expected: >2, Actual: %d"), numScreenModes); |
|
247 return; |
|
248 } |
|
249 //Get original screen mode and size values |
|
250 TInt originalScreenMode = TheClient->iScreen->CurrentScreenMode(); |
|
251 TPixelsAndRotation sizeAndRotation; |
|
252 TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); |
|
253 TSize originalScreenSize = sizeAndRotation.iPixelSize; |
|
254 |
|
255 SendCtrlAltShift('U'); |
|
256 TheClient->iWs.Flush(); |
|
257 TheClient->iScreen->GetScreenModeSizeAndRotation(TheClient->iScreen->CurrentScreenMode(),sizeAndRotation); |
|
258 TEST(sizeAndRotation.iPixelSize.iHeight!=originalScreenSize.iHeight && sizeAndRotation.iPixelSize.iWidth!=originalScreenSize.iWidth); |
|
259 if (sizeAndRotation.iPixelSize.iHeight==originalScreenSize.iHeight || sizeAndRotation.iPixelSize.iWidth==originalScreenSize.iWidth) |
|
260 INFO_PRINTF5(_L("iPixelSize - Expected: !%d !%d, Actual: %d %d"), originalScreenSize.iHeight, originalScreenSize.iWidth, sizeAndRotation.iPixelSize.iHeight, sizeAndRotation.iPixelSize.iWidth); |
|
261 TheClient->iScreen->SetScreenMode(originalScreenMode); |
|
262 TheClient->iWs.Flush(); |
|
263 } |
|
264 |
|
265 void CTKey::KeyOfDeathL() |
|
266 { |
|
267 //Key of Death |
|
268 #if defined(LOGGING) |
|
269 TLogMessageText buf; |
|
270 _LIT(KNum1,"Priority Zero Window Groups=%d Total=%d (Before Process Creation)"); |
|
271 buf.Format(KNum1,TheClient->iWs.NumWindowGroups(0),TheClient->iWs.NumWindowGroups()); |
|
272 LOG_MESSAGE(buf); |
|
273 LogWindowGroupIds(); |
|
274 #endif |
|
275 CProcess* process = CProcess::NewL(CProcess::eProcessKeyTest,iTest->iScreenNumber); |
|
276 RWindowGroup group(TheClient->iWs); |
|
277 group.Construct(1234); |
|
278 TheClient->Flush(); //Make sure the window group above is created before the one in the other process |
|
279 TInt id=TheClient->iGroup->GroupWin()->Identifier(); |
|
280 group.SetOwningWindowGroup(id); |
|
281 group.DefaultOwningWindow(); |
|
282 |
|
283 iSem.Wait(); |
|
284 User::After(TTimeIntervalMicroSeconds32(100000)); //0.1 secs |
|
285 TInt numGroups=TheClient->iWs.NumWindowGroups(); |
|
286 TInt numGroups0=TheClient->iWs.NumWindowGroups(0); |
|
287 |
|
288 #if defined(LOGGING) |
|
289 _LIT(KNum2,"NewWinGpId=%d Priority Zero Window Groups=%d Total=%d (After Process Creation)"); |
|
290 buf.Format(KNum2,id,numGroups0,numGroups); |
|
291 LOG_MESSAGE(buf); |
|
292 _LIT(KLog1,"Sending Key Of Death"); |
|
293 buf.Copy(KLog1); |
|
294 LOG_MESSAGE(buf); |
|
295 LogWindowGroupIds(); |
|
296 #endif |
|
297 group.SetOrdinalPosition(1); //Make sure that the window group we have just created is behind the one created by the other process (belt and braces) |
|
298 SendCtrlAltShift('K'); |
|
299 TheClient->iWs.Flush(); |
|
300 #if defined(LOGGING) |
|
301 _LIT(KLog2,"Sent Key Of Death"); |
|
302 buf.Copy(KLog2); |
|
303 LOG_MESSAGE(buf); |
|
304 #endif |
|
305 TInt numGroups2; |
|
306 TInt numGroups0b; |
|
307 TInt tries=3; |
|
308 FOREVER //On multi-core platforms need to wait for the Key of Death procedure to complete |
|
309 { |
|
310 numGroups2=TheClient->iWs.NumWindowGroups(); |
|
311 numGroups0b=TheClient->iWs.NumWindowGroups(0); |
|
312 if (--tries==0) |
|
313 break; |
|
314 if (numGroups!=numGroups2 || numGroups0!=numGroups0b) |
|
315 { |
|
316 tries=1; |
|
317 continue; |
|
318 } |
|
319 User::After(100000); //0.1secs |
|
320 } |
|
321 TEST(numGroups==numGroups2+1); |
|
322 _LIT(KLog,"KeyOfDeath Num WinGps Before=%d After=%d (should be one less)"); |
|
323 if (numGroups!=numGroups2+1) |
|
324 LOG_MESSAGE3(KLog,numGroups,numGroups2); |
|
325 TEST(numGroups0==numGroups0b+1); |
|
326 if (numGroups0!=numGroups0b+1) |
|
327 LOG_MESSAGE3(KLog,numGroups0,numGroups0b); |
|
328 group.Close(); |
|
329 |
|
330 TBool processDead=!process->StillAlive(); |
|
331 TEST(processDead); |
|
332 if (!processDead) |
|
333 { |
|
334 _LIT(KLog,"Other Thread Still Alive"); |
|
335 LOG_MESSAGE(KLog); |
|
336 } |
|
337 delete process; |
|
338 |
|
339 #if defined(LOGGING) |
|
340 _LIT(KLog3,"Finished KeyOfDeath Test"); |
|
341 buf.Copy(KLog3); |
|
342 LOG_MESSAGE(buf); |
|
343 LogWindowGroupIds(); |
|
344 #endif |
|
345 } |
|
346 |
|
347 #define CONTRAST_UP 'A' //'a'-'a'+1 |
|
348 #define CONTRAST_DOWN 'B' //'b'-'a'+1 |
|
349 |
|
350 void CTKey::TestContrastL(TBool aChange) |
|
351 { |
|
352 TInt contrast=0; |
|
353 TInt newContrast=0; |
|
354 TInt maxContrast=0; |
|
355 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); |
|
356 TInt diff=aChange ? 1:0; |
|
357 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); |
|
358 |
|
359 SendCtrlAltShift(CONTRAST_UP); |
|
360 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
361 if ((contrast==maxContrast) && aChange) |
|
362 { |
|
363 TEST(newContrast==0); |
|
364 if (newContrast!=0) |
|
365 INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); |
|
366 } |
|
367 else |
|
368 { |
|
369 TEST(contrast+diff==newContrast); |
|
370 if (contrast+diff!=newContrast) |
|
371 INFO_PRINTF3(_L("contrast+diff==newContrast - Expected: %d, Actual: %d"), contrast+diff, newContrast); |
|
372 } |
|
373 |
|
374 SendCtrlAltShift(CONTRAST_DOWN); |
|
375 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
376 TEST(contrast==newContrast); |
|
377 if (contrast!=newContrast) |
|
378 INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); |
|
379 |
|
380 SendCtrlAltShift(CONTRAST_DOWN); |
|
381 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
382 if (contrast==0) |
|
383 { |
|
384 TEST(maxContrast==newContrast); |
|
385 if (maxContrast!=newContrast) |
|
386 INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); |
|
387 |
|
388 } |
|
389 else |
|
390 { |
|
391 TEST(contrast-diff==newContrast); |
|
392 if (contrast-diff!=newContrast) |
|
393 INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); |
|
394 |
|
395 } |
|
396 |
|
397 SendCtrlAltShift(CONTRAST_UP); |
|
398 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
399 TEST(contrast==newContrast); |
|
400 if (contrast!=newContrast) |
|
401 INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); |
|
402 |
|
403 } |
|
404 |
|
405 void CTKey::TestDefaultContrastL(TBool aChange) |
|
406 { |
|
407 TInt contrast=0; |
|
408 TInt newContrast=0; |
|
409 TInt maxContrast=0; |
|
410 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast)); |
|
411 TInt diff=aChange ? 1:0; |
|
412 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)); |
|
413 |
|
414 SendKey(EKeyIncContrast); |
|
415 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
416 if ((contrast==maxContrast) && aChange) |
|
417 { |
|
418 TEST(newContrast==0); |
|
419 if (0!=newContrast) |
|
420 INFO_PRINTF3(_L("newContrast==0 - Expected: %d, Actual: %d"), 0, newContrast); |
|
421 } |
|
422 else |
|
423 { |
|
424 TEST(contrast+diff==newContrast); |
|
425 if (contrast+diff!=newContrast) |
|
426 INFO_PRINTF3(_L("newContrast==contrast+diff - Expected: %d, Actual: %d"), contrast+diff, newContrast); |
|
427 } |
|
428 |
|
429 SendKey(EKeyDecContrast); |
|
430 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
431 TEST(contrast==newContrast); |
|
432 if (contrast!=newContrast) |
|
433 INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); |
|
434 |
|
435 SendKey(EKeyDecContrast); |
|
436 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
437 if (contrast==0) |
|
438 { |
|
439 TEST(maxContrast==newContrast); |
|
440 if (maxContrast!=newContrast) |
|
441 INFO_PRINTF3(_L("maxContrast==newContrast - Expected: %d, Actual: %d"), maxContrast, newContrast); |
|
442 } |
|
443 else |
|
444 { |
|
445 TEST(contrast-diff==newContrast); |
|
446 if (contrast-diff!=newContrast) |
|
447 INFO_PRINTF3(_L("contrast-diff==newContrast - Expected: %d, Actual: %d"), contrast-diff, newContrast); |
|
448 } |
|
449 |
|
450 SendKey(EKeyIncContrast); |
|
451 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,newContrast)); |
|
452 TEST(contrast==newContrast); |
|
453 if (contrast!=newContrast) |
|
454 INFO_PRINTF3(_L("contrast==newContrast - Expected: %d, Actual: %d"), contrast, newContrast); |
|
455 |
|
456 } |
|
457 |
|
458 void CTKey::ContrastKeysL() |
|
459 { |
|
460 TInt maxContrast=0; |
|
461 TInt contrast=0; |
|
462 TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrastMax,maxContrast); |
|
463 if (err==KErrNotSupported) |
|
464 return; |
|
465 else if (err==KErrNone) |
|
466 err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast); |
|
467 if (err==KErrNotSupported) |
|
468 return; |
|
469 TEST(err==KErrNone); |
|
470 if (err!=KErrNone) |
|
471 INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); |
|
472 |
|
473 if (contrast==0) |
|
474 err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,++contrast); |
|
475 else if (contrast==maxContrast) |
|
476 err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayContrast,--contrast); |
|
477 if (err==KErrNotSupported) |
|
478 return; |
|
479 TEST(err==KErrNone); |
|
480 if (err!=KErrNone) |
|
481 INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayContrast,contrast)=KErrNone - Expected: %d, Actual: %d"), KErrNone, err); |
|
482 TestDefaultContrastL(ETrue); |
|
483 |
|
484 SetHotKey(EHotKeyIncContrast,CONTRAST_UP); |
|
485 SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); |
|
486 TestContrastL(ETrue); |
|
487 TestDefaultContrastL(ETrue); |
|
488 |
|
489 TheClient->iWs.ClearHotKeys(EHotKeyIncContrast); |
|
490 TheClient->iWs.ClearHotKeys(EHotKeyDecContrast); |
|
491 TestContrastL(EFalse); |
|
492 TestDefaultContrastL(EFalse); |
|
493 |
|
494 TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); |
|
495 TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); |
|
496 TestContrastL(EFalse); |
|
497 TestDefaultContrastL(ETrue); |
|
498 |
|
499 SetHotKey(EHotKeyIncContrast,CONTRAST_UP); |
|
500 SetHotKey(EHotKeyDecContrast,CONTRAST_DOWN); |
|
501 TestContrastL(ETrue); |
|
502 TestDefaultContrastL(ETrue); |
|
503 |
|
504 TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncContrast); |
|
505 TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecContrast); |
|
506 TestContrastL(EFalse); |
|
507 TestDefaultContrastL(ETrue); |
|
508 } |
|
509 |
|
510 #define BACKLIGHT_ON 'A' //'o'-'a'+1 |
|
511 #define BACKLIGHT_OFF 'B' //'p'-'a'+1 |
|
512 #define BACKLIGHT_TOGGLE 'C' //'q'-'a'+1 |
|
513 /** Test for reaction against backlight ON/OFF/TOGGLE buttons defined above. |
|
514 If aChange is false button presses must not affect the state of backlight. |
|
515 */ |
|
516 void CTKey::TestBackLightL(TBool aChange) |
|
517 { |
|
518 TBool state; |
|
519 SendCtrlAltShift(BACKLIGHT_ON); |
|
520 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
521 TEST(state==aChange); |
|
522 if (state!=aChange) |
|
523 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
524 |
|
525 SendCtrlAltShift(BACKLIGHT_TOGGLE); |
|
526 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
527 TEST(state==EFalse); |
|
528 if (state!=EFalse) |
|
529 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
530 |
|
531 SendCtrlAltShift(BACKLIGHT_TOGGLE); |
|
532 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
533 TEST(state==aChange); |
|
534 if (state!=aChange) |
|
535 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
536 |
|
537 SendCtrlAltShift(BACKLIGHT_OFF); |
|
538 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
539 TEST(state==EFalse); |
|
540 if (state!=EFalse) |
|
541 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
542 |
|
543 SendCtrlAltShift(BACKLIGHT_TOGGLE); |
|
544 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
545 TEST(state==aChange); |
|
546 if (state!=aChange) |
|
547 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
548 |
|
549 SendCtrlAltShift(BACKLIGHT_TOGGLE); |
|
550 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
551 TEST(state==EFalse); |
|
552 if (state!=EFalse) |
|
553 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
554 |
|
555 } |
|
556 |
|
557 /** Test for reaction against default backlight ON/OFF/TOGGLE buttons. |
|
558 If aChange is false button presses must not affect the state of backlight. |
|
559 */ |
|
560 void CTKey::TestDefaultBackLightL(TBool aChange) |
|
561 { |
|
562 TBool state; |
|
563 SendKey(EKeyBacklightOn); |
|
564 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
565 TEST(state==aChange); |
|
566 if (state!=aChange) |
|
567 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
568 |
|
569 SendKey(EKeyBacklightToggle); |
|
570 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
571 TEST(state==EFalse); |
|
572 if (state!=EFalse) |
|
573 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
574 |
|
575 SendKey(EKeyBacklightToggle); |
|
576 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
577 TEST(state==aChange); |
|
578 if (state!=aChange) |
|
579 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
580 |
|
581 SendKey(EKeyBacklightOff); |
|
582 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
583 TEST(state==EFalse); |
|
584 if (state!=EFalse) |
|
585 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
586 |
|
587 SendKey(EKeyBacklightToggle); |
|
588 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
589 TEST(state==aChange); |
|
590 if (state!=aChange) |
|
591 INFO_PRINTF3(_L("state==aChange - Expected: %d, Actual: %d"), aChange, state); |
|
592 |
|
593 SendKey(EKeyBacklightToggle); |
|
594 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,state)); |
|
595 TEST(state==EFalse); |
|
596 if (state!=EFalse) |
|
597 INFO_PRINTF3(_L("state==EFalse - Expected: %d, Actual: %d"), EFalse, state); |
|
598 |
|
599 } |
|
600 |
|
601 void CTKey::BackLightKeysL() |
|
602 { |
|
603 // Turns backlight off |
|
604 TBool prevState; |
|
605 TInt err=HAL::Get(iTest->iScreenNumber,HALData::EBacklightState,prevState); |
|
606 if (err==KErrNotSupported) |
|
607 { |
|
608 _LIT(KLog,"Cannot test BackLight Key presses as cannot read its state on screen %d"); |
|
609 LOG_MESSAGE2(KLog,iTest->iScreenNumber); |
|
610 return; |
|
611 } |
|
612 else if (err==KErrNone) |
|
613 err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,EFalse); |
|
614 if (err==KErrNotSupported) |
|
615 { |
|
616 _LIT(KLog,"Cannot test BackLight Key presses as cannot set its state on screen %d"); |
|
617 LOG_MESSAGE2(KLog,iTest->iScreenNumber); |
|
618 return; |
|
619 } |
|
620 TEST(err==KErrNone); |
|
621 if (err!=KErrNone) |
|
622 { |
|
623 _LIT(KLog,"Reading or Setting BackLight state gave error %d on screen %d"); |
|
624 LOG_MESSAGE3(KLog,err,iTest->iScreenNumber); |
|
625 } |
|
626 |
|
627 // Tests that default backlight ON/OFF/TOGGLE buttons work |
|
628 TestDefaultBackLightL(ETrue); |
|
629 |
|
630 // Sets user defined backlight buttons and tests that both default and user defined buttons work |
|
631 SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); |
|
632 SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); |
|
633 SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); |
|
634 TestBackLightL(ETrue); |
|
635 TestDefaultBackLightL(ETrue); |
|
636 |
|
637 // Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work |
|
638 TheClient->iWs.ClearHotKeys(EHotKeyBacklightOn); |
|
639 TheClient->iWs.ClearHotKeys(EHotKeyBacklightOff); |
|
640 TheClient->iWs.ClearHotKeys(EHotKeyBacklightToggle); |
|
641 TestBackLightL(EFalse); |
|
642 TestDefaultBackLightL(EFalse); |
|
643 |
|
644 // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work |
|
645 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); |
|
646 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); |
|
647 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); |
|
648 TestBackLightL(EFalse); |
|
649 TestDefaultBackLightL(ETrue); |
|
650 |
|
651 // Sets user defined backlight buttons and tests that both default and user defined buttons work |
|
652 SetHotKey(EHotKeyBacklightOn,BACKLIGHT_ON); |
|
653 SetHotKey(EHotKeyBacklightOff,BACKLIGHT_OFF); |
|
654 SetHotKey(EHotKeyBacklightToggle,BACKLIGHT_TOGGLE); |
|
655 TestBackLightL(ETrue); |
|
656 TestDefaultBackLightL(ETrue); |
|
657 |
|
658 // Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work |
|
659 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOn); |
|
660 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightOff); |
|
661 TheClient->iWs.RestoreDefaultHotKey(EHotKeyBacklightToggle); |
|
662 TestBackLightL(EFalse); |
|
663 TestDefaultBackLightL(ETrue); |
|
664 |
|
665 //Restores previous backlight state |
|
666 //err=UserHal::SetBacklightOn(prevState); |
|
667 err=HAL::Set(iTest->iScreenNumber,HALData::EBacklightState,prevState); |
|
668 TEST(err==KErrNone); |
|
669 if (err!=KErrNone) |
|
670 { |
|
671 _LIT(KLog,"Failed to set BackLight state back to previous state: %d on screen %d, error code: %d"); |
|
672 LOG_MESSAGE4(KLog,prevState,iTest->iScreenNumber,err); |
|
673 } |
|
674 } |
|
675 |
|
676 #define BRIGHTNESS_UP 'N' |
|
677 #define BRIGHTNESS_DOWN 'J' |
|
678 /** If aChange is true, checks that programmicaly defined brightness buttons increase and decrease brightness properly. |
|
679 If aChange is false, checks that programmicaly defined brightness buttons don't affect brightness. |
|
680 */ |
|
681 void CTKey::TestBrightnessL(TBool aChange) |
|
682 { |
|
683 TInt brightness; |
|
684 TInt newBrightness; |
|
685 TInt diff=aChange ? 1:0; |
|
686 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); |
|
687 |
|
688 SendCtrlAltShift(BRIGHTNESS_UP); |
|
689 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
690 TEST(brightness+diff==newBrightness); |
|
691 if (brightness+diff!=newBrightness) |
|
692 INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); |
|
693 |
|
694 SendCtrlAltShift(BRIGHTNESS_DOWN); |
|
695 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
696 TEST(brightness==newBrightness); |
|
697 if (brightness!=newBrightness) |
|
698 INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); |
|
699 |
|
700 SendCtrlAltShift(BRIGHTNESS_DOWN); |
|
701 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
702 TEST(brightness-diff==newBrightness); |
|
703 if (brightness-diff!=newBrightness) |
|
704 INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); |
|
705 |
|
706 SendCtrlAltShift(BRIGHTNESS_UP); |
|
707 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
708 TEST(brightness==newBrightness); |
|
709 if (brightness!=newBrightness) |
|
710 INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); |
|
711 } |
|
712 |
|
713 /** If aChange is true, checks that default brightness buttons increase and decrease brightness properly (increase/decrease by 1). |
|
714 If aChange is false, checks that default brightness buttons don't affect brightness. |
|
715 */ |
|
716 void CTKey::TestDefaultBrightnessL(TBool aChange) |
|
717 { |
|
718 TInt brightness; |
|
719 TInt newBrightness; |
|
720 TInt diff=aChange ? 1:0; |
|
721 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness)); |
|
722 |
|
723 SendKey(EKeyIncBrightness); |
|
724 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
725 TEST(brightness+diff==newBrightness); |
|
726 if (brightness+diff!=newBrightness) |
|
727 INFO_PRINTF3(_L("brightness+diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness+diff); |
|
728 |
|
729 SendKey(EKeyDecBrightness); |
|
730 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
731 TEST(brightness==newBrightness); |
|
732 if (brightness!=newBrightness) |
|
733 INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); |
|
734 |
|
735 SendKey(EKeyDecBrightness); |
|
736 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
737 TEST(brightness-diff==newBrightness); |
|
738 if (brightness-diff!=newBrightness) |
|
739 INFO_PRINTF3(_L("brightness-diff==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness-diff); |
|
740 |
|
741 SendKey(EKeyIncBrightness); |
|
742 User::LeaveIfError(HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,newBrightness)); |
|
743 TEST(brightness==newBrightness); |
|
744 if (brightness!=newBrightness) |
|
745 INFO_PRINTF3(_L("brightness==newBrightness - Expected: %d, Actual: %d"), newBrightness, brightness); |
|
746 } |
|
747 |
|
748 void CTKey::BrightnessKeysL() |
|
749 { |
|
750 INFO_PRINTF1(_L("AUTO Brightness Key Test ")); |
|
751 TInt maxBrightness; |
|
752 TInt brightness=0; //To stop warning |
|
753 // get maximum brightness and current |
|
754 TInt err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightnessMax,maxBrightness); |
|
755 if (err==KErrNotSupported) |
|
756 return; |
|
757 else if (err==KErrNone) |
|
758 err=HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness); |
|
759 if (err==KErrNotSupported) |
|
760 return; |
|
761 INFO_PRINTF1(_L(" Supported")); |
|
762 TEST(err==KErrNone); |
|
763 if (err!=KErrNone) |
|
764 INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); |
|
765 |
|
766 // sets brightness to be neither maximal nor minimal |
|
767 if (brightness==0) |
|
768 err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,++brightness); |
|
769 else if (brightness==maxBrightness) |
|
770 err=HAL::Set(iTest->iScreenNumber,HALData::EDisplayBrightness,--brightness); |
|
771 if (err==KErrNotSupported) |
|
772 return; |
|
773 INFO_PRINTF1(_L(" Changeable")); |
|
774 TEST(err==KErrNone); |
|
775 if (err!=KErrNone) |
|
776 INFO_PRINTF3(_L("HAL::Get(iTest->iScreenNumber,HALData::EDisplayBrightness,brightness) return value - Expected: %d, Actual: %d"), KErrNone, err); |
|
777 |
|
778 // Test default brightness buttons increase/decrease brightness by 1 |
|
779 TestDefaultBrightnessL(ETrue); |
|
780 |
|
781 // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 |
|
782 INFO_PRINTF1(_L(" First Test")); |
|
783 SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); |
|
784 SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); |
|
785 TestBrightnessL(ETrue); |
|
786 TestDefaultBrightnessL(ETrue); |
|
787 |
|
788 // Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness |
|
789 INFO_PRINTF1(_L(" Second Test")); |
|
790 TheClient->iWs.ClearHotKeys(EHotKeyIncBrightness); |
|
791 TheClient->iWs.ClearHotKeys(EHotKeyDecBrightness); |
|
792 TestBrightnessL(EFalse); |
|
793 TestDefaultBrightnessL(EFalse); |
|
794 |
|
795 // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 |
|
796 INFO_PRINTF1(_L(" Third Test")); |
|
797 TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); |
|
798 TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); |
|
799 TestBrightnessL(EFalse); |
|
800 TestDefaultBrightnessL(ETrue); |
|
801 |
|
802 // Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 |
|
803 INFO_PRINTF1(_L(" Fourth Test")); |
|
804 SetHotKey(EHotKeyIncBrightness,BRIGHTNESS_UP); |
|
805 SetHotKey(EHotKeyDecBrightness,BRIGHTNESS_DOWN); |
|
806 TestBrightnessL(ETrue); |
|
807 TestDefaultBrightnessL(ETrue); |
|
808 |
|
809 // Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 |
|
810 INFO_PRINTF1(_L(" Fifth Test")); |
|
811 TheClient->iWs.RestoreDefaultHotKey(EHotKeyIncBrightness); |
|
812 TheClient->iWs.RestoreDefaultHotKey(EHotKeyDecBrightness); |
|
813 TestBrightnessL(EFalse); |
|
814 TestDefaultBrightnessL(ETrue); |
|
815 } |
|
816 |
|
817 void CTKey::TestDefaultScreenSizeModeL(TInt aKeys,TBool aChange) |
|
818 { |
|
819 TInt screenMode=TheClient->iScreen->CurrentScreenMode(); |
|
820 TInt key; |
|
821 TInt retVal; |
|
822 for (key=0;key<aKeys;++key) |
|
823 { |
|
824 iVisibleGroup->SetMode(key); |
|
825 SendKey(EKeyScreenDimension0+key); |
|
826 if (aChange) |
|
827 { |
|
828 retVal = TheClient->iScreen->CurrentScreenMode(); |
|
829 TEST(retVal==key); |
|
830 if (retVal!=key) |
|
831 INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); |
|
832 } |
|
833 else |
|
834 { |
|
835 retVal = TheClient->iScreen->CurrentScreenMode(); |
|
836 TEST(retVal==screenMode); |
|
837 if (retVal!=screenMode) |
|
838 INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); |
|
839 } |
|
840 } |
|
841 } |
|
842 |
|
843 #define DIMENSION0 'P' |
|
844 #define DIMENSION1 'Q' |
|
845 #define DIMENSION2 'R' |
|
846 #define DIMENSION3 'N' |
|
847 void CTKey::TestScreenSizeModeL(TInt aKeys,TBool aChange) |
|
848 { |
|
849 TInt screenMode=TheClient->iScreen->CurrentScreenMode(); |
|
850 TInt key; |
|
851 TInt retVal; |
|
852 for (key=0;key<aKeys;++key) |
|
853 { |
|
854 iVisibleGroup->SetMode(key); |
|
855 switch (key) |
|
856 { |
|
857 case 0: |
|
858 SendCtrlAltShift(DIMENSION0); |
|
859 break; |
|
860 case 1: |
|
861 SendCtrlAltShift(DIMENSION1); |
|
862 break; |
|
863 case 2: |
|
864 SendCtrlAltShift(DIMENSION2); |
|
865 break; |
|
866 case 3: |
|
867 SendCtrlAltShift(DIMENSION3); |
|
868 break; |
|
869 default: |
|
870 INFO_PRINTF2(_L("Error Invalid Key: %d"),key); |
|
871 TEST(EFalse); |
|
872 break; |
|
873 } |
|
874 |
|
875 |
|
876 if (aChange) |
|
877 { |
|
878 retVal = TheClient->iScreen->CurrentScreenMode(); |
|
879 TEST(retVal==key); |
|
880 if (retVal!=key) |
|
881 INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), key, retVal); |
|
882 |
|
883 } |
|
884 else |
|
885 { |
|
886 retVal = TheClient->iScreen->CurrentScreenMode(); |
|
887 TEST(retVal==screenMode); |
|
888 if (retVal!=screenMode) |
|
889 INFO_PRINTF3(_L("TheClient->iScreen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), screenMode, retVal); |
|
890 |
|
891 } |
|
892 } |
|
893 } |
|
894 |
|
895 void CTKey::ScreenSizeModeKeysL() |
|
896 { |
|
897 // The test does nothing if there is only one possible screen mode -> return |
|
898 TInt numScreenModes=TheClient->iScreen->NumScreenModes(); |
|
899 if (numScreenModes<2) |
|
900 return; |
|
901 |
|
902 // Use at most 4 different modes for the test |
|
903 if (numScreenModes>4) {numScreenModes=4;} |
|
904 |
|
905 // Set screen mode 3 |
|
906 TInt screenMode=TheClient->iScreen->CurrentScreenMode(); |
|
907 iVisibleGroup->SetMode(numScreenModes-1); |
|
908 TheClient->iScreen->SetScreenMode(numScreenModes-1); |
|
909 |
|
910 // Test default screen mode switch buttons |
|
911 TestDefaultScreenSizeModeL(numScreenModes,ETrue); |
|
912 |
|
913 // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. |
|
914 SetHotKey(EHotKeyScreenDimension0,DIMENSION0); |
|
915 SetHotKey(EHotKeyScreenDimension1,DIMENSION1); |
|
916 SetHotKey(EHotKeyScreenDimension2,DIMENSION2); |
|
917 SetHotKey(EHotKeyScreenDimension3,DIMENSION3); |
|
918 TestDefaultScreenSizeModeL(numScreenModes,ETrue); |
|
919 TestScreenSizeModeL(numScreenModes,ETrue); |
|
920 |
|
921 // Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes |
|
922 TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension0); |
|
923 TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension1); |
|
924 TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension2); |
|
925 TheClient->iWs.ClearHotKeys(EHotKeyScreenDimension3); |
|
926 TestDefaultScreenSizeModeL(numScreenModes,EFalse); |
|
927 TestScreenSizeModeL(numScreenModes,EFalse); |
|
928 |
|
929 // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes |
|
930 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); |
|
931 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); |
|
932 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); |
|
933 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); |
|
934 TestDefaultScreenSizeModeL(numScreenModes,ETrue); |
|
935 TestScreenSizeModeL(numScreenModes,EFalse); |
|
936 |
|
937 // Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. |
|
938 SetHotKey(EHotKeyScreenDimension0,DIMENSION0); |
|
939 SetHotKey(EHotKeyScreenDimension1,DIMENSION1); |
|
940 SetHotKey(EHotKeyScreenDimension2,DIMENSION2); |
|
941 SetHotKey(EHotKeyScreenDimension3,DIMENSION3); |
|
942 TestDefaultScreenSizeModeL(numScreenModes,ETrue); |
|
943 TestScreenSizeModeL(numScreenModes,ETrue); |
|
944 |
|
945 // Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes |
|
946 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension0); |
|
947 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension1); |
|
948 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension2); |
|
949 TheClient->iWs.RestoreDefaultHotKey(EHotKeyScreenDimension3); |
|
950 TestDefaultScreenSizeModeL(numScreenModes,ETrue); |
|
951 TestScreenSizeModeL(numScreenModes,EFalse); |
|
952 |
|
953 // Restore initial screen mode |
|
954 iVisibleGroup->SetMode(screenMode); |
|
955 TheClient->iScreen->SetScreenMode(screenMode); |
|
956 } |
|
957 |
|
958 void CTKey::RunTestCaseL(TInt /*aCurTestCase*/) |
|
959 { |
|
960 _LIT(KTest0,"KeyOfDeath"); |
|
961 _LIT(KTest1,"Contrast"); |
|
962 _LIT(KTest2,"BackLight"); |
|
963 _LIT(KTest3,"Brightness"); |
|
964 _LIT(KTest4,"Screen Size Mode"); |
|
965 ((CTKeyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
966 #ifdef _DEBUG |
|
967 _LIT(KTest5,"Orientation"); |
|
968 _LIT(KTest6,"CycleDisplaySize"); |
|
969 #endif |
|
970 switch(++iTest->iState) |
|
971 { |
|
972 /** |
|
973 @SYMTestCaseID GRAPHICS-WSERV-0106 |
|
974 |
|
975 @SYMDEF DEF081259 |
|
976 |
|
977 @SYMTestCaseDesc Key of Death test |
|
978 |
|
979 @SYMTestPriority High |
|
980 |
|
981 @SYMTestStatus Implemented |
|
982 |
|
983 @SYMTestActions Creates a new client process and runs it. |
|
984 Waits until the process is started and simulates Ctrl-Alt-Shift-K press. |
|
985 When starts the process assumes that TAutoServer.exe exists in z:\sys\bin directory. |
|
986 Otherwise the test will not exit a wait-state and will be aborted. |
|
987 |
|
988 @SYMTestExpectedResults Checks that the process is dead after the Ctrl-Alt-Shift-K press. |
|
989 Check also that the difference between amounts of window groups efore |
|
990 death-key press and after death-key press is 1. |
|
991 */ |
|
992 case 1: |
|
993 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0106")); |
|
994 iTest->LogSubTest(KTest0); |
|
995 KeyOfDeathL(); |
|
996 break; |
|
997 case 2: |
|
998 /** |
|
999 @SYMTestCaseID GRAPHICS-WSERV-0539 |
|
1000 */ |
|
1001 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0539")); |
|
1002 iTest->LogSubTest(KTest1); |
|
1003 ContrastKeysL(); |
|
1004 break; |
|
1005 /** |
|
1006 @SYMTestCaseID GRAPHICS-WSERV-0107 |
|
1007 |
|
1008 @SYMDEF DEF081259 |
|
1009 |
|
1010 @SYMTestCaseDesc Test backlight |
|
1011 |
|
1012 @SYMTestPriority High |
|
1013 |
|
1014 @SYMTestStatus Implemented |
|
1015 |
|
1016 @SYMTestActions Does nothing if hardware attributes are not supported. |
|
1017 1. Turns backlight off. |
|
1018 2. Tests that default backlight ON/OFF/TOGGLE buttons work. |
|
1019 3. Sets user defined backlight buttons and tests that both default and user defined buttons work. |
|
1020 4. Calls RWsSession::ClearHotKeys and tests that both default and user defined buttons don't work. |
|
1021 5. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. |
|
1022 6. Sets user defined backlight buttons and tests that both default and user defined buttons work. |
|
1023 7. Calls RWsSession::RestoreDefaultHotKey and tests that only default buttons work. |
|
1024 8. Restores previous backlight state. |
|
1025 |
|
1026 @SYMTestExpectedResults Expects that actions described above give positive result. |
|
1027 The test also checks that programmatic turn off/on doesn't fail. |
|
1028 */ |
|
1029 case 3: |
|
1030 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0107")); |
|
1031 iTest->LogSubTest(KTest2); |
|
1032 BackLightKeysL(); |
|
1033 break; |
|
1034 /** |
|
1035 @SYMTestCaseID GRAPHICS-WSERV-0108 |
|
1036 |
|
1037 @SYMDEF DEF081259 |
|
1038 |
|
1039 @SYMTestCaseDesc Test brightness |
|
1040 |
|
1041 @SYMTestPriority High |
|
1042 |
|
1043 @SYMTestStatus Implemented |
|
1044 |
|
1045 @SYMTestActions Does nothing if hardware attributes are not supported. |
|
1046 1. Get maximum brightness and current, test that those operations don't fail |
|
1047 2. Sets brightness to be neither maximal nor minimal, test that those operations don't fail |
|
1048 3. Test default brightness buttons increase/decrease brightness by 1 |
|
1049 4. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 |
|
1050 5. Clear brightness buttons, test that default and program defined brightness buttons doesn't affect brightness |
|
1051 6. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 |
|
1052 7. Add new inc/dec buttons, test that default and program defined brightness buttons increase/decrease brightness by 1 |
|
1053 8. Restore default brightness buttons, test that only default brightness buttons increase/decrease brightness by 1 |
|
1054 |
|
1055 @SYMTestExpectedResults Expects that actions described above give positive result. |
|
1056 The test also checks that programmatic brightness increase and decrease doesn't fail. |
|
1057 */ |
|
1058 case 4: |
|
1059 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0108")); |
|
1060 iTest->LogSubTest(KTest3); |
|
1061 BrightnessKeysL(); |
|
1062 break; |
|
1063 /** |
|
1064 @SYMTestCaseID GRAPHICS-WSERV-0109 |
|
1065 |
|
1066 @SYMDEF DEF081259 |
|
1067 |
|
1068 @SYMTestCaseDesc Test screen mode switching |
|
1069 |
|
1070 @SYMTestPriority High |
|
1071 |
|
1072 @SYMTestStatus Implemented |
|
1073 |
|
1074 @SYMTestActions The test does nothing if there is only one possible screen mode. It uses at most 4 different modes for the test. |
|
1075 1. Test default screen mode switch buttons |
|
1076 2. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. |
|
1077 3. Clear all screen mode switch buttons. Test that default and program defined screen mode switch buttons don't affect screen modes |
|
1078 4. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes |
|
1079 5. Add new screen mode switch buttons. Test that default and program defined screen mode switch buttons switch modes. |
|
1080 6. Restore default screen mode switch buttons. Test that only default screen mode switch buttons switch screen modes |
|
1081 7. Restore initial screen mode |
|
1082 |
|
1083 |
|
1084 |
|
1085 @SYMTestExpectedResults Expects that actions described above give positive result. |
|
1086 */ |
|
1087 case 5: |
|
1088 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0109")); |
|
1089 iTest->LogSubTest(KTest4); |
|
1090 ScreenSizeModeKeysL(); |
|
1091 break; |
|
1092 #ifdef _DEBUG |
|
1093 case 6: |
|
1094 /** |
|
1095 @SYMTestCaseID GRAPHICS-WSERV-0540 |
|
1096 */ |
|
1097 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0540")); |
|
1098 iTest->LogSubTest(KTest5); |
|
1099 KeyOfOrientation(); |
|
1100 break; |
|
1101 case 7: |
|
1102 /** |
|
1103 @SYMTestCaseID GRAPHICS-WSERV-0541 |
|
1104 */ |
|
1105 ((CTKeyStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0541")); |
|
1106 iTest->LogSubTest(KTest6); |
|
1107 CycleDisplaySize(); |
|
1108 break; |
|
1109 #endif |
|
1110 default: |
|
1111 ((CTKeyStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
1112 ((CTKeyStep*)iStep)->CloseTMSGraphicsStep(); |
|
1113 TestComplete(); |
|
1114 } |
|
1115 ((CTKeyStep*)iStep)->RecordTestResultL(); |
|
1116 } |
|
1117 |
|
1118 |
|
1119 __WS_CONSTRUCT_STEP__(Key) |