|
1 // Copyright (c) 2006-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 <e32std.h> |
|
23 #include <hal.h> |
|
24 #include <u32hal.h> |
|
25 |
|
26 #include <graphics/surfaceupdateclient.h> |
|
27 #include <graphics/suerror.h> |
|
28 #include <limits.h> |
|
29 #include "surfaceupdatetest.h" |
|
30 #include "tsurfaceupdate.h" |
|
31 #include "surfaceupdate.h" |
|
32 |
|
33 |
|
34 CTSurfaceUpdate::CTSurfaceUpdate(CTestStep* aStep) : |
|
35 CTGraphicsBase(aStep) |
|
36 { |
|
37 } |
|
38 |
|
39 CTSurfaceUpdate::~CTSurfaceUpdate() |
|
40 { |
|
41 while (iReceivers.Count()) |
|
42 { |
|
43 CTContentUpdateReceiver *receiver = iReceivers[0]; |
|
44 iReceivers.Remove(0); |
|
45 CloseTestUpdateReceiver(receiver); |
|
46 } |
|
47 iReceivers.Reset(); |
|
48 } |
|
49 |
|
50 void CTSurfaceUpdate::ConstructL() |
|
51 { |
|
52 SetupContentUpdateReceiversL(); |
|
53 } |
|
54 |
|
55 void CTSurfaceUpdate::SetupContentUpdateReceiversL() |
|
56 { |
|
57 //first receiver |
|
58 CTContentUpdateReceiver *receiver; |
|
59 User::LeaveIfError(StartTestUpdateReceiver(receiver, 1)); |
|
60 iReceivers.AppendL(receiver); |
|
61 |
|
62 //second receiver |
|
63 CTContentUpdateReceiver *receiver2; |
|
64 User::LeaveIfError(StartTestUpdateReceiver(receiver2, 2)); |
|
65 iReceivers.AppendL(receiver2); |
|
66 |
|
67 //third receiver |
|
68 CTContentUpdateReceiver *receiver3; |
|
69 User::LeaveIfError(StartTestUpdateReceiver(receiver3, 3)); |
|
70 iReceivers.AppendL(receiver3); |
|
71 |
|
72 User::LeaveIfError(Provider()->Register(0, receiver, -1)); |
|
73 User::LeaveIfError(Provider()->Register(1, receiver2, 1)); |
|
74 User::LeaveIfError(Provider()->Register(2, receiver3, 2)); |
|
75 } |
|
76 |
|
77 /** |
|
78 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0001 |
|
79 |
|
80 |
|
81 @SYMPREQ 1007 |
|
82 |
|
83 @SYMREQ 8223 |
|
84 |
|
85 @SYMTestCaseDesc Initialization of the server environment twice. |
|
86 |
|
87 @SYMTestPriority High |
|
88 |
|
89 @SYMTestStatus Implemented |
|
90 |
|
91 @SYMTestActions Attempt to start the server for the second time. |
|
92 |
|
93 @SYMTestExpectedResults Must return KErrAlreadyExists. |
|
94 */ |
|
95 void CTSurfaceUpdate::TestCase1() |
|
96 { |
|
97 INFO_PRINTF1(_L("Attempt to start the server for the second time")); |
|
98 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
|
99 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
|
100 TEST(res==KErrNone); |
|
101 TEST(surfaceUpdateProvider!=NULL); |
|
102 TEST(surfaceUpdateProvider==Provider()); |
|
103 } |
|
104 |
|
105 /** |
|
106 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0002 |
|
107 |
|
108 @SYMPREQ 1007 |
|
109 |
|
110 @SYMREQ 8223 |
|
111 |
|
112 @SYMTestCaseDesc Submit update commands and subscribe for notifications. |
|
113 |
|
114 @SYMTestPriority High |
|
115 |
|
116 @SYMTestStatus Implemented |
|
117 |
|
118 @SYMTestActions Create connection to the server. |
|
119 Subscribe for different notifications (consumed, displayed, displayedXTimes). |
|
120 Submit update command. Wait for notifications to arrive. |
|
121 Repeat for a few times in a row . |
|
122 |
|
123 @SYMTestExpectedResults Errors, which will be conveyed in |
|
124 TRequestStatus must be equal to KErrNone. The order must be consistent with |
|
125 before and after submission (Before submission < composition < after submission). |
|
126 */ |
|
127 void CTSurfaceUpdate::TestCase2L() |
|
128 { |
|
129 INFO_PRINTF1(_L("Submit update and subscribe for notifications")); |
|
130 const TInt KMaxSubmissionNumber = 60; //it should be divisible by 3! |
|
131 RSurfaceUpdateSession session; |
|
132 TInt res = session.Connect(); |
|
133 User::LeaveIfError(res); |
|
134 |
|
135 iSurfaceOrder = CRequestOrder::NewL(KMaxSubmissionNumber); |
|
136 |
|
137 iReceivers[0]->SetCompositionOrder(iSurfaceOrder); |
|
138 iReceivers[1]->SetCompositionOrder(iSurfaceOrder); |
|
139 iReceivers[2]->SetCompositionOrder(iSurfaceOrder); |
|
140 |
|
141 TInt screen = 0; |
|
142 TInt buffer = 2; |
|
143 TSurfaceId surface = |
|
144 { |
|
145 1,2,3,4 |
|
146 }; |
|
147 TRect rc[2] = |
|
148 { |
|
149 TRect(1,2, 10, 20), |
|
150 TRect(5,6, 30, 30) |
|
151 }; |
|
152 RRegion region(2, rc); |
|
153 |
|
154 // Test that submitting for an update before any noitfications causes no problems |
|
155 TEST(KErrNone == session.SubmitUpdate(screen, surface, buffer, ®ion)); |
|
156 |
|
157 iSurfaceOrder->ResetAll(); |
|
158 for(TInt submissionNumber = 0; submissionNumber < KMaxSubmissionNumber/3; submissionNumber++) |
|
159 { |
|
160 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
161 |
|
162 TRequestStatus status = KRequestPending; |
|
163 TRequestStatus status1 = KRequestPending; |
|
164 TRequestStatus status2 = KRequestPending; |
|
165 TTimeStamp timeStamp; |
|
166 |
|
167 iSurfaceOrder->SetOrder(EOrderBefore); |
|
168 session.NotifyWhenAvailable(status); |
|
169 session.NotifyWhenDisplayed(status1, timeStamp); |
|
170 session.NotifyWhenDisplayedXTimes(10, status2); |
|
171 |
|
172 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
173 TEST(res==KErrNone); |
|
174 |
|
175 User::WaitForRequest(status); |
|
176 User::WaitForRequest(status1); |
|
177 User::WaitForRequest(status2); |
|
178 iSurfaceOrder->SetOrder(EOrderAfter); |
|
179 |
|
180 TEST(status == KErrNone); |
|
181 TEST(status1 == KErrNone); |
|
182 TEST(status2 == KErrNone); |
|
183 } |
|
184 |
|
185 for(TInt i=0; i < KMaxSubmissionNumber/3; i++) |
|
186 { |
|
187 TInt positionBefore=-1; |
|
188 TInt positionComposition=-1; |
|
189 TInt positionAfter=-1; |
|
190 for(TInt j=0; j < KMaxSubmissionNumber; j++) |
|
191 { |
|
192 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderBefore)) |
|
193 { |
|
194 positionBefore=j; |
|
195 } |
|
196 |
|
197 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderComposition)) |
|
198 { |
|
199 positionComposition=j; |
|
200 } |
|
201 |
|
202 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderAfter)) |
|
203 { |
|
204 positionAfter=j; |
|
205 } |
|
206 } |
|
207 TEST((positionBefore != -1) && (positionComposition != -1) && (positionAfter != -1)); |
|
208 TEST(positionBefore < positionComposition); |
|
209 TEST(positionAfter > positionComposition); |
|
210 } |
|
211 |
|
212 delete iSurfaceOrder; |
|
213 iSurfaceOrder = NULL; |
|
214 iReceivers[0]->SetCompositionOrder(NULL); |
|
215 iReceivers[1]->SetCompositionOrder(NULL); |
|
216 iReceivers[2]->SetCompositionOrder(NULL); |
|
217 |
|
218 session.Close(); |
|
219 } |
|
220 |
|
221 /** |
|
222 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0003 |
|
223 |
|
224 @SYMPREQ 1007 |
|
225 |
|
226 @SYMREQ 8223 |
|
227 |
|
228 @SYMTestCaseDesc Submit a few requests, then consume them. |
|
229 |
|
230 @SYMTestPriority High |
|
231 |
|
232 @SYMTestStatus Implemented |
|
233 |
|
234 @SYMTestActions A. Request notifications of the same type consecutively |
|
235 (no submit in-between) and check that the behaviour is correct. |
|
236 B. Create connection to the server with sufficient number of |
|
237 outstanding asynchronous message slots. |
|
238 1. Subscribe for different notifications (consumed, displayed, |
|
239 displayedXTimes). |
|
240 2. Submit update command. |
|
241 3 Repeat step 1 & 2 a few times. |
|
242 Wait for notifications (from all requests) to arrive. |
|
243 Repeat 1& 2 & 3 a few times in a row |
|
244 |
|
245 @SYMTestExpectedResults A. The last of each notification request type |
|
246 to be issued before the submission will return with KErrNone, as will |
|
247 the SubmitUpdate. B. Errors, which will be conveyed in TRequestStatus |
|
248 must be equal to KErrNone. The order must be consistent with |
|
249 before and after submission (Before submission < composition < after submission). |
|
250 */ |
|
251 void CTSurfaceUpdate::TestCase3L() |
|
252 { |
|
253 INFO_PRINTF1(_L("Submission a few update requests in a row, then waiting for notifications to arrive")); |
|
254 RSurfaceUpdateSession session; |
|
255 |
|
256 const TInt KNumberAsynchronousRequests = 42; //it should be divisible by 3! |
|
257 TInt res = session.Connect(KNumberAsynchronousRequests); |
|
258 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests as: %d"), KNumberAsynchronousRequests); |
|
259 User::LeaveIfError(res); |
|
260 |
|
261 iSurfaceOrder = CRequestOrder::NewL(KNumberAsynchronousRequests); |
|
262 |
|
263 iReceivers[0]->SetCompositionOrder(iSurfaceOrder); |
|
264 iReceivers[1]->SetCompositionOrder(iSurfaceOrder); |
|
265 iReceivers[2]->SetCompositionOrder(iSurfaceOrder); |
|
266 |
|
267 TInt screen = 0; |
|
268 TInt screen1 = 1; |
|
269 TInt buffer = 2; |
|
270 TSurfaceId surface = |
|
271 { |
|
272 1,2,3,4 |
|
273 }; |
|
274 |
|
275 TRect rc[] = |
|
276 { |
|
277 TRect(1,2, 3, 4), |
|
278 TRect(5,6, 7, 8), |
|
279 TRect(9, 10, 11, 12), |
|
280 TRect(13, 14, 15, 16), |
|
281 }; |
|
282 RRegion region(4, rc); |
|
283 |
|
284 // Test calling two notifies in a row followed by a submit |
|
285 TRequestStatus stat[6]; |
|
286 session.NotifyWhenAvailable(stat[0]); |
|
287 session.NotifyWhenAvailable(stat[1]); |
|
288 TTimeStamp tStamp[2]; |
|
289 session.NotifyWhenDisplayed(stat[2], tStamp[0]); |
|
290 session.NotifyWhenDisplayed(stat[3], tStamp[1]); |
|
291 session.NotifyWhenDisplayedXTimes(10, stat[4]); |
|
292 session.NotifyWhenDisplayedXTimes(10, stat[5]); |
|
293 TEST(KErrNone == session.SubmitUpdate(0 , surface, buffer, ®ion)); |
|
294 // The last requests for notification will be fulfilled, the others ignored |
|
295 User::WaitForRequest(stat[1]); |
|
296 User::WaitForRequest(stat[3]); |
|
297 User::WaitForRequest(stat[5]); |
|
298 TEST(stat[1] == KErrNone); |
|
299 TEST(stat[3] == KErrNone); |
|
300 TEST(stat[5] == KErrNone); |
|
301 |
|
302 // Submit a few requests, then consume them |
|
303 for(TInt index1 = 0; index1 < 5; index1++) |
|
304 { |
|
305 INFO_PRINTF2(_L("Attempt number %d"), index1+1); |
|
306 |
|
307 TRequestStatus status[KNumberAsynchronousRequests]; |
|
308 TTimeStamp timeStamp[KNumberAsynchronousRequests]; |
|
309 |
|
310 // Reset all values |
|
311 iSurfaceOrder->ResetAll(); |
|
312 |
|
313 for(TInt index2 = 0; index2 < KNumberAsynchronousRequests; index2 += 3) |
|
314 { |
|
315 INFO_PRINTF2(_L("Submission number %d"), index2 / 3 + 1); |
|
316 status[index2]=KRequestPending; |
|
317 session.NotifyWhenAvailable(status[index2]); |
|
318 status[index2 + 1]=KRequestPending; |
|
319 session.NotifyWhenDisplayed(status[index2 + 1], timeStamp[index2 / 3]); |
|
320 status[index2 + 2]=KRequestPending; |
|
321 session.NotifyWhenDisplayedXTimes(10, status[index2 + 2]); |
|
322 |
|
323 iSurfaceOrder->SetOrder(EOrderBefore); |
|
324 |
|
325 res = session.SubmitUpdate((index2 % 2) ? screen : screen1, surface, buffer, ®ion); |
|
326 TEST(res==KErrNone); |
|
327 } |
|
328 |
|
329 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++) |
|
330 { |
|
331 User::WaitForRequest(status[submissionNumber]); |
|
332 TEST(status[submissionNumber] == KErrNone); |
|
333 |
|
334 if(((submissionNumber - 1) % 3) == 0) |
|
335 { |
|
336 iSurfaceOrder->SetOrder(EOrderAfter); |
|
337 } |
|
338 } |
|
339 |
|
340 for(TInt i=0; i < KNumberAsynchronousRequests/3; i++) |
|
341 { |
|
342 TInt positionBefore=-1; |
|
343 TInt positionComposition=-1; |
|
344 TInt positionAfter=-1; |
|
345 for(TInt j=0; j < KNumberAsynchronousRequests; j++) |
|
346 { |
|
347 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderBefore)) |
|
348 { |
|
349 positionBefore=j; |
|
350 } |
|
351 |
|
352 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderComposition)) |
|
353 { |
|
354 positionComposition=j; |
|
355 } |
|
356 |
|
357 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderAfter)) |
|
358 { |
|
359 positionAfter=j; |
|
360 } |
|
361 } |
|
362 TEST((positionBefore != -1) && (positionComposition != -1) && (positionAfter != -1)); |
|
363 TEST(positionBefore < positionComposition); |
|
364 TEST(positionAfter > positionComposition); |
|
365 } |
|
366 } |
|
367 |
|
368 delete iSurfaceOrder; |
|
369 iSurfaceOrder = NULL; |
|
370 iReceivers[0]->SetCompositionOrder(NULL); |
|
371 iReceivers[1]->SetCompositionOrder(NULL); |
|
372 iReceivers[2]->SetCompositionOrder(NULL); |
|
373 |
|
374 session.Close(); |
|
375 } |
|
376 |
|
377 /** |
|
378 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0004 |
|
379 |
|
380 @SYMPREQ 1007 |
|
381 |
|
382 @SYMREQ 8223 |
|
383 |
|
384 @SYMTestCaseDesc Cancellation of the requests. |
|
385 |
|
386 @SYMTestPriority High |
|
387 |
|
388 @SYMTestStatus Implemented |
|
389 |
|
390 @SYMTestActions Create connection to the server. |
|
391 1. Test cancellation without SubmitUpdate |
|
392 2. Check cancellation before submission does nothing bad. |
|
393 3. Subscribe for different notifications (consumed, displayed, |
|
394 displayedXTimes). |
|
395 4. Submit update command. 5. Repeat steps 3 & 4 a few times. |
|
396 Cancel all outstanding notifications. Wait for cancelled notifications |
|
397 to arrive. |
|
398 |
|
399 @SYMTestExpectedResults Notifications must arrive straightway with |
|
400 KErrCancel error code or KErrNone, if events have already occurred. |
|
401 */ |
|
402 void CTSurfaceUpdate::TestCase4L() |
|
403 { |
|
404 INFO_PRINTF1(_L("Submission a few requests in a row and then cancelling them")); |
|
405 RSurfaceUpdateSession session; |
|
406 |
|
407 const TInt KNumberAsynchronousRequests = 99; //should be divisible by 3! |
|
408 TInt res = session.Connect(KNumberAsynchronousRequests); |
|
409 INFO_PRINTF1(_L("Test CancelAllUpdateNotifications without SubmitUpdate")); |
|
410 // Test CancelAllUpdateNotifications without SubmitUpdate |
|
411 TRequestStatus status1, status2, status3; |
|
412 TTimeStamp ts; |
|
413 session.NotifyWhenAvailable(status1); |
|
414 session.NotifyWhenDisplayed(status2, ts); |
|
415 session.NotifyWhenDisplayedXTimes(5, status3); |
|
416 session.CancelAllUpdateNotifications(); |
|
417 User::WaitForRequest(status1); |
|
418 User::WaitForRequest(status2); |
|
419 User::WaitForRequest(status3); |
|
420 TEST(status1==KErrCancel); |
|
421 TEST(status2==KErrCancel); |
|
422 TEST(status3==KErrCancel); |
|
423 |
|
424 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests as: %d"), KNumberAsynchronousRequests); |
|
425 User::LeaveIfError(res); |
|
426 |
|
427 TInt screen = 0; |
|
428 TInt screen1 = 1; |
|
429 TInt buffer = 2; |
|
430 TSurfaceId surface = |
|
431 { |
|
432 1,2,3,4 |
|
433 }; |
|
434 TRect rc[] = |
|
435 { |
|
436 TRect(1,2, 3, 4), |
|
437 TRect(5,6, 7, 8), |
|
438 TRect(9, 10, 11, 12), |
|
439 TRect(13, 14, 15, 16), |
|
440 }; |
|
441 RRegion region(4, rc); |
|
442 |
|
443 // Check that cancelling notifications before any submission does nothing bad |
|
444 session.CancelAllUpdateNotifications(); |
|
445 |
|
446 for(TInt index1 = 0; index1 < 2; index1++) |
|
447 { |
|
448 INFO_PRINTF2(_L("Attempt number %d"), index1+1); |
|
449 |
|
450 TRequestStatus status[KNumberAsynchronousRequests]; |
|
451 |
|
452 TTimeStamp timeStamp[KNumberAsynchronousRequests]; |
|
453 TUint64 timestampComposition[KNumberAsynchronousRequests]; |
|
454 TUint64 timestampBefore[KNumberAsynchronousRequests]; |
|
455 TUint64 timestampAfter[KNumberAsynchronousRequests]; |
|
456 for(TInt index2 = 0; index2 < KNumberAsynchronousRequests; index2 += 3) |
|
457 { |
|
458 INFO_PRINTF2(_L("Submission number %d"), index2 / 3 + 1); |
|
459 status[index2]=KRequestPending; |
|
460 session.NotifyWhenAvailable(status[index2]); |
|
461 status[index2 + 1]=KRequestPending; |
|
462 session.NotifyWhenDisplayed(status[index2 + 1], timeStamp[index2 / 3]); |
|
463 status[index2 + 2]=KRequestPending; |
|
464 session.NotifyWhenDisplayedXTimes(10, status[index2 + 2]); |
|
465 |
|
466 timestampBefore[index2 / 3] = User::FastCounter(); |
|
467 res = session.SubmitUpdate((index2 % 2) ? screen : screen1, surface, buffer, ®ion); |
|
468 TEST(res==KErrNone); |
|
469 } |
|
470 TBool cancel=EFalse; |
|
471 session.CancelAllUpdateNotifications(); |
|
472 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++) |
|
473 { |
|
474 User::WaitForRequest(status[submissionNumber]); |
|
475 TEST((status[submissionNumber] == KErrCancel) || (status[submissionNumber] == KErrNone) ); |
|
476 if(status[submissionNumber] == KErrCancel) |
|
477 { |
|
478 cancel = ETrue; |
|
479 } |
|
480 |
|
481 if((status[submissionNumber] == KErrNone) && ((submissionNumber - 1) % 3) == 0) |
|
482 { |
|
483 TInt index22 = submissionNumber / 3; |
|
484 timestampAfter[index22] = User::FastCounter(); |
|
485 |
|
486 if(timestampAfter[index22] < timestampBefore[index22]) |
|
487 { |
|
488 timestampAfter[index22] += UINT_MAX; |
|
489 } |
|
490 timestampComposition[index22] = timeStamp[index22](); |
|
491 if(timestampComposition[index22] < timestampBefore[index22]) |
|
492 { |
|
493 timestampComposition[index22] += UINT_MAX; |
|
494 } |
|
495 |
|
496 TEST(timestampComposition[index22] != 0); |
|
497 TEST(timestampAfter[index22] >= timestampComposition[index22]); |
|
498 TEST(timestampBefore[index22] <= timestampComposition[index22]); |
|
499 } |
|
500 } |
|
501 TEST(cancel); |
|
502 } |
|
503 session.Close(); |
|
504 } |
|
505 |
|
506 /** |
|
507 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0005 |
|
508 |
|
509 @SYMPREQ 1007 |
|
510 |
|
511 @SYMREQ 8223 |
|
512 |
|
513 @SYMTestCaseDesc Submission from multiple sessions. |
|
514 |
|
515 @SYMTestPriority High |
|
516 |
|
517 @SYMTestStatus Implemented |
|
518 |
|
519 @SYMTestActions Create a few connections to the server. For each connection: |
|
520 1. Subscribe for different notifications (consumed, displayed, |
|
521 displayedXTimes). |
|
522 2. Submit update command. Wait for notifications to arrive. |
|
523 |
|
524 @SYMTestExpectedResults Errors, which will be conveyed in |
|
525 TRequestStatus must be equal to KErrNone. Timestamps must be consistent |
|
526 with time before and after submissions. |
|
527 */ |
|
528 void CTSurfaceUpdate::TestCase5L() |
|
529 { |
|
530 INFO_PRINTF1(_L("Submission a few update requests in a row from different sessions, then waiting for notifications to arrive")); |
|
531 |
|
532 const TInt KNumberAsynchronousRequests = 9; |
|
533 const TInt KNumberSessions = 5; |
|
534 TInt res = KErrNone; |
|
535 |
|
536 RSurfaceUpdateSession sessions[KNumberSessions]; |
|
537 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests per each session as: %d"), KNumberAsynchronousRequests); |
|
538 INFO_PRINTF2(_L("Set number of sessions: %d"), KNumberSessions); |
|
539 |
|
540 TInt screen = 0; |
|
541 TInt screen1 = 1; |
|
542 TInt buffer = 2; |
|
543 TSurfaceId surface = |
|
544 { |
|
545 1,2,3,4 |
|
546 }; |
|
547 TRect rc[] = |
|
548 { |
|
549 TRect(1,2, 3, 4), |
|
550 TRect(5,6, 7, 8), |
|
551 TRect(9, 10, 11, 12), |
|
552 TRect(13, 14, 15, 16), |
|
553 }; |
|
554 RRegion region(4, rc); |
|
555 |
|
556 TRequestStatus status[KNumberAsynchronousRequests * KNumberSessions]; |
|
557 |
|
558 for(TInt index2 = 0; index2 < KNumberSessions; index2++) |
|
559 { |
|
560 res = sessions[index2].Connect(KNumberAsynchronousRequests); |
|
561 User::LeaveIfError(res); |
|
562 } |
|
563 |
|
564 for(TInt index1 = 0; index1 < 3; index1++) |
|
565 { |
|
566 INFO_PRINTF2(_L("Attempt number %d"), index1+1); |
|
567 |
|
568 for(TInt index2 = 0; index2 < KNumberSessions; index2++) |
|
569 { |
|
570 TTimeStamp timeStamp; |
|
571 INFO_PRINTF2(_L("Session number %d"), index2 + 1); |
|
572 |
|
573 for(TInt index3 = index2 * KNumberAsynchronousRequests; |
|
574 index3 < (index2 + 1) * KNumberAsynchronousRequests; index3 += 3) |
|
575 { |
|
576 INFO_PRINTF2(_L("Submission number %d"), index3 / 3 + 1); |
|
577 status[index3]=KRequestPending; |
|
578 sessions[index2].NotifyWhenAvailable(status[index3]); |
|
579 status[index3 + 1]=KRequestPending; |
|
580 sessions[index2].NotifyWhenDisplayed(status[index3 + 1], timeStamp); |
|
581 status[index3 + 2]=KRequestPending; |
|
582 sessions[index2].NotifyWhenDisplayedXTimes(10, status[index3 + 2]); |
|
583 res = sessions[index2].SubmitUpdate((index3 % 2) ? screen : screen1, surface, buffer, ®ion); |
|
584 if(res != KErrNone) |
|
585 { |
|
586 ERR_PRINTF2(_L("Returned SubmitUpdate code %d"), res); |
|
587 TEST(EFail); |
|
588 } |
|
589 } |
|
590 } |
|
591 |
|
592 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests * KNumberSessions; submissionNumber++) |
|
593 { |
|
594 User::WaitForRequest(status[submissionNumber]); |
|
595 if(status[submissionNumber] != KErrNone) |
|
596 { |
|
597 ERR_PRINTF2(_L("Returned request status %d"), status[submissionNumber].Int()); |
|
598 TEST(EFail); |
|
599 } |
|
600 } |
|
601 } |
|
602 |
|
603 for(TInt index5 = 0; index5 < KNumberSessions; index5++) |
|
604 { |
|
605 sessions[index5].Close(); |
|
606 } |
|
607 } |
|
608 |
|
609 /** |
|
610 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0023 |
|
611 |
|
612 |
|
613 @SYMPREQ 1007/11596 |
|
614 |
|
615 @SYMREQ 8223 |
|
616 |
|
617 @SYMTestCaseDesc SubmitUpdate() to cope with Global Updates |
|
618 |
|
619 @SYMTestPriority High |
|
620 |
|
621 @SYMTestStatus Implemented |
|
622 |
|
623 @SYMTestActions |
|
624 1. Submit for a global update before subscribing for any notifications. |
|
625 From this point onwards, all further cases assume that we’ve subscribed |
|
626 for different notifications (available, displayed, displayedXTimes) |
|
627 before submitting a global update: |
|
628 2. Submit a global update for a surface that is not visible on any screen. |
|
629 3. Submit a global update for a surface that is only visible on one screen. |
|
630 4. Submit a global update for a surface that is visible on different screens. |
|
631 |
|
632 @SYMTestExpectedResults |
|
633 1. Submitting for an update before any notifications causes no problems. |
|
634 2. SubmitUpdate() signals KErrNotVisible |
|
635 3. TRequestStatus signals KErrNone in all cases. Timestamps must be valid. |
|
636 4. TRequestStatus signals KErrNone in all cases. Timestamps must be valid. |
|
637 */ |
|
638 void CTSurfaceUpdate::TestCase15() |
|
639 { |
|
640 INFO_PRINTF1(_L("SubmitUpdate() to cope with Global Updates")); |
|
641 |
|
642 RSurfaceUpdateSession session; |
|
643 TInt res = session.Connect(); |
|
644 TEST(res == KErrNone); |
|
645 |
|
646 TInt buffer = 2; |
|
647 TSurfaceId surface = |
|
648 { |
|
649 1,2,3,4 |
|
650 }; |
|
651 |
|
652 // Test that submitting for an update before any noitfications causes no problems |
|
653 TInt numReceivers = iReceivers.Count(); |
|
654 |
|
655 //make all screens invisible |
|
656 INFO_PRINTF1(_L("make all screens invisible")); |
|
657 for(TInt index = 0; index < numReceivers; index++) |
|
658 { |
|
659 CTContentUpdateReceiver* receiver = iReceivers[index]; |
|
660 receiver->SetVisible(EFalse); |
|
661 } |
|
662 |
|
663 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++) |
|
664 { |
|
665 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
666 |
|
667 TRequestStatus status = KRequestPending; |
|
668 TRequestStatus status1 = KRequestPending; |
|
669 TRequestStatus status2 = KRequestPending; |
|
670 TTimeStamp timeStamp; |
|
671 |
|
672 session.NotifyWhenAvailable(status); |
|
673 session.NotifyWhenDisplayed(status1, timeStamp); |
|
674 session.NotifyWhenDisplayedXTimes(10, status2); |
|
675 |
|
676 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
677 TEST(res==KErrNone); |
|
678 |
|
679 User::WaitForRequest(status); |
|
680 User::WaitForRequest(status1); |
|
681 User::WaitForRequest(status2); |
|
682 |
|
683 TEST(status == KErrNotVisible); |
|
684 TEST(status1 == KErrNotVisible); |
|
685 TEST(status2 == KErrNotVisible); |
|
686 } |
|
687 |
|
688 //make only one screen visible |
|
689 CTContentUpdateReceiver* receiver = iReceivers[0]; |
|
690 receiver->SetVisible(ETrue); |
|
691 INFO_PRINTF1(_L("Make visible one screen")); |
|
692 |
|
693 |
|
694 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++) |
|
695 { |
|
696 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
697 |
|
698 TRequestStatus status = KRequestPending; |
|
699 TRequestStatus status1 = KRequestPending; |
|
700 TRequestStatus status2 = KRequestPending; |
|
701 TUint64 timestampComposition = 0; |
|
702 TTimeStamp timeStamp; |
|
703 |
|
704 TUint64 timestampBefore = User::FastCounter(); |
|
705 |
|
706 session.NotifyWhenAvailable(status); |
|
707 session.NotifyWhenDisplayed(status1, timeStamp); |
|
708 session.NotifyWhenDisplayedXTimes(10, status2); |
|
709 |
|
710 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
711 TEST(res==KErrNone); |
|
712 |
|
713 User::WaitForRequest(status); |
|
714 User::WaitForRequest(status1); |
|
715 User::WaitForRequest(status2); |
|
716 |
|
717 TUint64 timestampAfter = User::FastCounter(); |
|
718 if(timestampAfter < timestampBefore) |
|
719 { |
|
720 timestampAfter += UINT_MAX; |
|
721 } |
|
722 timestampComposition = timeStamp(); |
|
723 if(timestampComposition < timestampBefore) |
|
724 { |
|
725 timestampComposition += UINT_MAX; |
|
726 } |
|
727 |
|
728 TEST(status == KErrNone); |
|
729 TEST(status1 == KErrNone); |
|
730 TEST(status2 == KErrNone); |
|
731 |
|
732 TEST(timestampComposition != 0); |
|
733 TEST(timestampAfter >= timestampComposition); |
|
734 TEST(timestampBefore <= timestampComposition); |
|
735 |
|
736 INFO_PRINTF2(_L("Time before composition: %lu"), timestampBefore); |
|
737 INFO_PRINTF2(_L("Time at composition: %lu"), timestampComposition); |
|
738 INFO_PRINTF2(_L("Time after composition: %lu"), timestampAfter); |
|
739 } |
|
740 |
|
741 //make another screen visible |
|
742 INFO_PRINTF1(_L("make another screen visible")); |
|
743 receiver->SetVisible(EFalse); |
|
744 receiver = iReceivers[1]; |
|
745 receiver->SetVisible(ETrue); |
|
746 |
|
747 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++) |
|
748 { |
|
749 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
750 |
|
751 TRequestStatus status = KRequestPending; |
|
752 TRequestStatus status1 = KRequestPending; |
|
753 TRequestStatus status2 = KRequestPending; |
|
754 TUint64 timestampComposition = 0; |
|
755 TTimeStamp timeStamp; |
|
756 |
|
757 TUint64 timestampBefore = User::FastCounter(); |
|
758 |
|
759 session.NotifyWhenAvailable(status); |
|
760 session.NotifyWhenDisplayed(status1, timeStamp); |
|
761 session.NotifyWhenDisplayedXTimes(10, status2); |
|
762 |
|
763 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
764 TEST(res==KErrNone); |
|
765 |
|
766 User::WaitForRequest(status); |
|
767 User::WaitForRequest(status1); |
|
768 User::WaitForRequest(status2); |
|
769 |
|
770 TUint64 timestampAfter = User::FastCounter(); |
|
771 if(timestampAfter < timestampBefore) |
|
772 { |
|
773 timestampAfter += UINT_MAX; |
|
774 } |
|
775 timestampComposition = timeStamp(); |
|
776 if(timestampComposition < timestampBefore) |
|
777 { |
|
778 timestampComposition += UINT_MAX; |
|
779 } |
|
780 |
|
781 TEST(status == KErrNone); |
|
782 TEST(status1 == KErrNone); |
|
783 TEST(status2 == KErrNone); |
|
784 |
|
785 TEST(timestampComposition != 0); |
|
786 TEST(timestampAfter >= timestampComposition); |
|
787 TEST(timestampBefore <= timestampComposition); |
|
788 |
|
789 INFO_PRINTF2(_L("Time before composition: %lu"), timestampBefore); |
|
790 INFO_PRINTF2(_L("Time at composition: %lu"), timestampComposition); |
|
791 INFO_PRINTF2(_L("Time after composition: %lu"), timestampAfter); |
|
792 } |
|
793 |
|
794 //make all screens visible |
|
795 for(TInt index = 0; index < numReceivers; index++) |
|
796 { |
|
797 CTContentUpdateReceiver* receiver = iReceivers[index]; |
|
798 receiver->SetVisible(ETrue); |
|
799 } |
|
800 |
|
801 session.Close(); |
|
802 } |
|
803 |
|
804 |
|
805 /** |
|
806 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0024 |
|
807 |
|
808 @SYMPREQ 1007/11596 |
|
809 |
|
810 @SYMREQ 8223 |
|
811 |
|
812 @SYMTestCaseDesc CancelAllUpdateNotifications() to deal with global updates |
|
813 correctly. |
|
814 |
|
815 @SYMTestPriority High |
|
816 |
|
817 @SYMTestStatus Implemented |
|
818 |
|
819 @SYMTestActions |
|
820 The test consists of a single surface, visible on screens A (master), B & C. |
|
821 The test will submit for different notifications (available, displayed, |
|
822 displayedXTimes) and then submit a global update. |
|
823 These actions will be repeated a number of times. |
|
824 Finally, the test will cancel all outstanding notifications via |
|
825 CancelAllUpdateNotifications() and wait for the cancelled notifications to arrive. |
|
826 |
|
827 @SYMTestExpectedResults |
|
828 Notifications to arrive straight away with KErrCancel, otherwise with |
|
829 KErrNone if the events have already occurred. |
|
830 */ |
|
831 void CTSurfaceUpdate::TestCase16L() |
|
832 { |
|
833 INFO_PRINTF1(_L("CancelAllUpdateNotifications() to deal with global updates correctly")); |
|
834 RSurfaceUpdateSession session; |
|
835 |
|
836 const TInt KNumberAsynchronousRequests = 33; //should be divisible by 3! |
|
837 TInt res = session.Connect(KNumberAsynchronousRequests); |
|
838 INFO_PRINTF1(_L("Test CancelAllUpdateNotifications without SubmitUpdate")); |
|
839 // Test CancelAllUpdateNotifications without SubmitUpdate |
|
840 TRequestStatus status1, status2, status3; |
|
841 TTimeStamp ts; |
|
842 |
|
843 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests as: %d"), KNumberAsynchronousRequests); |
|
844 User::LeaveIfError(res); |
|
845 |
|
846 TInt buffer = 2; |
|
847 TSurfaceId surface = |
|
848 { |
|
849 1,2,3,4 |
|
850 }; |
|
851 |
|
852 for(TInt index1 = 0; index1 < 2; index1++) |
|
853 { |
|
854 INFO_PRINTF2(_L("Attempt number %d"), index1+1); |
|
855 |
|
856 TRequestStatus status[KNumberAsynchronousRequests]; |
|
857 |
|
858 TTimeStamp timeStamp[KNumberAsynchronousRequests]; |
|
859 TUint64 timestampComposition[KNumberAsynchronousRequests]; |
|
860 TUint64 timestampBefore[KNumberAsynchronousRequests]; |
|
861 TUint64 timestampAfter[KNumberAsynchronousRequests]; |
|
862 for(TInt index2 = 0; index2 < KNumberAsynchronousRequests; index2 += 3) |
|
863 { |
|
864 INFO_PRINTF2(_L("Submission number %d"), index2 / 3 + 1); |
|
865 status[index2]=KRequestPending; |
|
866 session.NotifyWhenAvailable(status[index2]); |
|
867 status[index2 + 1]=KRequestPending; |
|
868 session.NotifyWhenDisplayed(status[index2 + 1], timeStamp[index2 / 3]); |
|
869 status[index2 + 2]=KRequestPending; |
|
870 session.NotifyWhenDisplayedXTimes(10, status[index2 + 2]); |
|
871 |
|
872 timestampBefore[index2 / 3] = User::FastCounter(); |
|
873 res = session.SubmitUpdate(KAllScreens, surface, buffer); |
|
874 TEST(res==KErrNone); |
|
875 } |
|
876 TBool cancel=EFalse; |
|
877 session.CancelAllUpdateNotifications(); |
|
878 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++) |
|
879 { |
|
880 User::WaitForRequest(status[submissionNumber]); |
|
881 TEST((status[submissionNumber] == KErrCancel) || (status[submissionNumber] == KErrNone) ); |
|
882 if(status[submissionNumber] == KErrCancel) |
|
883 { |
|
884 cancel = ETrue; |
|
885 } |
|
886 |
|
887 if((status[submissionNumber] == KErrNone) && ((submissionNumber - 1) % 3) == 0) |
|
888 { |
|
889 TInt index22 = submissionNumber / 3; |
|
890 timestampAfter[index22] = User::FastCounter(); |
|
891 |
|
892 if(timestampAfter[index22] < timestampBefore[index22]) |
|
893 { |
|
894 timestampAfter[index22] += UINT_MAX; |
|
895 } |
|
896 timestampComposition[index22] = timeStamp[index22](); |
|
897 if(timestampComposition[index22] < timestampBefore[index22]) |
|
898 { |
|
899 timestampComposition[index22] += UINT_MAX; |
|
900 } |
|
901 |
|
902 TEST(timestampComposition[index22] != 0); |
|
903 TEST(timestampAfter[index22] >= timestampComposition[index22]); |
|
904 TEST(timestampBefore[index22] <= timestampComposition[index22]); |
|
905 } |
|
906 } |
|
907 TEST(cancel); |
|
908 } |
|
909 session.Close(); |
|
910 } |
|
911 |
|
912 /** |
|
913 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0027 |
|
914 |
|
915 @SYMPREQ 1007/11598 |
|
916 |
|
917 @SYMREQ 8223 |
|
918 |
|
919 @SYMTestCaseDesc NotifyWhenAvailable() to deal with global updates and be signalled correctly |
|
920 @SYMTestPriority High |
|
921 |
|
922 @SYMTestStatus Implemented |
|
923 |
|
924 @SYMTestActions |
|
925 The test consists of a single surface, visible on screens B (master) and C, |
|
926 but not visible on A. |
|
927 1. Screens are ordered in the following priority : A > B > C |
|
928 2. Set priority of the receiver threads as follows A < B < C. |
|
929 3. Set receiver A invisible. |
|
930 4. Make global submit update with notify when displayed and notify |
|
931 when displayed X times. |
|
932 5. Repeat step 4 a few times. |
|
933 |
|
934 @SYMTestExpectedResults |
|
935 Notification to arrive with error code KErrNone initiated by the |
|
936 master display. |
|
937 */ |
|
938 void CTSurfaceUpdate::TestCaseNotifyWhenAvailableGlobal() |
|
939 { |
|
940 INFO_PRINTF1(_L("NotifyWhenAvailable() to deal with global updates and be signalled correctly")); |
|
941 |
|
942 RSurfaceUpdateSession session; |
|
943 TInt res = session.Connect(); |
|
944 TEST(res == KErrNone); |
|
945 |
|
946 TInt buffer = 2; |
|
947 TSurfaceId surface = |
|
948 { |
|
949 1,2,3,4 |
|
950 }; |
|
951 |
|
952 TEST(iReceivers[2]->OutstandingRequest()==EFalse); |
|
953 TEST(iReceivers[1]->OutstandingRequest()==EFalse); |
|
954 TEST(iReceivers[0]->OutstandingRequest()==EFalse); |
|
955 |
|
956 //change the order. |
|
957 //higher screen number means that the screen is higher priority. |
|
958 //So Receiver0 is lowest screen priority |
|
959 res = iReceivers[2]->SetInternalPriority(EPriorityLess); |
|
960 TEST(res == KErrNone); |
|
961 res = iReceivers[1]->SetInternalPriority(EPriorityNormal); |
|
962 TEST(res == KErrNone); |
|
963 res = iReceivers[0]->SetInternalPriority(EPriorityAbsoluteHighNormal); |
|
964 TEST(res == KErrNone); |
|
965 iReceivers[2]->SetVisible(EFalse); |
|
966 User::After(TTimeIntervalMicroSeconds32(100000)); //make sure that priority takes place |
|
967 |
|
968 for(TInt submissionNumber = 0; submissionNumber < 20; submissionNumber++) |
|
969 { |
|
970 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
971 |
|
972 TRequestStatus status = KRequestPending; |
|
973 |
|
974 session.NotifyWhenAvailable(status); |
|
975 |
|
976 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
977 TEST(res==KErrNone); |
|
978 |
|
979 User::WaitForRequest(status); |
|
980 |
|
981 TEST(status == KErrNone); |
|
982 TEST(iReceivers[2]->OutstandingRequest()==EFalse); |
|
983 TEST(iReceivers[1]->OutstandingRequest()==EFalse); |
|
984 TEST(iReceivers[0]->OutstandingRequest()==EFalse); |
|
985 } |
|
986 |
|
987 //restore envorienment |
|
988 iReceivers[0]->SetInternalPriority(EPriorityNormal); |
|
989 iReceivers[1]->SetInternalPriority(EPriorityNormal); |
|
990 iReceivers[2]->SetInternalPriority(EPriorityNormal); |
|
991 iReceivers[2]->SetVisible(ETrue); |
|
992 User::After(TTimeIntervalMicroSeconds32(100000)); //make sure that priority takes place |
|
993 WaitUntilAllNotificationsProcessed(); |
|
994 session.Close(); |
|
995 } |
|
996 |
|
997 /** |
|
998 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0028 |
|
999 |
|
1000 @SYMPREQ 1007/11599, 1007/11600, 1007/11601 |
|
1001 |
|
1002 @SYMREQ 8223 |
|
1003 |
|
1004 @SYMTestCaseDesc NotifyWhenDisplayed() & NotifyWhenDisplayedXTimes() to deal with global updates and be signalled correctly |
|
1005 @SYMTestPriority High |
|
1006 |
|
1007 @SYMTestStatus Implemented |
|
1008 |
|
1009 @SYMTestActions |
|
1010 The test consists of a single surface, visible on screens B (master) and C, but not visible on A. |
|
1011 1. Screens are ordered in the following priority : A > B > C. |
|
1012 2. Set priority of the receiver threads as follows A < B < C. |
|
1013 3. Set receiver A invisible. |
|
1014 4. Make global submit update with notify when displayed and notify when displayed X times. |
|
1015 Repeat step 4 a few times. |
|
1016 |
|
1017 5. Screens are ordered in the following priority : A > B > C. |
|
1018 6. Set priority of the receiver threads as follows A > B > C. |
|
1019 7. Set receiver A invisible. |
|
1020 8. Make global submit update with notify when displayed and notify when displayed X times. |
|
1021 Repeat step 4 a few times. |
|
1022 |
|
1023 |
|
1024 @SYMTestExpectedResults |
|
1025 Notification to arrive with error code KErrNone initiated by the master display. |
|
1026 There is no outstanding request for receiver A & B after steps 4 and 8. |
|
1027 */ |
|
1028 void CTSurfaceUpdate::TestCase17() |
|
1029 { |
|
1030 INFO_PRINTF1(_L("NotifyWhenDisplayed() && NotifyWhenDisplayedXTimes() to deal with global updates and be signalled correctly")); |
|
1031 |
|
1032 RSurfaceUpdateSession session; |
|
1033 TInt res = session.Connect(); |
|
1034 TEST(res == KErrNone); |
|
1035 |
|
1036 TInt buffer = 2; |
|
1037 TSurfaceId surface = |
|
1038 { |
|
1039 1,2,3,4 |
|
1040 }; |
|
1041 |
|
1042 //change the order, receiver with highest priority has a lowest internal priority |
|
1043 res = iReceivers[2]->SetInternalPriority(EPriorityLess); |
|
1044 TEST(res == KErrNone); |
|
1045 res = iReceivers[1]->SetInternalPriority(EPriorityNormal); |
|
1046 TEST(res == KErrNone); |
|
1047 res = iReceivers[0]->SetInternalPriority(EPriorityAbsoluteHighNormal); |
|
1048 TEST(res == KErrNone); |
|
1049 iReceivers[2]->SetVisible(EFalse); |
|
1050 User::After(TTimeIntervalMicroSeconds32(100000)); //make sure that priority setting takes place |
|
1051 |
|
1052 for(TInt submissionNumber = 0; submissionNumber < 10; submissionNumber++) |
|
1053 { |
|
1054 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
1055 |
|
1056 TRequestStatus status = KRequestPending; |
|
1057 TRequestStatus status1 = KRequestPending; |
|
1058 TTimeStamp timeStamp; |
|
1059 |
|
1060 session.NotifyWhenDisplayed(status, timeStamp); |
|
1061 session.NotifyWhenDisplayedXTimes(10, status1); |
|
1062 |
|
1063 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
1064 TEST(res==KErrNone); |
|
1065 |
|
1066 User::WaitForRequest(status); |
|
1067 User::WaitForRequest(status1); |
|
1068 |
|
1069 TEST(status == KErrNone); |
|
1070 TEST(status1 == KErrNone); |
|
1071 TEST(iReceivers[0]->OutstandingRequest() == EFalse); |
|
1072 TEST(iReceivers[1]->OutstandingRequest() == EFalse); |
|
1073 TEST(iReceivers[2]->OutstandingRequest() == EFalse); |
|
1074 } |
|
1075 |
|
1076 //change the order, receiver with highest priority has a highest internal priority |
|
1077 res = iReceivers[0]->SetInternalPriority(EPriorityLess); |
|
1078 TEST(res == KErrNone); |
|
1079 res = iReceivers[1]->SetInternalPriority(EPriorityNormal); |
|
1080 TEST(res == KErrNone); |
|
1081 res = iReceivers[2]->SetInternalPriority(EPriorityAbsoluteHighNormal); |
|
1082 TEST(res == KErrNone); |
|
1083 iReceivers[2]->SetVisible(EFalse); |
|
1084 User::After(TTimeIntervalMicroSeconds32(100000)); //make sure that priority takes place |
|
1085 |
|
1086 TInt numUnprocessedSignals = 0; |
|
1087 for(TInt submissionNumber = 0; submissionNumber < 10; submissionNumber++) |
|
1088 { |
|
1089 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1); |
|
1090 |
|
1091 TRequestStatus status = KRequestPending; |
|
1092 TRequestStatus status1 = KRequestPending; |
|
1093 TTimeStamp timeStamp; |
|
1094 |
|
1095 session.NotifyWhenDisplayed(status, timeStamp); |
|
1096 session.NotifyWhenDisplayedXTimes(10, status1); |
|
1097 |
|
1098 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
1099 TEST(res==KErrNone); |
|
1100 |
|
1101 User::WaitForRequest(status); |
|
1102 User::WaitForRequest(status1); |
|
1103 |
|
1104 TEST(status == KErrNone); |
|
1105 TEST(status1 == KErrNone); |
|
1106 if(iReceivers[0]->OutstandingRequest()) |
|
1107 { |
|
1108 numUnprocessedSignals++; |
|
1109 INFO_PRINTF1(_L("Unprocessed signals")); |
|
1110 |
|
1111 } |
|
1112 TEST(iReceivers[1]->OutstandingRequest() == EFalse); |
|
1113 TEST(iReceivers[2]->OutstandingRequest() == EFalse); |
|
1114 TEST(iReceivers[0]->OutstandingRequest()); //receiver is signalled last, in since its priority is lowest, |
|
1115 //SUS shouldn’t wait for it before the signal goes back to client |
|
1116 } |
|
1117 |
|
1118 INFO_PRINTF2(_L("Number unprocessed signals %d"), numUnprocessedSignals); |
|
1119 TEST(numUnprocessedSignals > 0); |
|
1120 |
|
1121 //restore envorienment |
|
1122 iReceivers[0]->SetInternalPriority(EPriorityNormal); |
|
1123 iReceivers[1]->SetInternalPriority(EPriorityNormal); |
|
1124 iReceivers[2]->SetInternalPriority(EPriorityNormal); |
|
1125 iReceivers[2]->SetVisible(ETrue); |
|
1126 User::After(TTimeIntervalMicroSeconds32(100000)); //make sure that priority takes place |
|
1127 WaitUntilAllNotificationsProcessed(); |
|
1128 |
|
1129 session.Close(); |
|
1130 } |
|
1131 |
|
1132 /** |
|
1133 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0029 |
|
1134 |
|
1135 |
|
1136 @SYMPREQ 1007/11596 |
|
1137 |
|
1138 @SYMREQ 8223 |
|
1139 |
|
1140 @SYMTestCaseDesc Register with identical priorities. |
|
1141 |
|
1142 @SYMTestPriority High |
|
1143 |
|
1144 @SYMTestStatus Implemented |
|
1145 |
|
1146 @SYMTestActions |
|
1147 1. Start the server. |
|
1148 2. Create two content update receivers |
|
1149 3. Register receiverA using Register() with a priority |
|
1150 4. Register receiverB using Register() with the same priority |
|
1151 5. Unregister receiverA |
|
1152 6. Register receiverB using Register() with the same priority as before |
|
1153 |
|
1154 @SYMTestExpectedResults |
|
1155 Step 4 should fail, returning KErrAlreadyExists. |
|
1156 Step 6 should succeed. |
|
1157 */ |
|
1158 void CTSurfaceUpdate::TestCaseRegisterIdenticalPrioritiesL() |
|
1159 { |
|
1160 INFO_PRINTF1(_L("Register with identical priorities test")); |
|
1161 const TInt KIdenticalPriority = 100; |
|
1162 |
|
1163 // Start two content update receivers for register test |
|
1164 CTContentUpdateReceiver* receiverA; |
|
1165 CTContentUpdateReceiver* receiverB; |
|
1166 User::LeaveIfError(StartTestUpdateReceiver(receiverA, 8)); |
|
1167 iReceivers.AppendL(receiverA); |
|
1168 User::LeaveIfError(StartTestUpdateReceiver(receiverB, 9)); |
|
1169 iReceivers.AppendL(receiverB); |
|
1170 |
|
1171 INFO_PRINTF2(_L("Registering receiver A with priority %i"), KIdenticalPriority); |
|
1172 User::LeaveIfError(Provider()->Register(receiverA->Screen(), receiverA, KIdenticalPriority)); |
|
1173 |
|
1174 INFO_PRINTF2(_L("Registering receiver B with the same priority (%i), which should return KErrAlreadyExists"), KIdenticalPriority); |
|
1175 TInt ret = Provider()->Register(receiverB->Screen(), receiverB, KIdenticalPriority); |
|
1176 if(KErrAlreadyExists == ret) |
|
1177 { |
|
1178 INFO_PRINTF1(_L("KErrAlreadyExists returned as expected")); |
|
1179 } |
|
1180 else |
|
1181 { |
|
1182 ERR_PRINTF3(_L("Test failed - expected Register() to return KErrAlreadyExists(%i) but instead returned %i"), KErrAlreadyExists, ret); |
|
1183 User::Leave(ret); |
|
1184 } |
|
1185 |
|
1186 INFO_PRINTF1(_L("Unregistering receiver A")); |
|
1187 User::LeaveIfError(Provider()->Register(receiverA->Screen(), NULL, KIdenticalPriority)); |
|
1188 |
|
1189 INFO_PRINTF2(_L("Registering receiver B with the same priority (%i), which should succeed"), KIdenticalPriority); |
|
1190 User::LeaveIfError(Provider()->Register(receiverB->Screen(), receiverB, KIdenticalPriority)); |
|
1191 } |
|
1192 |
|
1193 /** |
|
1194 negative testing |
|
1195 */ |
|
1196 |
|
1197 |
|
1198 /** |
|
1199 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0006 |
|
1200 |
|
1201 @SYMPREQ 1007 |
|
1202 |
|
1203 @SYMREQ 8223 |
|
1204 |
|
1205 @SYMTestCaseDesc Negative testing - various cases |
|
1206 |
|
1207 @SYMTestPriority High |
|
1208 |
|
1209 @SYMTestStatus Implemented |
|
1210 |
|
1211 @SYMTestActions 6. The client mustn't try to send any command to the server before |
|
1212 establishing a connection. |
|
1213 7. Attempt to connect twice |
|
1214 8. Attempt notify then submit with invalid parameters |
|
1215 9. Submission with screen which doesn't exist in the system |
|
1216 10. Submission with invalid number of counts in NotifyWhenDisplayedXTimes() |
|
1217 11. Number of outstanding requests exceeds pre-defined value |
|
1218 12. Submission of region with empty rectangle list |
|
1219 13. Assigning receiver to the screen with negative number |
|
1220 |
|
1221 @SYMTestExpectedResults 6. Shouldn't panic and subsequent session connect should succeed. |
|
1222 7. Second attempt to connect should return KErrAlreadyExists |
|
1223 8. With invalid parameters we get KErrArgument; with a screen that doesn't exist we |
|
1224 get KErrUpdateReceiverNotAvailable |
|
1225 9. Too big a screen number results in KErrUpdateReceiverNotAvailable; -ve buffer results in KErrArgument. |
|
1226 10. With a negative diplayedXtimes number, we expect KErrArgument |
|
1227 11. When we exceed the number of allowed outstanding requests, we get KErrBusy |
|
1228 12. With empty region, all return codes are KErrNone. |
|
1229 13. Registering with negative screen gives KErrArgument |
|
1230 */ |
|
1231 void CTSurfaceUpdate::TestCase6L() |
|
1232 { |
|
1233 INFO_PRINTF1(_L("negative testing")); |
|
1234 RSurfaceUpdateSession session; |
|
1235 TRequestStatus status; |
|
1236 TRequestStatus status1; |
|
1237 TRequestStatus status2; |
|
1238 TRequestStatus status3; |
|
1239 TRequestStatus status4; |
|
1240 TRequestStatus status5; |
|
1241 TInt res; |
|
1242 TTimeStamp timeStamp; |
|
1243 |
|
1244 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0006 apply operation on disconnected session |
|
1245 TInt screen = 0; |
|
1246 TInt buffer = 2; |
|
1247 TSurfaceId surface = |
|
1248 { |
|
1249 1,2,3,4 |
|
1250 }; |
|
1251 TRect rc[2] = |
|
1252 { |
|
1253 TRect(1,2, 10, 20), |
|
1254 |
|
1255 TRect(5,6, 30, 30) |
|
1256 }; |
|
1257 |
|
1258 RRegion region(2, rc); |
|
1259 |
|
1260 //next command will be ignored, but shouldn't cause a panic |
|
1261 INFO_PRINTF1(_L("close disconnected session")); |
|
1262 session.Close(); |
|
1263 |
|
1264 User::LeaveIfError(session.Connect()); |
|
1265 |
|
1266 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0007 Attempt to connect twice |
|
1267 INFO_PRINTF1(_L("try to connect twice")); |
|
1268 res = session.Connect(); |
|
1269 TEST(res == KErrAlreadyExists); |
|
1270 |
|
1271 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0008 wrong parameters |
|
1272 INFO_PRINTF1(_L("specifying wrong parametrs")); |
|
1273 INFO_PRINTF1(_L("specify a negative screen number")); |
|
1274 screen = -10; |
|
1275 session.NotifyWhenAvailable(status); |
|
1276 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1277 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1278 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1279 User::WaitForRequest(status); |
|
1280 User::WaitForRequest(status1); |
|
1281 User::WaitForRequest(status2); |
|
1282 |
|
1283 TEST(status == KErrArgument); |
|
1284 TEST(status1 == KErrArgument); |
|
1285 TEST(status2 == KErrArgument); |
|
1286 TEST(res == KErrArgument); |
|
1287 |
|
1288 INFO_PRINTF1(_L("receiver for the following screen doesn't exist")); |
|
1289 screen = 10; |
|
1290 session.NotifyWhenAvailable(status); |
|
1291 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1292 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1293 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1294 User::WaitForRequest(status); |
|
1295 User::WaitForRequest(status1); |
|
1296 User::WaitForRequest(status2); |
|
1297 |
|
1298 TEST(status == KErrUpdateReceiverNotAvailable); |
|
1299 TEST(status1 == KErrUpdateReceiverNotAvailable); |
|
1300 TEST(status2 == KErrUpdateReceiverNotAvailable); |
|
1301 TEST(res == KErrUpdateReceiverNotAvailable); |
|
1302 |
|
1303 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0009 Submission with screen which doesn't exist in the system |
|
1304 INFO_PRINTF1(_L("too big screen number")); |
|
1305 screen = 100000; |
|
1306 session.NotifyWhenAvailable(status); |
|
1307 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1308 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1309 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1310 User::WaitForRequest(status); |
|
1311 User::WaitForRequest(status1); |
|
1312 User::WaitForRequest(status2); |
|
1313 |
|
1314 TEST(status == KErrUpdateReceiverNotAvailable); |
|
1315 TEST(status1 == KErrUpdateReceiverNotAvailable); |
|
1316 TEST(status2 == KErrUpdateReceiverNotAvailable); |
|
1317 TEST(res == KErrUpdateReceiverNotAvailable); |
|
1318 |
|
1319 INFO_PRINTF1(_L("negative buffer")); |
|
1320 screen = 0; |
|
1321 buffer = -10; |
|
1322 session.NotifyWhenAvailable(status); |
|
1323 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1324 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1325 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1326 User::WaitForRequest(status); |
|
1327 User::WaitForRequest(status1); |
|
1328 User::WaitForRequest(status2); |
|
1329 |
|
1330 TEST(status == KErrArgument); |
|
1331 TEST(status1 == KErrArgument); |
|
1332 TEST(status2 == KErrArgument); |
|
1333 TEST(res == KErrArgument); |
|
1334 |
|
1335 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0010 Submission with invalid number of counts in NotifyWhenDisplayedXTimes() |
|
1336 INFO_PRINTF1(_L("displaying for negative number of times")); |
|
1337 screen = 0; |
|
1338 buffer = 0; |
|
1339 TInt displayedXTimes = -10; |
|
1340 session.NotifyWhenAvailable(status); |
|
1341 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1342 session.NotifyWhenDisplayedXTimes(displayedXTimes, status2); |
|
1343 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1344 User::WaitForRequest(status); |
|
1345 User::WaitForRequest(status1); |
|
1346 User::WaitForRequest(status2); |
|
1347 |
|
1348 TEST(status == KErrNone); |
|
1349 TEST(status1 == KErrNone); |
|
1350 TEST(status2 == KErrArgument); |
|
1351 TEST(res == KErrNone); |
|
1352 |
|
1353 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0011 Number of outstanding requests exceeds pre-defined value |
|
1354 INFO_PRINTF1(_L("number of outstanding requests exceeds pre-defined value")); |
|
1355 session.Close(); |
|
1356 User::LeaveIfError(session.Connect(4)); |
|
1357 buffer = 0; |
|
1358 session.NotifyWhenAvailable(status); |
|
1359 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1360 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1361 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1362 TEST(res == KErrNone); |
|
1363 |
|
1364 session.NotifyWhenAvailable(status3); |
|
1365 session.NotifyWhenDisplayed(status4, timeStamp); |
|
1366 session.NotifyWhenDisplayedXTimes(10, status5); |
|
1367 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1368 TEST(res == KErrNone); |
|
1369 |
|
1370 User::WaitForRequest(status); |
|
1371 User::WaitForRequest(status1); |
|
1372 User::WaitForRequest(status2); |
|
1373 User::WaitForRequest(status3); |
|
1374 User::WaitForRequest(status4); |
|
1375 User::WaitForRequest(status5); |
|
1376 |
|
1377 TEST(status == KErrNone); |
|
1378 TEST(status1== KErrNone); |
|
1379 TEST(status2== KErrNone); |
|
1380 TEST(status3== KErrNone); |
|
1381 TEST(status4== KErrServerBusy); |
|
1382 TEST(status5== KErrServerBusy); |
|
1383 |
|
1384 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0012 Submission of region with empty rectangle list |
|
1385 INFO_PRINTF1(_L("specify empty region")); |
|
1386 RRegion region1; |
|
1387 session.NotifyWhenAvailable(status); |
|
1388 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1389 session.NotifyWhenDisplayedXTimes(10, status2); |
|
1390 res = session.SubmitUpdate(screen, surface, buffer, ®ion1); |
|
1391 TEST(res == KErrNone); |
|
1392 |
|
1393 User::WaitForRequest(status); |
|
1394 User::WaitForRequest(status1); |
|
1395 User::WaitForRequest(status2); |
|
1396 TEST(status == KErrNone); |
|
1397 TEST(status1== KErrNone); |
|
1398 TEST(status2== KErrNone); |
|
1399 |
|
1400 //register with negative screen |
|
1401 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0013 Assigning receiver to the screen with negative number |
|
1402 INFO_PRINTF1(_L("register with negative screen")); |
|
1403 res = Provider()->Register(-1, NULL, 1); |
|
1404 TEST(res==KErrArgument); |
|
1405 session.Close(); |
|
1406 } |
|
1407 |
|
1408 /** |
|
1409 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0014 |
|
1410 |
|
1411 @SYMPREQ 1007 |
|
1412 |
|
1413 @SYMREQ 8223 |
|
1414 |
|
1415 @SYMTestCaseDesc OOM testing. |
|
1416 |
|
1417 @SYMTestPriority High |
|
1418 |
|
1419 @SYMTestStatus Implemented |
|
1420 |
|
1421 @SYMTestActions Create connection to the server. |
|
1422 Set server in special mode which simulates heap allocation failure. |
|
1423 1. Subscribe for notifications. |
|
1424 2. Submit update command with not empty region. |
|
1425 |
|
1426 @SYMTestExpectedResults Submit return code and notifications must arrive |
|
1427 with KErrNoMemory in the case of memory allocation failures. |
|
1428 */ |
|
1429 void CTSurfaceUpdate::TestCase7L() |
|
1430 { |
|
1431 RMisbehavingSession session; |
|
1432 TRequestStatus status; |
|
1433 TRequestStatus status1; |
|
1434 TRequestStatus status2; |
|
1435 TTimeStamp timeStamp; |
|
1436 TSurfaceId surface = |
|
1437 { |
|
1438 1,2,3,4 |
|
1439 }; |
|
1440 TRect rc[2] = |
|
1441 { |
|
1442 TRect(1,2, 10, 20), |
|
1443 TRect(5,6, 30, 30) |
|
1444 }; |
|
1445 |
|
1446 RRegion region(2, rc); |
|
1447 TInt buffer = 0; |
|
1448 TInt screen = 0; |
|
1449 User::LeaveIfError(session.Connect()); |
|
1450 TInt res = KErrNone; |
|
1451 |
|
1452 //create another receiver |
|
1453 CTContentUpdateReceiver *receiver4; |
|
1454 User::LeaveIfError(StartTestUpdateReceiver(receiver4, 4)); |
|
1455 iReceivers.AppendL(receiver4); |
|
1456 |
|
1457 TInt ii = 1; |
|
1458 const TInt screenNo = 16; |
|
1459 // Cause a failure on all the allocs on server side |
|
1460 for(ii = 1; ; ++ii) |
|
1461 { |
|
1462 session.SetFailRate(ii); |
|
1463 res = Provider()->Register(screenNo, receiver4, -100); |
|
1464 if(res != KErrNoMemory) |
|
1465 break; |
|
1466 } |
|
1467 TEST(res == KErrNone); |
|
1468 //unregister receiver |
|
1469 User::LeaveIfError(Provider()->Register(screenNo, NULL, 0)); |
|
1470 //try to do the same same thing again, to make sure that it won't panic |
|
1471 User::LeaveIfError(Provider()->Register(screenNo, NULL, 0)); //unregister the function |
|
1472 TInt index = iReceivers.Find(receiver4); |
|
1473 TEST(index != KErrNotFound); |
|
1474 CloseTestUpdateReceiver(receiver4); |
|
1475 iReceivers.Remove(index); |
|
1476 //end register testing |
|
1477 |
|
1478 // Cause a failure on all the allocs on server side |
|
1479 for(ii = 1; ; ++ii) |
|
1480 { |
|
1481 // Test 1st alloc failure |
|
1482 session.SetFailRate(ii); |
|
1483 session.NotifyWhenAvailable(status); |
|
1484 session.NotifyWhenDisplayed(status1, timeStamp); |
|
1485 session.NotifyWhenDisplayedXTimes(1, status2); |
|
1486 res = session.SubmitUpdate(screen, surface, buffer, ®ion); |
|
1487 User::WaitForRequest(status); |
|
1488 User::WaitForRequest(status1); |
|
1489 User::WaitForRequest(status2); |
|
1490 |
|
1491 // Whenever we hit error codes that aren't no memory, we're finished |
|
1492 if(res != KErrNoMemory || status.Int() != KErrNoMemory || status1.Int() != KErrNoMemory || status2.Int() != KErrNoMemory) |
|
1493 break; |
|
1494 |
|
1495 TEST(res == KErrNoMemory); // Since the first alloc fail kills the server |
|
1496 TEST(status.Int() == KErrNoMemory); |
|
1497 } |
|
1498 |
|
1499 TEST(res == KErrNone); |
|
1500 TEST((status.Int() == KErrNone) || (status.Int() == KErrNoMemory)); |
|
1501 TEST((status1.Int() == KErrNone) || (status1.Int() == KErrNoMemory)); |
|
1502 TEST((status2.Int() == KErrNone) || (status2.Int() == KErrNoMemory)); |
|
1503 session.SetFailRate(0); // turns off oom failures |
|
1504 session.Close(); |
|
1505 } |
|
1506 |
|
1507 /** |
|
1508 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0015 |
|
1509 |
|
1510 @SYMPREQ 1007 |
|
1511 |
|
1512 @SYMREQ 8223 |
|
1513 |
|
1514 @SYMTestCaseDesc Causing panic of client |
|
1515 |
|
1516 @SYMTestPriority High |
|
1517 |
|
1518 @SYMTestStatus Implemented |
|
1519 |
|
1520 @SYMTestActions Create second thread which connects to the server. |
|
1521 Pass an invalid opcode to the server which will cause a client panic. |
|
1522 |
|
1523 @SYMTestExpectedResults The thread will die with the correct exit reason |
|
1524 (EUpdateServPanicBadRequest) and the correct exit category (SurfUpServ). |
|
1525 */ |
|
1526 void CTSurfaceUpdate::TestCase8() |
|
1527 { |
|
1528 // Create another thread in which we will panic the client |
|
1529 _LIT(KThreadName, "TestPanicClientThread"); |
|
1530 RThread thread; |
|
1531 TEST(KErrNone == thread.Create(KThreadName, |
|
1532 PanicClientThread, |
|
1533 KDefaultStackSize, |
|
1534 &User::Heap(), |
|
1535 NULL)); |
|
1536 TRequestStatus rendezvousStatus; |
|
1537 thread.Rendezvous(rendezvousStatus); |
|
1538 thread.Resume(); |
|
1539 User::WaitForRequest(rendezvousStatus); |
|
1540 _LIT(KExitCategory,"SurfUpServ"); |
|
1541 TBuf<16> exitCategory(KExitCategory); |
|
1542 TEST(thread.ExitReason() == EUpdateServPanicBadRequest); |
|
1543 TEST(thread.ExitCategory() == exitCategory); |
|
1544 thread.Close(); |
|
1545 } |
|
1546 |
|
1547 /** |
|
1548 Thread function called from TestCase8L in order to panic the client. |
|
1549 */ |
|
1550 TInt CTSurfaceUpdate::PanicClientThread(TAny*) |
|
1551 { |
|
1552 User::SetJustInTime(EFalse); |
|
1553 RMisbehavingSession session; |
|
1554 TInt err = session.Connect(); |
|
1555 if(KErrNone != err) |
|
1556 return err; |
|
1557 session.TestPassingInvalidOpcode(); |
|
1558 // Exit reason will be the panic number due to the invalid op code: |
|
1559 // returning zero here is redundant |
|
1560 return 0; |
|
1561 } |
|
1562 |
|
1563 /** |
|
1564 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0016 |
|
1565 |
|
1566 |
|
1567 @SYMPREQ 1007 |
|
1568 |
|
1569 @SYMREQ 8223 |
|
1570 |
|
1571 @SYMTestCaseDesc Calling submit before any notify with invalid arguments. |
|
1572 |
|
1573 @SYMTestPriority High |
|
1574 |
|
1575 @SYMTestStatus Implemented |
|
1576 |
|
1577 @SYMTestActions Set an invalid screen number and call SubmitUpdate (before a notify). |
|
1578 Set an invalid buffer number and call SubmitUpdate (before a notify). |
|
1579 Set a Null surfaceId and call SubmitUpdate (before a notify). |
|
1580 |
|
1581 @SYMTestExpectedResults SubmitUpdate will return KErrArgument in both cases. |
|
1582 */ |
|
1583 void CTSurfaceUpdate::TestCase9L() |
|
1584 { |
|
1585 RSurfaceUpdateSession session; |
|
1586 User::LeaveIfError(session.Connect()); |
|
1587 |
|
1588 // Test submit before notify with -ve screen |
|
1589 TInt screen = -1; |
|
1590 TSurfaceId surface = |
|
1591 { |
|
1592 1,2,3,4 |
|
1593 }; |
|
1594 TInt buffer = 1; |
|
1595 TInt res = session.SubmitUpdate(screen, surface, buffer, NULL); |
|
1596 TEST(res == KErrArgument); |
|
1597 |
|
1598 // Test submit before notify with -ve buffer |
|
1599 screen = 1; |
|
1600 buffer = -1; |
|
1601 res = session.SubmitUpdate(screen, surface, buffer, NULL); |
|
1602 TEST(res == KErrArgument); |
|
1603 |
|
1604 //Test submit before notify with Null surfaceId |
|
1605 surface = TSurfaceId::CreateNullId(); |
|
1606 screen = 1; |
|
1607 buffer = 1; |
|
1608 res = session.SubmitUpdate(screen, surface, buffer, NULL); |
|
1609 TEST(res == KErrArgument); |
|
1610 session.Close(); |
|
1611 } |
|
1612 |
|
1613 /** |
|
1614 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0017 |
|
1615 |
|
1616 |
|
1617 @SYMPREQ 1007 |
|
1618 |
|
1619 @SYMREQ 8223 |
|
1620 |
|
1621 @SYMTestCaseDesc Using a rogue client to call multiple notifies in a row. |
|
1622 |
|
1623 @SYMTestPriority High |
|
1624 |
|
1625 @SYMTestStatus Implemented |
|
1626 |
|
1627 @SYMTestActions Create a second thread which will call multiple notifies |
|
1628 in succession (not interleaved with Submits). |
|
1629 |
|
1630 @SYMTestExpectedResults The thread should have an exit category |
|
1631 of SurfUpServ and and exit reason of EUpdateServPanicDataIntegrity in |
|
1632 all cases. |
|
1633 */ |
|
1634 void CTSurfaceUpdate::TestCase10() |
|
1635 { |
|
1636 for(TInt testNum = 0; testNum < 3; ++testNum) |
|
1637 { |
|
1638 _LIT(KThreadName, "TestMultipleNotify%d"); |
|
1639 TBuf<19> threadName; |
|
1640 threadName.Format(KThreadName, testNum); |
|
1641 RThread thread; |
|
1642 TRequestStatus status; |
|
1643 TMultipleNotify statusCol(status, testNum); |
|
1644 TEST(KErrNone == thread.Create(threadName, |
|
1645 TestMultipleNotifyThreadL, |
|
1646 KDefaultStackSize, |
|
1647 &User::Heap(), |
|
1648 &statusCol)); |
|
1649 TRequestStatus rendezvousStatus; |
|
1650 thread.Rendezvous(rendezvousStatus); |
|
1651 thread.Resume(); |
|
1652 User::WaitForRequest(rendezvousStatus); |
|
1653 // We expect the first request to be cancelled. |
|
1654 //The request can also be on a pending state if the connection is closed before the |
|
1655 //cancellation has been transferred to client |
|
1656 TEST((KErrCancel == status.Int()) || (status.Int() == KRequestPending)); |
|
1657 // We expect the second request to Panic the client |
|
1658 _LIT(KExitCategory,"SurfUpServ"); |
|
1659 TBuf<16> exitCategory(KExitCategory); |
|
1660 TEST(thread.ExitReason() == EUpdateServPanicDataIntegrity); |
|
1661 TEST(thread.ExitCategory() == exitCategory); |
|
1662 thread.Close(); |
|
1663 } |
|
1664 } |
|
1665 |
|
1666 /** |
|
1667 Thread function called from TestCase10 in order to submit multiple notifies. |
|
1668 */ |
|
1669 TInt CTSurfaceUpdate::TestMultipleNotifyThreadL(TAny* aStatusCol) |
|
1670 { |
|
1671 User::SetJustInTime(EFalse); |
|
1672 RMisbehavingSession badSession; |
|
1673 User::LeaveIfError(badSession.Connect()); |
|
1674 TMultipleNotify* statusCol = static_cast<TMultipleNotify*>(aStatusCol); |
|
1675 TRequestStatus status; |
|
1676 switch(statusCol->iTestNum) |
|
1677 { |
|
1678 case 0: |
|
1679 badSession.NotifyWhenAvailableNoChecking(statusCol->iStatus); |
|
1680 badSession.NotifyWhenAvailableNoChecking(status); |
|
1681 break; |
|
1682 case 1: |
|
1683 badSession.NotifyWhenDisplayedNoChecking(statusCol->iStatus); |
|
1684 badSession.NotifyWhenDisplayedNoChecking(status); |
|
1685 break; |
|
1686 case 2: |
|
1687 badSession.NotifyWhenDisplayedXTimesNoChecking(10, statusCol->iStatus); |
|
1688 badSession.NotifyWhenDisplayedXTimesNoChecking(10, status); |
|
1689 break; |
|
1690 default: |
|
1691 _LIT(KMultipleNotifyPanic, "MultNotifyPanic"); |
|
1692 User::Panic(KMultipleNotifyPanic, 1); |
|
1693 break; |
|
1694 } |
|
1695 User::WaitForRequest(statusCol->iStatus); |
|
1696 User::WaitForRequest(status); |
|
1697 // Exit reason will be the panic number due to the invalid op code: |
|
1698 // returning zero here is redundant |
|
1699 return 0; |
|
1700 } |
|
1701 |
|
1702 /** |
|
1703 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0018 |
|
1704 |
|
1705 @SYMPREQ 1007 |
|
1706 |
|
1707 @SYMREQ 8223 |
|
1708 |
|
1709 @SYMTestCaseDesc Use a rogue client to misbehave in various ways. |
|
1710 |
|
1711 @SYMTestPriority High |
|
1712 |
|
1713 @SYMTestStatus Implemented |
|
1714 |
|
1715 @SYMTestActions 1. Attempt to connect with an incorrect version number. |
|
1716 Connect to the server, communicate with server without proper client side checking: |
|
1717 2. Submit update with a negative buffer number (no client side checking). |
|
1718 3. Submit update with a negative screen number (no client side checking). |
|
1719 4. Call NotifyWhenDisplayedXTimes with no client side checking and a count of 0. |
|
1720 |
|
1721 @SYMTestExpectedResults 1. KErrNotSupported |
|
1722 2. KErrArgument |
|
1723 3. KErrArgument |
|
1724 4. Status int is KErrArgument (SubmitUpdate == KErrNone). |
|
1725 */ |
|
1726 void CTSurfaceUpdate::TestCase11() |
|
1727 { |
|
1728 // Attempt to connect with the wrong version number |
|
1729 RMisbehavingSession session; |
|
1730 TEST(KErrNotSupported == session.Connect(KDefaultMessageSlot, ETrue)); |
|
1731 |
|
1732 TEST(KErrNone == session.Connect()); |
|
1733 TInt screen = 0; |
|
1734 TSurfaceId surface = |
|
1735 { |
|
1736 1,2,3,4 |
|
1737 }; |
|
1738 TInt buffer = -1; |
|
1739 |
|
1740 // Call RMisbehavingSession::SubmitUpdate which doesn't do the correct |
|
1741 // client side checking |
|
1742 TEST(KErrArgument == session.SubmitUpdateNoChecking(screen, surface, buffer, NULL)); |
|
1743 |
|
1744 // Test with -ve screen |
|
1745 screen = -1; |
|
1746 buffer = 0; |
|
1747 TEST(KErrArgument == session.SubmitUpdateNoChecking(screen, surface, buffer, NULL)); |
|
1748 |
|
1749 // Test calling NotifyWhenDisplayedXTimes with no client side checking and a count of 0 |
|
1750 screen = 0; |
|
1751 buffer = 1; |
|
1752 TRequestStatus status; |
|
1753 session.NotifyWhenDisplayedXTimesNoChecking(0, status); |
|
1754 TEST(KErrNone == session.SubmitUpdateNoChecking(screen, surface, buffer, NULL)); |
|
1755 User::WaitForRequest(status); |
|
1756 TEST(KErrArgument == status.Int()); |
|
1757 |
|
1758 session.Close(); |
|
1759 } |
|
1760 |
|
1761 /** |
|
1762 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0019 |
|
1763 |
|
1764 |
|
1765 @SYMPREQ 1007 |
|
1766 |
|
1767 @SYMREQ 8223 |
|
1768 |
|
1769 @SYMTestCaseDesc Starting the surface update server in two different threads. |
|
1770 |
|
1771 @SYMTestPriority High |
|
1772 |
|
1773 @SYMTestStatus Implemented |
|
1774 |
|
1775 @SYMTestActions Start the surface update server in two different threads. |
|
1776 |
|
1777 @SYMTestExpectedResults Thread 1: KErrNone |
|
1778 Thread 2: KErrAlreadyExists. |
|
1779 */ |
|
1780 void CTSurfaceUpdate::TestCase12L() |
|
1781 { |
|
1782 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
|
1783 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
|
1784 TEST(res == KErrNone); |
|
1785 User::LeaveIfError(res); |
|
1786 |
|
1787 _LIT(KThreadName, "TestServerStartupTwoThreads"); |
|
1788 TTime tm; |
|
1789 TBuf<32> buf; |
|
1790 tm.UniversalTime(); |
|
1791 TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C"))); |
|
1792 TEST(res == KErrNone); |
|
1793 User::LeaveIfError(res); |
|
1794 TBuf<128> threadName(KThreadName); |
|
1795 threadName.Append(buf); //guarantee uniqueness of the thread name |
|
1796 RThread thread; |
|
1797 res = thread.Create(threadName, |
|
1798 TestServerStartupTwoThreads, |
|
1799 KDefaultStackSize, |
|
1800 &User::Heap(), |
|
1801 NULL); |
|
1802 TEST(res == KErrNone); |
|
1803 User::LeaveIfError(res); |
|
1804 TRequestStatus rendezvousStatus; |
|
1805 thread.Rendezvous(rendezvousStatus); |
|
1806 thread.Resume(); |
|
1807 User::WaitForRequest(rendezvousStatus); |
|
1808 TEST(KErrAlreadyExists == rendezvousStatus.Int()); |
|
1809 } |
|
1810 |
|
1811 /** |
|
1812 Starting the update server in another thread - called from TestCase12 |
|
1813 */ |
|
1814 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny*) |
|
1815 { |
|
1816 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL; |
|
1817 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider); |
|
1818 return res; |
|
1819 } |
|
1820 |
|
1821 /** |
|
1822 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020 |
|
1823 |
|
1824 @SYMPREQ 1007 |
|
1825 |
|
1826 @SYMREQ 8223 |
|
1827 |
|
1828 @SYMTestCaseDesc Requesting notifies, leaving enough time for them to |
|
1829 complete before requesting the subsequent notification. |
|
1830 |
|
1831 @SYMTestPriority High |
|
1832 |
|
1833 @SYMTestStatus Implemented |
|
1834 |
|
1835 @SYMTestActions Execute some notifies and submits, wait for a short period (100us), |
|
1836 then cancel them all. |
|
1837 |
|
1838 @SYMTestExpectedResults Two results are acceptable: KErrNone (notify |
|
1839 completed before it was cancelled) or KErrCancel (notify sucessfully cancelled). |
|
1840 */ |
|
1841 void CTSurfaceUpdate::TestCase13L() |
|
1842 { |
|
1843 RSurfaceUpdateSession session; |
|
1844 const TInt numNotifies = 10; |
|
1845 User::LeaveIfError(session.Connect(numNotifies)); |
|
1846 |
|
1847 TRequestStatus statusArray[numNotifies]; |
|
1848 TInt screen = 0; |
|
1849 TSurfaceId surface = |
|
1850 { |
|
1851 1,2,3,4 |
|
1852 }; |
|
1853 TInt buffer = 1; |
|
1854 |
|
1855 // Send the same type of notification request multiply, cancelling after each submission |
|
1856 for(TInt ii = 0; ii < numNotifies; ++ii) |
|
1857 { |
|
1858 session.NotifyWhenAvailable(statusArray[ii]); |
|
1859 TEST(KErrNone == session.SubmitUpdate(screen, surface, buffer, NULL)); |
|
1860 session.CancelAllUpdateNotifications(); |
|
1861 User::After(100); // Enough time for the notify to be processed |
|
1862 } |
|
1863 |
|
1864 // Check that the error codes are acceptable |
|
1865 for(TInt ii = 0; ii < numNotifies; ++ii) |
|
1866 { |
|
1867 TInt ret = statusArray[ii].Int(); |
|
1868 TEST(statusArray[ii].Int() == KErrNone || statusArray[ii].Int() == KErrCancel); |
|
1869 } |
|
1870 |
|
1871 session.Close(); |
|
1872 } |
|
1873 |
|
1874 /** |
|
1875 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0021 |
|
1876 |
|
1877 @SYMPREQ 1007 |
|
1878 |
|
1879 @SYMREQ 8223 |
|
1880 |
|
1881 @SYMTestCaseDesc Terminating and restarting the server. |
|
1882 |
|
1883 @SYMTestPriority High |
|
1884 |
|
1885 @SYMTestStatus Implemented |
|
1886 |
|
1887 @SYMTestActions Terminate and restart the server |
|
1888 |
|
1889 @SYMTestExpectedResults Test that trying to connect the session after |
|
1890 termination of the server results in KErrNotFound, and that the server |
|
1891 can be restarted with result KErrNone. |
|
1892 */ |
|
1893 void CTSurfaceUpdate::TestCaseTerminateServer() |
|
1894 { |
|
1895 (static_cast <CTSurfaceUpdateStep*> (iStep)) ->TerminateServer(); |
|
1896 |
|
1897 //at that point server has been terminated |
|
1898 RSurfaceUpdateSession session; |
|
1899 TInt res = session.Connect(); |
|
1900 TEST(res == KErrNotFound); |
|
1901 session.Close(); |
|
1902 |
|
1903 res = (static_cast <CTSurfaceUpdateStep*> (iStep)) ->StartServer(); |
|
1904 TEST(res == KErrNone); |
|
1905 res = session.Connect(); |
|
1906 TEST(res == KErrNone); |
|
1907 session.Close(); |
|
1908 } |
|
1909 |
|
1910 /** |
|
1911 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0022 |
|
1912 |
|
1913 @SYMPREQ 1007 |
|
1914 |
|
1915 @SYMREQ 8223 |
|
1916 |
|
1917 @SYMTestCaseDesc Terminating the thread while some outstanding request in progress. |
|
1918 |
|
1919 @SYMTestPriority High |
|
1920 |
|
1921 @SYMTestStatus Implemented |
|
1922 |
|
1923 @SYMTestActions Terminate the thread which has outstanding request to |
|
1924 the server for surface update notifications. |
|
1925 |
|
1926 @SYMTestExpectedResults Surface update surface should process the request |
|
1927 and try to send notification without hanging. |
|
1928 |
|
1929 */ |
|
1930 void CTSurfaceUpdate::TestCase14() |
|
1931 { |
|
1932 _LIT(KThreadNameTemplate, "TestPanicClientThread1_%d"); |
|
1933 |
|
1934 RThread thread; |
|
1935 const TInt KMaxIndex = 50; |
|
1936 for(TInt index = 0; index < KMaxIndex; index++) |
|
1937 { |
|
1938 const TInt KUnexpectedLeavePanic = 194; |
|
1939 TBuf<128> threadName; |
|
1940 threadName.Format(KThreadNameTemplate, index); |
|
1941 TInt res = thread.Create(threadName, |
|
1942 PanicClientThread1, |
|
1943 KDefaultStackSize, |
|
1944 &User::Heap(), |
|
1945 this); |
|
1946 TEST(res == KErrNone); |
|
1947 TRequestStatus status = KRequestPending; |
|
1948 thread.Logon(status); |
|
1949 thread.Resume(); |
|
1950 User::WaitForRequest(status); |
|
1951 |
|
1952 res = thread.ExitReason(); |
|
1953 TEST(res == KUnexpectedLeavePanic); |
|
1954 if(res != KUnexpectedLeavePanic) |
|
1955 { |
|
1956 INFO_PRINTF2(_L("Thread exits with error code %d"), res); |
|
1957 } |
|
1958 thread.Close(); |
|
1959 } |
|
1960 } |
|
1961 |
|
1962 /** |
|
1963 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0025 |
|
1964 |
|
1965 @SYMPREQ 1007/11599, 1007/11600, 1007/11601 |
|
1966 |
|
1967 @SYMREQ 8223 |
|
1968 |
|
1969 @SYMTestCaseDesc SubmitUpdate() with a global and a per-display |
|
1970 update cannot be mixed. |
|
1971 @SYMTestPriority High |
|
1972 |
|
1973 @SYMTestStatus Implemented |
|
1974 |
|
1975 @SYMTestActions |
|
1976 Create the session and make a global submit update. |
|
1977 Subscribe for all notifications and make per screen submit update. |
|
1978 Create another session and make a per screen update. |
|
1979 Subscribe for all notifications and make a global submit update. |
|
1980 |
|
1981 |
|
1982 @SYMTestExpectedResults |
|
1983 Mixing two different types of submit update should fail with an error KErrNotSupported. |
|
1984 */ |
|
1985 void CTSurfaceUpdate::TestCase18() |
|
1986 { |
|
1987 INFO_PRINTF1(_L("SubmitUpdate() to deal with both a global and a per-display update in the same session")); |
|
1988 |
|
1989 RSurfaceUpdateSession session; |
|
1990 TInt buffer = 2; |
|
1991 TSurfaceId surface = |
|
1992 { |
|
1993 1,2,3,4 |
|
1994 }; |
|
1995 |
|
1996 TInt res = session.Connect(); |
|
1997 TEST(res == KErrNone); |
|
1998 |
|
1999 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
2000 TEST(res==KErrNone); |
|
2001 |
|
2002 TRequestStatus status = KRequestPending; |
|
2003 TRequestStatus status1 = KRequestPending; |
|
2004 TRequestStatus status2 = KRequestPending; |
|
2005 TTimeStamp timeStamp; |
|
2006 |
|
2007 session.NotifyWhenAvailable(status); |
|
2008 session.NotifyWhenDisplayed(status1, timeStamp); |
|
2009 session.NotifyWhenDisplayedXTimes(10, status2); |
|
2010 |
|
2011 res = session.SubmitUpdate(1, surface, buffer, NULL); |
|
2012 TEST(res==KErrNotSupported); |
|
2013 |
|
2014 User::WaitForRequest(status); |
|
2015 User::WaitForRequest(status1); |
|
2016 User::WaitForRequest(status2); |
|
2017 |
|
2018 TEST(status == KErrNotSupported); |
|
2019 TEST(status1 == KErrNotSupported); |
|
2020 TEST(status2 == KErrNotSupported); |
|
2021 |
|
2022 session.Close(); |
|
2023 //make per screen update first |
|
2024 res = session.Connect(); |
|
2025 TEST(res == KErrNone); |
|
2026 |
|
2027 res = session.SubmitUpdate(1, surface, buffer, NULL); |
|
2028 TEST(res==KErrNone); |
|
2029 |
|
2030 status = KRequestPending; |
|
2031 status1 = KRequestPending; |
|
2032 status2 = KRequestPending; |
|
2033 |
|
2034 session.NotifyWhenAvailable(status); |
|
2035 session.NotifyWhenDisplayed(status1, timeStamp); |
|
2036 session.NotifyWhenDisplayedXTimes(10, status2); |
|
2037 |
|
2038 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL); |
|
2039 TEST(res==KErrNotSupported); |
|
2040 |
|
2041 User::WaitForRequest(status); |
|
2042 User::WaitForRequest(status1); |
|
2043 User::WaitForRequest(status2); |
|
2044 |
|
2045 TEST(status == KErrNotSupported); |
|
2046 TEST(status1 == KErrNotSupported); |
|
2047 TEST(status2 == KErrNotSupported); |
|
2048 |
|
2049 session.Close(); |
|
2050 } |
|
2051 |
|
2052 /** |
|
2053 Thread function called from TestCase14 in order to panic the client |
|
2054 */ |
|
2055 TInt CTSurfaceUpdate::PanicClientThread1(TAny* aAny) |
|
2056 { |
|
2057 CTSurfaceUpdate* surfaceUpdateTest = (CTSurfaceUpdate*) aAny; |
|
2058 surfaceUpdateTest->GenerateMultipleUpdateWithPanic(); |
|
2059 |
|
2060 return 0; |
|
2061 } |
|
2062 |
|
2063 /** |
|
2064 Helper function for test case described in TestCase14 |
|
2065 */ |
|
2066 void CTSurfaceUpdate::GenerateMultipleUpdateWithPanic() |
|
2067 { |
|
2068 TRequestStatus status = KRequestPending; |
|
2069 TTimeStamp timeStamp; |
|
2070 RSurfaceUpdateSession session; |
|
2071 TInt screen = 0; |
|
2072 TSurfaceId surface = |
|
2073 { |
|
2074 1,2,3,4 |
|
2075 }; |
|
2076 TInt buffer = 0; |
|
2077 |
|
2078 TInt res = session.Connect(); |
|
2079 TEST(res == KErrNone); |
|
2080 session.NotifyWhenDisplayed(status, timeStamp); |
|
2081 res = session.SubmitUpdate(screen, surface, buffer); |
|
2082 TEST(res == KErrNone); |
|
2083 User::After(TTimeIntervalMicroSeconds32(100000)); |
|
2084 |
|
2085 User::PanicUnexpectedLeave(); |
|
2086 } |
|
2087 |
|
2088 void CTSurfaceUpdate::ResetSusL() |
|
2089 { |
|
2090 while (iReceivers.Count() > 0) |
|
2091 { |
|
2092 CTContentUpdateReceiver *receiver = iReceivers[0]; |
|
2093 iReceivers.Remove(0); |
|
2094 CloseTestUpdateReceiver(receiver); |
|
2095 } |
|
2096 (static_cast<CTSurfaceUpdateStep*>(iStep))->TerminateServer(); |
|
2097 User::LeaveIfError((static_cast<CTSurfaceUpdateStep*>(iStep))->StartServer()); |
|
2098 } |
|
2099 |
|
2100 void CTSurfaceUpdate::SetupTestCaseRegisterPanicL() |
|
2101 { |
|
2102 ResetSusL(); |
|
2103 // Start two content update receivers for register test |
|
2104 CTContentUpdateReceiver* receiverA; |
|
2105 CTContentUpdateReceiver* receiverB; |
|
2106 User::LeaveIfError(StartTestUpdateReceiver(receiverA, 0)); |
|
2107 iReceivers.AppendL(receiverA); |
|
2108 User::LeaveIfError(StartTestUpdateReceiver(receiverB, 1)); |
|
2109 iReceivers.AppendL(receiverB); |
|
2110 } |
|
2111 |
|
2112 void CTSurfaceUpdate::DoTestCaseRegisterPanicL(TThreadFunction aThreadFunction) |
|
2113 { |
|
2114 _LIT(KRegisterThreadName, "TestPanicRegisterThread"); |
|
2115 RThread thread; |
|
2116 TInt res = thread.Create(KRegisterThreadName, aThreadFunction, |
|
2117 KDefaultStackSize, &User::Heap(), this); |
|
2118 TEST(res == KErrNone); |
|
2119 User::LeaveIfError(res); |
|
2120 TRequestStatus status = KRequestPending; |
|
2121 thread.Logon(status); |
|
2122 thread.Resume(); |
|
2123 User::WaitForRequest(status); |
|
2124 |
|
2125 res = thread.ExitReason(); |
|
2126 TEST(res == EUpdateServPanicRegister); |
|
2127 if(res != EUpdateServPanicRegister) |
|
2128 { |
|
2129 ERR_PRINTF2(_L("Thread exits with error code %d"), res); |
|
2130 } |
|
2131 thread.Close(); |
|
2132 } |
|
2133 |
|
2134 /** |
|
2135 * Ensure that there is no outstanding request from all receivers |
|
2136 */ |
|
2137 void CTSurfaceUpdate::WaitUntilAllNotificationsProcessed() |
|
2138 { |
|
2139 const TInt KMaxIterationNumber = 10; |
|
2140 TInt ii = 0; |
|
2141 for(; ii < KMaxIterationNumber; ii++) |
|
2142 { |
|
2143 if(((iReceivers[0]->OutstandingRequest() == EFalse)) && |
|
2144 ((iReceivers[1]->OutstandingRequest() == EFalse)) && |
|
2145 ((iReceivers[2]->OutstandingRequest() == EFalse))) |
|
2146 break; |
|
2147 INFO_PRINTF2(_L("Wait until all notification processed, iteration %d"), ii); |
|
2148 User::After(KCompositionIntervalLong); |
|
2149 } |
|
2150 TEST(ii < KMaxIterationNumber);//We have waited enough, if it fails, something weird going on |
|
2151 } |
|
2152 |
|
2153 void CTSurfaceUpdate::RunTestCaseL(TInt aCurTestCase) |
|
2154 { |
|
2155 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
2156 switch(aCurTestCase) |
|
2157 { |
|
2158 case 1: |
|
2159 { |
|
2160 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0001")); |
|
2161 if((static_cast <CTSurfaceUpdateStep*> (iStep)) -> iGce) |
|
2162 { |
|
2163 INFO_PRINTF1(_L("TestCase1")); |
|
2164 TRAPD(ret, TestCase1()); |
|
2165 TEST(ret == KErrNone); |
|
2166 } |
|
2167 else |
|
2168 { |
|
2169 TestComplete(); |
|
2170 } |
|
2171 break; |
|
2172 } |
|
2173 case 2: |
|
2174 { |
|
2175 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0002")); |
|
2176 INFO_PRINTF1(_L("TestCase2L")); |
|
2177 TRAPD(ret, TestCase2L()); |
|
2178 TEST(ret == KErrNone); |
|
2179 break; |
|
2180 } |
|
2181 case 3: |
|
2182 { |
|
2183 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0003")); |
|
2184 INFO_PRINTF1(_L("TestCase3L")); |
|
2185 TRAPD(ret, TestCase3L()); |
|
2186 TEST(ret == KErrNone); |
|
2187 break; |
|
2188 } |
|
2189 case 4: |
|
2190 { |
|
2191 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0004")); |
|
2192 INFO_PRINTF1(_L("TestCase4L")); |
|
2193 TRAPD(ret, TestCase4L()); |
|
2194 TEST(ret == KErrNone); |
|
2195 break; |
|
2196 } |
|
2197 case 5: |
|
2198 { |
|
2199 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0005")); |
|
2200 INFO_PRINTF1(_L("TestCase5L")); |
|
2201 TRAPD(ret, TestCase5L()); |
|
2202 TEST(ret == KErrNone); |
|
2203 break; |
|
2204 } |
|
2205 case 6: |
|
2206 { |
|
2207 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0006")); |
|
2208 INFO_PRINTF1(_L("TestCase6L")); |
|
2209 TRAPD(ret, TestCase6L()); |
|
2210 TEST(ret == KErrNone); |
|
2211 break; |
|
2212 } |
|
2213 case 7: |
|
2214 { |
|
2215 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0014")); |
|
2216 INFO_PRINTF1(_L("TestCase7L")); |
|
2217 TRAPD(ret, TestCase7L()); |
|
2218 TEST(ret == KErrNone); |
|
2219 break; |
|
2220 } |
|
2221 case 8: |
|
2222 { |
|
2223 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0015")); |
|
2224 INFO_PRINTF1(_L("TestCase8")); |
|
2225 TRAPD(ret, TestCase8()); |
|
2226 TEST(ret == KErrNone); |
|
2227 break; |
|
2228 } |
|
2229 case 9: |
|
2230 { |
|
2231 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0016")); |
|
2232 INFO_PRINTF1(_L("TestCase9L")); |
|
2233 TRAPD(ret, TestCase9L()); |
|
2234 TEST(ret == KErrNone); |
|
2235 break; |
|
2236 } |
|
2237 case 10: |
|
2238 { |
|
2239 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0017")); |
|
2240 INFO_PRINTF1(_L("TestCase10")); |
|
2241 TRAPD(ret, TestCase10()); |
|
2242 TEST(ret == KErrNone); |
|
2243 break; |
|
2244 } |
|
2245 case 11: |
|
2246 { |
|
2247 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0018")); |
|
2248 INFO_PRINTF1(_L("TestCase11")); |
|
2249 TRAPD(ret, TestCase11()); |
|
2250 TEST(ret == KErrNone); |
|
2251 break; |
|
2252 } |
|
2253 case 12: |
|
2254 { |
|
2255 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019")); |
|
2256 INFO_PRINTF1(_L("TestCase12")); |
|
2257 TRAPD(ret, TestCase12L()); |
|
2258 TEST(ret == KErrNone); |
|
2259 break; |
|
2260 } |
|
2261 case 13: |
|
2262 { |
|
2263 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020")); |
|
2264 INFO_PRINTF1(_L("TestCase13L")); |
|
2265 TRAPD(ret, TestCase13L()); |
|
2266 TEST(ret == KErrNone); |
|
2267 break; |
|
2268 } |
|
2269 case 14: |
|
2270 { |
|
2271 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0022")); |
|
2272 INFO_PRINTF1(_L("TestCase14")); |
|
2273 TestCase14(); |
|
2274 break; |
|
2275 } |
|
2276 case 15: |
|
2277 { |
|
2278 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0023")); |
|
2279 INFO_PRINTF1(_L("TestCase15")); |
|
2280 TRAPD(ret, TestCase15()); |
|
2281 TEST(ret == KErrNone); |
|
2282 break; |
|
2283 } |
|
2284 case 16: |
|
2285 { |
|
2286 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0024")); |
|
2287 INFO_PRINTF1(_L("TestCase16")); |
|
2288 TRAPD(ret, TestCase16L()); |
|
2289 TEST(ret == KErrNone); |
|
2290 break; |
|
2291 } |
|
2292 case 17: |
|
2293 { |
|
2294 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0028")); |
|
2295 INFO_PRINTF1(_L("TestCase17")); |
|
2296 TRAPD(ret, TestCase17()); |
|
2297 TEST(ret == KErrNone); |
|
2298 break; |
|
2299 } |
|
2300 case 18: |
|
2301 { |
|
2302 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0025")); |
|
2303 INFO_PRINTF1(_L("TestCase18")); |
|
2304 TRAPD(ret, TestCase18()); |
|
2305 TEST(ret == KErrNone); |
|
2306 break; |
|
2307 } |
|
2308 case 19: |
|
2309 { |
|
2310 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0027")); |
|
2311 INFO_PRINTF1(_L("TestCaseNotifyWhenAvailableGlobal")); |
|
2312 TRAPD(ret, TestCaseNotifyWhenAvailableGlobal()); |
|
2313 TEST(ret == KErrNone); |
|
2314 break; |
|
2315 } |
|
2316 case 20: |
|
2317 { |
|
2318 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0029")); |
|
2319 INFO_PRINTF1(_L("TestCaseRegisterIdenticalPrioritiesL")); |
|
2320 TRAPD(ret, TestCaseRegisterIdenticalPrioritiesL()); |
|
2321 TEST(ret == KErrNone); |
|
2322 break; |
|
2323 } |
|
2324 case 21: |
|
2325 {//should be the last test case |
|
2326 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0021")); |
|
2327 INFO_PRINTF1(_L("TestCaseTerminateServer")); |
|
2328 TRAPD(ret, TestCaseTerminateServer()); |
|
2329 TEST(ret == KErrNone); |
|
2330 break; |
|
2331 } |
|
2332 default: |
|
2333 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
2334 ((CTSurfaceUpdateStep*)iStep)->CloseTMSGraphicsStep(); |
|
2335 TestComplete(); |
|
2336 break; |
|
2337 } |
|
2338 ((CTSurfaceUpdateStep*)iStep)->RecordTestResultL(); |
|
2339 } |
|
2340 |
|
2341 //-------------- |
|
2342 __CONSTRUCT_STEP__(SurfaceUpdate) |
|
2343 |
|
2344 void CTSurfaceUpdateStep::TestSetupL() |
|
2345 { |
|
2346 #ifdef __WINS__ |
|
2347 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &iGce); |
|
2348 #else |
|
2349 iGce = ETrue; |
|
2350 // we would need to check here whether it is gce-mode or not. |
|
2351 #endif |
|
2352 if(iGce) |
|
2353 { |
|
2354 User::LeaveIfError(StartServer()); |
|
2355 } |
|
2356 else |
|
2357 {//it should work for both cases, but that would be waste of time |
|
2358 INFO_PRINTF1(_L("This test must be run in the GCE environment")); |
|
2359 } |
|
2360 } |
|
2361 |
|
2362 void CTSurfaceUpdateStep::TestClose() |
|
2363 { |
|
2364 TerminateServer(); |
|
2365 } |
|
2366 |
|
2367 TInt CTSurfaceUpdateStep::StartServer() |
|
2368 { |
|
2369 return StartSurfaceUpdateServer(iSurfaceUpdateProvider); |
|
2370 } |
|
2371 |
|
2372 void CTSurfaceUpdateStep::TerminateServer() |
|
2373 { |
|
2374 if(iSurfaceUpdateProvider) |
|
2375 { |
|
2376 iSurfaceUpdateProvider->Terminate(); |
|
2377 iSurfaceUpdateProvider = NULL; |
|
2378 } |
|
2379 } |
|
2380 |
|
2381 //------------- |
|
2382 // Code for client that doesn't quite behave as it should |
|
2383 |
|
2384 TInt RMisbehavingSession::Connect(TInt aMessageSlots, TBool aWrongVersion /*= false*/) |
|
2385 { |
|
2386 if(Handle()) |
|
2387 { |
|
2388 return KErrAlreadyExists; |
|
2389 } |
|
2390 iStatusAvailable = NULL; |
|
2391 iStatusDisplayed = NULL; |
|
2392 iStatusDisplayedXTimes = NULL; |
|
2393 if(aWrongVersion) |
|
2394 return CreateSession(KTestSurfaceUpdateServerName, WrongVersion(), aMessageSlots); |
|
2395 else |
|
2396 return CreateSession(KTestSurfaceUpdateServerName, Version(), aMessageSlots); |
|
2397 } |
|
2398 |
|
2399 |
|
2400 void RMisbehavingSession::Close() |
|
2401 { |
|
2402 if(Handle()) |
|
2403 { |
|
2404 RHandleBase::Close(); |
|
2405 } |
|
2406 iStatusAvailable = NULL; |
|
2407 iStatusDisplayed = NULL; |
|
2408 iStatusDisplayedXTimes = NULL; |
|
2409 } |
|
2410 |
|
2411 TVersion RMisbehavingSession::Version() const |
|
2412 { |
|
2413 return (TVersion(KSurfaceUpdateServMajorVersionNumber, KSurfaceUpdateServMinorVersionNumber, KSurfaceUpdateServBuildVersionNumber)); |
|
2414 } |
|
2415 |
|
2416 TVersion RMisbehavingSession::WrongVersion() const |
|
2417 { |
|
2418 return (TVersion(KSurfaceUpdateServMajorVersionNumber + 1, KSurfaceUpdateServMinorVersionNumber + 1, KSurfaceUpdateServBuildVersionNumber + 1)); |
|
2419 } |
|
2420 |
|
2421 /** |
|
2422 Send the NotifyWhenAvailable request directly to the server (without waiting for submit) |
|
2423 */ |
|
2424 void RMisbehavingSession::NotifyWhenAvailableNoChecking(TRequestStatus& aStatus) |
|
2425 { |
|
2426 SendReceive(EUpdateServNotifyWhenAvailable, aStatus); |
|
2427 } |
|
2428 |
|
2429 /** |
|
2430 Send the NotifyWhenDisplayed request directly to the server (without waiting for submit) |
|
2431 */ |
|
2432 void RMisbehavingSession::NotifyWhenDisplayedNoChecking(TRequestStatus& aStatus) |
|
2433 { |
|
2434 TTimeStamp* timeStamp = NULL; |
|
2435 TIpcArgs args(timeStamp); |
|
2436 SendReceive(EUpdateServNotifyWhenDisplayed, args, aStatus); |
|
2437 } |
|
2438 |
|
2439 /** |
|
2440 Send the NotifyWhenDisplayedXTimes request directly to the server (without waiting for submit) |
|
2441 */ |
|
2442 void RMisbehavingSession::NotifyWhenDisplayedXTimesNoChecking(TInt aCount, TRequestStatus& aStatus) |
|
2443 { |
|
2444 TIpcArgs args(aCount); |
|
2445 SendReceive(EUpdateServNotifyWhenDisplayedXTimes, args, aStatus); |
|
2446 } |
|
2447 |
|
2448 /** |
|
2449 Submit an update to the server without doing any checking of values such as screen number and buffer |
|
2450 */ |
|
2451 TInt RMisbehavingSession::SubmitUpdateNoChecking(TInt aScreen, const TSurfaceId& aSurfaceId, |
|
2452 TInt aBuffer, const TRegion* aDirtyRegion) |
|
2453 { |
|
2454 TPckgC<TSurfaceId> pckgSurfaceId(aSurfaceId); |
|
2455 TIpcArgs theArgs(aScreen, &pckgSurfaceId, aBuffer); |
|
2456 if(aDirtyRegion) |
|
2457 { |
|
2458 const TInt regionCount = aDirtyRegion->Count(); |
|
2459 if(regionCount > 0) |
|
2460 { |
|
2461 TPtrC8 ptrRect(reinterpret_cast<const TUint8*> (aDirtyRegion->RectangleList()), regionCount * sizeof(TRect)); |
|
2462 theArgs.Set(3, &ptrRect); |
|
2463 } |
|
2464 } |
|
2465 return SendReceive(EUpdateServSubmitUpdate, theArgs); |
|
2466 } |
|
2467 |
|
2468 /** |
|
2469 Pass an invalid opcode to the surface update server |
|
2470 */ |
|
2471 void RMisbehavingSession::TestPassingInvalidOpcode(TInt aInvalidOpcode) |
|
2472 { |
|
2473 SendReceive(aInvalidOpcode); |
|
2474 } |
|
2475 |
|
2476 /** |
|
2477 Set the fail rate for OOM checking, server side. |
|
2478 */ |
|
2479 void RMisbehavingSession::SetFailRate(TInt aFailRate) |
|
2480 { |
|
2481 TIpcArgs args(aFailRate); |
|
2482 SendReceive(EUpdateServOOM, args); |
|
2483 } |
|
2484 |
|
2485 /** |
|
2486 Implementation of NotifyWhenAvailable. Intended to behave the same as |
|
2487 RSurfaceUpdateSession::NotifyWhenAvailable except it assumes that the handle |
|
2488 to the RClass is never a Null handle. |
|
2489 */ |
|
2490 void RMisbehavingSession::NotifyWhenAvailable(TRequestStatus& aStatus) |
|
2491 { |
|
2492 iStatusAvailable = &aStatus; |
|
2493 } |
|
2494 |
|
2495 /** |
|
2496 Implementation of NotifyWhenDisplayed. Intended to behave the same as |
|
2497 RSurfaceUpdateSession::NotifyWhenDisplayed except it assumes that the handle |
|
2498 to the RClass is never a Null handle. |
|
2499 */ |
|
2500 void RMisbehavingSession::NotifyWhenDisplayed(TRequestStatus& aStatus, TTimeStamp& aTimeStamp) |
|
2501 { |
|
2502 iStatusDisplayed = &aStatus; |
|
2503 iTimeStamp = &aTimeStamp; |
|
2504 } |
|
2505 |
|
2506 /** |
|
2507 Implementation of NotifyWhenDisplayedXTimes. Intended to behave the same as |
|
2508 RSurfaceUpdateSession::NotifyWhenDisplayedXTimes except it assumes that the handle |
|
2509 to the RClass is never a Null handle. |
|
2510 */ |
|
2511 void RMisbehavingSession::NotifyWhenDisplayedXTimes(TInt aCount, TRequestStatus& aStatus) |
|
2512 { |
|
2513 iStatusDisplayedXTimes = &aStatus; |
|
2514 iCount = aCount; |
|
2515 } |
|
2516 |
|
2517 /** |
|
2518 Implementation of NotifyWhenAvailable. Intended to behave the same as |
|
2519 RSurfaceUpdateSession::NotifyWhenAvailable except it assumes that the user |
|
2520 will not pass invalid parameters to the function. |
|
2521 */ |
|
2522 TInt RMisbehavingSession::SubmitUpdate(TInt aScreen, const TSurfaceId& aSurfaceId, |
|
2523 TInt aBuffer, const TRegion* aDirtyRegion/* = NULL*/) |
|
2524 { |
|
2525 if(iStatusAvailable) |
|
2526 { |
|
2527 SendReceive(EUpdateServNotifyWhenAvailable, *iStatusAvailable); |
|
2528 iStatusAvailable= NULL; |
|
2529 } |
|
2530 |
|
2531 if(iStatusDisplayed) |
|
2532 { |
|
2533 TIpcArgs args(iTimeStamp); |
|
2534 SendReceive(EUpdateServNotifyWhenDisplayed, args, *iStatusDisplayed); |
|
2535 iStatusDisplayed=NULL; |
|
2536 } |
|
2537 |
|
2538 if(iStatusDisplayedXTimes) |
|
2539 { |
|
2540 TIpcArgs args(iCount); |
|
2541 SendReceive(EUpdateServNotifyWhenDisplayedXTimes, |
|
2542 args, *iStatusDisplayedXTimes); |
|
2543 iStatusDisplayedXTimes=NULL; |
|
2544 } |
|
2545 |
|
2546 TPckgC<TSurfaceId> pckgSurfaceId(aSurfaceId); |
|
2547 TIpcArgs theArgs(aScreen, &pckgSurfaceId, aBuffer); |
|
2548 |
|
2549 if(aDirtyRegion) |
|
2550 { |
|
2551 const TInt regionCount = aDirtyRegion->Count(); |
|
2552 if(regionCount > 0) |
|
2553 { |
|
2554 TPtrC8 ptrRect(reinterpret_cast<const TUint8*> (aDirtyRegion->RectangleList()), regionCount * sizeof(TRect)); |
|
2555 theArgs.Set(3, &ptrRect); |
|
2556 } |
|
2557 } |
|
2558 |
|
2559 //final request for composition |
|
2560 return SendReceive(EUpdateServSubmitUpdate, theArgs); |
|
2561 } |
|
2562 |
|
2563 /** |
|
2564 Implementation of NotifyWhenAvailable. Intended to behave the same as |
|
2565 RSurfaceUpdateSession::CancelAllUpdateNotifications except it assumes that the handle |
|
2566 to the RClass is never a Null handle. |
|
2567 */ |
|
2568 void RMisbehavingSession::CancelAllUpdateNotifications() |
|
2569 { |
|
2570 SendReceive(EUpdateServCancelAllNotifications); |
|
2571 } |
|
2572 |
|
2573 |