|
1 // Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "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 // Out of memory tests |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 |
|
25 #include "TOOM.H" |
|
26 |
|
27 |
|
28 typedef COomFailBase *(*COmmCreate)(CTOom *aTest); |
|
29 |
|
30 COomFailBase *CreateOomConnect(CTOom *aTest) |
|
31 {return(new(ELeave) COomConnect(aTest));} |
|
32 |
|
33 COomFailBase *CreateOomWindow(CTOom *aTest) |
|
34 {return(new(ELeave) COomWindow(aTest));} |
|
35 |
|
36 COomFailBase *CreateOomWindowGroup(CTOom *aTest) |
|
37 {return(new(ELeave) COomWindowGroup(aTest));} |
|
38 |
|
39 COomFailBase *CreateOomBackedUpWindow(CTOom *aTest) |
|
40 {return(new(ELeave) COomBackedUpWindow(aTest));} |
|
41 |
|
42 COomFailBase *CreateOomBackupResize(CTOom *aTest) |
|
43 {return(new(ELeave) COomBackupResize(aTest));} |
|
44 |
|
45 COomFailBase *CreateOomBlankWindow(CTOom *aTest) |
|
46 {return(new(ELeave) COomBlankWindow(aTest));} |
|
47 |
|
48 COomFailBase *CreateOomGc(CTOom *aTest) |
|
49 {return(new(ELeave) COomGc(aTest));} |
|
50 |
|
51 COomFailBase *CreateOomScreenDevice(CTOom *aTest) |
|
52 {return(new(ELeave) COomScreenDevice(aTest));} |
|
53 |
|
54 COomFailBase *CreateOomPointerBuffer(CTOom *aTest) |
|
55 {return(new(ELeave) COomPointerBuffer(aTest));} |
|
56 |
|
57 COomFailBase *CreateOomPolygon(CTOom *aTest) |
|
58 {return(new(ELeave) COomPolygon(aTest));} |
|
59 |
|
60 COomFailBase *CreateOomPriorityKey(CTOom *aTest) |
|
61 {return(new(ELeave) COomPriorityKey(aTest));} |
|
62 |
|
63 COomFailBase *CreateOomCaptureKey(CTOom *aTest) |
|
64 {return(new(ELeave) COomCaptureKey(aTest));} |
|
65 |
|
66 COomFailBase *CreateOomCaptureKeyUpDown(CTOom *aTest) |
|
67 {return(new(ELeave) COomCaptureKeyUpDown(aTest));} |
|
68 |
|
69 COomFailBase *CreateOomLongKeyCapture(CTOom *aTest) |
|
70 {return(new(ELeave) COomLongKeyCapture(aTest));} |
|
71 |
|
72 COomFailBase *CreateOomHotKey(CTOom *aTest) |
|
73 {return(new(ELeave) COomHotKey(aTest));} |
|
74 |
|
75 COomFailBase *CreateOomGroupName(CTOom *aTest) |
|
76 {return(new(ELeave) COomGroupName(aTest));} |
|
77 |
|
78 COomFailBase *CreateOomMessageSend(CTOom *aTest) |
|
79 {return(new(ELeave) COomMessageSend(aTest));} |
|
80 |
|
81 COomFailBase *CreateOomMessageFetch(CTOom *aTest) |
|
82 {return(new(ELeave) COomMessageFetch(aTest));} |
|
83 |
|
84 COomFailBase *CreateOomSprite(CTOom *aTest) |
|
85 {return(new(ELeave) COomSprite(aTest));} |
|
86 |
|
87 COomFailBase *CreateOomPointerCursor(CTOom *aTest) |
|
88 {return(new(ELeave) COomPointerCursor(aTest));} |
|
89 |
|
90 COomFailBase *CreateOomCopyScreen(CTOom *aTest) |
|
91 {return(new(ELeave) COomCopyScreen(aTest));} |
|
92 |
|
93 COomFailBase *CreateOomRequestEvents(CTOom *aTest) |
|
94 {return(new(ELeave) COomRequestEvents(aTest));} |
|
95 |
|
96 COomFailBase *CreateOomCustomTextCursor(CTOom *aTest) |
|
97 {return(new(ELeave) COomCustomTextCursor(aTest));} |
|
98 |
|
99 COomFailBase *CreateOomTranspWindow(CTOom *aTest) |
|
100 {return(new(ELeave) COomTranspWindow(aTest));} |
|
101 |
|
102 COomFailBase *CreateOomObscuredWindow(CTOom *aTest) |
|
103 {return(new(ELeave) COomObscuredWindow(aTest));} |
|
104 |
|
105 COmmCreate CreateOomFailTest[]={ |
|
106 CreateOomConnect, |
|
107 CreateOomWindow, |
|
108 CreateOomWindowGroup, |
|
109 CreateOomBackedUpWindow, |
|
110 CreateOomBackupResize, |
|
111 CreateOomBlankWindow, |
|
112 CreateOomGc, |
|
113 CreateOomScreenDevice, |
|
114 CreateOomPointerBuffer, |
|
115 CreateOomPolygon, |
|
116 CreateOomPriorityKey, |
|
117 CreateOomCaptureKey, |
|
118 CreateOomCaptureKeyUpDown, |
|
119 CreateOomLongKeyCapture, |
|
120 CreateOomHotKey, |
|
121 CreateOomGroupName, |
|
122 CreateOomSprite, |
|
123 CreateOomPointerCursor, |
|
124 CreateOomCopyScreen, |
|
125 CreateOomRequestEvents, |
|
126 CreateOomMessageSend, |
|
127 CreateOomMessageFetch, |
|
128 CreateOomCustomTextCursor, |
|
129 CreateOomTranspWindow, |
|
130 CreateOomObscuredWindow, |
|
131 }; |
|
132 |
|
133 // |
|
134 // Individual out of memory test classes // |
|
135 // |
|
136 |
|
137 COomFailBase::COomFailBase(CTOom *aTest) : iTest(aTest) |
|
138 {} |
|
139 |
|
140 void COomFailBase::ConstructL() |
|
141 { |
|
142 iTest->INFO_PRINTF1(TestName()); |
|
143 } |
|
144 |
|
145 void COomFailBase::PreFail() |
|
146 {} |
|
147 |
|
148 void COomFailBase::ClearUpL() |
|
149 {} |
|
150 |
|
151 void COomFailBase::Flush() |
|
152 { |
|
153 iWs.Flush(); |
|
154 } |
|
155 |
|
156 COomConnect::COomConnect(CTOom *aTest) : COomFailBase(aTest) |
|
157 {} |
|
158 |
|
159 TOomTestName COomConnect::TestName() |
|
160 { |
|
161 return(_L("Connect")); |
|
162 } |
|
163 |
|
164 /** Creates a wserv session, connects and creates CWsScreenDevice object |
|
165 */ |
|
166 TInt COomConnect::Fail() |
|
167 { |
|
168 TInt err = iWs.Connect(); |
|
169 if (err!=KErrNone) |
|
170 return err; |
|
171 |
|
172 TRAP(err, iDummyScreen = new (ELeave) CWsScreenDevice(iWs)); |
|
173 if (err!=KErrNone) |
|
174 { |
|
175 iWs.Close(); |
|
176 return err; |
|
177 } |
|
178 |
|
179 if ((err=iDummyScreen->Construct(iTest->ScreenNumber()))!=KErrNone) |
|
180 { |
|
181 delete iDummyScreen; |
|
182 iDummyScreen = NULL; |
|
183 iWs.Close(); |
|
184 return err; |
|
185 } |
|
186 |
|
187 return err; |
|
188 } |
|
189 |
|
190 void COomConnect::ClearUpL() |
|
191 { |
|
192 if (iDummyScreen) |
|
193 { |
|
194 delete iDummyScreen; |
|
195 iDummyScreen = NULL; |
|
196 } |
|
197 iWs.Close(); |
|
198 } |
|
199 |
|
200 // |
|
201 |
|
202 COomSetup::COomSetup(CTOom *aTest) : COomFailBase(aTest) |
|
203 {} |
|
204 |
|
205 void COomSetup::ConstructL() |
|
206 { |
|
207 COomFailBase::ConstructL(); |
|
208 User::LeaveIfError(iWs.Connect()); |
|
209 iDummyScreen = new (ELeave) CWsScreenDevice(iWs); |
|
210 User::LeaveIfError(iDummyScreen->Construct(iTest->ScreenNumber())); |
|
211 |
|
212 iWinGroup=RWindowGroup(iWs); |
|
213 iWinGroup.Construct(556); |
|
214 iWinGroup.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close |
|
215 } |
|
216 |
|
217 COomSetup::~COomSetup() |
|
218 { |
|
219 iWinGroup.Close(); |
|
220 delete iDummyScreen; |
|
221 iDummyScreen = NULL; |
|
222 |
|
223 iTest->TEST(iWs.ResourceCount()==0); |
|
224 if (iWs.ResourceCount()!=0) |
|
225 iTest->INFO_PRINTF3(_L("iWs.ResourceCount() return value - Expected: %d, Actual: %d"), 0, iWs.ResourceCount()); |
|
226 |
|
227 iWs.Close(); |
|
228 } |
|
229 |
|
230 // |
|
231 |
|
232 COomWindowGroup::COomWindowGroup(CTOom *aTest) : COomSetup(aTest) |
|
233 {} |
|
234 |
|
235 TOomTestName COomWindowGroup::TestName() |
|
236 { |
|
237 return(_L("Window Group")); |
|
238 } |
|
239 |
|
240 /** Creates a RWindowGroup object |
|
241 */ |
|
242 TInt COomWindowGroup::Fail() |
|
243 { |
|
244 iFailWinGroup=RWindowGroup(iWs); |
|
245 return(iFailWinGroup.Construct(987)); |
|
246 } |
|
247 |
|
248 void COomWindowGroup::ClearUpL() |
|
249 { |
|
250 iFailWinGroup.Close(); |
|
251 } |
|
252 |
|
253 // |
|
254 |
|
255 COomWindow::COomWindow(CTOom *aTest) : COomSetup(aTest) |
|
256 {} |
|
257 |
|
258 TOomTestName COomWindow::TestName() |
|
259 { |
|
260 return(_L("Window")); |
|
261 } |
|
262 |
|
263 /** Creates a RWindow object |
|
264 */ |
|
265 TInt COomWindow::Fail() |
|
266 { |
|
267 iFailWin=RWindow(iWs); |
|
268 return(iFailWin.Construct(iWinGroup,11)); |
|
269 } |
|
270 |
|
271 void COomWindow::ClearUpL() |
|
272 { |
|
273 iFailWin.Close(); |
|
274 } |
|
275 |
|
276 // |
|
277 |
|
278 COomBackedUpWindow::COomBackedUpWindow(CTOom *aTest) : COomSetup(aTest) |
|
279 {} |
|
280 |
|
281 TOomTestName COomBackedUpWindow::TestName() |
|
282 { |
|
283 return(_L("Backed up window")); |
|
284 } |
|
285 |
|
286 /** Creates a RBackedUpWindow object |
|
287 */ |
|
288 TInt COomBackedUpWindow::Fail() |
|
289 { |
|
290 iFailWin=RBackedUpWindow(iWs); |
|
291 return(iFailWin.Construct(iWinGroup,EGray16,22)); |
|
292 } |
|
293 |
|
294 void COomBackedUpWindow::ClearUpL() |
|
295 { |
|
296 iFailWin.Close(); |
|
297 } |
|
298 |
|
299 // |
|
300 |
|
301 COomBackupResize::COomBackupResize(CTOom *aTest) : COomSetup(aTest) |
|
302 {} |
|
303 |
|
304 COomBackupResize::~COomBackupResize() |
|
305 { |
|
306 iFailWin.Close(); |
|
307 } |
|
308 |
|
309 TOomTestName COomBackupResize::TestName() |
|
310 { |
|
311 return(_L("Resize backed up window")); |
|
312 } |
|
313 |
|
314 void COomBackupResize::ConstructL() |
|
315 { |
|
316 COomSetup::ConstructL(); |
|
317 iFailWin=RBackedUpWindow(iWs); |
|
318 User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,33)); |
|
319 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); |
|
320 iFailWin.Activate(); |
|
321 } |
|
322 |
|
323 /** Sets the size of previously created backed-up window |
|
324 */ |
|
325 TInt COomBackupResize::Fail() |
|
326 { |
|
327 return(iFailWin.SetSizeErr(TSize(100,100))); |
|
328 } |
|
329 |
|
330 void COomBackupResize::ClearUpL() |
|
331 //Virtual fn declared in CoomFailBase. This is the only one that can leave, I think, but one is enough |
|
332 { |
|
333 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); |
|
334 } |
|
335 |
|
336 // |
|
337 |
|
338 COomBlankWindow::COomBlankWindow(CTOom *aTest) : COomSetup(aTest) |
|
339 {} |
|
340 |
|
341 TOomTestName COomBlankWindow::TestName() |
|
342 { |
|
343 return(_L("Blank window")); |
|
344 } |
|
345 |
|
346 /** Creates a RBlankWindow object |
|
347 */ |
|
348 TInt COomBlankWindow::Fail() |
|
349 { |
|
350 iFailWin=RBlankWindow(iWs); |
|
351 return(iFailWin.Construct(iWinGroup,44)); |
|
352 } |
|
353 |
|
354 void COomBlankWindow::ClearUpL() |
|
355 { |
|
356 iFailWin.Close(); |
|
357 } |
|
358 |
|
359 // |
|
360 |
|
361 COomPointerBuffer::COomPointerBuffer(CTOom *aTest) : COomSetup(aTest) |
|
362 {} |
|
363 |
|
364 COomPointerBuffer::~COomPointerBuffer() |
|
365 { |
|
366 iFailWin.Close(); |
|
367 } |
|
368 |
|
369 TOomTestName COomPointerBuffer::TestName() |
|
370 { |
|
371 return(_L("Pointer buffer")); |
|
372 } |
|
373 |
|
374 void COomPointerBuffer::ConstructL() |
|
375 { |
|
376 COomSetup::ConstructL(); |
|
377 iFailWin=RBackedUpWindow(iWs); |
|
378 User::LeaveIfError(iFailWin.Construct(iWinGroup,EGray16,55)); |
|
379 User::LeaveIfError(iFailWin.SetSizeErr(TSize(10,10))); |
|
380 iFailWin.Activate(); |
|
381 } |
|
382 |
|
383 /** Allocates a buffer for storing pointer movements for previously created backed-up window |
|
384 */ |
|
385 TInt COomPointerBuffer::Fail() |
|
386 { |
|
387 return(iFailWin.AllocPointerMoveBuffer(10,0)); |
|
388 } |
|
389 |
|
390 void COomPointerBuffer::ClearUpL() |
|
391 { |
|
392 iFailWin.FreePointerMoveBuffer(); |
|
393 } |
|
394 |
|
395 // |
|
396 |
|
397 COomPriorityKey::COomPriorityKey(CTOom *aTest) : COomSetup(aTest) |
|
398 {} |
|
399 |
|
400 COomPriorityKey::~COomPriorityKey() |
|
401 { |
|
402 } |
|
403 |
|
404 TOomTestName COomPriorityKey::TestName() |
|
405 { |
|
406 return(_L("Priority key")); |
|
407 } |
|
408 |
|
409 void COomPriorityKey::ConstructL() |
|
410 { |
|
411 COomSetup::ConstructL(); |
|
412 } |
|
413 |
|
414 /** Adds a priority key for a previously created window group |
|
415 */ |
|
416 TInt COomPriorityKey::Fail() |
|
417 { |
|
418 return(iWinGroup.AddPriorityKey(1,0,0)); |
|
419 } |
|
420 |
|
421 void COomPriorityKey::ClearUpL() |
|
422 { |
|
423 iWinGroup.RemovePriorityKey(1,0,0); |
|
424 } |
|
425 |
|
426 // |
|
427 |
|
428 COomCaptureKeyBase::COomCaptureKeyBase(CTOom *aTest) : COomSetup(aTest) |
|
429 {} |
|
430 |
|
431 COomCaptureKeyBase::~COomCaptureKeyBase() |
|
432 {} |
|
433 |
|
434 void COomCaptureKeyBase::ConstructL() |
|
435 { |
|
436 COomSetup::ConstructL(); |
|
437 } |
|
438 |
|
439 COomCaptureKey::COomCaptureKey(CTOom *aTest) : COomCaptureKeyBase(aTest) |
|
440 {} |
|
441 |
|
442 COomCaptureKey::~COomCaptureKey() |
|
443 { |
|
444 } |
|
445 |
|
446 TOomTestName COomCaptureKey::TestName() |
|
447 { |
|
448 return(_L("Capture key")); |
|
449 } |
|
450 |
|
451 /** Requests a capture keys for a previously created window group |
|
452 */ |
|
453 TInt COomCaptureKey::Fail() |
|
454 { |
|
455 for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++) |
|
456 { |
|
457 TInt ret=iWinGroup.CaptureKey('a',0,0); |
|
458 if (ret<0) |
|
459 return(ret); |
|
460 iCapKey[iIndex]=ret; |
|
461 } |
|
462 return(KErrNone); |
|
463 } |
|
464 |
|
465 void COomCaptureKey::ClearUpL() |
|
466 { |
|
467 for (TInt index=0;index<iIndex;index++) |
|
468 iWinGroup.CancelCaptureKey(iCapKey[index]); |
|
469 } |
|
470 |
|
471 // |
|
472 |
|
473 COomCaptureKeyUpDown::COomCaptureKeyUpDown(CTOom *aTest) : COomCaptureKeyBase(aTest) |
|
474 {} |
|
475 |
|
476 COomCaptureKeyUpDown::~COomCaptureKeyUpDown() |
|
477 { |
|
478 } |
|
479 |
|
480 TOomTestName COomCaptureKeyUpDown::TestName() |
|
481 { |
|
482 return(_L("Capture up/down keys")); |
|
483 } |
|
484 |
|
485 /** Requests the capture of key-up and key-down events for a previously created window group |
|
486 */ |
|
487 TInt COomCaptureKeyUpDown::Fail() |
|
488 { |
|
489 for (iIndex=0;iIndex<(TInt)(sizeof(iCapKey)/sizeof(iCapKey[0]));iIndex++) |
|
490 { |
|
491 TInt ret=iWinGroup.CaptureKeyUpAndDowns('a',0,0); |
|
492 if (ret<0) |
|
493 return(ret); |
|
494 iCapKey[iIndex]=ret; |
|
495 } |
|
496 return(KErrNone); |
|
497 } |
|
498 |
|
499 void COomCaptureKeyUpDown::ClearUpL() |
|
500 { |
|
501 for (TInt index=0;index<iIndex;index++) |
|
502 iWinGroup.CancelCaptureKeyUpAndDowns(iCapKey[index]); |
|
503 } |
|
504 |
|
505 // |
|
506 |
|
507 COomLongKeyCapture::COomLongKeyCapture(CTOom *aTest) : COomCaptureKeyBase(aTest) |
|
508 {} |
|
509 |
|
510 COomLongKeyCapture::~COomLongKeyCapture() |
|
511 { |
|
512 } |
|
513 |
|
514 TOomTestName COomLongKeyCapture::TestName() |
|
515 { |
|
516 _LIT(KLongKeyCapTestName, "Long key capture"); |
|
517 return KLongKeyCapTestName(); |
|
518 } |
|
519 |
|
520 /** |
|
521 Requests capture of long key events for a previously created window group |
|
522 */ |
|
523 TInt COomLongKeyCapture::Fail() |
|
524 { |
|
525 for (iIndex=0; iIndex < KNumCapKeyRequest; iIndex++) |
|
526 { |
|
527 TInt ret=iWinGroup.CaptureLongKey(' ','a',0,0,2,ELongCaptureNormal); |
|
528 if (ret<0) |
|
529 return(ret); |
|
530 iCapKey[iIndex]=ret; |
|
531 } |
|
532 return(KErrNone); |
|
533 } |
|
534 |
|
535 void COomLongKeyCapture::ClearUpL() |
|
536 { |
|
537 for (TInt index=0;index<iIndex;index++) |
|
538 iWinGroup.CancelCaptureLongKey(iCapKey[index]); |
|
539 } |
|
540 |
|
541 // |
|
542 |
|
543 COomHotKey::COomHotKey(CTOom *aTest) : COomSetup(aTest) |
|
544 {} |
|
545 |
|
546 COomHotKey::~COomHotKey() |
|
547 { |
|
548 } |
|
549 |
|
550 TOomTestName COomHotKey::TestName() |
|
551 { |
|
552 return(_L("hot keys")); |
|
553 } |
|
554 |
|
555 void COomHotKey::ConstructL() |
|
556 { |
|
557 COomSetup::ConstructL(); |
|
558 } |
|
559 |
|
560 /** Sets hot key for the session. |
|
561 */ |
|
562 TInt COomHotKey::Fail() |
|
563 { |
|
564 return(iWs.SetHotKey(EHotKeyEnableLogging,'a',0,0)); |
|
565 } |
|
566 |
|
567 void COomHotKey::ClearUpL() |
|
568 { |
|
569 iWs.RestoreDefaultHotKey(EHotKeyEnableLogging); |
|
570 } |
|
571 |
|
572 // |
|
573 |
|
574 COomGroupName::COomGroupName(CTOom *aTest) : COomSetup(aTest) |
|
575 {} |
|
576 |
|
577 COomGroupName::~COomGroupName() |
|
578 { |
|
579 } |
|
580 |
|
581 TOomTestName COomGroupName::TestName() |
|
582 { |
|
583 return(_L("Group name")); |
|
584 } |
|
585 |
|
586 void COomGroupName::ConstructL() |
|
587 { |
|
588 COomSetup::ConstructL(); |
|
589 } |
|
590 |
|
591 /** Sets the window group's name. |
|
592 */ |
|
593 TInt COomGroupName::Fail() |
|
594 { |
|
595 return(iWinGroup.SetName(_L("A Name"))); |
|
596 } |
|
597 |
|
598 void COomGroupName::ClearUpL() |
|
599 { |
|
600 iWinGroup.SetName(_L("")); |
|
601 } |
|
602 |
|
603 // |
|
604 |
|
605 COomMessageSend::COomMessageSend(CTOom *aTest) : COomSetup(aTest) |
|
606 {} |
|
607 |
|
608 COomMessageSend::~COomMessageSend() |
|
609 { |
|
610 } |
|
611 |
|
612 TOomTestName COomMessageSend::TestName() |
|
613 { |
|
614 return(_L("MessageSend")); |
|
615 } |
|
616 |
|
617 void COomMessageSend::ConstructL() |
|
618 { |
|
619 COomSetup::ConstructL(); |
|
620 } |
|
621 |
|
622 void COomMessageSend::PreFail() |
|
623 { |
|
624 iWinGroup2=RWindowGroup(iWs); |
|
625 iWinGroup2.Construct(557); |
|
626 iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close |
|
627 } |
|
628 |
|
629 /** Sends a message to another window group |
|
630 */ |
|
631 TInt COomMessageSend::Fail() |
|
632 { |
|
633 TBuf8<0x20> params(_L8("SomeParams")); |
|
634 return(iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(123),params)); |
|
635 } |
|
636 |
|
637 void COomMessageSend::ClearUpL() |
|
638 { |
|
639 iWinGroup2.Close(); |
|
640 } |
|
641 |
|
642 // |
|
643 |
|
644 COomMessageFetch::COomMessageFetch(CTOom *aTest) : COomSetup(aTest) |
|
645 {} |
|
646 |
|
647 COomMessageFetch::~COomMessageFetch() |
|
648 { |
|
649 } |
|
650 |
|
651 TOomTestName COomMessageFetch::TestName() |
|
652 { |
|
653 return(_L("MessageFetch")); |
|
654 } |
|
655 |
|
656 void COomMessageFetch::ConstructL() |
|
657 { |
|
658 COomSetup::ConstructL(); |
|
659 } |
|
660 |
|
661 #define CLIENT_HANDLE 555 |
|
662 #define UID_VALUE 123 |
|
663 #define MESSAGE_LEN 0x20 |
|
664 void COomMessageFetch::PreFail() |
|
665 { |
|
666 iWinGroup2=RWindowGroup(iWs); |
|
667 iWinGroup2.Construct(CLIENT_HANDLE); |
|
668 iWinGroup2.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close |
|
669 TBuf8<MESSAGE_LEN> params(_L8("SomeParams")); |
|
670 TBool retVal = iWs.SendMessageToWindowGroup(iWinGroup2.Identifier(),TUid::Uid(UID_VALUE),params); |
|
671 iTest->TEST(retVal==KErrNone); |
|
672 if (retVal!=KErrNone) |
|
673 iTest->INFO_PRINTF3(_L("iWs.SendMessageToWindowGroup() return value - Expected: %d, Actual: %d"), KErrNone, retVal); |
|
674 } |
|
675 |
|
676 /** Fetches a message |
|
677 */ |
|
678 TInt COomMessageFetch::Fail() |
|
679 { |
|
680 TWsEvent event; |
|
681 TPtr8 ptr(NULL,0); |
|
682 TUid uid; |
|
683 event.SetType(EEventMessageReady); |
|
684 event.SetHandle(CLIENT_HANDLE); |
|
685 event.SetTimeNow(); |
|
686 SEventMessageReady& eventMessageReady=*(SEventMessageReady*)event.EventData(); |
|
687 eventMessageReady.iWindowGroupIdentifier=iWinGroup2.Identifier(); |
|
688 eventMessageReady.iMessageUid=TUid::Uid(UID_VALUE); |
|
689 eventMessageReady.iMessageParametersSize=MESSAGE_LEN; |
|
690 TInt ret=TheClient->iWs.FetchMessage(uid,ptr,event); |
|
691 if (ret==KErrNone) |
|
692 User::Free((TAny *)ptr.Ptr()); |
|
693 return(ret); |
|
694 } |
|
695 |
|
696 void COomMessageFetch::ClearUpL() |
|
697 { |
|
698 iWinGroup2.Close(); |
|
699 } |
|
700 |
|
701 // |
|
702 |
|
703 COomRequestEvents::COomRequestEvents(CTOom *aTest) : COomSetup(aTest) |
|
704 {} |
|
705 |
|
706 COomRequestEvents::~COomRequestEvents() |
|
707 { |
|
708 } |
|
709 |
|
710 TOomTestName COomRequestEvents::TestName() |
|
711 { |
|
712 return(_L("Request events")); |
|
713 } |
|
714 |
|
715 void COomRequestEvents::ConstructL() |
|
716 { |
|
717 COomSetup::ConstructL(); |
|
718 } |
|
719 |
|
720 /** Enables window group change events and modifier change events |
|
721 */ |
|
722 TInt COomRequestEvents::Fail() |
|
723 { |
|
724 TInt err; |
|
725 if ((err=iWinGroup.EnableOnEvents())==KErrNone) |
|
726 if ((err=iWinGroup.EnableGroupChangeEvents())==KErrNone) |
|
727 err=iWinGroup.EnableModifierChangedEvents(EModifierCapsLock,EEventControlAlways); |
|
728 return(err); |
|
729 } |
|
730 |
|
731 void COomRequestEvents::ClearUpL() |
|
732 { |
|
733 iWinGroup.DisableOnEvents(); |
|
734 iWinGroup.DisableGroupChangeEvents(); |
|
735 iWinGroup.DisableModifierChangedEvents(); |
|
736 } |
|
737 |
|
738 // |
|
739 |
|
740 COomCopyScreen::COomCopyScreen(CTOom *aTest) : COomSetup(aTest) |
|
741 {} |
|
742 |
|
743 TOomTestName COomCopyScreen::TestName() |
|
744 { |
|
745 return(_L("Copy screen")); |
|
746 } |
|
747 |
|
748 COomCopyScreen::~COomCopyScreen() |
|
749 { |
|
750 delete iScrDev; |
|
751 delete iBitmap; |
|
752 } |
|
753 |
|
754 void COomCopyScreen::ConstructL() |
|
755 { |
|
756 COomSetup::ConstructL(); |
|
757 iScrDev=new(ELeave) CWsScreenDevice(iWs); |
|
758 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); |
|
759 iBitmap=new(ELeave) CFbsBitmap(); |
|
760 User::LeaveIfError(iBitmap->Create(TSize(100,100),EGray4)); |
|
761 } |
|
762 |
|
763 /** Copies screen to bitmap |
|
764 */ |
|
765 TInt COomCopyScreen::Fail() |
|
766 { |
|
767 TInt ret=iScrDev->CopyScreenToBitmap(iBitmap); |
|
768 if (ret==KErrNone) |
|
769 ret=iScrDev->CopyScreenToBitmap(iBitmap,TRect(10,10,50,50)); |
|
770 return(ret); |
|
771 } |
|
772 |
|
773 void COomCopyScreen::ClearUpL() |
|
774 { |
|
775 } |
|
776 |
|
777 // |
|
778 |
|
779 COomSpriteBase::COomSpriteBase(CTOom *aTest) : COomSetup(aTest) |
|
780 {} |
|
781 |
|
782 COomSpriteBase::~COomSpriteBase() |
|
783 { |
|
784 iWin.Close(); |
|
785 delete iBitmap; |
|
786 delete iMask; |
|
787 delete iBitmap2; |
|
788 delete iMask2; |
|
789 } |
|
790 |
|
791 void COomSpriteBase::ConstructL() |
|
792 { |
|
793 COomSetup::ConstructL(); |
|
794 iWin=RWindow(iWs); |
|
795 User::LeaveIfError(iWin.Construct(iWinGroup,33)); |
|
796 User::LeaveIfError(iWin.SetSizeErr(TSize(100,100))); |
|
797 iWin.Activate(); |
|
798 iBitmap=new(ELeave) CFbsBitmap(); |
|
799 User::LeaveIfError(iBitmap->Create(TSize(10,10),EGray4)); |
|
800 iBitmap2=new(ELeave) CFbsBitmap(); |
|
801 User::LeaveIfError(iBitmap2->Create(TSize(40,40),EGray4)); |
|
802 iMask=new(ELeave) CFbsBitmap(); |
|
803 User::LeaveIfError(iMask->Create(TSize(10,10),EGray4)); |
|
804 iMask2=new(ELeave) CFbsBitmap(); |
|
805 User::LeaveIfError(iMask2->Create(TSize(40,40),EGray4)); |
|
806 } |
|
807 |
|
808 // |
|
809 |
|
810 COomSprite::COomSprite(CTOom *aTest) : COomSpriteBase(aTest) |
|
811 {} |
|
812 |
|
813 TOomTestName COomSprite::TestName() |
|
814 { |
|
815 return(_L("Sprites")); |
|
816 } |
|
817 |
|
818 /** Creates a sprite. |
|
819 */ |
|
820 TInt COomSprite::Fail() |
|
821 { |
|
822 iSprite=RWsSprite(iWs); |
|
823 TInt err=iSprite.Construct(iWin,TPoint(10,10),0); |
|
824 if (err==KErrNone) |
|
825 { |
|
826 TSpriteMember sprite; |
|
827 sprite.iBitmap=iBitmap; |
|
828 sprite.iMaskBitmap=iMask; |
|
829 sprite.iInvertMask=EFalse; |
|
830 sprite.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
831 sprite.iOffset=TPoint(0,0); |
|
832 sprite.iInterval=TTimeIntervalMicroSeconds32(100000); |
|
833 if ((err=iSprite.AppendMember(sprite))==KErrNone) |
|
834 if ((err=iSprite.Activate())==KErrNone) |
|
835 { |
|
836 sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap |
|
837 sprite.iMaskBitmap=iMask2; |
|
838 if ((err=iSprite.AppendMember(sprite))==KErrNone) |
|
839 err=iSprite.UpdateMember(1,sprite); |
|
840 } |
|
841 } |
|
842 return(err); |
|
843 } |
|
844 |
|
845 void COomSprite::ClearUpL() |
|
846 { |
|
847 iSprite.Close(); |
|
848 } |
|
849 |
|
850 // |
|
851 |
|
852 COomPointerCursor::COomPointerCursor(CTOom *aTest) : COomSpriteBase(aTest) |
|
853 {} |
|
854 |
|
855 TOomTestName COomPointerCursor::TestName() |
|
856 { |
|
857 return(_L("Pointer cursor")); |
|
858 } |
|
859 |
|
860 /** Creates a pointer cursor. |
|
861 */ |
|
862 TInt COomPointerCursor::Fail() |
|
863 { |
|
864 iPointerCursor=RWsPointerCursor(iWs); |
|
865 TInt err=iPointerCursor.Construct(0); |
|
866 if (err==KErrNone) |
|
867 { |
|
868 TSpriteMember sprite; |
|
869 sprite.iBitmap=iBitmap; |
|
870 sprite.iMaskBitmap=iMask; |
|
871 sprite.iInvertMask=EFalse; |
|
872 sprite.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
873 sprite.iOffset=TPoint(0,0); |
|
874 sprite.iInterval=TTimeIntervalMicroSeconds32(100000); |
|
875 if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) |
|
876 if ((err=iPointerCursor.Activate())==KErrNone) |
|
877 { |
|
878 sprite.iBitmap=iBitmap2; // Bigger bitmap to force resize of bitmap |
|
879 sprite.iMaskBitmap=iMask2; |
|
880 if ((err=iPointerCursor.AppendMember(sprite))==KErrNone) |
|
881 err=iPointerCursor.UpdateMember(1,sprite); |
|
882 } |
|
883 } |
|
884 return(err); |
|
885 } |
|
886 |
|
887 void COomPointerCursor::ClearUpL() |
|
888 { |
|
889 iPointerCursor.Close(); |
|
890 } |
|
891 |
|
892 // |
|
893 |
|
894 COomGc::COomGc(CTOom *aTest) : COomSetup(aTest) |
|
895 {} |
|
896 |
|
897 COomGc::~COomGc() |
|
898 { |
|
899 delete iScrDev; |
|
900 } |
|
901 |
|
902 TOomTestName COomGc::TestName() |
|
903 { |
|
904 return(_L("Graphic Context")); |
|
905 } |
|
906 |
|
907 void COomGc::ConstructL() |
|
908 { |
|
909 COomSetup::ConstructL(); |
|
910 iScrDev=new(ELeave) CWsScreenDevice(iWs); |
|
911 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); |
|
912 } |
|
913 |
|
914 /** Creates a graphical context for a previously created screen device. |
|
915 */ |
|
916 TInt COomGc::Fail() |
|
917 { |
|
918 TRAPD(err,iFailGc=new(ELeave) CWindowGc(iScrDev)); |
|
919 if (err!=KErrNone) |
|
920 return(err); |
|
921 return(iFailGc->Construct()); |
|
922 } |
|
923 |
|
924 void COomGc::ClearUpL() |
|
925 { |
|
926 delete iFailGc; |
|
927 iFailGc=NULL; |
|
928 } |
|
929 |
|
930 // |
|
931 |
|
932 COomPolygon::COomPolygon(CTOom *aTest) : COomSetup(aTest), iPnts(5) |
|
933 {} |
|
934 |
|
935 COomPolygon::~COomPolygon() |
|
936 { |
|
937 delete iGc; |
|
938 delete iScrDev; |
|
939 iWin.Close(); |
|
940 } |
|
941 |
|
942 TOomTestName COomPolygon::TestName() |
|
943 { |
|
944 return(_L("Polygon")); |
|
945 } |
|
946 |
|
947 void COomPolygon::ConstructL() |
|
948 { |
|
949 COomSetup::ConstructL(); |
|
950 iScrDev=new(ELeave) CWsScreenDevice(iWs); |
|
951 User::LeaveIfError(iScrDev->Construct(iTest->ScreenNumber())); |
|
952 User::LeaveIfError(iScrDev->CreateContext(iGc)); |
|
953 iWin=RBackedUpWindow(iWs); |
|
954 User::LeaveIfError(iWin.Construct(iWinGroup,EGray16,33)); |
|
955 User::LeaveIfError(iWin.SetSizeErr(TSize(40,40))); |
|
956 iWin.Activate(); |
|
957 TInt index; |
|
958 for(index=0;index<20;index+=2) |
|
959 iPnts.AppendL(TPoint(20+index,index)); |
|
960 for(index=0;index<20;index+=2) |
|
961 iPnts.AppendL(TPoint(40-index,20+index)); |
|
962 for(index=0;index<20;index+=2) |
|
963 iPnts.AppendL(TPoint(20-index,40-index)); |
|
964 for(index=0;index<20;index+=2) |
|
965 iPnts.AppendL(TPoint(index,20-index)); |
|
966 } |
|
967 |
|
968 /** Draws a polygon. |
|
969 */ |
|
970 TInt COomPolygon::Fail() |
|
971 { |
|
972 iGc->Activate(iWin); |
|
973 iGc->Clear(); |
|
974 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
975 iGc->SetBrushColor(TRgb::Gray4(2)); |
|
976 iGc->SetPenColor(TRgb::Gray4(0)); |
|
977 TInt err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EAlternate); |
|
978 if (err!=KErrNone) |
|
979 return(err); |
|
980 err=iGc->DrawPolygon(&iPnts,CGraphicsContext::EWinding); |
|
981 if (err!=KErrNone) |
|
982 return(err); |
|
983 return(KErrNone); |
|
984 } |
|
985 |
|
986 void COomPolygon::ClearUpL() |
|
987 { |
|
988 iGc->Deactivate(); |
|
989 } |
|
990 |
|
991 // |
|
992 |
|
993 COomScreenDevice::COomScreenDevice(CTOom *aTest) : COomSetup(aTest) |
|
994 {} |
|
995 |
|
996 TOomTestName COomScreenDevice::TestName() |
|
997 { |
|
998 return(_L("Screen device")); |
|
999 } |
|
1000 |
|
1001 /** Creates a screen device handle. |
|
1002 */ |
|
1003 TInt COomScreenDevice::Fail() |
|
1004 { |
|
1005 TRAPD(err,iScrDev=new(ELeave) CWsScreenDevice(iWs)); |
|
1006 if (err!=KErrNone) |
|
1007 return(err); |
|
1008 return(iScrDev->Construct(iTest->ScreenNumber())); |
|
1009 } |
|
1010 |
|
1011 void COomScreenDevice::ClearUpL() |
|
1012 { |
|
1013 delete iScrDev; |
|
1014 iScrDev=NULL; |
|
1015 } |
|
1016 |
|
1017 // |
|
1018 |
|
1019 COomCustomTextCursor::COomCustomTextCursor(CTOom *aTest) : COomSetup(aTest) |
|
1020 {} |
|
1021 |
|
1022 COomCustomTextCursor::~COomCustomTextCursor() |
|
1023 { |
|
1024 delete iMemberArray; |
|
1025 delete iBitmap; |
|
1026 } |
|
1027 |
|
1028 TOomTestName COomCustomTextCursor::TestName() |
|
1029 { |
|
1030 return(_L("Custom Text Cursor")); |
|
1031 } |
|
1032 |
|
1033 void COomCustomTextCursor::ConstructL() |
|
1034 { |
|
1035 COomSetup::ConstructL(); |
|
1036 |
|
1037 iBitmap = new(ELeave) CFbsBitmap; |
|
1038 User::LeaveIfError(iBitmap->Load(TEST_BITMAP_NAME, EMbmWsautotestBmp1)); |
|
1039 |
|
1040 TSpriteMember member; |
|
1041 member.iMaskBitmap=NULL; |
|
1042 member.iInvertMask=EFalse; |
|
1043 member.iDrawMode=CGraphicsContext::EDrawModePEN; |
|
1044 member.iOffset=TPoint(); |
|
1045 member.iInterval=TTimeIntervalMicroSeconds32(0); |
|
1046 member.iBitmap = iBitmap; |
|
1047 |
|
1048 iMemberArray = new(ELeave) CArrayFixFlat<TSpriteMember>(1); |
|
1049 iMemberArray->AppendL(member); |
|
1050 } |
|
1051 |
|
1052 /** Adds a custom text cursor to the server's list of cursors. |
|
1053 */ |
|
1054 TInt COomCustomTextCursor::Fail() |
|
1055 { |
|
1056 TInt err = TheClient->iWs.SetCustomTextCursor(0x98765432, iMemberArray->Array(), 0, RWsSession::ECustomTextCursorAlignTop); |
|
1057 if (err == KErrAlreadyExists) |
|
1058 return KErrNone; |
|
1059 else |
|
1060 return err; |
|
1061 } |
|
1062 |
|
1063 void COomCustomTextCursor::ClearUpL() |
|
1064 { |
|
1065 } |
|
1066 |
|
1067 COomTranspWindow::COomTranspWindow(CTOom *aTest) : COomSetup(aTest) |
|
1068 {} |
|
1069 |
|
1070 COomTranspWindow::~COomTranspWindow() |
|
1071 { |
|
1072 delete iBackgroundWin; |
|
1073 delete iFirst; |
|
1074 delete iSecond; |
|
1075 |
|
1076 delete iFbsBitmap; |
|
1077 delete iWsBitmap; |
|
1078 delete iFbsBitmapDevice; |
|
1079 delete iFbsBitmapGc; |
|
1080 delete iWsBitmapDevice; |
|
1081 delete iWsBitmapGc; |
|
1082 } |
|
1083 |
|
1084 TOomTestName COomTranspWindow::TestName() |
|
1085 { |
|
1086 return(_L("Transparent Window")); |
|
1087 } |
|
1088 |
|
1089 void COomTranspWindow::ConstructL() |
|
1090 { |
|
1091 COomSetup::ConstructL(); |
|
1092 |
|
1093 iTransparencyEnabled = (TransparencySupportedL() == KErrNone); |
|
1094 if(!iTransparencyEnabled) |
|
1095 return; |
|
1096 |
|
1097 iFbsBitmap = new (ELeave) CFbsBitmap; |
|
1098 |
|
1099 // Do the creation |
|
1100 const TSize KSizeForBitmap(10,10); |
|
1101 iFbsBitmap->Create(KSizeForBitmap,EGray256); |
|
1102 |
|
1103 // Fill the bitmap with a colour |
|
1104 iFbsBitmapDevice=CFbsBitmapDevice::NewL(iFbsBitmap); |
|
1105 |
|
1106 iFbsBitmapDevice->CreateContext(iFbsBitmapGc); |
|
1107 |
|
1108 iFbsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1109 iFbsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1110 iFbsBitmapGc->SetBrushColor(128); |
|
1111 iFbsBitmapGc->DrawRect(TRect(KSizeForBitmap)); |
|
1112 |
|
1113 // Create a CWsBitmap, and fill it with a colour |
|
1114 iWsBitmap = new (ELeave) CWsBitmap(TheClient->iWs); |
|
1115 |
|
1116 // Do the creation |
|
1117 iWsBitmap->Create(KSizeForBitmap,EGray256); |
|
1118 |
|
1119 // Fill the bitmap with a colour |
|
1120 iWsBitmapDevice=CFbsBitmapDevice::NewL(iWsBitmap); |
|
1121 |
|
1122 iWsBitmapDevice->CreateContext(iWsBitmapGc); |
|
1123 iWsBitmapGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1124 iWsBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1125 iWsBitmapGc->SetBrushColor(128); |
|
1126 iWsBitmapGc->DrawRect(TRect(KSizeForBitmap)); |
|
1127 } |
|
1128 |
|
1129 |
|
1130 /** Does nothing if transparency is not enabled. Creates a blank window with |
|
1131 * two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap |
|
1132 * or a CWsBitmap, and changing from one to the other. |
|
1133 * Changes child-windows' sizes and toggles their visibility. |
|
1134 */ |
|
1135 TInt COomTranspWindow::Fail() |
|
1136 { |
|
1137 if(!iTransparencyEnabled) |
|
1138 return KErrNone; |
|
1139 TSize scrSize(TheClient->iScreen->SizeInPixels()); |
|
1140 TRAPD(res, iBackgroundWin = new (ELeave) CBlankWindow(TRgb(0,0,238))); |
|
1141 if(res != KErrNone) |
|
1142 { |
|
1143 return res; |
|
1144 } |
|
1145 |
|
1146 TDisplayMode mode=EColor256; |
|
1147 TRAP(res, iBackgroundWin->SetUpL(TPoint(50,50),scrSize-TSize(100,100),TheClient->iGroup,*TheClient->iGc,&mode)); |
|
1148 if(res != KErrNone) |
|
1149 { |
|
1150 return res; |
|
1151 } |
|
1152 |
|
1153 TheClient->Flush(); |
|
1154 TheClient->WaitForRedrawsToFinish(); |
|
1155 |
|
1156 iBackgroundWin->Win()->SetBackgroundColor(TRgb(51,204,51)); |
|
1157 iBackgroundWin->Invalidate(); |
|
1158 |
|
1159 TheClient->Flush(); |
|
1160 TheClient->WaitForRedrawsToFinish(); |
|
1161 |
|
1162 TRect thePos1(20, 20, 60, 60); |
|
1163 TRect thePos2(100, 40, 160, 80); |
|
1164 TRAP(res, iFirst = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); |
|
1165 if(res != KErrNone) |
|
1166 { |
|
1167 return res; |
|
1168 } |
|
1169 |
|
1170 TRAP(res, iSecond = CTransWindow::NewL(iBackgroundWin, TRgb(255,0,0,128),&mode)); |
|
1171 if(res != KErrNone) |
|
1172 { |
|
1173 return res; |
|
1174 } |
|
1175 |
|
1176 TRAP(res, iFirst->SetExtL(thePos1.iTl,thePos1.Size())); |
|
1177 if(res != KErrNone) |
|
1178 { |
|
1179 return res; |
|
1180 } |
|
1181 |
|
1182 TRAP(res, iSecond->SetExtL(thePos2.iTl,thePos2.Size())); |
|
1183 if(res != KErrNone) |
|
1184 { |
|
1185 return res; |
|
1186 } |
|
1187 |
|
1188 res=SetTransparencyTesting(); |
|
1189 if(res != KErrNone) |
|
1190 { |
|
1191 return res; |
|
1192 } |
|
1193 |
|
1194 TheClient->Flush(); |
|
1195 //TheClient->WaitForRedrawsToFinish(); |
|
1196 |
|
1197 iFirst->Activate(); |
|
1198 iFirst->AssignGC(*TheClient->iGc); |
|
1199 |
|
1200 iSecond->Activate(); |
|
1201 iSecond->AssignGC(*TheClient->iGc); |
|
1202 |
|
1203 iFirst->Win()->SetBackgroundColor(TRgb(0, 0, 255)); |
|
1204 iSecond->Win()->SetBackgroundColor(TRgb(0, 0, 255)); |
|
1205 iFirst->Invalidate(); |
|
1206 iSecond->Invalidate(); |
|
1207 |
|
1208 iFirst->AdjustSize(150,10, 0); |
|
1209 iSecond->AdjustSize(150,10, 0); |
|
1210 |
|
1211 TheClient->Flush(); |
|
1212 TheClient->WaitForRedrawsToFinish(); |
|
1213 |
|
1214 iFirst->ToggleVisibility(); |
|
1215 iSecond->ToggleVisibility(); |
|
1216 |
|
1217 TheClient->Flush(); |
|
1218 TheClient->WaitForRedrawsToFinish(); |
|
1219 |
|
1220 iFirst->AdjustSize(200,10, 0); |
|
1221 iSecond->AdjustSize(200,10, 0); |
|
1222 |
|
1223 iFirst->ToggleVisibility(); |
|
1224 iSecond->ToggleVisibility(); |
|
1225 |
|
1226 TheClient->Flush(); |
|
1227 TheClient->WaitForRedrawsToFinish(); |
|
1228 |
|
1229 return KErrNone; |
|
1230 } |
|
1231 |
|
1232 |
|
1233 // This function tests setting the transparency via a factor, CFbsBitmap |
|
1234 // or a CWsBitmap, and changing from one to the other. |
|
1235 TInt COomTranspWindow::SetTransparencyTesting() |
|
1236 { |
|
1237 TInt res; |
|
1238 TLogMessageText buf; |
|
1239 |
|
1240 // Need all nine transitions, from the 3 ways to the same 3 ways. |
|
1241 // The ways are Factor, CWsBitmap, CFbsBitmap |
|
1242 const TRgb KTransparencyFactor(128,128,128); |
|
1243 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); |
|
1244 if (res!=KErrNone) |
|
1245 { |
|
1246 buf=_L("test failure!! with SetTransparencyFactor -1"); |
|
1247 TheClient->LogMessage(buf); |
|
1248 return res; |
|
1249 } |
|
1250 |
|
1251 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); |
|
1252 if (res!=KErrNone) |
|
1253 { |
|
1254 buf=_L("test failure!! with SetTransparencyBitmap - fbs -2"); |
|
1255 TheClient->LogMessage(buf); |
|
1256 return res; |
|
1257 } |
|
1258 |
|
1259 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); |
|
1260 if (res!=KErrNone) |
|
1261 { |
|
1262 buf=_L("test failure!! with SetTransparencyBitmap - Ws -3"); |
|
1263 TheClient->LogMessage(buf); |
|
1264 return res; |
|
1265 } |
|
1266 |
|
1267 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); |
|
1268 if (res!=KErrNone) |
|
1269 { |
|
1270 buf=_L("test failure!! with SetTransparencyBitmap - fbs -4"); |
|
1271 TheClient->LogMessage(buf); |
|
1272 return res; |
|
1273 } |
|
1274 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); |
|
1275 if (res!=KErrNone) |
|
1276 { |
|
1277 buf=_L("test failure!! with SetTransparencyBitmap - Ws -5"); |
|
1278 TheClient->LogMessage(buf); |
|
1279 return res; |
|
1280 } |
|
1281 res=iFirst->Win()->SetTransparencyWsBitmap(*iWsBitmap); |
|
1282 if (res!=KErrNone) |
|
1283 { |
|
1284 buf=_L("test failure!! with SetTransparencyBitmap - Ws -6"); |
|
1285 TheClient->LogMessage(buf); |
|
1286 return res; |
|
1287 } |
|
1288 |
|
1289 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); |
|
1290 if (res!=KErrNone) |
|
1291 { |
|
1292 buf=_L("test failure!! with SetTransparencyBitmap - fbs -7"); |
|
1293 TheClient->LogMessage(buf); |
|
1294 return res; |
|
1295 } |
|
1296 |
|
1297 res=iFirst->Win()->SetTransparencyBitmap(*iFbsBitmap); |
|
1298 if (res!=KErrNone) |
|
1299 { |
|
1300 buf=_L("test failure!! with SetTransparencyBitmap - fbs -8"); |
|
1301 TheClient->LogMessage(buf); |
|
1302 return res; |
|
1303 } |
|
1304 |
|
1305 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); |
|
1306 if (res!=KErrNone) |
|
1307 { |
|
1308 buf=_L("test failure!! with SetTransparencyFactor -9"); |
|
1309 TheClient->LogMessage(buf); |
|
1310 return res; |
|
1311 } |
|
1312 |
|
1313 res=iFirst->Win()->SetTransparencyFactor(KTransparencyFactor); |
|
1314 if (res!=KErrNone) |
|
1315 { |
|
1316 buf=_L("test failure!! with SetTransparencyFactor -10"); |
|
1317 TheClient->LogMessage(buf); |
|
1318 return res; |
|
1319 } |
|
1320 |
|
1321 return res; |
|
1322 } |
|
1323 |
|
1324 void COomTranspWindow::ClearUpL() |
|
1325 { |
|
1326 delete iFirst; |
|
1327 iFirst = NULL; |
|
1328 delete iSecond; |
|
1329 iSecond = NULL; |
|
1330 delete iBackgroundWin; |
|
1331 iBackgroundWin = NULL; |
|
1332 } |
|
1333 |
|
1334 // |
|
1335 |
|
1336 CWindowWithOneLine* CWindowWithOneLine::NewL(CTWinBase& aParent, const TRect& aExtent) |
|
1337 { |
|
1338 CWindowWithOneLine* self = new(ELeave) CWindowWithOneLine; |
|
1339 CleanupStack::PushL(self); |
|
1340 self->ConstructL(aParent); |
|
1341 const TSize screenSize(TheClient->iScreen->SizeInPixels()); |
|
1342 self->SetExtL(aExtent.iTl, aExtent.Size()); |
|
1343 self->AssignGC(*TheClient->iGc); |
|
1344 self->Activate(); |
|
1345 self->DrawNow(); |
|
1346 CleanupStack::Pop(self); |
|
1347 return self; |
|
1348 } |
|
1349 |
|
1350 void CWindowWithOneLine::Draw() |
|
1351 { |
|
1352 iGc->DrawLine(TPoint(0,0), TPoint(Size().iWidth, Size().iHeight)); |
|
1353 } |
|
1354 |
|
1355 // |
|
1356 |
|
1357 COomObscuredWindow::COomObscuredWindow(CTOom *aTest) : COomSetup(aTest) |
|
1358 {} |
|
1359 |
|
1360 TOomTestName COomObscuredWindow::TestName() |
|
1361 { |
|
1362 return(_L("Obscured window")); |
|
1363 } |
|
1364 |
|
1365 TInt COomObscuredWindow::Fail() |
|
1366 { |
|
1367 TRAPD(err, DoFailL()); |
|
1368 return err; |
|
1369 } |
|
1370 |
|
1371 |
|
1372 void COomObscuredWindow::DoFailL() |
|
1373 { |
|
1374 #ifdef __WINS__ |
|
1375 RDebug::Print(_L("COomObscuredWindow::DoFailL - enter")); |
|
1376 #endif |
|
1377 const TRect extent(20, 20, 100, 100); |
|
1378 CBlankWindow* backgroundWindow = new(ELeave) CBlankWindow(TRgb(12, 23, 34)); |
|
1379 CleanupStack::PushL(backgroundWindow); |
|
1380 TDisplayMode mode = EColor16MAP; |
|
1381 backgroundWindow->SetUpL(extent.iTl, extent.Size(), TheClient->iGroup, *TheClient->iGc, &mode); |
|
1382 |
|
1383 CWindowWithOneLine* window = CWindowWithOneLine::NewL(*backgroundWindow, extent); |
|
1384 CleanupStack::PushL(window); |
|
1385 #ifdef __WINS__ |
|
1386 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 1")); |
|
1387 #endif |
|
1388 TheClient->WaitForRedrawsToFinish(); |
|
1389 |
|
1390 CBlankWindow* obscuringWindow = new(ELeave) CBlankWindow(TRgb(255, 0, 0)); |
|
1391 CleanupStack::PushL(obscuringWindow); |
|
1392 obscuringWindow->SetUpL(extent.iTl, extent.Size(), backgroundWindow, *TheClient->iGc, &mode); |
|
1393 |
|
1394 TheClient->Flush(); |
|
1395 #ifdef __WINS__ |
|
1396 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 2")); |
|
1397 #endif |
|
1398 TheClient->WaitForRedrawsToFinish(); |
|
1399 |
|
1400 window->Invalidate(); |
|
1401 |
|
1402 for(TInt i = 0; i < 50; i++) |
|
1403 { |
|
1404 RWindow anotherWin(iWs); |
|
1405 User::LeaveIfError(anotherWin.Construct(iWinGroup, 11)); |
|
1406 anotherWin.Close(); |
|
1407 |
|
1408 if(i % 4) |
|
1409 window->Invalidate(); |
|
1410 |
|
1411 TheClient->Flush(); |
|
1412 #ifdef __WINS__ |
|
1413 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 3 - %d"), i); |
|
1414 #endif |
|
1415 TheClient->WaitForRedrawsToFinish(); |
|
1416 } |
|
1417 |
|
1418 TheClient->Flush(); |
|
1419 #ifdef __WINS__ |
|
1420 RDebug::Print(_L("COomObscuredWindow - WaitForRedrawsToFinish - 4")); |
|
1421 #endif |
|
1422 TheClient->WaitForRedrawsToFinish(); |
|
1423 |
|
1424 CleanupStack::PopAndDestroy(obscuringWindow); |
|
1425 CleanupStack::PopAndDestroy(window); |
|
1426 CleanupStack::PopAndDestroy(backgroundWindow); |
|
1427 #ifdef __WINS__ |
|
1428 RDebug::Print(_L("COomObscuredWindow::DoFailL - exit")); |
|
1429 #endif |
|
1430 } |
|
1431 |
|
1432 void COomObscuredWindow::ClearUpL() |
|
1433 { |
|
1434 } |
|
1435 |
|
1436 // |
|
1437 |
|
1438 CTOom::CTOom(CTestStep* aStep) : CTWsGraphicsBase(aStep) |
|
1439 { |
|
1440 iState = 0; |
|
1441 } |
|
1442 |
|
1443 const TDesC& CTOom::TestName() const |
|
1444 { |
|
1445 _LIT(KTestName,"CTOom"); |
|
1446 return(KTestName()); |
|
1447 } |
|
1448 |
|
1449 void CTOom::DoOomTestL(COomFailBase *aOomTest) |
|
1450 { |
|
1451 //TLogMessageText buf; |
|
1452 TEST(aOomTest!=NULL); |
|
1453 if (aOomTest==NULL) |
|
1454 INFO_PRINTF1(_L("aOomTest - Expected: Not Null, Actual: NULL")); |
|
1455 |
|
1456 TRAPD(ret1,aOomTest->ConstructL()); |
|
1457 TEST(ret1==KErrNone); |
|
1458 if (ret1!=KErrNone) |
|
1459 INFO_PRINTF3(_L("aOomTest->ConstructL() return value - Expected: %d, Actual: %d"), KErrNone, ret1); |
|
1460 |
|
1461 aOomTest->Flush(); |
|
1462 __UHEAP_MARK; |
|
1463 // TInt oldCount=TheClient->iWs.HeapCount(); |
|
1464 for(TInt mode=0;mode<3;mode++) |
|
1465 { |
|
1466 /*buf.Format(_L("OOMTest[%d] Mode=%d"),iState,mode), |
|
1467 TheClient->LogMessage(buf);*/ |
|
1468 TInt successCount=0; |
|
1469 for(TInt count=1;;count++) |
|
1470 { |
|
1471 TInt ret; |
|
1472 aOomTest->PreFail(); |
|
1473 if (mode==0) |
|
1474 TheClient->iWs.HeapSetFail(RHeap::EDeterministic,count); |
|
1475 else if (mode==1) |
|
1476 TheClient->iWs.HeapSetBurstFail(RHeap::EBurstFailNext, count, KMaxTUint16); |
|
1477 else if (mode==3) |
|
1478 { |
|
1479 __UHEAP_SETFAIL(RHeap::EDeterministic,count); //Leavescan will complain about EFailNext, although it isn't a leaving function |
|
1480 } |
|
1481 ret=aOomTest->Fail(); |
|
1482 if (mode==0) |
|
1483 TheClient->iWs.HeapSetFail(RHeap::ENone,0); |
|
1484 else if (mode==1) |
|
1485 TheClient->iWs.HeapSetBurstFail(RHeap::ENone, 0, 0); |
|
1486 else if (mode==2) |
|
1487 { |
|
1488 __UHEAP_RESET; |
|
1489 } |
|
1490 aOomTest->ClearUpL(); //In just 1 case this could leave... |
|
1491 aOomTest->Flush(); |
|
1492 if (ret==KErrNone) |
|
1493 { |
|
1494 if (successCount==10) |
|
1495 break; |
|
1496 successCount++; |
|
1497 } |
|
1498 else |
|
1499 { |
|
1500 /*if (successCount>0) |
|
1501 { |
|
1502 buf.Format(_L("[%d,%d] Count=%d, MaxSuccess=%d"),iState,mode,count,successCount); |
|
1503 TheClient->LogMessage(buf); |
|
1504 }*/ |
|
1505 successCount=0; |
|
1506 /*if (ret!=KErrNoMemory) |
|
1507 { |
|
1508 buf.Format(_L("[%d,%d] Fail, Count=%d, Error=%d"),iState,mode,count,ret); |
|
1509 TheClient->LogMessage(buf); |
|
1510 }*/ |
|
1511 TEST(ret==KErrNoMemory); |
|
1512 if (ret!=KErrNoMemory) |
|
1513 INFO_PRINTF3(_L("aOomTest->Fail() return value - Expected: %d, Actual: %d"), KErrNoMemory, ret); |
|
1514 |
|
1515 } |
|
1516 } |
|
1517 /*buf.Format(_L("[%d,%d] LastCount=%d"),iState,mode,count), |
|
1518 TheClient->LogMessage(buf);*/ |
|
1519 } |
|
1520 // TEST(oldCount>=TheClient->iWs.HeapCount()); |
|
1521 __UHEAP_MARKEND; |
|
1522 delete aOomTest; |
|
1523 /*buf.Format(_L("OOMTest[%d] Finished"),iState); |
|
1524 TheClient->LogMessage(buf);*/ |
|
1525 } |
|
1526 |
|
1527 void CTOom::ConstructL() |
|
1528 { |
|
1529 iShieldWin=RBlankWindow(TheClient->iWs); |
|
1530 User::LeaveIfError(iShieldWin.Construct(*(TheClient->iGroup->GroupWin()),1)); |
|
1531 // iShieldWin.SetOrdinalPosition(0,-1); |
|
1532 iShieldWin.Activate(); |
|
1533 } |
|
1534 |
|
1535 CTOom::~CTOom() |
|
1536 { |
|
1537 iShieldWin.Close(); |
|
1538 } |
|
1539 |
|
1540 /** |
|
1541 @SYMTestCaseID GRAPHICS-WSERV-0124 |
|
1542 |
|
1543 @SYMDEF DEF081259 |
|
1544 |
|
1545 @SYMTestCaseDesc Out of memory tests |
|
1546 |
|
1547 @SYMTestPriority High |
|
1548 |
|
1549 @SYMTestStatus Implemented |
|
1550 |
|
1551 @SYMTestActions Uses deterministic heap failure mode to test WSERV classes against out-of-memory errors. |
|
1552 Sets and unsets deterministic mode using both RWsSession.HeapSetFail() methods and |
|
1553 __UHEAP_SETFAIL/__UHEAP_RESET macros (doing this both client and WSERV threads are tested). |
|
1554 On each step the test creates a failure object and repeatedly asks it to do some work (calling Fail() method). |
|
1555 A failure object is an object which encapsulates some allocation functionality inside it's Fail() method. |
|
1556 The test is performed for 23 different failure objects that do the following: |
|
1557 1. Creates a wserv session, connects and creates CWsScreenDevice object. |
|
1558 2. Creates a RWindowGroup object. |
|
1559 3. Creates a RWindow object. |
|
1560 4. Creates a RBackedUpWindow object. |
|
1561 5. Sets the size of previously created backed-up window. |
|
1562 6. Creates a RBlankWindow object. |
|
1563 7. Allocates a buffer for storing pointer movements for a previously created backed-up window. |
|
1564 8. Adds a priority key for a previously created window group. |
|
1565 9. Requests a capture keys for a previously created window group. |
|
1566 10. Requests the capture of key-up and key-down events for a previously created window group. |
|
1567 11. Sets hot key for the session. |
|
1568 12. Sets the window group's name. |
|
1569 13. Sends a message to another window group. |
|
1570 14. Fetches a message. |
|
1571 15. Enables window group change events and modifier change events. |
|
1572 16. Copies screen to bitmap. |
|
1573 17. Creates a sprite. |
|
1574 18. Creates a pointer cursor. |
|
1575 19. Creates a graphical context for a previously created screen device. |
|
1576 20. Draws a polygon. |
|
1577 21. Creates a screen device handle. |
|
1578 22. Adds a custom text cursor to the server's list of cursors. |
|
1579 23. Does nothing if transparency is not enabled. Creates a blank window with |
|
1580 two transparent child-windows. Tests setting the transparency via a factor, CFbsBitmap |
|
1581 or a CWsBitmap, and changing from one to the other. |
|
1582 Changes child-windows' sizes and toggles their visibility. |
|
1583 |
|
1584 |
|
1585 @SYMTestExpectedResults The test checks that the creation failure objects doesn't fail and their's work either causes no errors or causes KErrNoMemory error. |
|
1586 */ |
|
1587 void CTOom::RunTestCaseL(TInt /*aCurTestCase*/) |
|
1588 { |
|
1589 ((CTOomStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0124")); |
|
1590 if (iState==0) |
|
1591 { |
|
1592 // commented by Anton Golovko, 01.03.2006 while converting to TEF |
|
1593 // the code below prevented the test to do anything. |
|
1594 // if (iTest->IsFullRomL()) |
|
1595 // { |
|
1596 // TestComplete(); |
|
1597 // return; |
|
1598 // } |
|
1599 iOldCount=TheClient->iWs.HeapCount(); |
|
1600 } |
|
1601 else if (iState==sizeof(CreateOomFailTest)/sizeof(CreateOomFailTest[0])) |
|
1602 { |
|
1603 iTest->CloseAllPanicWindows(); |
|
1604 TInt heapCount=TheClient->iWs.HeapCount(); |
|
1605 if (heapCount>iOldCount) |
|
1606 { |
|
1607 TEST(iOldCount>=heapCount-184); //For some uninvestigated reason 184 object get allocated on the server side, partly because of INFO_PRINTF1 |
|
1608 if (iOldCount<heapCount-184) |
|
1609 INFO_PRINTF3(_L("iOldCount>=heapCount-174 - Expected: %d, Actual: %d"), heapCount-184, iOldCount); |
|
1610 |
|
1611 } |
|
1612 ((CTOomStep*)iStep)->CloseTMSGraphicsStep(); |
|
1613 TestComplete(); |
|
1614 return; |
|
1615 } |
|
1616 DoOomTestL(CreateOomFailTest[iState++](this)); |
|
1617 ((CTOomStep*)iStep)->RecordTestResultL(); |
|
1618 } |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 __WS_CONSTRUCT_STEP__(Oom) |
|
1624 |