Update contrib.
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
26 #include <graphics/surfaceupdateclient.h>
27 #include <graphics/suerror.h>
29 #include "surfaceupdatetest.h"
30 #include "tsurfaceupdate.h"
31 #include "surfaceupdate.h"
34 CTSurfaceUpdate::CTSurfaceUpdate(CTestStep* aStep) :
39 CTSurfaceUpdate::~CTSurfaceUpdate()
41 while (iReceivers.Count())
43 CTContentUpdateReceiver *receiver = iReceivers[0];
45 CloseTestUpdateReceiver(receiver);
50 void CTSurfaceUpdate::ConstructL()
52 SetupContentUpdateReceiversL();
55 void CTSurfaceUpdate::SetupContentUpdateReceiversL()
58 CTContentUpdateReceiver *receiver;
59 User::LeaveIfError(StartTestUpdateReceiver(receiver, 1));
60 iReceivers.AppendL(receiver);
63 CTContentUpdateReceiver *receiver2;
64 User::LeaveIfError(StartTestUpdateReceiver(receiver2, 2));
65 iReceivers.AppendL(receiver2);
68 CTContentUpdateReceiver *receiver3;
69 User::LeaveIfError(StartTestUpdateReceiver(receiver3, 3));
70 iReceivers.AppendL(receiver3);
72 User::LeaveIfError(Provider()->Register(0, receiver, -1));
73 User::LeaveIfError(Provider()->Register(1, receiver2, 1));
74 User::LeaveIfError(Provider()->Register(2, receiver3, 2));
78 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0001
85 @SYMTestCaseDesc Initialization of the server environment twice.
89 @SYMTestStatus Implemented
91 @SYMTestActions Attempt to start the server for the second time.
93 @SYMTestExpectedResults Must return KErrAlreadyExists.
95 void CTSurfaceUpdate::TestCase1()
97 INFO_PRINTF1(_L("Attempt to start the server for the second time"));
98 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL;
99 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider);
101 TEST(surfaceUpdateProvider!=NULL);
102 TEST(surfaceUpdateProvider==Provider());
106 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0002
112 @SYMTestCaseDesc Submit update commands and subscribe for notifications.
114 @SYMTestPriority High
116 @SYMTestStatus Implemented
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 .
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).
127 void CTSurfaceUpdate::TestCase2L()
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);
135 iSurfaceOrder = CRequestOrder::NewL(KMaxSubmissionNumber);
137 iReceivers[0]->SetCompositionOrder(iSurfaceOrder);
138 iReceivers[1]->SetCompositionOrder(iSurfaceOrder);
139 iReceivers[2]->SetCompositionOrder(iSurfaceOrder);
152 RRegion region(2, rc);
154 // Test that submitting for an update before any noitfications causes no problems
155 TEST(KErrNone == session.SubmitUpdate(screen, surface, buffer, ®ion));
157 iSurfaceOrder->ResetAll();
158 for(TInt submissionNumber = 0; submissionNumber < KMaxSubmissionNumber/3; submissionNumber++)
160 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
162 TRequestStatus status = KRequestPending;
163 TRequestStatus status1 = KRequestPending;
164 TRequestStatus status2 = KRequestPending;
165 TTimeStamp timeStamp;
167 iSurfaceOrder->SetOrder(EOrderBefore);
168 session.NotifyWhenAvailable(status);
169 session.NotifyWhenDisplayed(status1, timeStamp);
170 session.NotifyWhenDisplayedXTimes(10, status2);
172 res = session.SubmitUpdate(screen, surface, buffer, ®ion);
175 User::WaitForRequest(status);
176 User::WaitForRequest(status1);
177 User::WaitForRequest(status2);
178 iSurfaceOrder->SetOrder(EOrderAfter);
180 TEST(status == KErrNone);
181 TEST(status1 == KErrNone);
182 TEST(status2 == KErrNone);
185 for(TInt i=0; i < KMaxSubmissionNumber/3; i++)
187 TInt positionBefore=-1;
188 TInt positionComposition=-1;
189 TInt positionAfter=-1;
190 for(TInt j=0; j < KMaxSubmissionNumber; j++)
192 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderBefore))
197 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderComposition))
199 positionComposition=j;
202 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderAfter))
207 TEST((positionBefore != -1) && (positionComposition != -1) && (positionAfter != -1));
208 TEST(positionBefore < positionComposition);
209 TEST(positionAfter > positionComposition);
212 delete iSurfaceOrder;
213 iSurfaceOrder = NULL;
214 iReceivers[0]->SetCompositionOrder(NULL);
215 iReceivers[1]->SetCompositionOrder(NULL);
216 iReceivers[2]->SetCompositionOrder(NULL);
222 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0003
228 @SYMTestCaseDesc Submit a few requests, then consume them.
230 @SYMTestPriority High
232 @SYMTestStatus Implemented
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,
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
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).
251 void CTSurfaceUpdate::TestCase3L()
253 INFO_PRINTF1(_L("Submission a few update requests in a row, then waiting for notifications to arrive"));
254 RSurfaceUpdateSession session;
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);
261 iSurfaceOrder = CRequestOrder::NewL(KNumberAsynchronousRequests);
263 iReceivers[0]->SetCompositionOrder(iSurfaceOrder);
264 iReceivers[1]->SetCompositionOrder(iSurfaceOrder);
265 iReceivers[2]->SetCompositionOrder(iSurfaceOrder);
279 TRect(9, 10, 11, 12),
280 TRect(13, 14, 15, 16),
282 RRegion region(4, rc);
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);
302 // Submit a few requests, then consume them
303 for(TInt index1 = 0; index1 < 5; index1++)
305 INFO_PRINTF2(_L("Attempt number %d"), index1+1);
307 TRequestStatus status[KNumberAsynchronousRequests];
308 TTimeStamp timeStamp[KNumberAsynchronousRequests];
311 iSurfaceOrder->ResetAll();
313 for(TInt index2 = 0; index2 < KNumberAsynchronousRequests; index2 += 3)
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]);
323 iSurfaceOrder->SetOrder(EOrderBefore);
325 res = session.SubmitUpdate((index2 % 2) ? screen : screen1, surface, buffer, ®ion);
329 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++)
331 User::WaitForRequest(status[submissionNumber]);
332 TEST(status[submissionNumber] == KErrNone);
334 if(((submissionNumber - 1) % 3) == 0)
336 iSurfaceOrder->SetOrder(EOrderAfter);
340 for(TInt i=0; i < KNumberAsynchronousRequests/3; i++)
342 TInt positionBefore=-1;
343 TInt positionComposition=-1;
344 TInt positionAfter=-1;
345 for(TInt j=0; j < KNumberAsynchronousRequests; j++)
347 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderBefore))
352 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderComposition))
354 positionComposition=j;
357 if((iSurfaceOrder->GetOrderNumber(j) == i) && (iSurfaceOrder->GetOrderType(j) == EOrderAfter))
362 TEST((positionBefore != -1) && (positionComposition != -1) && (positionAfter != -1));
363 TEST(positionBefore < positionComposition);
364 TEST(positionAfter > positionComposition);
368 delete iSurfaceOrder;
369 iSurfaceOrder = NULL;
370 iReceivers[0]->SetCompositionOrder(NULL);
371 iReceivers[1]->SetCompositionOrder(NULL);
372 iReceivers[2]->SetCompositionOrder(NULL);
378 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0004
384 @SYMTestCaseDesc Cancellation of the requests.
386 @SYMTestPriority High
388 @SYMTestStatus Implemented
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,
395 4. Submit update command. 5. Repeat steps 3 & 4 a few times.
396 Cancel all outstanding notifications. Wait for cancelled notifications
399 @SYMTestExpectedResults Notifications must arrive straightway with
400 KErrCancel error code or KErrNone, if events have already occurred.
402 void CTSurfaceUpdate::TestCase4L()
404 INFO_PRINTF1(_L("Submission a few requests in a row and then cancelling them"));
405 RSurfaceUpdateSession session;
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;
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);
424 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests as: %d"), KNumberAsynchronousRequests);
425 User::LeaveIfError(res);
438 TRect(9, 10, 11, 12),
439 TRect(13, 14, 15, 16),
441 RRegion region(4, rc);
443 // Check that cancelling notifications before any submission does nothing bad
444 session.CancelAllUpdateNotifications();
446 for(TInt index1 = 0; index1 < 2; index1++)
448 INFO_PRINTF2(_L("Attempt number %d"), index1+1);
450 TRequestStatus status[KNumberAsynchronousRequests];
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)
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]);
466 timestampBefore[index2 / 3] = User::FastCounter();
467 res = session.SubmitUpdate((index2 % 2) ? screen : screen1, surface, buffer, ®ion);
471 session.CancelAllUpdateNotifications();
472 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++)
474 User::WaitForRequest(status[submissionNumber]);
475 TEST((status[submissionNumber] == KErrCancel) || (status[submissionNumber] == KErrNone) );
476 if(status[submissionNumber] == KErrCancel)
481 if((status[submissionNumber] == KErrNone) && ((submissionNumber - 1) % 3) == 0)
483 TInt index22 = submissionNumber / 3;
484 timestampAfter[index22] = User::FastCounter();
486 if(timestampAfter[index22] < timestampBefore[index22])
488 timestampAfter[index22] += UINT_MAX;
490 timestampComposition[index22] = timeStamp[index22]();
491 if(timestampComposition[index22] < timestampBefore[index22])
493 timestampComposition[index22] += UINT_MAX;
496 TEST(timestampComposition[index22] != 0);
497 TEST(timestampAfter[index22] >= timestampComposition[index22]);
498 TEST(timestampBefore[index22] <= timestampComposition[index22]);
507 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0005
513 @SYMTestCaseDesc Submission from multiple sessions.
515 @SYMTestPriority High
517 @SYMTestStatus Implemented
519 @SYMTestActions Create a few connections to the server. For each connection:
520 1. Subscribe for different notifications (consumed, displayed,
522 2. Submit update command. Wait for notifications to arrive.
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.
528 void CTSurfaceUpdate::TestCase5L()
530 INFO_PRINTF1(_L("Submission a few update requests in a row from different sessions, then waiting for notifications to arrive"));
532 const TInt KNumberAsynchronousRequests = 9;
533 const TInt KNumberSessions = 5;
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);
551 TRect(9, 10, 11, 12),
552 TRect(13, 14, 15, 16),
554 RRegion region(4, rc);
556 TRequestStatus status[KNumberAsynchronousRequests * KNumberSessions];
558 for(TInt index2 = 0; index2 < KNumberSessions; index2++)
560 res = sessions[index2].Connect(KNumberAsynchronousRequests);
561 User::LeaveIfError(res);
564 for(TInt index1 = 0; index1 < 3; index1++)
566 INFO_PRINTF2(_L("Attempt number %d"), index1+1);
568 for(TInt index2 = 0; index2 < KNumberSessions; index2++)
570 TTimeStamp timeStamp;
571 INFO_PRINTF2(_L("Session number %d"), index2 + 1);
573 for(TInt index3 = index2 * KNumberAsynchronousRequests;
574 index3 < (index2 + 1) * KNumberAsynchronousRequests; index3 += 3)
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);
586 ERR_PRINTF2(_L("Returned SubmitUpdate code %d"), res);
592 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests * KNumberSessions; submissionNumber++)
594 User::WaitForRequest(status[submissionNumber]);
595 if(status[submissionNumber] != KErrNone)
597 ERR_PRINTF2(_L("Returned request status %d"), status[submissionNumber].Int());
603 for(TInt index5 = 0; index5 < KNumberSessions; index5++)
605 sessions[index5].Close();
610 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0023
617 @SYMTestCaseDesc SubmitUpdate() to cope with Global Updates
619 @SYMTestPriority High
621 @SYMTestStatus Implemented
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.
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.
638 void CTSurfaceUpdate::TestCase15()
640 INFO_PRINTF1(_L("SubmitUpdate() to cope with Global Updates"));
642 RSurfaceUpdateSession session;
643 TInt res = session.Connect();
644 TEST(res == KErrNone);
652 // Test that submitting for an update before any noitfications causes no problems
653 TInt numReceivers = iReceivers.Count();
655 //make all screens invisible
656 INFO_PRINTF1(_L("make all screens invisible"));
657 for(TInt index = 0; index < numReceivers; index++)
659 CTContentUpdateReceiver* receiver = iReceivers[index];
660 receiver->SetVisible(EFalse);
663 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++)
665 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
667 TRequestStatus status = KRequestPending;
668 TRequestStatus status1 = KRequestPending;
669 TRequestStatus status2 = KRequestPending;
670 TTimeStamp timeStamp;
672 session.NotifyWhenAvailable(status);
673 session.NotifyWhenDisplayed(status1, timeStamp);
674 session.NotifyWhenDisplayedXTimes(10, status2);
676 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
679 User::WaitForRequest(status);
680 User::WaitForRequest(status1);
681 User::WaitForRequest(status2);
683 TEST(status == KErrNotVisible);
684 TEST(status1 == KErrNotVisible);
685 TEST(status2 == KErrNotVisible);
688 //make only one screen visible
689 CTContentUpdateReceiver* receiver = iReceivers[0];
690 receiver->SetVisible(ETrue);
691 INFO_PRINTF1(_L("Make visible one screen"));
694 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++)
696 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
698 TRequestStatus status = KRequestPending;
699 TRequestStatus status1 = KRequestPending;
700 TRequestStatus status2 = KRequestPending;
701 TUint64 timestampComposition = 0;
702 TTimeStamp timeStamp;
704 TUint64 timestampBefore = User::FastCounter();
706 session.NotifyWhenAvailable(status);
707 session.NotifyWhenDisplayed(status1, timeStamp);
708 session.NotifyWhenDisplayedXTimes(10, status2);
710 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
713 User::WaitForRequest(status);
714 User::WaitForRequest(status1);
715 User::WaitForRequest(status2);
717 TUint64 timestampAfter = User::FastCounter();
718 if(timestampAfter < timestampBefore)
720 timestampAfter += UINT_MAX;
722 timestampComposition = timeStamp();
723 if(timestampComposition < timestampBefore)
725 timestampComposition += UINT_MAX;
728 TEST(status == KErrNone);
729 TEST(status1 == KErrNone);
730 TEST(status2 == KErrNone);
732 TEST(timestampComposition != 0);
733 TEST(timestampAfter >= timestampComposition);
734 TEST(timestampBefore <= timestampComposition);
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);
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);
747 for(TInt submissionNumber = 0; submissionNumber < 5; submissionNumber++)
749 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
751 TRequestStatus status = KRequestPending;
752 TRequestStatus status1 = KRequestPending;
753 TRequestStatus status2 = KRequestPending;
754 TUint64 timestampComposition = 0;
755 TTimeStamp timeStamp;
757 TUint64 timestampBefore = User::FastCounter();
759 session.NotifyWhenAvailable(status);
760 session.NotifyWhenDisplayed(status1, timeStamp);
761 session.NotifyWhenDisplayedXTimes(10, status2);
763 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
766 User::WaitForRequest(status);
767 User::WaitForRequest(status1);
768 User::WaitForRequest(status2);
770 TUint64 timestampAfter = User::FastCounter();
771 if(timestampAfter < timestampBefore)
773 timestampAfter += UINT_MAX;
775 timestampComposition = timeStamp();
776 if(timestampComposition < timestampBefore)
778 timestampComposition += UINT_MAX;
781 TEST(status == KErrNone);
782 TEST(status1 == KErrNone);
783 TEST(status2 == KErrNone);
785 TEST(timestampComposition != 0);
786 TEST(timestampAfter >= timestampComposition);
787 TEST(timestampBefore <= timestampComposition);
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);
794 //make all screens visible
795 for(TInt index = 0; index < numReceivers; index++)
797 CTContentUpdateReceiver* receiver = iReceivers[index];
798 receiver->SetVisible(ETrue);
806 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0024
812 @SYMTestCaseDesc CancelAllUpdateNotifications() to deal with global updates
815 @SYMTestPriority High
817 @SYMTestStatus Implemented
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.
827 @SYMTestExpectedResults
828 Notifications to arrive straight away with KErrCancel, otherwise with
829 KErrNone if the events have already occurred.
831 void CTSurfaceUpdate::TestCase16L()
833 INFO_PRINTF1(_L("CancelAllUpdateNotifications() to deal with global updates correctly"));
834 RSurfaceUpdateSession session;
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;
843 INFO_PRINTF2(_L("Set number of outstanding asynchronous requests as: %d"), KNumberAsynchronousRequests);
844 User::LeaveIfError(res);
852 for(TInt index1 = 0; index1 < 2; index1++)
854 INFO_PRINTF2(_L("Attempt number %d"), index1+1);
856 TRequestStatus status[KNumberAsynchronousRequests];
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)
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]);
872 timestampBefore[index2 / 3] = User::FastCounter();
873 res = session.SubmitUpdate(KAllScreens, surface, buffer);
877 session.CancelAllUpdateNotifications();
878 for(TInt submissionNumber = 0; submissionNumber < KNumberAsynchronousRequests; submissionNumber++)
880 User::WaitForRequest(status[submissionNumber]);
881 TEST((status[submissionNumber] == KErrCancel) || (status[submissionNumber] == KErrNone) );
882 if(status[submissionNumber] == KErrCancel)
887 if((status[submissionNumber] == KErrNone) && ((submissionNumber - 1) % 3) == 0)
889 TInt index22 = submissionNumber / 3;
890 timestampAfter[index22] = User::FastCounter();
892 if(timestampAfter[index22] < timestampBefore[index22])
894 timestampAfter[index22] += UINT_MAX;
896 timestampComposition[index22] = timeStamp[index22]();
897 if(timestampComposition[index22] < timestampBefore[index22])
899 timestampComposition[index22] += UINT_MAX;
902 TEST(timestampComposition[index22] != 0);
903 TEST(timestampAfter[index22] >= timestampComposition[index22]);
904 TEST(timestampBefore[index22] <= timestampComposition[index22]);
913 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0027
919 @SYMTestCaseDesc NotifyWhenAvailable() to deal with global updates and be signalled correctly
920 @SYMTestPriority High
922 @SYMTestStatus Implemented
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.
934 @SYMTestExpectedResults
935 Notification to arrive with error code KErrNone initiated by the
938 void CTSurfaceUpdate::TestCaseNotifyWhenAvailableGlobal()
940 INFO_PRINTF1(_L("NotifyWhenAvailable() to deal with global updates and be signalled correctly"));
942 RSurfaceUpdateSession session;
943 TInt res = session.Connect();
944 TEST(res == KErrNone);
952 TEST(iReceivers[2]->OutstandingRequest()==EFalse);
953 TEST(iReceivers[1]->OutstandingRequest()==EFalse);
954 TEST(iReceivers[0]->OutstandingRequest()==EFalse);
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
968 for(TInt submissionNumber = 0; submissionNumber < 20; submissionNumber++)
970 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
972 TRequestStatus status = KRequestPending;
974 session.NotifyWhenAvailable(status);
976 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
979 User::WaitForRequest(status);
981 TEST(status == KErrNone);
982 TEST(iReceivers[2]->OutstandingRequest()==EFalse);
983 TEST(iReceivers[1]->OutstandingRequest()==EFalse);
984 TEST(iReceivers[0]->OutstandingRequest()==EFalse);
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();
998 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0028
1000 @SYMPREQ 1007/11599, 1007/11600, 1007/11601
1004 @SYMTestCaseDesc NotifyWhenDisplayed() & NotifyWhenDisplayedXTimes() to deal with global updates and be signalled correctly
1005 @SYMTestPriority High
1007 @SYMTestStatus Implemented
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.
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.
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.
1028 void CTSurfaceUpdate::TestCase17()
1030 INFO_PRINTF1(_L("NotifyWhenDisplayed() && NotifyWhenDisplayedXTimes() to deal with global updates and be signalled correctly"));
1032 RSurfaceUpdateSession session;
1033 TInt res = session.Connect();
1034 TEST(res == KErrNone);
1037 TSurfaceId surface =
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
1052 for(TInt submissionNumber = 0; submissionNumber < 10; submissionNumber++)
1054 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
1056 TRequestStatus status = KRequestPending;
1057 TRequestStatus status1 = KRequestPending;
1058 TTimeStamp timeStamp;
1060 session.NotifyWhenDisplayed(status, timeStamp);
1061 session.NotifyWhenDisplayedXTimes(10, status1);
1063 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
1064 TEST(res==KErrNone);
1066 User::WaitForRequest(status);
1067 User::WaitForRequest(status1);
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);
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
1086 TInt numUnprocessedSignals = 0;
1087 for(TInt submissionNumber = 0; submissionNumber < 10; submissionNumber++)
1089 INFO_PRINTF2(_L("Submission number %d"), submissionNumber+1);
1091 TRequestStatus status = KRequestPending;
1092 TRequestStatus status1 = KRequestPending;
1093 TTimeStamp timeStamp;
1095 session.NotifyWhenDisplayed(status, timeStamp);
1096 session.NotifyWhenDisplayedXTimes(10, status1);
1098 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
1099 TEST(res==KErrNone);
1101 User::WaitForRequest(status);
1102 User::WaitForRequest(status1);
1104 TEST(status == KErrNone);
1105 TEST(status1 == KErrNone);
1106 if(iReceivers[0]->OutstandingRequest())
1108 numUnprocessedSignals++;
1109 INFO_PRINTF1(_L("Unprocessed signals"));
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
1118 INFO_PRINTF2(_L("Number unprocessed signals %d"), numUnprocessedSignals);
1119 TEST(numUnprocessedSignals > 0);
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();
1133 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0029
1140 @SYMTestCaseDesc Register with identical priorities.
1142 @SYMTestPriority High
1144 @SYMTestStatus Implemented
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
1154 @SYMTestExpectedResults
1155 Step 4 should fail, returning KErrAlreadyExists.
1156 Step 6 should succeed.
1158 void CTSurfaceUpdate::TestCaseRegisterIdenticalPrioritiesL()
1160 INFO_PRINTF1(_L("Register with identical priorities test"));
1161 const TInt KIdenticalPriority = 100;
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);
1171 INFO_PRINTF2(_L("Registering receiver A with priority %i"), KIdenticalPriority);
1172 User::LeaveIfError(Provider()->Register(receiverA->Screen(), receiverA, KIdenticalPriority));
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)
1178 INFO_PRINTF1(_L("KErrAlreadyExists returned as expected"));
1182 ERR_PRINTF3(_L("Test failed - expected Register() to return KErrAlreadyExists(%i) but instead returned %i"), KErrAlreadyExists, ret);
1186 INFO_PRINTF1(_L("Unregistering receiver A"));
1187 User::LeaveIfError(Provider()->Register(receiverA->Screen(), NULL, KIdenticalPriority));
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));
1199 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0006
1205 @SYMTestCaseDesc Negative testing - various cases
1207 @SYMTestPriority High
1209 @SYMTestStatus Implemented
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
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
1231 void CTSurfaceUpdate::TestCase6L()
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;
1242 TTimeStamp timeStamp;
1244 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0006 apply operation on disconnected session
1247 TSurfaceId surface =
1258 RRegion region(2, rc);
1260 //next command will be ignored, but shouldn't cause a panic
1261 INFO_PRINTF1(_L("close disconnected session"));
1264 User::LeaveIfError(session.Connect());
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);
1271 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0008 wrong parameters
1272 INFO_PRINTF1(_L("specifying wrong parametrs"));
1273 INFO_PRINTF1(_L("specify a negative screen number"));
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);
1283 TEST(status == KErrArgument);
1284 TEST(status1 == KErrArgument);
1285 TEST(status2 == KErrArgument);
1286 TEST(res == KErrArgument);
1288 INFO_PRINTF1(_L("receiver for the following screen doesn't exist"));
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);
1298 TEST(status == KErrUpdateReceiverNotAvailable);
1299 TEST(status1 == KErrUpdateReceiverNotAvailable);
1300 TEST(status2 == KErrUpdateReceiverNotAvailable);
1301 TEST(res == KErrUpdateReceiverNotAvailable);
1303 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0009 Submission with screen which doesn't exist in the system
1304 INFO_PRINTF1(_L("too big screen number"));
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);
1314 TEST(status == KErrUpdateReceiverNotAvailable);
1315 TEST(status1 == KErrUpdateReceiverNotAvailable);
1316 TEST(status2 == KErrUpdateReceiverNotAvailable);
1317 TEST(res == KErrUpdateReceiverNotAvailable);
1319 INFO_PRINTF1(_L("negative buffer"));
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);
1330 TEST(status == KErrArgument);
1331 TEST(status1 == KErrArgument);
1332 TEST(status2 == KErrArgument);
1333 TEST(res == KErrArgument);
1335 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0010 Submission with invalid number of counts in NotifyWhenDisplayedXTimes()
1336 INFO_PRINTF1(_L("displaying for negative number of times"));
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);
1348 TEST(status == KErrNone);
1349 TEST(status1 == KErrNone);
1350 TEST(status2 == KErrArgument);
1351 TEST(res == KErrNone);
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"));
1356 User::LeaveIfError(session.Connect(4));
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);
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);
1370 User::WaitForRequest(status);
1371 User::WaitForRequest(status1);
1372 User::WaitForRequest(status2);
1373 User::WaitForRequest(status3);
1374 User::WaitForRequest(status4);
1375 User::WaitForRequest(status5);
1377 TEST(status == KErrNone);
1378 TEST(status1== KErrNone);
1379 TEST(status2== KErrNone);
1380 TEST(status3== KErrNone);
1381 TEST(status4== KErrServerBusy);
1382 TEST(status5== KErrServerBusy);
1384 //@SYMTestCaseID GRAPHICS-SURFACEUPDATE-0012 Submission of region with empty rectangle list
1385 INFO_PRINTF1(_L("specify empty region"));
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);
1393 User::WaitForRequest(status);
1394 User::WaitForRequest(status1);
1395 User::WaitForRequest(status2);
1396 TEST(status == KErrNone);
1397 TEST(status1== KErrNone);
1398 TEST(status2== KErrNone);
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);
1409 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0014
1415 @SYMTestCaseDesc OOM testing.
1417 @SYMTestPriority High
1419 @SYMTestStatus Implemented
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.
1426 @SYMTestExpectedResults Submit return code and notifications must arrive
1427 with KErrNoMemory in the case of memory allocation failures.
1429 void CTSurfaceUpdate::TestCase7L()
1431 RMisbehavingSession session;
1432 TRequestStatus status;
1433 TRequestStatus status1;
1434 TRequestStatus status2;
1435 TTimeStamp timeStamp;
1436 TSurfaceId surface =
1446 RRegion region(2, rc);
1449 User::LeaveIfError(session.Connect());
1450 TInt res = KErrNone;
1452 //create another receiver
1453 CTContentUpdateReceiver *receiver4;
1454 User::LeaveIfError(StartTestUpdateReceiver(receiver4, 4));
1455 iReceivers.AppendL(receiver4);
1458 const TInt screenNo = 16;
1459 // Cause a failure on all the allocs on server side
1462 session.SetFailRate(ii);
1463 res = Provider()->Register(screenNo, receiver4, -100);
1464 if(res != KErrNoMemory)
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
1478 // Cause a failure on all the allocs on server side
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);
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)
1495 TEST(res == KErrNoMemory); // Since the first alloc fail kills the server
1496 TEST(status.Int() == KErrNoMemory);
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
1508 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0015
1514 @SYMTestCaseDesc Causing panic of client
1516 @SYMTestPriority High
1518 @SYMTestStatus Implemented
1520 @SYMTestActions Create second thread which connects to the server.
1521 Pass an invalid opcode to the server which will cause a client panic.
1523 @SYMTestExpectedResults The thread will die with the correct exit reason
1524 (EUpdateServPanicBadRequest) and the correct exit category (SurfUpServ).
1526 void CTSurfaceUpdate::TestCase8()
1528 // Create another thread in which we will panic the client
1529 _LIT(KThreadName, "TestPanicClientThread");
1531 TEST(KErrNone == thread.Create(KThreadName,
1536 TRequestStatus rendezvousStatus;
1537 thread.Rendezvous(rendezvousStatus);
1539 User::WaitForRequest(rendezvousStatus);
1540 _LIT(KExitCategory,"SurfUpServ");
1541 TBuf<16> exitCategory(KExitCategory);
1542 TEST(thread.ExitReason() == EUpdateServPanicBadRequest);
1543 TEST(thread.ExitCategory() == exitCategory);
1548 Thread function called from TestCase8L in order to panic the client.
1550 TInt CTSurfaceUpdate::PanicClientThread(TAny*)
1552 User::SetJustInTime(EFalse);
1553 RMisbehavingSession session;
1554 TInt err = session.Connect();
1557 session.TestPassingInvalidOpcode();
1558 // Exit reason will be the panic number due to the invalid op code:
1559 // returning zero here is redundant
1564 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0016
1571 @SYMTestCaseDesc Calling submit before any notify with invalid arguments.
1573 @SYMTestPriority High
1575 @SYMTestStatus Implemented
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).
1581 @SYMTestExpectedResults SubmitUpdate will return KErrArgument in both cases.
1583 void CTSurfaceUpdate::TestCase9L()
1585 RSurfaceUpdateSession session;
1586 User::LeaveIfError(session.Connect());
1588 // Test submit before notify with -ve screen
1590 TSurfaceId surface =
1595 TInt res = session.SubmitUpdate(screen, surface, buffer, NULL);
1596 TEST(res == KErrArgument);
1598 // Test submit before notify with -ve buffer
1601 res = session.SubmitUpdate(screen, surface, buffer, NULL);
1602 TEST(res == KErrArgument);
1604 //Test submit before notify with Null surfaceId
1605 surface = TSurfaceId::CreateNullId();
1608 res = session.SubmitUpdate(screen, surface, buffer, NULL);
1609 TEST(res == KErrArgument);
1614 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0017
1621 @SYMTestCaseDesc Using a rogue client to call multiple notifies in a row.
1623 @SYMTestPriority High
1625 @SYMTestStatus Implemented
1627 @SYMTestActions Create a second thread which will call multiple notifies
1628 in succession (not interleaved with Submits).
1630 @SYMTestExpectedResults The thread should have an exit category
1631 of SurfUpServ and and exit reason of EUpdateServPanicDataIntegrity in
1634 void CTSurfaceUpdate::TestCase10()
1636 for(TInt testNum = 0; testNum < 3; ++testNum)
1638 _LIT(KThreadName, "TestMultipleNotify%d");
1639 TBuf<19> threadName;
1640 threadName.Format(KThreadName, testNum);
1642 TRequestStatus status;
1643 TMultipleNotify statusCol(status, testNum);
1644 TEST(KErrNone == thread.Create(threadName,
1645 TestMultipleNotifyThreadL,
1649 TRequestStatus rendezvousStatus;
1650 thread.Rendezvous(rendezvousStatus);
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);
1667 Thread function called from TestCase10 in order to submit multiple notifies.
1669 TInt CTSurfaceUpdate::TestMultipleNotifyThreadL(TAny* aStatusCol)
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)
1679 badSession.NotifyWhenAvailableNoChecking(statusCol->iStatus);
1680 badSession.NotifyWhenAvailableNoChecking(status);
1683 badSession.NotifyWhenDisplayedNoChecking(statusCol->iStatus);
1684 badSession.NotifyWhenDisplayedNoChecking(status);
1687 badSession.NotifyWhenDisplayedXTimesNoChecking(10, statusCol->iStatus);
1688 badSession.NotifyWhenDisplayedXTimesNoChecking(10, status);
1691 _LIT(KMultipleNotifyPanic, "MultNotifyPanic");
1692 User::Panic(KMultipleNotifyPanic, 1);
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
1703 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0018
1709 @SYMTestCaseDesc Use a rogue client to misbehave in various ways.
1711 @SYMTestPriority High
1713 @SYMTestStatus Implemented
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.
1721 @SYMTestExpectedResults 1. KErrNotSupported
1724 4. Status int is KErrArgument (SubmitUpdate == KErrNone).
1726 void CTSurfaceUpdate::TestCase11()
1728 // Attempt to connect with the wrong version number
1729 RMisbehavingSession session;
1730 TEST(KErrNotSupported == session.Connect(KDefaultMessageSlot, ETrue));
1732 TEST(KErrNone == session.Connect());
1734 TSurfaceId surface =
1740 // Call RMisbehavingSession::SubmitUpdate which doesn't do the correct
1741 // client side checking
1742 TEST(KErrArgument == session.SubmitUpdateNoChecking(screen, surface, buffer, NULL));
1744 // Test with -ve screen
1747 TEST(KErrArgument == session.SubmitUpdateNoChecking(screen, surface, buffer, NULL));
1749 // Test calling NotifyWhenDisplayedXTimes with no client side checking and a count of 0
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());
1763 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0019
1770 @SYMTestCaseDesc Starting the surface update server in two different threads.
1772 @SYMTestPriority High
1774 @SYMTestStatus Implemented
1776 @SYMTestActions Start the surface update server in two different threads.
1778 @SYMTestExpectedResults Thread 1: KErrNone
1780 The "provider" returned to both threads should also be the same value!
1782 void CTSurfaceUpdate::TestCase12L()
1784 MSurfaceUpdateServerProvider *surfaceUpdateProvider = NULL;
1785 TInt res = StartSurfaceUpdateServer(surfaceUpdateProvider);
1786 TEST(res == KErrNone);
1787 User::LeaveIfError(res);
1789 _LIT(KThreadName, "TestServerStartupTwoThreads");
1793 TRAP(res, tm.FormatL(buf, _L("_%H%T%S%C")));
1794 TEST(res == KErrNone);
1795 User::LeaveIfError(res);
1796 TBuf<128> threadName(KThreadName);
1797 threadName.Append(buf); //guarantee uniqueness of the thread name
1799 MSurfaceUpdateServerProvider *surfaceUpdateProvider2 = NULL;
1800 res = thread.Create(threadName,
1801 TestServerStartupTwoThreads,
1804 &surfaceUpdateProvider2);
1805 TEST(res == KErrNone);
1806 User::LeaveIfError(res);
1807 TRequestStatus rendezvousStatus;
1808 thread.Rendezvous(rendezvousStatus);
1810 User::WaitForRequest(rendezvousStatus);
1811 TEST(KErrNone == rendezvousStatus.Int());
1812 // Check that we get the same provider for both threads!
1813 TEST(surfaceUpdateProvider2 == surfaceUpdateProvider);
1818 Starting the update server in another thread - called from TestCase12
1820 TInt CTSurfaceUpdate::TestServerStartupTwoThreads(TAny *aArgPtr)
1822 MSurfaceUpdateServerProvider **surfaceUpdateProviderPtr =
1823 reinterpret_cast<MSurfaceUpdateServerProvider **>(aArgPtr);
1824 TInt res = StartSurfaceUpdateServer(*surfaceUpdateProviderPtr);
1829 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0020
1835 @SYMTestCaseDesc Requesting notifies, leaving enough time for them to
1836 complete before requesting the subsequent notification.
1838 @SYMTestPriority High
1840 @SYMTestStatus Implemented
1842 @SYMTestActions Execute some notifies and submits, wait for a short period (100us),
1843 then cancel them all.
1845 @SYMTestExpectedResults Two results are acceptable: KErrNone (notify
1846 completed before it was cancelled) or KErrCancel (notify sucessfully cancelled).
1848 void CTSurfaceUpdate::TestCase13L()
1850 RSurfaceUpdateSession session;
1851 const TInt numNotifies = 10;
1852 User::LeaveIfError(session.Connect(numNotifies));
1854 TRequestStatus statusArray[numNotifies];
1856 TSurfaceId surface =
1862 // Send the same type of notification request multiply, cancelling after each submission
1863 for(TInt ii = 0; ii < numNotifies; ++ii)
1865 session.NotifyWhenAvailable(statusArray[ii]);
1866 TEST(KErrNone == session.SubmitUpdate(screen, surface, buffer, NULL));
1867 session.CancelAllUpdateNotifications();
1868 User::After(100); // Enough time for the notify to be processed
1871 // Check that the error codes are acceptable
1872 for(TInt ii = 0; ii < numNotifies; ++ii)
1874 TInt ret = statusArray[ii].Int();
1875 TEST(statusArray[ii].Int() == KErrNone || statusArray[ii].Int() == KErrCancel);
1882 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0021
1888 @SYMTestCaseDesc Terminating and restarting the server.
1890 @SYMTestPriority High
1892 @SYMTestStatus Implemented
1894 @SYMTestActions Terminate and restart the server
1896 @SYMTestExpectedResults Test that trying to connect the session after
1897 termination of the server results in KErrNotFound, and that the server
1898 can be restarted with result KErrNone.
1900 void CTSurfaceUpdate::TestCaseTerminateServer()
1902 (static_cast <CTSurfaceUpdateStep*> (iStep)) ->TerminateServer();
1904 //at that point server has been terminated
1905 RSurfaceUpdateSession session;
1906 TInt res = session.Connect();
1907 TEST(res == KErrNotFound);
1910 res = (static_cast <CTSurfaceUpdateStep*> (iStep)) ->StartServer();
1911 TEST(res == KErrNone);
1912 res = session.Connect();
1913 TEST(res == KErrNone);
1918 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0022
1924 @SYMTestCaseDesc Terminating the thread while some outstanding request in progress.
1926 @SYMTestPriority High
1928 @SYMTestStatus Implemented
1930 @SYMTestActions Terminate the thread which has outstanding request to
1931 the server for surface update notifications.
1933 @SYMTestExpectedResults Surface update surface should process the request
1934 and try to send notification without hanging.
1937 void CTSurfaceUpdate::TestCase14()
1939 _LIT(KThreadNameTemplate, "TestPanicClientThread1_%d");
1942 const TInt KMaxIndex = 50;
1943 for(TInt index = 0; index < KMaxIndex; index++)
1945 const TInt KUnexpectedLeavePanic = 194;
1946 TBuf<128> threadName;
1947 threadName.Format(KThreadNameTemplate, index);
1948 TInt res = thread.Create(threadName,
1953 TEST(res == KErrNone);
1954 TRequestStatus status = KRequestPending;
1955 thread.Logon(status);
1957 User::WaitForRequest(status);
1959 res = thread.ExitReason();
1960 TEST(res == KUnexpectedLeavePanic);
1961 if(res != KUnexpectedLeavePanic)
1963 INFO_PRINTF2(_L("Thread exits with error code %d"), res);
1970 @SYMTestCaseID GRAPHICS-SURFACEUPDATE-0025
1972 @SYMPREQ 1007/11599, 1007/11600, 1007/11601
1976 @SYMTestCaseDesc SubmitUpdate() with a global and a per-display
1977 update cannot be mixed.
1978 @SYMTestPriority High
1980 @SYMTestStatus Implemented
1983 Create the session and make a global submit update.
1984 Subscribe for all notifications and make per screen submit update.
1985 Create another session and make a per screen update.
1986 Subscribe for all notifications and make a global submit update.
1989 @SYMTestExpectedResults
1990 Mixing two different types of submit update should fail with an error KErrNotSupported.
1992 void CTSurfaceUpdate::TestCase18()
1994 INFO_PRINTF1(_L("SubmitUpdate() to deal with both a global and a per-display update in the same session"));
1996 RSurfaceUpdateSession session;
1998 TSurfaceId surface =
2003 TInt res = session.Connect();
2004 TEST(res == KErrNone);
2006 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
2007 TEST(res==KErrNone);
2009 TRequestStatus status = KRequestPending;
2010 TRequestStatus status1 = KRequestPending;
2011 TRequestStatus status2 = KRequestPending;
2012 TTimeStamp timeStamp;
2014 session.NotifyWhenAvailable(status);
2015 session.NotifyWhenDisplayed(status1, timeStamp);
2016 session.NotifyWhenDisplayedXTimes(10, status2);
2018 res = session.SubmitUpdate(1, surface, buffer, NULL);
2019 TEST(res==KErrNotSupported);
2021 User::WaitForRequest(status);
2022 User::WaitForRequest(status1);
2023 User::WaitForRequest(status2);
2025 TEST(status == KErrNotSupported);
2026 TEST(status1 == KErrNotSupported);
2027 TEST(status2 == KErrNotSupported);
2030 //make per screen update first
2031 res = session.Connect();
2032 TEST(res == KErrNone);
2034 res = session.SubmitUpdate(1, surface, buffer, NULL);
2035 TEST(res==KErrNone);
2037 status = KRequestPending;
2038 status1 = KRequestPending;
2039 status2 = KRequestPending;
2041 session.NotifyWhenAvailable(status);
2042 session.NotifyWhenDisplayed(status1, timeStamp);
2043 session.NotifyWhenDisplayedXTimes(10, status2);
2045 res = session.SubmitUpdate(KAllScreens, surface, buffer, NULL);
2046 TEST(res==KErrNotSupported);
2048 User::WaitForRequest(status);
2049 User::WaitForRequest(status1);
2050 User::WaitForRequest(status2);
2052 TEST(status == KErrNotSupported);
2053 TEST(status1 == KErrNotSupported);
2054 TEST(status2 == KErrNotSupported);
2060 Thread function called from TestCase14 in order to panic the client
2062 TInt CTSurfaceUpdate::PanicClientThread1(TAny* aAny)
2064 CTSurfaceUpdate* surfaceUpdateTest = (CTSurfaceUpdate*) aAny;
2065 surfaceUpdateTest->GenerateMultipleUpdateWithPanic();
2071 Helper function for test case described in TestCase14
2073 void CTSurfaceUpdate::GenerateMultipleUpdateWithPanic()
2075 TRequestStatus status = KRequestPending;
2076 TTimeStamp timeStamp;
2077 RSurfaceUpdateSession session;
2079 TSurfaceId surface =
2085 TInt res = session.Connect();
2086 TEST(res == KErrNone);
2087 session.NotifyWhenDisplayed(status, timeStamp);
2088 res = session.SubmitUpdate(screen, surface, buffer);
2089 TEST(res == KErrNone);
2090 User::After(TTimeIntervalMicroSeconds32(100000));
2092 User::PanicUnexpectedLeave();
2095 void CTSurfaceUpdate::ResetSusL()
2097 while (iReceivers.Count() > 0)
2099 CTContentUpdateReceiver *receiver = iReceivers[0];
2100 iReceivers.Remove(0);
2101 CloseTestUpdateReceiver(receiver);
2103 (static_cast<CTSurfaceUpdateStep*>(iStep))->TerminateServer();
2104 User::LeaveIfError((static_cast<CTSurfaceUpdateStep*>(iStep))->StartServer());
2107 void CTSurfaceUpdate::SetupTestCaseRegisterPanicL()
2110 // Start two content update receivers for register test
2111 CTContentUpdateReceiver* receiverA;
2112 CTContentUpdateReceiver* receiverB;
2113 User::LeaveIfError(StartTestUpdateReceiver(receiverA, 0));
2114 iReceivers.AppendL(receiverA);
2115 User::LeaveIfError(StartTestUpdateReceiver(receiverB, 1));
2116 iReceivers.AppendL(receiverB);
2119 void CTSurfaceUpdate::DoTestCaseRegisterPanicL(TThreadFunction aThreadFunction)
2121 _LIT(KRegisterThreadName, "TestPanicRegisterThread");
2123 TInt res = thread.Create(KRegisterThreadName, aThreadFunction,
2124 KDefaultStackSize, &User::Heap(), this);
2125 TEST(res == KErrNone);
2126 User::LeaveIfError(res);
2127 TRequestStatus status = KRequestPending;
2128 thread.Logon(status);
2130 User::WaitForRequest(status);
2132 res = thread.ExitReason();
2133 TEST(res == EUpdateServPanicRegister);
2134 if(res != EUpdateServPanicRegister)
2136 ERR_PRINTF2(_L("Thread exits with error code %d"), res);
2142 * Ensure that there is no outstanding request from all receivers
2144 void CTSurfaceUpdate::WaitUntilAllNotificationsProcessed()
2146 const TInt KMaxIterationNumber = 10;
2148 for(; ii < KMaxIterationNumber; ii++)
2150 if(((iReceivers[0]->OutstandingRequest() == EFalse)) &&
2151 ((iReceivers[1]->OutstandingRequest() == EFalse)) &&
2152 ((iReceivers[2]->OutstandingRequest() == EFalse)))
2154 INFO_PRINTF2(_L("Wait until all notification processed, iteration %d"), ii);
2155 User::After(KCompositionIntervalLong);
2157 TEST(ii < KMaxIterationNumber);//We have waited enough, if it fails, something weird going on
2160 void CTSurfaceUpdate::RunTestCaseL(TInt aCurTestCase)
2162 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
2163 switch(aCurTestCase)
2167 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0001"));
2168 if((static_cast <CTSurfaceUpdateStep*> (iStep)) -> iGce)
2170 INFO_PRINTF1(_L("TestCase1"));
2171 TRAPD(ret, TestCase1());
2172 TEST(ret == KErrNone);
2182 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0002"));
2183 INFO_PRINTF1(_L("TestCase2L"));
2184 TRAPD(ret, TestCase2L());
2185 TEST(ret == KErrNone);
2190 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0003"));
2191 INFO_PRINTF1(_L("TestCase3L"));
2192 TRAPD(ret, TestCase3L());
2193 TEST(ret == KErrNone);
2198 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0004"));
2199 INFO_PRINTF1(_L("TestCase4L"));
2200 TRAPD(ret, TestCase4L());
2201 TEST(ret == KErrNone);
2206 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0005"));
2207 INFO_PRINTF1(_L("TestCase5L"));
2208 TRAPD(ret, TestCase5L());
2209 TEST(ret == KErrNone);
2214 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0006"));
2215 INFO_PRINTF1(_L("TestCase6L"));
2216 TRAPD(ret, TestCase6L());
2217 TEST(ret == KErrNone);
2222 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0014"));
2223 INFO_PRINTF1(_L("TestCase7L"));
2224 TRAPD(ret, TestCase7L());
2225 TEST(ret == KErrNone);
2230 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0015"));
2231 INFO_PRINTF1(_L("TestCase8"));
2232 TRAPD(ret, TestCase8());
2233 TEST(ret == KErrNone);
2238 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0016"));
2239 INFO_PRINTF1(_L("TestCase9L"));
2240 TRAPD(ret, TestCase9L());
2241 TEST(ret == KErrNone);
2246 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0017"));
2247 INFO_PRINTF1(_L("TestCase10"));
2248 TRAPD(ret, TestCase10());
2249 TEST(ret == KErrNone);
2254 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0018"));
2255 INFO_PRINTF1(_L("TestCase11"));
2256 TRAPD(ret, TestCase11());
2257 TEST(ret == KErrNone);
2262 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0019"));
2263 INFO_PRINTF1(_L("TestCase12L"));
2264 TRAPD(ret, TestCase12L());
2265 TEST(ret == KErrNone);
2270 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0020"));
2271 INFO_PRINTF1(_L("TestCase13L"));
2272 TRAPD(ret, TestCase13L());
2273 TEST(ret == KErrNone);
2278 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0022"));
2279 INFO_PRINTF1(_L("TestCase14"));
2285 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0023"));
2286 INFO_PRINTF1(_L("TestCase15"));
2287 TRAPD(ret, TestCase15());
2288 TEST(ret == KErrNone);
2293 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0024"));
2294 INFO_PRINTF1(_L("TestCase16"));
2295 TRAPD(ret, TestCase16L());
2296 TEST(ret == KErrNone);
2301 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0028"));
2302 INFO_PRINTF1(_L("TestCase17"));
2303 TRAPD(ret, TestCase17());
2304 TEST(ret == KErrNone);
2309 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0025"));
2310 INFO_PRINTF1(_L("TestCase18"));
2311 TRAPD(ret, TestCase18());
2312 TEST(ret == KErrNone);
2317 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0027"));
2318 INFO_PRINTF1(_L("TestCaseNotifyWhenAvailableGlobal"));
2319 TRAPD(ret, TestCaseNotifyWhenAvailableGlobal());
2320 TEST(ret == KErrNone);
2325 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0029"));
2326 INFO_PRINTF1(_L("TestCaseRegisterIdenticalPrioritiesL"));
2327 TRAPD(ret, TestCaseRegisterIdenticalPrioritiesL());
2328 TEST(ret == KErrNone);
2332 {//should be the last test case
2333 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEUPDATE-0021"));
2334 INFO_PRINTF1(_L("TestCaseTerminateServer"));
2335 TRAPD(ret, TestCaseTerminateServer());
2336 TEST(ret == KErrNone);
2340 ((CTSurfaceUpdateStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
2341 ((CTSurfaceUpdateStep*)iStep)->CloseTMSGraphicsStep();
2345 ((CTSurfaceUpdateStep*)iStep)->RecordTestResultL();
2349 __CONSTRUCT_STEP__(SurfaceUpdate)
2351 void CTSurfaceUpdateStep::TestSetupL()
2354 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalBoolProperty, (TAny*)"symbian_graphics_use_gce", &iGce);
2357 // we would need to check here whether it is gce-mode or not.
2361 User::LeaveIfError(StartServer());
2364 {//it should work for both cases, but that would be waste of time
2365 INFO_PRINTF1(_L("This test must be run in the GCE environment"));
2369 void CTSurfaceUpdateStep::TestClose()
2374 TInt CTSurfaceUpdateStep::StartServer()
2376 return StartSurfaceUpdateServer(iSurfaceUpdateProvider);
2379 void CTSurfaceUpdateStep::TerminateServer()
2381 if(iSurfaceUpdateProvider)
2383 iSurfaceUpdateProvider->Terminate();
2384 iSurfaceUpdateProvider = NULL;
2389 // Code for client that doesn't quite behave as it should
2391 TInt RMisbehavingSession::Connect(TInt aMessageSlots, TBool aWrongVersion /*= false*/)
2395 return KErrAlreadyExists;
2397 iStatusAvailable = NULL;
2398 iStatusDisplayed = NULL;
2399 iStatusDisplayedXTimes = NULL;
2401 return CreateSession(KTestSurfaceUpdateServerName, WrongVersion(), aMessageSlots);
2403 return CreateSession(KTestSurfaceUpdateServerName, Version(), aMessageSlots);
2407 void RMisbehavingSession::Close()
2411 RHandleBase::Close();
2413 iStatusAvailable = NULL;
2414 iStatusDisplayed = NULL;
2415 iStatusDisplayedXTimes = NULL;
2418 TVersion RMisbehavingSession::Version() const
2420 return (TVersion(KSurfaceUpdateServMajorVersionNumber, KSurfaceUpdateServMinorVersionNumber, KSurfaceUpdateServBuildVersionNumber));
2423 TVersion RMisbehavingSession::WrongVersion() const
2425 return (TVersion(KSurfaceUpdateServMajorVersionNumber + 1, KSurfaceUpdateServMinorVersionNumber + 1, KSurfaceUpdateServBuildVersionNumber + 1));
2429 Send the NotifyWhenAvailable request directly to the server (without waiting for submit)
2431 void RMisbehavingSession::NotifyWhenAvailableNoChecking(TRequestStatus& aStatus)
2433 SendReceive(EUpdateServNotifyWhenAvailable, aStatus);
2437 Send the NotifyWhenDisplayed request directly to the server (without waiting for submit)
2439 void RMisbehavingSession::NotifyWhenDisplayedNoChecking(TRequestStatus& aStatus)
2441 TTimeStamp* timeStamp = NULL;
2442 TIpcArgs args(timeStamp);
2443 SendReceive(EUpdateServNotifyWhenDisplayed, args, aStatus);
2447 Send the NotifyWhenDisplayedXTimes request directly to the server (without waiting for submit)
2449 void RMisbehavingSession::NotifyWhenDisplayedXTimesNoChecking(TInt aCount, TRequestStatus& aStatus)
2451 TIpcArgs args(aCount);
2452 SendReceive(EUpdateServNotifyWhenDisplayedXTimes, args, aStatus);
2456 Submit an update to the server without doing any checking of values such as screen number and buffer
2458 TInt RMisbehavingSession::SubmitUpdateNoChecking(TInt aScreen, const TSurfaceId& aSurfaceId,
2459 TInt aBuffer, const TRegion* aDirtyRegion)
2461 TPckgC<TSurfaceId> pckgSurfaceId(aSurfaceId);
2462 TIpcArgs theArgs(aScreen, &pckgSurfaceId, aBuffer);
2465 const TInt regionCount = aDirtyRegion->Count();
2468 TPtrC8 ptrRect(reinterpret_cast<const TUint8*> (aDirtyRegion->RectangleList()), regionCount * sizeof(TRect));
2469 theArgs.Set(3, &ptrRect);
2472 return SendReceive(EUpdateServSubmitUpdate, theArgs);
2476 Pass an invalid opcode to the surface update server
2478 void RMisbehavingSession::TestPassingInvalidOpcode(TInt aInvalidOpcode)
2480 SendReceive(aInvalidOpcode);
2484 Set the fail rate for OOM checking, server side.
2486 void RMisbehavingSession::SetFailRate(TInt aFailRate)
2488 TIpcArgs args(aFailRate);
2489 SendReceive(EUpdateServOOM, args);
2493 Implementation of NotifyWhenAvailable. Intended to behave the same as
2494 RSurfaceUpdateSession::NotifyWhenAvailable except it assumes that the handle
2495 to the RClass is never a Null handle.
2497 void RMisbehavingSession::NotifyWhenAvailable(TRequestStatus& aStatus)
2499 iStatusAvailable = &aStatus;
2503 Implementation of NotifyWhenDisplayed. Intended to behave the same as
2504 RSurfaceUpdateSession::NotifyWhenDisplayed except it assumes that the handle
2505 to the RClass is never a Null handle.
2507 void RMisbehavingSession::NotifyWhenDisplayed(TRequestStatus& aStatus, TTimeStamp& aTimeStamp)
2509 iStatusDisplayed = &aStatus;
2510 iTimeStamp = &aTimeStamp;
2514 Implementation of NotifyWhenDisplayedXTimes. Intended to behave the same as
2515 RSurfaceUpdateSession::NotifyWhenDisplayedXTimes except it assumes that the handle
2516 to the RClass is never a Null handle.
2518 void RMisbehavingSession::NotifyWhenDisplayedXTimes(TInt aCount, TRequestStatus& aStatus)
2520 iStatusDisplayedXTimes = &aStatus;
2525 Implementation of NotifyWhenAvailable. Intended to behave the same as
2526 RSurfaceUpdateSession::NotifyWhenAvailable except it assumes that the user
2527 will not pass invalid parameters to the function.
2529 TInt RMisbehavingSession::SubmitUpdate(TInt aScreen, const TSurfaceId& aSurfaceId,
2530 TInt aBuffer, const TRegion* aDirtyRegion/* = NULL*/)
2532 if(iStatusAvailable)
2534 SendReceive(EUpdateServNotifyWhenAvailable, *iStatusAvailable);
2535 iStatusAvailable= NULL;
2538 if(iStatusDisplayed)
2540 TIpcArgs args(iTimeStamp);
2541 SendReceive(EUpdateServNotifyWhenDisplayed, args, *iStatusDisplayed);
2542 iStatusDisplayed=NULL;
2545 if(iStatusDisplayedXTimes)
2547 TIpcArgs args(iCount);
2548 SendReceive(EUpdateServNotifyWhenDisplayedXTimes,
2549 args, *iStatusDisplayedXTimes);
2550 iStatusDisplayedXTimes=NULL;
2553 TPckgC<TSurfaceId> pckgSurfaceId(aSurfaceId);
2554 TIpcArgs theArgs(aScreen, &pckgSurfaceId, aBuffer);
2558 const TInt regionCount = aDirtyRegion->Count();
2561 TPtrC8 ptrRect(reinterpret_cast<const TUint8*> (aDirtyRegion->RectangleList()), regionCount * sizeof(TRect));
2562 theArgs.Set(3, &ptrRect);
2566 //final request for composition
2567 return SendReceive(EUpdateServSubmitUpdate, theArgs);
2571 Implementation of NotifyWhenAvailable. Intended to behave the same as
2572 RSurfaceUpdateSession::CancelAllUpdateNotifications except it assumes that the handle
2573 to the RClass is never a Null handle.
2575 void RMisbehavingSession::CancelAllUpdateNotifications()
2577 SendReceive(EUpdateServCancelAllNotifications);