os/graphics/egl/egltest/endpointtestsuite/automated/tsrc/egltest_endpointstreamingtests_local.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @test
    22  @internalComponent - Internal Symbian test code
    23 */
    24 
    25 
    26 #include "egltest_endpointstreamingtests.h"
    27 #include "egltest_surface.h"
    28 
    29 
    30 static const TTestCase KStreamingTestCases[] =
    31 {
    32     {
    33         TESTIDS("582"),
    34         CASETITLE("Functional: Streaming: aStatusDisplayed behaves properly within streaming block"),
    35         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
    36         {
    37         { EInitializeCase,      0, EGL_SUCCESS },
    38         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
    39         { ECreateEndpointCase,  0, EGL_SUCCESS },
    40         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 50000 },
    41         { EContentUpdateCase,   0, EGL_SUCCESS },
    42         { EBeginStreamingCase,  0, EGL_SUCCESS },
    43         { ETimeStampCase,       0, KErrNone },
    44         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
    45         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    46         { EWaitForCase,         0, KErrNone, 0, ENotifyWhenDisplayed, 55000, 50000 },
    47         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 100000 },
    48         { ETimeStampCase,       0, KErrNone },
    49         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
    50         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    51         { EWaitForCase,         0, KErrNone, 0, ENotifyWhenDisplayed, 110000, 100000 },
    52         { EEndStreamingCase,    0, EGL_SUCCESS },
    53         { EDestroyEndpointCase, 0, EGL_SUCCESS },
    54         { ETerminateCase,       0, EGL_SUCCESS },
    55         { EFinishedCase }
    56         },
    57     },
    58     {
    59         TESTIDS("584"),
    60         CASETITLE("Functional: Streaming: aStatusDisplayed behaves properly outside of streaming block"),
    61         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
    62         {
    63         { EInitializeCase,      0, EGL_SUCCESS },
    64         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
    65         { ECreateEndpointCase,  0, EGL_SUCCESS },
    66         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 50000 },
    67         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
    68         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    69         { EWaitForCase,         0, KErrNotVisible, 0, ENotifyWhenDisplayed, 55000 },
    70         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
    71         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    72         { EWaitForCase,         0, KErrNotVisible, 0, ENotifyWhenDisplayed, 5000 },
    73         { EEndStreamingCase,    0, EGL_SUCCESS },
    74         { EDestroyEndpointCase, 0, EGL_SUCCESS },
    75         { ETerminateCase,       0, EGL_SUCCESS },
    76         { EFinishedCase }
    77         },
    78     },
    79     {
    80         TESTIDS("585"),
    81         CASETITLE("Functional: Streaming: aStatusDisplayedXTimes behaves properly outside streaming block"),
    82         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
    83         {
    84         { EInitializeCase,      0, EGL_SUCCESS },
    85         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
    86         { ECreateEndpointCase,  0, EGL_SUCCESS },
    87         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 50000 },
    88         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDispXTimes, 2 },
    89         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    90         { EWaitForCase,         0, KErrNotVisible, 0, ENotifyWhenDispXTimes, 5000 },
    91         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDispXTimes, 10 },
    92         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
    93         { EWaitForCase,         0, KErrNotVisible, 0, ENotifyWhenDispXTimes, 5000 },
    94         { EEndStreamingCase,    0, EGL_SUCCESS },
    95         { EDestroyEndpointCase, 0, EGL_SUCCESS },
    96         { ETerminateCase,       0, EGL_SUCCESS },
    97         { EFinishedCase }
    98         },
    99     },
   100     {
   101         TESTIDS("586"),
   102         CASETITLE("Functional: Streaming: Additional SubmitUpdate issued before aStatusDisplayed is notified results in error KErrOverflow"),
   103         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
   104         {
   105         { EInitializeCase,      0, EGL_SUCCESS },
   106         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
   107         { ECreateEndpointCase,  0, EGL_SUCCESS },
   108         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 20000 },
   109         { EContentUpdateCase,   0, EGL_SUCCESS },
   110         { EBeginStreamingCase,  0, EGL_SUCCESS },
   111         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
   112         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   113         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   114         { EWaitForCase,         0, KErrOverflow, 0, ENotifyWhenDisplayed, 10000 },
   115         { EEndStreamingCase,    0, EGL_SUCCESS },
   116         { EDestroyEndpointCase, 0, EGL_SUCCESS },
   117         { ETerminateCase,       0, EGL_SUCCESS },
   118         { EFinishedCase }
   119         },
   120     },
   121     {
   122         TESTIDS("587A"),
   123         CASETITLE("Functional: Streaming: aStatusDisplayed behaves properly on transition out of streaming block (variant 1)"),
   124         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
   125         {
   126         { EInitializeCase,      0, EGL_SUCCESS },
   127         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
   128         { ECreateEndpointCase,  0, EGL_SUCCESS },
   129         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 20000 },
   130         { EContentUpdateCase,   0, EGL_SUCCESS },
   131         { EBeginStreamingCase,  0, EGL_SUCCESS },
   132         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
   133         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   134         { EWaitForCase,         0, KErrNone, 0, ENotifyWhenDisplayed, 25000 },
   135         { EEndStreamingCase,    0, EGL_SUCCESS },
   136         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
   137         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   138         { EWaitForCase,         0, KErrNotVisible, 0, ENotifyWhenDisplayed, 25000 },
   139         { EDestroyEndpointCase, 0, EGL_SUCCESS },
   140         { ETerminateCase,       0, EGL_SUCCESS },
   141         { EFinishedCase }
   142         },
   143     },
   144     {
   145         TESTIDS("587B"),
   146         CASETITLE("Functional: Streaming: aStatusDisplayed behaves properly on transition out of streaming block (variant 2)"),
   147         SurfaceTypes2(ESurfTypeRaw, ESurfTypeRawSingleBuffered),
   148         {
   149         { EInitializeCase,      0, EGL_SUCCESS },
   150         { ECreateSurfaceCase,   0, EGL_SUCCESS, 0, EStandardSurface },
   151         { ECreateEndpointCase,  0, EGL_SUCCESS },
   152         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 20000 },
   153         { EContentUpdateCase,   0, EGL_SUCCESS },
   154         { EBeginStreamingCase,  0, EGL_SUCCESS },
   155         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
   156         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   157         { EWaitForCase,         0, KErrNone, 0, ENotifyWhenDisplayed, 25000 },
   158         { EDestroyEndpointCase, 0, EGL_SUCCESS },
   159         { ENotifyWhenCase,      0, KErrNone, 0, ENotifyWhenDisplayed },
   160         { EContentUpdateCase,   ENoWait, EGL_SUCCESS },
   161         { EWaitForCase,         0, KErrSurfaceNotRegistered, 0, ENotifyWhenDisplayed, 25000 },
   162         { ETerminateCase,       0, EGL_SUCCESS },
   163         { EFinishedCase }
   164         },
   165     },
   166 };
   167 
   168 
   169 static const TTestCases KTestCases[] =
   170 {
   171     TestCase(KStreamingTestCases),
   172 };
   173 
   174 const TInt KNumberTestCases = sizeof(KTestCases) / sizeof(KTestCases[0]);
   175 
   176 
   177 CEglTest_LocalTestStep_EndpointStreamingTests::CEglTest_LocalTestStep_EndpointStreamingTests():
   178     CEgltest_Local_Engine(KTestCases, KNumberTestCases)
   179     {
   180     }
   181 
   182 
   183 //------------------------------------------------------
   184 // GRAPHICS-EGL-583 can only be implemented with code...
   185 //------------------------------------------------------
   186 
   187 
   188 CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream()
   189 : CLocalTestStepBase(ETestUidEndpointEngine)  // We use the engine to do the remote side functionality.
   190     {
   191     }
   192 
   193 void CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::DoPreambleL()
   194     {
   195     }
   196 
   197 void CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::DoPostambleL()
   198     {
   199     }
   200 
   201 CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::~CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream()
   202     {
   203     }
   204 
   205 void CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::RunScript(const TEngineTestCase *aTestCases, TRemoteTestParams &params)
   206     {
   207     for(TInt i = 0; aTestCases[i].iCase != EFinishedCase; i++)
   208         {
   209         params.iEndpointEngine.iEngineTestCase = aTestCases[i];
   210         RunRemoteTestCase(aTestCases[i].iCase, params);
   211         }
   212     }
   213 
   214 TUint CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::TicksForDisplayXTimesL(CSurface* aSurface, TInt aNumTimes)
   215     {
   216     //Calculate timeout by assuming low framerate of 10 fps, 
   217     //multiplying period by number of times and an extra factor of 3.
   218     //This should be plenty. Measured in microseconds.
   219     TInt timeout = 3 * aNumTimes * TInt(1000000.0f / 10.0f);
   220     
   221     TRequestStatus dispXTimesRs;
   222     User::LeaveIfError(aSurface->Notify(ENotifyWhenDispXTimes, dispXTimesRs, aNumTimes));
   223     
   224     TUint startTickCount = User::TickCount();
   225     User::LeaveIfError(aSurface->SubmitContent(EFalse));
   226     
   227     TUint32 dummyTimeStamp;
   228     TInt err = aSurface->WaitFor(ENotifyWhenDispXTimes, dispXTimesRs, timeout, dummyTimeStamp);
   229     if(err != KErrNone)
   230         {
   231         ERR_PRINTF3(_L("Waiting for ENotifyWhenDispXTimes returned %d when we expected %d."), err, KErrNone);
   232         User::Leave(err);
   233         }
   234     
   235     return User::TickCount() - startTickCount;
   236     }
   237     
   238 void CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::DispXTimesInStreamTestL(TSurfaceType aSurfaceType)
   239     {
   240     //Local: Create surface and save the id for the remote side.
   241     CSurface* surface = CSurface::SurfaceFactoryL(aSurfaceType);
   242     CleanupStack::PushL(surface);
   243     surface->CreateL(EStandardSurface);
   244     surface->GetSurfaceParamsL(iParams.iEndpointEngine.iSurfaceParams);
   245     
   246     //Remote: Init remote side and create an endpoint from the surface. (tidy up ops are on cleanup stack)
   247     static const TEngineTestCase createEndpointSteps[] = 
   248         {
   249         { EInitializeCase,      0, EGL_SUCCESS },
   250         { ECreateEndpointCase,  0, EGL_SUCCESS },
   251         { EFinishedCase,        0, EGL_SUCCESS },
   252         };
   253     RunScript(createEndpointSteps, iParams);
   254     CleanupStack::PushL(TCleanupItem(CleanupRemoteTestStep, this));
   255     
   256     //Local: Submit update for the surface so that the endpoint enters the ready state.
   257     User::LeaveIfError(surface->SubmitContent(ETrue));
   258     
   259     //Remote: Set the EGL_DELAY_NOK value and begin streaming on the endpoint.
   260     static const TEngineTestCase setDelayAndBeginStreamingSteps[] = 
   261         {
   262         { ESetAttribCase,       0, EGL_SUCCESS, 0, 0, EGL_DELAY_NOK, 5000 },
   263         { EBeginStreamingCase,  0, EGL_SUCCESS },
   264         { EFinishedCase,        0, EGL_SUCCESS },
   265         };
   266     RunScript(setDelayAndBeginStreamingSteps, iParams);
   267     
   268     //Local: Get number of ticks between submitting content and X frames being displayed.
   269     TUint ticksForDisp20Times = TicksForDisplayXTimesL(surface, 20);
   270     INFO_PRINTF2(_L("ticksForDisp20Times = %d"), ticksForDisp20Times);
   271     TUint ticksForDisp200Times = TicksForDisplayXTimesL(surface, 200);
   272     INFO_PRINTF2(_L("ticksForDisp200Times = %d"), ticksForDisp200Times);
   273     
   274     //check to see if ticksForDisp200Times = 10 * ticksForDisp20Times (with some fuzz).
   275     if( (ticksForDisp200Times < 5*ticksForDisp20Times) || (ticksForDisp200Times > 15*ticksForDisp20Times) )
   276         {
   277         ERR_PRINTF1(_L("Ratio between time for display 20 times and display 200 times not within limits."));
   278         User::Leave(EFail);
   279         }
   280     else
   281         {
   282         INFO_PRINTF1(_L("Ratio between time for display 20 times and display 200 times is within limits."));
   283         }
   284     
   285     CleanupStack::PopAndDestroy(2, surface);
   286     }
   287 
   288 TVerdict CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::doTestStepL()
   289     {
   290     static const TRemoteTestParams nullParams = {};
   291     StartRemoteTestStep(nullParams);
   292     
   293     DispXTimesInStreamTestL(ESurfTypeRaw);
   294     DispXTimesInStreamTestL(ESurfTypeRawSingleBuffered);
   295     
   296     EndRemoteTestStep(nullParams);
   297     INFO_PRINTF1(_L("EndpointStreamingDispXTimesInStream test finished"));
   298     return TestStepResult();
   299     }
   300 
   301 void CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream::CleanupRemoteTestStep(TAny* aStreamingDispXTimesInStream)
   302     {
   303     CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream* self = 
   304                 static_cast<CEglTest_LocalTestStep_EndpointStreamingDispXTimesInStream*>(aStreamingDispXTimesInStream);
   305     
   306     //Remote: Destroy the endpoint and terminate EGL.
   307     static const TEngineTestCase destroyEndpointSteps[] = 
   308         {
   309         { EDestroyEndpointCase, 0, EGL_SUCCESS },
   310         { ETerminateCase,       0, EGL_SUCCESS },
   311         { EFinishedCase },
   312         };
   313     self->RunScript(destroyEndpointSteps, self->iParams);
   314     }
   315