sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@test
|
sl@0
|
22 |
@internalComponent - Internal Symbian test code
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#include "egltest_endpointtearing.h"
|
sl@0
|
27 |
#include "egltest_endpoint_images.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
|
sl@0
|
30 |
CEglTest_RemoteTestStep_EndpointTearing::CEglTest_RemoteTestStep_EndpointTearing() :
|
sl@0
|
31 |
CRemoteTestStepBase(ETestUidEndpointTearing)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
CEglTest_RemoteTestStep_EndpointTearing::~CEglTest_RemoteTestStep_EndpointTearing()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoStartRemoteTestStepL(const TRemoteTestParams& aMessageIn)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
REMOTE_INFO_PRINTF1(_L("Starting Remote Test Step."));
|
sl@0
|
44 |
|
sl@0
|
45 |
EglStartL();
|
sl@0
|
46 |
iDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
sl@0
|
47 |
|
sl@0
|
48 |
TSurfaceId surface = aMessageIn.iEndpointTearing.iSurfaceId;
|
sl@0
|
49 |
iEndpoint = EglEndpoint().CreateEndpoint(iDisplay, EGL_ENDPOINT_TYPE_CONSUMER_NOK, EGL_TSURFACEID_NOK, &surface, NULL);
|
sl@0
|
50 |
if(iEndpoint == EGL_NO_ENDPOINT_NOK)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
REMOTE_ERR_PRINTF2(_L("Failed to create endpoint. err = %d"), eglGetError());
|
sl@0
|
53 |
User::Leave(KErrBadHandle);
|
sl@0
|
54 |
}
|
sl@0
|
55 |
REMOTE_INFO_PRINTF1(_L("Endpoint created."));
|
sl@0
|
56 |
|
sl@0
|
57 |
return ERtvPass;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoEndRemoteTestStepL(const TRemoteTestParams& /*aMessageIn*/)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
REMOTE_INFO_PRINTF1(_L("Ending Remote Test Step."));
|
sl@0
|
64 |
EglEndpoint().DestroyEndpoint(iDisplay, iEndpoint);
|
sl@0
|
65 |
EglEndL();
|
sl@0
|
66 |
return ERtvPass;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::DoRunRemoteTestCaseL(TInt aTestCase, const TRemoteTestParams& aParams)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
switch(aTestCase)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
case 0: return TearingTestCaseL(aParams);
|
sl@0
|
75 |
default: return ERtvAbort;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::TearingTestCaseL(const TRemoteTestParams& /*aParams*/)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
//Begin streaming.
|
sl@0
|
83 |
EGLBoolean result = EglEndpoint().EndpointBeginStreaming(iDisplay, iEndpoint);
|
sl@0
|
84 |
if(result == EGL_FALSE)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
REMOTE_ERR_PRINTF2(_L("Failed to enter streaming block. err = %d"), eglGetError());
|
sl@0
|
87 |
User::Leave(KErrBadHandle);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
//Create an EglWindowSurface so we have a current context for vg operations.
|
sl@0
|
91 |
CEglWindowSurface* surface = CEglWindowSurface::NewL();
|
sl@0
|
92 |
CleanupStack::PushL(surface);
|
sl@0
|
93 |
surface->CreateL(EStandardSurface, TPoint(0, 0));
|
sl@0
|
94 |
surface->ActivateL();
|
sl@0
|
95 |
|
sl@0
|
96 |
REMOTE_INFO_PRINTF1(_L("Repeatedly acquiring images and checking for evidence of tearing."));
|
sl@0
|
97 |
|
sl@0
|
98 |
//The test should run for 7 seconds so we use a timer
|
sl@0
|
99 |
//and loop while the request status is KRequestPending.
|
sl@0
|
100 |
TRequestStatus notifyTimeDone;
|
sl@0
|
101 |
RTimer timer;
|
sl@0
|
102 |
User::LeaveIfError(timer.CreateLocal());
|
sl@0
|
103 |
CleanupClosePushL(timer);
|
sl@0
|
104 |
timer.After(notifyTimeDone, 7 * 1000000);
|
sl@0
|
105 |
|
sl@0
|
106 |
//Acquire and check that image is solid colour in a loop while the timer has not fired.
|
sl@0
|
107 |
TRemoteTestVerdict retVal = ERtvPass;
|
sl@0
|
108 |
TInt numIters = 0;
|
sl@0
|
109 |
while(notifyTimeDone.Int() == KRequestPending)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TRAPD(err, retVal = AcquireAndCheckImageL());
|
sl@0
|
112 |
if(err != KErrNone)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
//Cancel the timer, wait for the notification and re-leave.
|
sl@0
|
115 |
timer.Cancel();
|
sl@0
|
116 |
User::WaitForRequest(notifyTimeDone);
|
sl@0
|
117 |
User::Leave(err);
|
sl@0
|
118 |
}
|
sl@0
|
119 |
if(retVal != ERtvPass)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
REMOTE_ERR_PRINTF2(_L("Detected tearing in aquired image number %d"), numIters);
|
sl@0
|
122 |
timer.Cancel();
|
sl@0
|
123 |
break;
|
sl@0
|
124 |
}
|
sl@0
|
125 |
++numIters;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
//Tidy up the thread semaphore.
|
sl@0
|
129 |
User::WaitForRequest(notifyTimeDone);
|
sl@0
|
130 |
|
sl@0
|
131 |
REMOTE_ERR_PRINTF2(_L("Number of successful iterations: %d"), numIters);
|
sl@0
|
132 |
|
sl@0
|
133 |
CleanupStack::PopAndDestroy(2, surface);
|
sl@0
|
134 |
EglEndpoint().EndpointEndStreaming(iDisplay, iEndpoint);
|
sl@0
|
135 |
return retVal;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
|
sl@0
|
139 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::AcquireAndCheckImageL()
|
sl@0
|
140 |
{
|
sl@0
|
141 |
//Acquire an image from the endpoint.
|
sl@0
|
142 |
EGLImageKHR eglImage = EglEndpoint().AcquireImage(iDisplay, iEndpoint);
|
sl@0
|
143 |
if(eglImage == EGL_NO_IMAGE_KHR)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
REMOTE_ERR_PRINTF2(_L("Failed to acquire image from endpoint. err = %d"), eglGetError());
|
sl@0
|
146 |
User::Leave(KErrBadHandle);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
//Check the image. This bit can leave, so we trap it so we
|
sl@0
|
150 |
//have an opportunity to release the image before re-leaving.
|
sl@0
|
151 |
TRemoteTestVerdict retVal = ERtvPass;
|
sl@0
|
152 |
TRAPD(err, retVal = CheckImageL(eglImage));
|
sl@0
|
153 |
|
sl@0
|
154 |
//Release the image back to the endpoint.
|
sl@0
|
155 |
EGLBoolean err2 = EglEndpoint().ReleaseImage(iDisplay, iEndpoint, eglImage, EGL_OPENVG_API);
|
sl@0
|
156 |
|
sl@0
|
157 |
//Report the 1st error.
|
sl@0
|
158 |
User::LeaveIfError(err);
|
sl@0
|
159 |
if(err2 == EGL_FALSE)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
REMOTE_ERR_PRINTF2(_L("Failed to release image back to endpoint. err = %d"), eglGetError());
|
sl@0
|
162 |
User::Leave(KErrBadHandle);
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
return retVal;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
|
sl@0
|
169 |
TRemoteTestVerdict CEglTest_RemoteTestStep_EndpointTearing::CheckImageL(EGLImageKHR aEglImage)
|
sl@0
|
170 |
{
|
sl@0
|
171 |
//Convert the image to a CTestVgEglImage
|
sl@0
|
172 |
CTestVgEglImage* vgEglImage = CTestVgEglImage::NewL(aEglImage);
|
sl@0
|
173 |
CleanupStack::PushL(vgEglImage);
|
sl@0
|
174 |
|
sl@0
|
175 |
//Check the corners and center pixel are the same colour.
|
sl@0
|
176 |
TBool retVal = vgEglImage->IsSolidColourL();
|
sl@0
|
177 |
|
sl@0
|
178 |
CleanupStack::PopAndDestroy(vgEglImage);
|
sl@0
|
179 |
return retVal ? ERtvPass : ERtvFail;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|