os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointtearing_remote.cpp
First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 @internalComponent - Internal Symbian test code
26 #include "egltest_endpointtearing.h"
27 #include "egltest_endpoint_images.h"
30 CEglTest_RemoteTestStep_EndpointTearing::CEglTest_RemoteTestStep_EndpointTearing() :
31 CRemoteTestStepBase(ETestUidEndpointTearing)
36 CEglTest_RemoteTestStep_EndpointTearing::~CEglTest_RemoteTestStep_EndpointTearing()
41 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoStartRemoteTestStepL(const TRemoteTestParams& aMessageIn)
43 REMOTE_INFO_PRINTF1(_L("Starting Remote Test Step."));
46 iDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
48 TSurfaceId surface = aMessageIn.iEndpointTearing.iSurfaceId;
49 iEndpoint = EglEndpoint().CreateEndpoint(iDisplay, EGL_ENDPOINT_TYPE_CONSUMER_NOK, EGL_TSURFACEID_NOK, &surface, NULL);
50 if(iEndpoint == EGL_NO_ENDPOINT_NOK)
52 REMOTE_ERR_PRINTF2(_L("Failed to create endpoint. err = %d"), eglGetError());
53 User::Leave(KErrBadHandle);
55 REMOTE_INFO_PRINTF1(_L("Endpoint created."));
61 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoEndRemoteTestStepL(const TRemoteTestParams& /*aMessageIn*/)
63 REMOTE_INFO_PRINTF1(_L("Ending Remote Test Step."));
64 EglEndpoint().DestroyEndpoint(iDisplay, iEndpoint);
70 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aParams)
74 case 0: return TearingTestCaseL(aParams);
75 default: return ERtvAbort;
80 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::TearingTestCaseL(const TRemoteTestParams& /*aParams*/)
83 EGLBoolean result = EglEndpoint().EndpointBeginStreaming(iDisplay, iEndpoint);
84 if(result == EGL_FALSE)
86 REMOTE_ERR_PRINTF2(_L("Failed to enter streaming block. err = %d"), eglGetError());
87 User::Leave(KErrBadHandle);
90 //Create an EglWindowSurface so we have a current context for vg operations.
91 CEglWindowSurface* surface = CEglWindowSurface::NewL();
92 CleanupStack::PushL(surface);
93 surface->CreateL(EStandardSurface, TPoint(0, 0));
96 REMOTE_INFO_PRINTF1(_L("Repeatedly acquiring images and checking for evidence of tearing."));
98 //The test should run for 7 seconds so we use a timer
99 //and loop while the request status is KRequestPending.
100 TRequestStatus notifyTimeDone;
102 User::LeaveIfError(timer.CreateLocal());
103 CleanupClosePushL(timer);
104 timer.After(notifyTimeDone, 7 * 1000000);
106 //Acquire and check that image is solid colour in a loop while the timer has not fired.
107 TRemoteTestVerdict retVal = ERtvPass;
109 while(notifyTimeDone.Int() == KRequestPending)
111 TRAPD(err, retVal = AcquireAndCheckImageL());
114 //Cancel the timer, wait for the notification and re-leave.
116 User::WaitForRequest(notifyTimeDone);
119 if(retVal != ERtvPass)
121 REMOTE_ERR_PRINTF2(_L("Detected tearing in aquired image number %d"), numIters);
128 //Tidy up the thread semaphore.
129 User::WaitForRequest(notifyTimeDone);
131 REMOTE_ERR_PRINTF2(_L("Number of successful iterations: %d"), numIters);
133 CleanupStack::PopAndDestroy(2, surface);
134 EglEndpoint().EndpointEndStreaming(iDisplay, iEndpoint);
139 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::AcquireAndCheckImageL()
141 //Acquire an image from the endpoint.
142 EGLImageKHR eglImage = EglEndpoint().AcquireImage(iDisplay, iEndpoint);
143 if(eglImage == EGL_NO_IMAGE_KHR)
145 REMOTE_ERR_PRINTF2(_L("Failed to acquire image from endpoint. err = %d"), eglGetError());
146 User::Leave(KErrBadHandle);
149 //Check the image. This bit can leave, so we trap it so we
150 //have an opportunity to release the image before re-leaving.
151 TRemoteTestVerdict retVal = ERtvPass;
152 TRAPD(err, retVal = CheckImageL(eglImage));
154 //Release the image back to the endpoint.
155 EGLBoolean err2 = EglEndpoint().ReleaseImage(iDisplay, iEndpoint, eglImage, EGL_OPENVG_API);
157 //Report the 1st error.
158 User::LeaveIfError(err);
159 if(err2 == EGL_FALSE)
161 REMOTE_ERR_PRINTF2(_L("Failed to release image back to endpoint. err = %d"), eglGetError());
162 User::Leave(KErrBadHandle);
169 TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::CheckImageL(EGLImageKHR aEglImage)
171 //Convert the image to a CTestVgEglImage
172 CTestVgEglImage* vgEglImage = CTestVgEglImage::NewL(aEglImage);
173 CleanupStack::PushL(vgEglImage);
175 //Check the corners and center pixel are the same colour.
176 TBool retVal = vgEglImage->IsSolidColourL();
178 CleanupStack::PopAndDestroy(vgEglImage);
179 return retVal ? ERtvPass : ERtvFail;