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