|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "TSPRITE.H" |
|
23 |
|
24 CTTSprite::CTTSprite(CTestStep* aStep): |
|
25 CTWsGraphicsBase(aStep) |
|
26 { |
|
27 INFO_PRINTF1(_L("Testing TSprite functions")); |
|
28 } |
|
29 |
|
30 void CTTSprite::SetUpMember(TSpriteMember &aMember) |
|
31 { |
|
32 aMember.iMaskBitmap=NULL; |
|
33 aMember.iInvertMask=EFalse; |
|
34 aMember.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
35 aMember.iOffset=TPoint(); |
|
36 aMember.iInterval=TTimeIntervalMicroSeconds32(0); |
|
37 aMember.iBitmap=&iBitmap; |
|
38 } |
|
39 |
|
40 void CTTSprite::SetUpPointerCursorL(RWsPointerCursor &aCursor, RWsSession &aSession) |
|
41 { |
|
42 aCursor=RWsPointerCursor(aSession); |
|
43 TSpriteMember member; |
|
44 SetUpMember(member); |
|
45 User::LeaveIfError(aCursor.Construct(0)); |
|
46 User::LeaveIfError(aCursor.AppendMember(member)); |
|
47 User::LeaveIfError(aCursor.Activate()); |
|
48 } |
|
49 |
|
50 void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags/*=0*/) |
|
51 { |
|
52 aSprite=RWsSprite(aSession); |
|
53 User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags)); |
|
54 TSpriteMember member; |
|
55 SetUpMember(member); |
|
56 User::LeaveIfError(aSprite.AppendMember(member)); |
|
57 User::LeaveIfError(aSprite.Activate()); |
|
58 } |
|
59 |
|
60 void CTTSprite::ConstructL() |
|
61 { |
|
62 User::LeaveIfError(iBitmap.Load(TEST_BITMAP_NAME,0)); |
|
63 } |
|
64 |
|
65 CTTSprite::~CTTSprite() |
|
66 { |
|
67 } |
|
68 |
|
69 /** |
|
70 @SYMTestCaseID GRAPHICS-WSERV-0018 |
|
71 |
|
72 @SYMDEF DEF081259 |
|
73 |
|
74 @SYMTestCaseDesc General cursor tests involving a sprite |
|
75 |
|
76 @SYMTestPriority High |
|
77 |
|
78 @SYMTestStatus Implemented |
|
79 |
|
80 @SYMTestActions Carries out cursor and window tests before updating |
|
81 a cursor's member with a sprite |
|
82 |
|
83 @SYMTestExpectedResults When the cursor member is update returns KErrArgument |
|
84 */ |
|
85 |
|
86 void CTTSprite::GeneralTestsL() |
|
87 { |
|
88 // |
|
89 // Close cursor while still active on a window |
|
90 // |
|
91 |
|
92 RWindow win(TheClient->iWs); |
|
93 win.Construct(*TheClient->iGroup->GroupWin(),1); |
|
94 win.Activate(); |
|
95 SetUpPointerCursorL(iCursor1,TheClient->iWs); |
|
96 win.SetCustomPointerCursor(iCursor1); |
|
97 iCursor1.Close(); |
|
98 // |
|
99 // Close window while cursor active on it |
|
100 // |
|
101 SetUpPointerCursorL(iCursor1,TheClient->iWs); |
|
102 win.SetCustomPointerCursor(iCursor1); |
|
103 win.Close(); |
|
104 iCursor1.Close(); |
|
105 |
|
106 // |
|
107 // Close session with: |
|
108 // An open cursor active on a window & A closed cursor active on another window |
|
109 // |
|
110 RWsSession ws; |
|
111 User::LeaveIfError(ws.Connect()); |
|
112 // use correct screen |
|
113 // |
|
114 ws.SetFocusScreen(iTest->iScreenNumber); |
|
115 CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); |
|
116 CleanupStack::PushL(screen); |
|
117 User::LeaveIfError(screen->Construct(0)); |
|
118 |
|
119 RWindowGroup group(ws); |
|
120 User::LeaveIfError(group.Construct(123)); |
|
121 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close |
|
122 RWindow win2(ws); |
|
123 User::LeaveIfError(win2.Construct(group, 1)); |
|
124 win2.Activate(); |
|
125 RWindow win3(ws); |
|
126 User::LeaveIfError(win3.Construct(group, 2)); |
|
127 win3.Activate(); |
|
128 // |
|
129 SetUpPointerCursorL(iCursor1,ws); |
|
130 SetUpPointerCursorL(iCursor2,ws); |
|
131 win2.SetCustomPointerCursor(iCursor1); |
|
132 win3.SetCustomPointerCursor(iCursor2); |
|
133 // |
|
134 TSpriteMember member; |
|
135 member.iBitmap=member.iMaskBitmap=NULL; |
|
136 TInt err = iCursor1.UpdateMember(9999,member); |
|
137 TEST(err==KErrArgument); |
|
138 if (err!=KErrArgument) |
|
139 INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); |
|
140 |
|
141 iCursor1.Close(); |
|
142 |
|
143 CleanupStack::PopAndDestroy(screen); |
|
144 ws.Close(); |
|
145 } |
|
146 |
|
147 /** |
|
148 @SYMTestCaseID GRAPHICS-WSERV-0019 |
|
149 |
|
150 @SYMDEF DEF081259 |
|
151 |
|
152 @SYMTestCaseDesc Construct a sprite in a group window |
|
153 |
|
154 @SYMTestPriority High |
|
155 |
|
156 @SYMTestStatus Implemented |
|
157 |
|
158 @SYMTestActions Creates a sprite in a group window |
|
159 |
|
160 @SYMTestExpectedResults The sprite is created without error |
|
161 */ |
|
162 void CTTSprite::GroupWindowSpritesL() |
|
163 { |
|
164 RWsSprite sprite1; |
|
165 RWsSprite sprite2; |
|
166 SetUpSpriteL(sprite1,TheClient->iWs,*TheClient->iGroup->GroupWin()); |
|
167 SetUpSpriteL(sprite2,TheClient->iWs,*TheClient->iGroup->GroupWin()); |
|
168 TheClient->iWs.Flush(); |
|
169 sprite2.Close(); |
|
170 sprite1.Close(); |
|
171 } |
|
172 |
|
173 /** |
|
174 @SYMTestCaseID GRAPHICS-WSERV-0020 |
|
175 |
|
176 @SYMDEF DEF081259 |
|
177 |
|
178 @SYMTestCaseDesc Constructs a number of different sprites in different windows |
|
179 |
|
180 @SYMTestPriority High |
|
181 |
|
182 @SYMTestStatus Implemented |
|
183 |
|
184 @SYMTestActions Creates many sprites in three different windows and the checks |
|
185 the sprites can be manipulated |
|
186 |
|
187 @SYMTestExpectedResults The sprite are created and manipulated without error |
|
188 */ |
|
189 #define NUM_SPRITES 8 |
|
190 void CTTSprite::LotsSpritesL() |
|
191 { |
|
192 CTBlankWindow* win=new(ELeave) CTBlankWindow(); |
|
193 CTBlankWindow* win2=new(ELeave) CTBlankWindow(); |
|
194 TSize size(100,120); |
|
195 win->ConstructL(*TheClient->iGroup); |
|
196 win2->ConstructL(*win); |
|
197 win2->SetExt(TPoint(100,100),size); |
|
198 win2->SetColor(TRgb::Gray4(2)); |
|
199 RWindowBase window=*win->BaseWin(); |
|
200 RWindowBase window2=*win2->BaseWin(); |
|
201 window.Activate(); |
|
202 window2.Activate(); |
|
203 RWsSprite sprite[NUM_SPRITES]; |
|
204 TInt ii; |
|
205 //TheClient->iWs.SetAutoFlush(ETrue); |
|
206 for (ii=0;ii<NUM_SPRITES;ii++) |
|
207 SetUpSpriteL(sprite[ii],TheClient->iWs,window); |
|
208 sprite[4].Close(); |
|
209 sprite[2].SetPosition(TPoint(20,20)); |
|
210 sprite[0].Close(); |
|
211 win2->SetExt(TPoint(80,100),size); |
|
212 sprite[6].SetPosition(TPoint(60,120)); |
|
213 sprite[7].Close(); |
|
214 sprite[5].SetPosition(TPoint(100,120)); |
|
215 sprite[3].Close(); |
|
216 SetUpSpriteL(sprite[7],TheClient->iWs,window); |
|
217 sprite[7].SetPosition(TPoint(80,150)); |
|
218 sprite[1].Close(); |
|
219 win2->SetExt(TPoint(60,110),size); |
|
220 sprite[5].SetPosition(TPoint(50,40)); |
|
221 sprite[7].Close(); |
|
222 SetUpSpriteL(sprite[0],TheClient->iWs,window); |
|
223 sprite[0].SetPosition(TPoint(55,65)); |
|
224 sprite[6].Close(); |
|
225 win2->SetExt(TPoint(40,90),size); |
|
226 sprite[2].SetPosition(TPoint(80,45)); |
|
227 sprite[5].Close(); |
|
228 sprite[0].SetPosition(TPoint(90,60)); |
|
229 sprite[2].Close(); |
|
230 SetUpSpriteL(sprite[2],TheClient->iWs,window); |
|
231 sprite[2].SetPosition(TPoint(70,80)); |
|
232 sprite[0].Close(); |
|
233 win2->SetExt(TPoint(20,80),size); |
|
234 sprite[2].SetPosition(TPoint(600,200)); |
|
235 sprite[2].Close(); |
|
236 SetUpSpriteL(sprite[0],TheClient->iWs,window2,ESpriteFlash); |
|
237 sprite[0].SetPosition(TPoint(0,25)); |
|
238 SetUpSpriteL(sprite[1],TheClient->iWs,window2,ESpriteFlash); |
|
239 SetUpSpriteL(sprite[2],TheClient->iWs,window2,ESpriteFlash); |
|
240 sprite[2].SetPosition(TPoint(25,0)); |
|
241 win2->SetExt(TPoint(40,70),size); |
|
242 CTBlankWindow* win3=new(ELeave) CTBlankWindow(); |
|
243 win3->ConstructL(*TheClient->iGroup); |
|
244 win3->SetExt(TPoint(30,60),TSize(30,30)); |
|
245 win3->SetColor(TRgb::Gray4(1)); |
|
246 win3->BaseWin()->SetShadowHeight(10); |
|
247 win3->BaseWin()->Activate(); |
|
248 User::After(1000000); //1 sec so sprites has time to flash |
|
249 delete win2; |
|
250 delete win; |
|
251 delete win3; |
|
252 sprite[0].Close(); |
|
253 sprite[1].Close(); |
|
254 sprite[2].Close(); |
|
255 } |
|
256 |
|
257 /** |
|
258 @SYMTestCaseID GRAPHICS-WSERV-0021 |
|
259 |
|
260 @SYMDEF DEF081259 |
|
261 |
|
262 @SYMTestCaseDesc General PointerCursor Tests |
|
263 |
|
264 @SYMTestPriority High |
|
265 |
|
266 @SYMTestStatus Implemented |
|
267 |
|
268 @SYMTestActions Exercise the different pointercursor methods of a Window Server Session |
|
269 |
|
270 @SYMTestExpectedResults The methods are called without error |
|
271 */ |
|
272 void CTTSprite::GeneralPointerCursor() |
|
273 { |
|
274 if (!TestBase()->ConfigurationSupportsPointerEventTesting()) |
|
275 { |
|
276 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); |
|
277 return; |
|
278 } |
|
279 TInt currentSMode=TheClient->iScreen->CurrentScreenMode(); |
|
280 TInt altSMode=-1; |
|
281 if (TheClient->iScreen->NumScreenModes()>1) |
|
282 altSMode=(currentSMode==1?0:1); |
|
283 RWsSession &ws=TheClient->iWs; |
|
284 TRect rect=ws.PointerCursorArea(); |
|
285 TRect testRect1(TPoint(rect.iBr.iX/4,rect.iBr.iY/4),TSize(rect.Width()/2,rect.Height()/2)); |
|
286 TRect testRect2(TPoint(rect.iBr.iX/3,rect.iBr.iY/3),TSize(2*rect.Width()/3,2*rect.Height()/3)); |
|
287 ws.SetPointerCursorArea(testRect1); |
|
288 TEST(ws.PointerCursorArea()==testRect1); |
|
289 TEST(ws.PointerCursorArea(currentSMode)==testRect1); |
|
290 ws.SetPointerCursorArea(currentSMode,testRect2); |
|
291 TEST(ws.PointerCursorArea()==testRect2); |
|
292 TEST(ws.PointerCursorArea(currentSMode)==testRect2); |
|
293 ws.SetPointerCursorArea(rect); |
|
294 TEST(ws.PointerCursorArea()==rect); |
|
295 |
|
296 if (altSMode>=0) |
|
297 { |
|
298 rect=ws.PointerCursorArea(altSMode); |
|
299 testRect1.iTl.iX=rect.iBr.iX/4; |
|
300 testRect1.iTl.iY=rect.iBr.iY/4; |
|
301 testRect1.SetWidth(rect.Width()/2); |
|
302 testRect1.SetHeight(rect.Height()/2); |
|
303 ws.SetPointerCursorArea(altSMode,testRect1); |
|
304 TEST(ws.PointerCursorArea(altSMode)==testRect1); |
|
305 ws.SetPointerCursorArea(altSMode,rect); |
|
306 TEST(ws.PointerCursorArea(altSMode)==rect); |
|
307 } |
|
308 TPointerCursorMode currentMode=ws.PointerCursorMode(); |
|
309 TInt ii; |
|
310 TInt err1; |
|
311 for(ii=EPointerCursorFirstMode;ii<=EPointerCursorLastMode;ii++) |
|
312 { |
|
313 ws.SetPointerCursorMode(STATIC_CAST(TPointerCursorMode,ii)); |
|
314 err1 = ws.PointerCursorMode(); |
|
315 TEST(ii==err1); |
|
316 if (ii!=err1) |
|
317 INFO_PRINTF3(_L("ws.PointerCursorMode() return value - Expected: %d, Actual: %d"), ii, err1); |
|
318 } |
|
319 ws.SetPointerCursorMode(currentMode); |
|
320 TEST(currentMode==ws.PointerCursorMode()); |
|
321 TPoint point1(10,12); |
|
322 TPoint point2(24,20); |
|
323 ws.PointerCursorPosition(); |
|
324 ws.SetPointerCursorPosition(point1); |
|
325 TEST(ws.PointerCursorPosition()==point1); |
|
326 ws.SetPointerCursorPosition(point2); |
|
327 TEST(ws.PointerCursorPosition()==point2); |
|
328 } |
|
329 |
|
330 |
|
331 /** |
|
332 @SYMTestCaseID GRAPHICS-WSERV-0498 |
|
333 |
|
334 @SYMDEF PDEF137614 - Propagation to TB92 |
|
335 |
|
336 @SYMTestCaseDesc Test activating a pointer cursor |
|
337 |
|
338 @SYMTestPriority High |
|
339 |
|
340 @SYMTestStatus Implemented |
|
341 |
|
342 @SYMTestActions Construct and activate a pointer cursor. |
|
343 Check it is visible. |
|
344 Deactivate it |
|
345 Check it is removed |
|
346 |
|
347 |
|
348 @SYMTestExpectedResults |
|
349 The pointer cursor bitmp should be visible when activated and removed when deactivated. |
|
350 */ |
|
351 |
|
352 void CTTSprite::PointerCursorVisibleL() |
|
353 { |
|
354 if (!TestBase()->ConfigurationSupportsPointerEventTesting()) |
|
355 { |
|
356 INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing")); |
|
357 return; |
|
358 } |
|
359 |
|
360 // The pointer events need time to have an affect on the wserv |
|
361 static const TInt eventPropagationDelay = 100 * 1000; // 100 ms |
|
362 |
|
363 TInt screenNumber = TheClient->iScreen->GetScreenNumber(); |
|
364 |
|
365 if(screenNumber != 0) // pointer events only supported on emulator screen 0 |
|
366 { |
|
367 LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0")); |
|
368 return; |
|
369 } |
|
370 |
|
371 // set up objects used in test |
|
372 // 50x50 red rectangle colour 24 |
|
373 CFbsBitmap bitmap; |
|
374 User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8)); |
|
375 |
|
376 TSize bmSize = bitmap.SizeInPixels(); |
|
377 TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2); |
|
378 TRgb bmColour; |
|
379 bitmap.GetPixel(bmColour, bmSample); |
|
380 TEST(bmColour == KRgbRed); |
|
381 |
|
382 // single window, size of screen |
|
383 RWindow win(TheClient->iWs); |
|
384 User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1)); |
|
385 win.Activate(); |
|
386 |
|
387 // setup cursor mode |
|
388 TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow); |
|
389 |
|
390 // setup cursor to contain single 50x50 red bitmap |
|
391 RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs); |
|
392 TSpriteMember member; |
|
393 SetUpMember(member); |
|
394 member.iBitmap=&bitmap; |
|
395 User::LeaveIfError(iCursor1.Construct(0)); |
|
396 User::LeaveIfError(iCursor1.AppendMember(member)); |
|
397 User::LeaveIfError(iCursor1.Activate()); |
|
398 win.SetCustomPointerCursor(iCursor1); |
|
399 iCursor1.UpdateMember(0); |
|
400 |
|
401 // draw a green rect, size of screen as defined background and wait till it is rendered |
|
402 win.BeginRedraw(); |
|
403 TheGc->Activate(win); |
|
404 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
405 TheGc->SetBrushColor(KRgbGreen); |
|
406 TSize wSize = win.Size(); |
|
407 TheGc->DrawRect(TRect(TPoint(0,0), wSize)); |
|
408 TheGc->Deactivate(); |
|
409 win.EndRedraw(); |
|
410 TheClient->iWs.Finish(); |
|
411 |
|
412 // #### do test #### |
|
413 // define locations of simulated pointer events and sample positions of where we expect to see the cursor |
|
414 // The cursor will be moved and a check will be made to see if this has actually happened |
|
415 |
|
416 TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen |
|
417 TPoint sample1(pos1 + bmSample); // centre of sprite at pos1 |
|
418 TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen |
|
419 TPoint sample2 = pos2 + bmSample; // centre of sprite at pos2 |
|
420 |
|
421 TRgb pixel; |
|
422 |
|
423 // check initial state of screen at both sample positions |
|
424 TheClient->iScreen->GetPixel(pixel, sample1); |
|
425 TEST(pixel == KRgbGreen); |
|
426 |
|
427 TheClient->iScreen->GetPixel(pixel, sample2); |
|
428 TEST(pixel == KRgbGreen); |
|
429 |
|
430 TRawEvent e; // to simulate pointer events |
|
431 |
|
432 // simulate button 1 down event at pos1 |
|
433 e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY); |
|
434 e.SetDeviceNumber(screenNumber); |
|
435 UserSvr::AddEvent(e); |
|
436 |
|
437 User::After(eventPropagationDelay); |
|
438 |
|
439 // check red cursor visible on top of background |
|
440 TheClient->iScreen->GetPixel(pixel, sample1); |
|
441 TEST(pixel == KRgbRed); |
|
442 |
|
443 // simulate button 1 up event |
|
444 e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY); |
|
445 UserSvr::AddEvent(e); |
|
446 User::After(eventPropagationDelay); |
|
447 |
|
448 // Move cursor away to pos2 |
|
449 e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY); |
|
450 e.SetDeviceNumber(screenNumber); |
|
451 UserSvr::AddEvent(e); |
|
452 |
|
453 User::After(eventPropagationDelay); |
|
454 |
|
455 // check cursor has left this position ... |
|
456 TheClient->iScreen->GetPixel(pixel, sample1); |
|
457 TEST(pixel == KRgbGreen); |
|
458 // and arrived at the correct place |
|
459 TheClient->iScreen->GetPixel(pixel, sample2); |
|
460 TEST(pixel == KRgbRed); |
|
461 |
|
462 // simulate button 1 up event |
|
463 e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY); |
|
464 UserSvr::AddEvent(e); |
|
465 User::After(eventPropagationDelay); |
|
466 |
|
467 // remove the cursor |
|
468 win.ClearPointerCursor(); |
|
469 User::After(eventPropagationDelay); |
|
470 |
|
471 // check it has gone |
|
472 TheClient->iScreen->GetPixel(pixel, sample2); |
|
473 TEST(pixel == KRgbGreen); |
|
474 |
|
475 // #### clean up #### |
|
476 iCursor1.Close(); |
|
477 win.Close(); |
|
478 } |
|
479 |
|
480 |
|
481 /** |
|
482 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0053-0001 |
|
483 |
|
484 @SYMPREQ PGM027 |
|
485 |
|
486 @SYMTestCaseDesc Tests RWsPointerCursor::UpdateMember APIs. |
|
487 |
|
488 @SYMTestPriority 1 |
|
489 |
|
490 @SYMTestStatus Implemented |
|
491 |
|
492 @SYMTestActions This test calls RWsPointerCursor::UpdateMember |
|
493 |
|
494 @SYMTestExpectedResults Should run properly with out any Panics. |
|
495 |
|
496 */ |
|
497 void CTTSprite::SpriteUpdateMemberTestsL() |
|
498 { |
|
499 RWsPointerCursor iCursor1; |
|
500 |
|
501 CFbsBitmap bitmap; |
|
502 bitmap.Load(TEST_BITMAP_NAME,0); |
|
503 |
|
504 RWindow win(TheClient->iWs); |
|
505 win.Construct(*TheClient->iGroup->GroupWin(),1); |
|
506 win.Activate(); |
|
507 |
|
508 iCursor1=RWsPointerCursor(TheClient->iWs); |
|
509 TSpriteMember member; |
|
510 SetUpMember(member); |
|
511 member.iBitmap=&bitmap; |
|
512 User::LeaveIfError(iCursor1.Construct(0)); |
|
513 User::LeaveIfError(iCursor1.AppendMember(member)); |
|
514 User::LeaveIfError(iCursor1.Activate()); |
|
515 win.SetCustomPointerCursor(iCursor1); |
|
516 iCursor1.UpdateMember(0); |
|
517 |
|
518 RWsPointerCursor iCursor2; |
|
519 bitmap.Load(TEST_NEW_BITMAP_NAME,0); |
|
520 iCursor2=RWsPointerCursor(TheClient->iWs); |
|
521 User::LeaveIfError(iCursor2.Construct(0)); |
|
522 User::LeaveIfError(iCursor2.AppendMember(member)); |
|
523 User::LeaveIfError(iCursor2.Activate()); |
|
524 win.SetCustomPointerCursor(iCursor2); |
|
525 iCursor2.UpdateMember(1); |
|
526 |
|
527 iCursor1.Close(); |
|
528 iCursor2.Close(); |
|
529 win.Close(); |
|
530 } |
|
531 |
|
532 /** |
|
533 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001 |
|
534 |
|
535 @SYMPREQ PGM027 |
|
536 |
|
537 @SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. |
|
538 |
|
539 @SYMTestPriority 1 |
|
540 |
|
541 @SYMTestStatus Implemented |
|
542 |
|
543 @SYMTestActions This test calls RWsPointerCursor::UpdateMember |
|
544 |
|
545 @SYMTestExpectedResults Should run properly with out any Panics. |
|
546 |
|
547 */ |
|
548 void CTTSprite::SpriteUpdateMemberNegTestsL() |
|
549 { |
|
550 RWsPointerCursor iCursor1; |
|
551 |
|
552 CFbsBitmap bitmap; |
|
553 bitmap.Load(TEST_BITMAP_NAME,0); |
|
554 |
|
555 RWindow win(TheClient->iWs); |
|
556 win.Construct(*TheClient->iGroup->GroupWin(),1); |
|
557 win.Activate(); |
|
558 |
|
559 iCursor1=RWsPointerCursor(TheClient->iWs); |
|
560 TSpriteMember member; |
|
561 SetUpMember(member); |
|
562 member.iBitmap=&bitmap; |
|
563 User::LeaveIfError(iCursor1.Construct(0)); |
|
564 User::LeaveIfError(iCursor1.AppendMember(member)); |
|
565 User::LeaveIfError(iCursor1.Activate()); |
|
566 win.SetCustomPointerCursor(iCursor1); |
|
567 iCursor1.UpdateMember(-100); |
|
568 |
|
569 RWsPointerCursor iCursor2; |
|
570 bitmap.Load(TEST_NEW_BITMAP_NAME,0); |
|
571 iCursor2=RWsPointerCursor(TheClient->iWs); |
|
572 User::LeaveIfError(iCursor2.Construct(0)); |
|
573 User::LeaveIfError(iCursor2.AppendMember(member)); |
|
574 User::LeaveIfError(iCursor2.Activate()); |
|
575 win.SetCustomPointerCursor(iCursor2); |
|
576 iCursor2.UpdateMember(10000); |
|
577 |
|
578 iCursor1.Close(); |
|
579 iCursor2.Close(); |
|
580 win.Close(); |
|
581 } |
|
582 |
|
583 /** |
|
584 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0055-0001 |
|
585 |
|
586 @SYMPREQ PGM027 |
|
587 |
|
588 @SYMTestCaseDesc Tests FindWindowGroupIdentifier API. |
|
589 |
|
590 @SYMTestPriority 1 |
|
591 |
|
592 @SYMTestStatus Implemented |
|
593 |
|
594 @SYMTestActions Create windows session and call FindWindowGroupIdentifier \n |
|
595 with different thread Id's both with valid thread ids and in valid thread id's. |
|
596 |
|
597 @SYMTestExpectedResults Should run properly. |
|
598 |
|
599 */ |
|
600 void CTTSprite::FindWindowGroupThreadTestsL() |
|
601 { |
|
602 RThread proc; |
|
603 TInt ident; |
|
604 TUint64 id=proc.Id(); |
|
605 RWsSession ws1; |
|
606 User::LeaveIfError(ws1.Connect()); |
|
607 CleanupClosePushL(ws1); |
|
608 //Positive test for FindWindowGroupIdentifier |
|
609 ident=ws1.FindWindowGroupIdentifier(0,id); |
|
610 TEST(ws1.SetWindowGroupOrdinalPosition(ident,0)==KErrNone); |
|
611 TEST(ws1.SetWindowGroupOrdinalPosition(ident,1)==KErrNone); |
|
612 //Negative test for FindWindowGroupIdentifier |
|
613 TInt ret=ws1.FindWindowGroupIdentifier(0,id+200); |
|
614 TEST(ret==KErrNotFound); |
|
615 #if defined __WINS__ || defined __WINSCW__ |
|
616 ret=ws1.FindWindowGroupIdentifier(0,-200); |
|
617 TEST(ret==KErrNotFound); |
|
618 #endif//defined __WINS__ || defined __WINSCW__ |
|
619 CleanupStack::PopAndDestroy(1, &ws1); |
|
620 ws1.Close(); |
|
621 } |
|
622 |
|
623 /** |
|
624 @SYMTestCaseID GRAPHICS-WSERV-0462 |
|
625 |
|
626 @SYMDEF PDEF114190 |
|
627 |
|
628 @SYMTestCaseDesc Test sprite list cleanup when a window is deleted in low memory conditions |
|
629 |
|
630 @SYMTestPriority High |
|
631 |
|
632 @SYMTestStatus Implemented |
|
633 |
|
634 @SYMTestActions Have a loop which increases the number of allocations in the server thread before failure; |
|
635 Within the loop: |
|
636 1) Create a parent window and a child window of the parent; |
|
637 2) Create a sprite on the child window; |
|
638 3) Delete the parent window only, but not the child window; |
|
639 4) Create a testWindow and do redraw on this window; |
|
640 5) Do redraw on the testWindow. This testWindow's redraw will force checking the sprite list. |
|
641 This would panic the client thread due to this defect because the sprite on the orphaned |
|
642 window (which is the previous child window) is still in the sprite list; |
|
643 6) Delete all the windows involved. |
|
644 |
|
645 @SYMTestExpectedResults The sprite should be disabled when a window is deleted; |
|
646 The client thread should not be panic'd. |
|
647 The test should pass. |
|
648 */ |
|
649 void CTTSprite::SpriteOnWindowOrphanedTestsL() |
|
650 { |
|
651 TInt handles = 344; |
|
652 TInt loop = 0; |
|
653 TInt allocFailRate = 0; |
|
654 TInt err = KErrNone; |
|
655 |
|
656 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; |
|
657 CleanupStack::PushL(bitmap); |
|
658 User::LeaveIfError(bitmap->Create(TSize(500, 500), EColor16MU)); |
|
659 TSpriteMember spritemember; |
|
660 spritemember.iBitmap = bitmap; |
|
661 spritemember.iMaskBitmap = NULL; |
|
662 |
|
663 RWindowGroup group(TheClient->iWs); |
|
664 RWindow parent1(TheClient->iWs); |
|
665 RWindow child1(TheClient->iWs); |
|
666 RWindow testWindow(TheClient->iWs); |
|
667 RWsSprite sprite(TheClient->iWs); |
|
668 |
|
669 while (loop < 5) |
|
670 { |
|
671 TRect mainRect(TPoint(0,0), TSize(500,500)); |
|
672 err = group.Construct(++handles, EFalse); |
|
673 if (err == KErrNone) |
|
674 { |
|
675 TheClient->iWs.HeapSetFail(RHeap::EDeterministic, allocFailRate); |
|
676 |
|
677 //Create parent 1 |
|
678 err = parent1.Construct(group,++handles); |
|
679 if (err == KErrNone) |
|
680 { |
|
681 parent1.SetExtent(mainRect.iTl, mainRect.Size()); |
|
682 parent1.EnableRedrawStore(ETrue); |
|
683 parent1.Activate(); |
|
684 } |
|
685 } |
|
686 |
|
687 //Create child 1 |
|
688 if (err == KErrNone) |
|
689 { |
|
690 TRect childRect(TPoint (10, 10), TSize (200, 150)); |
|
691 err = child1.Construct(parent1,++handles); |
|
692 if (err == KErrNone) |
|
693 { |
|
694 child1.SetExtent(childRect.iTl, childRect.Size()); |
|
695 child1.SetBackgroundColor(TRgb(128,100,255,20)); |
|
696 child1.Activate(); |
|
697 } |
|
698 } |
|
699 |
|
700 //Add sprite to child 1 |
|
701 if (err == KErrNone) |
|
702 { |
|
703 err = sprite.Construct(child1,TPoint(10,10), 0); |
|
704 if (err == KErrNone) |
|
705 { |
|
706 err = sprite.AppendMember(spritemember); |
|
707 if (err == KErrNone) |
|
708 err = sprite.Activate(); |
|
709 } |
|
710 } |
|
711 |
|
712 //Only delete parent 1, but not child 1 |
|
713 parent1.Close(); |
|
714 |
|
715 if (err == KErrNone) |
|
716 { |
|
717 TRect testRect(TPoint(10, 30), TSize(200, 150)); |
|
718 //Create testWindow |
|
719 err = testWindow.Construct(group,++handles); |
|
720 if (err == KErrNone) |
|
721 { |
|
722 testWindow.SetExtent(testRect.iTl, testRect.Size()); |
|
723 testWindow.SetBackgroundColor(TRgb(128,100,255,20)); |
|
724 testWindow.EnableRedrawStore(ETrue); |
|
725 testWindow.Activate(); |
|
726 testWindow.BeginRedraw(); |
|
727 testWindow.EndRedraw(); |
|
728 TheClient->Flush(); |
|
729 } |
|
730 } |
|
731 TheClient->iWs.HeapSetFail(RAllocator::ENone, 0); |
|
732 |
|
733 sprite.Close(); |
|
734 child1.Close(); |
|
735 testWindow.Close(); |
|
736 group.Close(); |
|
737 ++allocFailRate; |
|
738 loop = (err == KErrNone) ? loop + 1 : 0; |
|
739 } |
|
740 CleanupStack::PopAndDestroy(bitmap); |
|
741 } |
|
742 void CTTSprite::ResizeMemberL() |
|
743 { |
|
744 #ifndef __WINS__ |
|
745 CTBlankWindow* win=new(ELeave) CTBlankWindow(); |
|
746 CleanupStack::PushL(win); |
|
747 win->ConstructL(*TheClient->iGroup); |
|
748 win->SetExt(TPoint(),TSize(640,240)); |
|
749 RWindowBase& window=*win->BaseWin(); |
|
750 window.Activate(); |
|
751 RWsSprite sprite(TheClient->iWs); |
|
752 CleanupClosePushL(sprite); |
|
753 User::LeaveIfError(sprite.Construct(window,TPoint(),0)); |
|
754 TSpriteMember member; |
|
755 member.iMaskBitmap=NULL; |
|
756 member.iInvertMask=EFalse; |
|
757 member.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
758 member.iOffset=TPoint(); |
|
759 member.iInterval=TTimeIntervalMicroSeconds32(250000); |
|
760 member.iBitmap=&iBitmap; |
|
761 User::LeaveIfError(sprite.AppendMember(member)); |
|
762 User::LeaveIfError(sprite.AppendMember(member)); |
|
763 User::LeaveIfError(sprite.Activate()); |
|
764 User::After(1000000); // // Interval is 1 sec. |
|
765 User::LeaveIfError(iBitmap.Resize(iBitmap.SizeInPixels() + TSize(100,100))); |
|
766 User::After(1000000); // Interval is 1 sec. |
|
767 CleanupStack::PopAndDestroy(&sprite); |
|
768 CleanupStack::PopAndDestroy(win); |
|
769 #endif // __WINS__ |
|
770 } |
|
771 |
|
772 |
|
773 void CTTSprite::SetUpSpriteL(RWsSprite &aSprite, RWindowTreeNode &aWindow,TPoint aPoint, TSpriteMember aMember, TInt aFlags/*=0*/) |
|
774 { |
|
775 User::LeaveIfError(aSprite.Construct(aWindow,aPoint,aFlags)); |
|
776 User::LeaveIfError(aSprite.AppendMember(aMember)); |
|
777 User::LeaveIfError(aSprite.Activate()); |
|
778 } |
|
779 /** |
|
780 @SYMTestCaseID GRAPHICS-WSERV-00-0001 |
|
781 |
|
782 @SYMDEF PDEF117721 |
|
783 |
|
784 @SYMTestCaseDesc Test Screenrotation does not cause panic by sprite with NULL bitmap and NULL maskbitmap |
|
785 |
|
786 @SYMTestPriority High |
|
787 |
|
788 @SYMTestStatus Implemented |
|
789 |
|
790 @SYMTestActions Defines two sprites and one with Null iBitmap and Null iMaskBitmap, then rotate the screen to 90 degrees |
|
791 |
|
792 @SYMTestExpectedResults the screen rotation will not cause wserv a panic |
|
793 */ |
|
794 void CTTSprite::RotateNullSpriteL() |
|
795 { |
|
796 if (TheClient->iScreen->NumScreenModes() < 2) |
|
797 { |
|
798 LOG_MESSAGE(_L("WARNING: Unable to rotate screen")); |
|
799 return; |
|
800 } |
|
801 // Sprite Members |
|
802 TSpriteMember spriteMember1,spriteMember2; |
|
803 SetUpMember(spriteMember1); |
|
804 SetUpMember(spriteMember2); |
|
805 spriteMember2.iBitmap = NULL; |
|
806 |
|
807 // Create windows |
|
808 RWindowGroup group(TheClient->iWs); |
|
809 User::LeaveIfError(group.Construct(ENullWsHandle,EFalse)); //Creates a Group Window |
|
810 CleanupClosePushL(group); |
|
811 RBlankWindow win(TheClient->iWs); |
|
812 User::LeaveIfError(win.Construct(group,ENullWsHandle)); //Creates a Blank Window |
|
813 CleanupClosePushL(win); |
|
814 win.SetVisible(ETrue); |
|
815 win.SetColor(TRgb::Gray4(2)); |
|
816 win.Activate(); |
|
817 TheClient->Flush(); |
|
818 |
|
819 // Create Sprites |
|
820 RWsSprite sprite1(TheClient->iWs); |
|
821 CleanupClosePushL(sprite1); |
|
822 SetUpSpriteL(sprite1, win,TPoint(20,70),spriteMember1,0); |
|
823 RWsSprite sprite2(TheClient->iWs); |
|
824 CleanupClosePushL(sprite2); |
|
825 SetUpSpriteL(sprite2, win,TPoint(80,130),spriteMember2,0); |
|
826 RWsSprite sprite3(TheClient->iWs); |
|
827 CleanupClosePushL(sprite3); |
|
828 SetUpSpriteL(sprite3, win,TPoint(2800,2130),spriteMember1,0); |
|
829 TheClient->Flush(); |
|
830 |
|
831 // Get the original screen mode |
|
832 CWsScreenDevice* device = TheClient->iScreen; |
|
833 TInt originalScreenMode = device->CurrentScreenMode(); |
|
834 TPixelsTwipsAndRotation originalModeSettings; |
|
835 device->GetScreenModeSizeAndRotation(originalScreenMode,originalModeSettings); |
|
836 |
|
837 // Rotate screens |
|
838 TPixelsAndRotation pixelsAndRotation; |
|
839 device->SetScreenMode( 1 ); |
|
840 device->GetDefaultScreenSizeAndRotation(pixelsAndRotation); |
|
841 device->SetCurrentRotations(1,pixelsAndRotation.iRotation); |
|
842 device->SetScreenSizeAndRotation(pixelsAndRotation); |
|
843 User::After(1000000); |
|
844 |
|
845 CleanupStack::PopAndDestroy(5,&group); |
|
846 // Restore the original screen mode |
|
847 device->SetScreenMode(originalScreenMode); |
|
848 device->SetCurrentRotations(originalScreenMode,originalModeSettings.iRotation); |
|
849 device->SetScreenSizeAndRotation(originalModeSettings); |
|
850 TheClient->Flush(); |
|
851 } |
|
852 |
|
853 /** |
|
854 @SYMTestCaseID GRAPHICS-WSERV-GCE-0700 |
|
855 |
|
856 @SYMDEF DEF123129 |
|
857 |
|
858 @SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang |
|
859 |
|
860 @SYMTestPriority High |
|
861 |
|
862 @SYMTestStatus Implemented |
|
863 |
|
864 @SYMTestActions Construct a sprite and add a member to it. Activate twice. |
|
865 |
|
866 @SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. |
|
867 */ |
|
868 void CTTSprite::DoubleActivateL() |
|
869 { |
|
870 RWsSession ws; |
|
871 User::LeaveIfError(ws.Connect()); |
|
872 CleanupClosePushL(ws); |
|
873 |
|
874 RWindowGroup group(ws); |
|
875 User::LeaveIfError(group.Construct(890, EFalse)); |
|
876 CleanupClosePushL(group); |
|
877 |
|
878 RWsSprite sprite = RWsSprite(ws); |
|
879 User::LeaveIfError(sprite.Construct(group,TPoint(),0)); |
|
880 CleanupClosePushL(sprite); |
|
881 CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; |
|
882 CleanupStack::PushL(bitmap); |
|
883 User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); |
|
884 TSpriteMember member; |
|
885 member.iMaskBitmap=NULL; |
|
886 member.iInvertMask=EFalse; |
|
887 member.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
888 member.iOffset=TPoint(); |
|
889 member.iInterval=TTimeIntervalMicroSeconds32(0); |
|
890 member.iBitmap=bitmap; |
|
891 User::LeaveIfError(sprite.AppendMember(member)); |
|
892 User::LeaveIfError(sprite.Activate()); |
|
893 User::LeaveIfError(sprite.Activate()); |
|
894 |
|
895 sprite.Close(); |
|
896 CleanupStack::PopAndDestroy(4, &ws); |
|
897 |
|
898 group.Close(); |
|
899 ws.Close(); |
|
900 } |
|
901 |
|
902 void CTTSprite::RunTestCaseL(TInt /*aCurTestCase*/) |
|
903 { |
|
904 _LIT(KTest1, "General Tests"); |
|
905 _LIT(KTest2, "Group Window Sprites Tests"); |
|
906 _LIT(KTest3, "Lots Sprites Tests"); |
|
907 _LIT(KTest4, "General Pointer Cursor Tests"); |
|
908 _LIT(KTest5, "Pointer Cursor Visible Tests"); |
|
909 _LIT(KTest6, "Update member tests"); |
|
910 _LIT(KTest7, "Negative tests for Update member"); |
|
911 _LIT(KTest8, "Window Group with Thread"); |
|
912 _LIT(KTest9, "Resize Sprite Member Tests"); |
|
913 _LIT(KTest10, "Rotate a NULL sprite"); |
|
914 _LIT(KTest11, "Sprite On Window Orphaned Tests"); |
|
915 _LIT(KTest12, "Sprite Double Activation Test"); |
|
916 |
|
917 ((CTTSpriteStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
918 switch(++iTest->iState) |
|
919 { |
|
920 case 1: |
|
921 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0018")); |
|
922 TheClient->iWs.SetFocusScreen(0); |
|
923 iTest->LogSubTest(KTest1); |
|
924 GeneralTestsL(); |
|
925 break; |
|
926 case 2: |
|
927 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0019")); |
|
928 iTest->LogSubTest(KTest2); |
|
929 GroupWindowSpritesL(); |
|
930 break; |
|
931 case 3: |
|
932 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0020")); |
|
933 iTest->LogSubTest(KTest3); |
|
934 LotsSpritesL(); |
|
935 break; |
|
936 case 4: |
|
937 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0021")); |
|
938 iTest->LogSubTest(KTest4); |
|
939 GeneralPointerCursor(); |
|
940 break; |
|
941 case 5: |
|
942 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); |
|
943 iTest->LogSubTest(KTest5); |
|
944 TRAPD(err, PointerCursorVisibleL()); |
|
945 TEST(err == KErrNone); |
|
946 break; |
|
947 case 6: |
|
948 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0053-0001")); |
|
949 iTest->LogSubTest(KTest6); |
|
950 TRAP(err, SpriteUpdateMemberTestsL()); |
|
951 TEST(err == KErrNone); |
|
952 break; |
|
953 case 7: |
|
954 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0054-0001")); |
|
955 iTest->LogSubTest(KTest7); |
|
956 TRAP(err, SpriteUpdateMemberNegTestsL()); |
|
957 TEST(err == KErrNone); |
|
958 break; |
|
959 case 8: |
|
960 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0055-0001")); |
|
961 iTest->LogSubTest(KTest8); |
|
962 TRAP(err, FindWindowGroupThreadTestsL()); |
|
963 TEST(err == KErrNone); |
|
964 break; |
|
965 case 9: |
|
966 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0526")); |
|
967 iTest->LogSubTest(KTest9); |
|
968 ResizeMemberL(); |
|
969 break; |
|
970 case 10: |
|
971 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00-0001")); |
|
972 iTest->LogSubTest(KTest10); |
|
973 RotateNullSpriteL(); |
|
974 break; |
|
975 case 11: |
|
976 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0462")); |
|
977 iTest->LogSubTest(KTest11); |
|
978 SpriteOnWindowOrphanedTestsL(); |
|
979 break; |
|
980 case 12: |
|
981 ((CTTSpriteStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-GCE-0700")); |
|
982 iTest->LogSubTest(KTest12); |
|
983 DoubleActivateL(); |
|
984 break; |
|
985 default: |
|
986 ((CTTSpriteStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
987 ((CTTSpriteStep*)iStep)->CloseTMSGraphicsStep(); |
|
988 TestComplete(); |
|
989 break; |
|
990 } |
|
991 ((CTTSpriteStep*)iStep)->RecordTestResultL(); |
|
992 } |
|
993 |
|
994 //-------------- |
|
995 __WS_CONSTRUCT_STEP__(TSprite) |
|
996 |