os/graphics/graphicscomposition/openwfcompositionengine/test/tscreeninterface/tscreeninterface.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
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
//
sl@0
     3
// Permission is hereby granted, free of charge, to any person obtaining a
sl@0
     4
// copy of this software and/or associated documentation files (the
sl@0
     5
// "Materials"), to deal in the Materials without restriction, including
sl@0
     6
// without limitation the rights to use, copy, modify, merge, publish,
sl@0
     7
// distribute, sublicense, and/or sell copies of the Materials, and to
sl@0
     8
// permit persons to whom the Materials are furnished to do so, subject to
sl@0
     9
// the following conditions:
sl@0
    10
//
sl@0
    11
// The above copyright notice and this permission notice shall be included
sl@0
    12
// in all copies or substantial portions of the Materials.
sl@0
    13
//
sl@0
    14
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
sl@0
    15
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
sl@0
    16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
sl@0
    17
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
sl@0
    18
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
sl@0
    19
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
sl@0
    20
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
sl@0
    21
//
sl@0
    22
// Description:
sl@0
    23
// Implementation of test class for OpenWF-C RI display driver interface 
sl@0
    24
//
sl@0
    25
sl@0
    26
#include <WF/openwfc_ri_display.h>
sl@0
    27
#include <WF/openwfc_ri_display_update.h>
sl@0
    28
#include <test/extendtef.h>
sl@0
    29
#include <test/tefunit.h>
sl@0
    30
#include <hal.h>
sl@0
    31
#include "tscreeninterface.h"
sl@0
    32
sl@0
    33
#define KCompositorVersion 0x01023456
sl@0
    34
#define KRgbRed         TRgb(0x0000ff)
sl@0
    35
#define KRgbGreen       TRgb(0x00ff00)
sl@0
    36
#define KRgbYellow      TRgb(0x00ffff)
sl@0
    37
#define KRgbBlue        TRgb(0xff0000)
sl@0
    38
sl@0
    39
const TInt KDefaultScreenNumber = 0;
sl@0
    40
const TTimeIntervalMicroSeconds32 KDelay = 1000000;  //delay in microseconds
sl@0
    41
const TTimeIntervalMicroSeconds32 KMinimalDelay = 1000;  //delay in microseconds
sl@0
    42
sl@0
    43
_LIT(KImageSectionName, "ImageInfo");
sl@0
    44
_LIT(KContiguousFlag, "ContiguousFlag");
sl@0
    45
_LIT(KNonFastpathablePixelFormat, "NonFastpathablePixelFormat");
sl@0
    46
_LIT(KFastpathablePixelFormat, "FastpathablePixelFormat");
sl@0
    47
sl@0
    48
/*
sl@0
    49
 * CTestScreenInterface implementation
sl@0
    50
 */
sl@0
    51
sl@0
    52
CTestScreenInterface::CTestScreenInterface()
sl@0
    53
:iContiguous(EFlagNotListed),
sl@0
    54
 iFastpathablePixelFormat(EUidPixelFormatARGB_8888_PRE),
sl@0
    55
 iNonFastpathablePixelFormat(EUidPixelFormatRGB_565),
sl@0
    56
 iMappable(ETrue),
sl@0
    57
 iMaxBuffers(2),
sl@0
    58
 iMinBuffers(1),
sl@0
    59
 iCacheAttrib(ECacheNotlisted)
sl@0
    60
	{
sl@0
    61
	// No implementation required
sl@0
    62
	}
sl@0
    63
sl@0
    64
CTestScreenInterface::~CTestScreenInterface()
sl@0
    65
	{
sl@0
    66
    TearDown();
sl@0
    67
	}
sl@0
    68
sl@0
    69
void CTestScreenInterface::SetupL()
sl@0
    70
	{
sl@0
    71
	iUtility = CStreamUtility::NewL();
sl@0
    72
	iRed.SetInternal(0xFFFF0000);
sl@0
    73
	iGreen.SetInternal(0xFF00FF00);
sl@0
    74
	iBlue.SetInternal(0xFF0000FF);
sl@0
    75
	ReadIniData();
sl@0
    76
    User::After(KDelay); // consider reading delay from ini file
sl@0
    77
	}
sl@0
    78
sl@0
    79
/**
sl@0
    80
 * test Suite furniture 
sl@0
    81
 **/
sl@0
    82
void CTestScreenInterface::TearDownL()
sl@0
    83
	{
sl@0
    84
    // Nothing leaves in this function, 
sl@0
    85
    // but TearDownL() is needed for the CTestFixture (TEF) interface
sl@0
    86
    TearDown();
sl@0
    87
	}
sl@0
    88
sl@0
    89
void CTestScreenInterface::TearDown()
sl@0
    90
    {
sl@0
    91
    if(iUtility)
sl@0
    92
        {
sl@0
    93
        delete iUtility;
sl@0
    94
        iUtility = NULL;
sl@0
    95
        }
sl@0
    96
    }
sl@0
    97
sl@0
    98
// Create a suite of all the tests
sl@0
    99
CTestSuite* CTestScreenInterface::CreateSuiteL(const TDesC& aName)
sl@0
   100
	{
sl@0
   101
	SymbianStreamRegisterScreenNotifications(0, 10, KCompositorVersion);
sl@0
   102
	SUB_SUITE_OPT(CTestScreenInterface,NULL);
sl@0
   103
sl@0
   104
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0100L);
sl@0
   105
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0101L);
sl@0
   106
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0102L);
sl@0
   107
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0103L);
sl@0
   108
		ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0104L);
sl@0
   109
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0105L);
sl@0
   110
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0106L);
sl@0
   111
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0107L);
sl@0
   112
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0108L);		
sl@0
   113
        ADD_THIS_TEST_STEP(GRAPHICS_OPENWFC_SCREENINTERFACE_0109L);
sl@0
   114
sl@0
   115
        END_SUITE;	
sl@0
   116
	
sl@0
   117
	}
sl@0
   118
sl@0
   119
/// This handles any non-member uses of the extended ASSERT_XXX macros
sl@0
   120
void TefUnitFailLeaveL()
sl@0
   121
	{
sl@0
   122
	User::Leave(KErrTEFUnitFail);
sl@0
   123
	}
sl@0
   124
sl@0
   125
void CTestScreenInterface::ReadIniData()
sl@0
   126
    {
sl@0
   127
    TBool contiguousFlag;
sl@0
   128
    TBool returnValue = iConfig.GetBool(KImageSectionName, KContiguousFlag, contiguousFlag);
sl@0
   129
    if (returnValue)
sl@0
   130
        {
sl@0
   131
        if(contiguousFlag)
sl@0
   132
            {
sl@0
   133
            iContiguous = EContiguous;
sl@0
   134
            }
sl@0
   135
        else
sl@0
   136
            {
sl@0
   137
            iContiguous = ENonContiguous;
sl@0
   138
            }
sl@0
   139
        }
sl@0
   140
    
sl@0
   141
    TInt fastpathablePixelFormat;
sl@0
   142
    returnValue = iConfig.GetHex(KImageSectionName, KFastpathablePixelFormat, fastpathablePixelFormat);
sl@0
   143
    if(returnValue)
sl@0
   144
        {
sl@0
   145
        iFastpathablePixelFormat = static_cast<TUidPixelFormat>(fastpathablePixelFormat);
sl@0
   146
        }
sl@0
   147
    
sl@0
   148
    TInt nonFastpathablePixelFormat;
sl@0
   149
    returnValue = iConfig.GetHex(KImageSectionName, KNonFastpathablePixelFormat, nonFastpathablePixelFormat);
sl@0
   150
    if(returnValue)
sl@0
   151
        {
sl@0
   152
        iNonFastpathablePixelFormat = static_cast<TUidPixelFormat>(nonFastpathablePixelFormat);
sl@0
   153
        }
sl@0
   154
    }
sl@0
   155
sl@0
   156
TInt CTestScreenInterface::BaseTestContiguousFlag(TBool aContiguous)
sl@0
   157
     {
sl@0
   158
      COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   159
      CleanupStack::PushL(screenContext);
sl@0
   160
      
sl@0
   161
      TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   162
      screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   163
                                  &screenRotation,
sl@0
   164
                                  sizeof(screenRotation));
sl@0
   165
      screenContext->CommitAttribute();
sl@0
   166
sl@0
   167
      COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   168
      screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   169
                                  sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   170
      
sl@0
   171
      TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   172
      SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   173
                                                  iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   174
                                                  surface, aContiguous, 1);
sl@0
   175
      ASSERT_FALSE((*ns).IsNull());
sl@0
   176
sl@0
   177
      iUtility->FillStreamL(ns, KRgbGreen);
sl@0
   178
      
sl@0
   179
      TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   180
      Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, _L("SetTopLayerSurface() returned %i"),err );
sl@0
   181
	  RDebug::Printf("SetTopLayerSurface() returned %i",err);
sl@0
   182
      
sl@0
   183
	  if (err==KErrNone)
sl@0
   184
	      {    //Must successfully SetTopLayerSurface before calling UpdateDisplay. 
sl@0
   185
          screenContext->UpdateDisplay();
sl@0
   186
	      }
sl@0
   187
sl@0
   188
      CleanupStack::PopAndDestroy(screenContext);
sl@0
   189
      
sl@0
   190
      return err;
sl@0
   191
     }
sl@0
   192
     
sl@0
   193
/**
sl@0
   194
@SYMTestCaseID			GRAPHICS_OPENWFC_SCREENINTERFACE_0100
sl@0
   195
@SYMTestCaseDesc		Create a screen size stream and display on screen
sl@0
   196
@SYMREQ					
sl@0
   197
@SYMPREQ				REQ 417-54885
sl@0
   198
@SYMTestType            Unit Test			
sl@0
   199
@SYMTestPriority        High		
sl@0
   200
@SYMTestPurpose			Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen 
sl@0
   201
@SYMTestActions	        
sl@0
   202
                        Create a screen context
sl@0
   203
                        Set display attributes 
sl@0
   204
                        Create a screen size stream based on the display attributes with contigous and non-contiguous flags
sl@0
   205
                        Fill the stream
sl@0
   206
                        Associates the stream with the topmost display layer
sl@0
   207
                        Update the screen
sl@0
   208
@SYMTestExpectedResults 
sl@0
   209
                        If contiguous flag is set in the ini file, and the stream is created using the flag, 
sl@0
   210
                        the stream should be properly displayed on screen. The stream created using the opposit flag from ini value should fail.
sl@0
   211
                        If contiguous flag is not set in the ini file, 
sl@0
   212
                        the stream should be properly displayed on screen for contiguous and non-contiguous flag.
sl@0
   213
 **/		
sl@0
   214
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()
sl@0
   215
	{
sl@0
   216
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L()"));
sl@0
   217
    LOG((" *** CTestScreenInterface test 0100L"));
sl@0
   218
 
sl@0
   219
    if(iContiguous != EFlagNotListed)
sl@0
   220
        {
sl@0
   221
sl@0
   222
        // We expect the opposit flag to the one from the ini file to fail
sl@0
   223
        if(iContiguous == EContiguous)
sl@0
   224
            {
sl@0
   225
            ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(ENonContiguous));       
sl@0
   226
            }
sl@0
   227
        else
sl@0
   228
            {
sl@0
   229
            ASSERT_TRUE(KErrNotSupported == BaseTestContiguousFlag(EContiguous));       
sl@0
   230
            }
sl@0
   231
        // The contiguous flag from the ini file should pass
sl@0
   232
        ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(iContiguous));
sl@0
   233
        // The last run here should be the "good" run so that it can do a Display() call.
sl@0
   234
        }
sl@0
   235
    else
sl@0
   236
        {
sl@0
   237
        // Contiguous or Non-contiguous flags should both pass if nothing set in the ini file
sl@0
   238
        ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(EContiguous));       
sl@0
   239
        ASSERT_TRUE(KErrNone == BaseTestContiguousFlag(ENonContiguous));           
sl@0
   240
        }
sl@0
   241
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0100L() done"));
sl@0
   242
    LOG((" *** CTestScreenInterface test 0100L done"));
sl@0
   243
	}
sl@0
   244
sl@0
   245
/**
sl@0
   246
@SYMTestCaseID			GRAPHICS_OPENWFC_SCREENINTERFACE_0101
sl@0
   247
@SYMTestCaseDesc		Create a stream, display on screen, then rotate the screen involving scaling
sl@0
   248
@SYMREQ					
sl@0
   249
@SYMPREQ				REQ 417-54885
sl@0
   250
@SYMTestType            Unit Test			
sl@0
   251
@SYMTestPriority        Medium		
sl@0
   252
@SYMTestPurpose			Verify screen rotation works  
sl@0
   253
@SYMTestActions	
sl@0
   254
                        Create a screen context
sl@0
   255
                        Set display attributes 
sl@0
   256
                        Create a screen size stream 
sl@0
   257
                        Fill the stream
sl@0
   258
                        Associates the stream with the topmost display layer
sl@0
   259
                        Update the screen
sl@0
   260
                        Rotate the screen 90 degrees, 180 degrees, 270 degrees
sl@0
   261
                        Update the screen respectively
sl@0
   262
@SYMTestExpectedResults
sl@0
   263
                        Methods should complete without error.
sl@0
   264
                        The stream should be properly displayed on screen
sl@0
   265
 **/
sl@0
   266
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()
sl@0
   267
	{
sl@0
   268
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0101L()"));
sl@0
   269
    LOG((" *** CTestScreenInterface test 0101L"));
sl@0
   270
 
sl@0
   271
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   272
    CleanupStack::PushL(screenContext);
sl@0
   273
    
sl@0
   274
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   275
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   276
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   277
sl@0
   278
    if (attributes.iSupportedRotations > 1)
sl@0
   279
        {    
sl@0
   280
        INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
sl@0
   281
        TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   282
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   283
                                &screenRotation0,
sl@0
   284
                                sizeof(screenRotation0));
sl@0
   285
        screenContext->CommitAttribute();
sl@0
   286
sl@0
   287
        TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   288
        SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   289
                                                iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   290
                                                surface, iContiguous, 1);
sl@0
   291
    
sl@0
   292
        ASSERT_FALSE((*ns).IsNull());
sl@0
   293
        iUtility->FillStreamL(ns, KRgbRed);
sl@0
   294
    
sl@0
   295
        TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   296
        ASSERT_TRUE(err == KErrNone);
sl@0
   297
sl@0
   298
        err = screenContext->UpdateDisplay();   
sl@0
   299
        ASSERT_TRUE(err == KErrNone);
sl@0
   300
sl@0
   301
        INFO_PRINTF1(_L("Rotate screen 90 degree"));
sl@0
   302
        // Rotate screen 90 degree and test
sl@0
   303
        TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
sl@0
   304
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   305
                                &screenRotation1,
sl@0
   306
                                sizeof(screenRotation1));
sl@0
   307
        screenContext->CommitAttribute();
sl@0
   308
sl@0
   309
        err = screenContext->UpdateDisplay();   
sl@0
   310
        ASSERT_TRUE(err == KErrNone);    
sl@0
   311
sl@0
   312
        if (attributes.iSupportedRotations > 2)
sl@0
   313
            {
sl@0
   314
            INFO_PRINTF1(_L("Rotate screen 180 degree"));
sl@0
   315
            // Rotate screen 180 degree and test
sl@0
   316
            TUint32 screenRotation2 = COpenWFC_RI_Display::EScreenRotate180;
sl@0
   317
            screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   318
                                    &screenRotation2,
sl@0
   319
                                    sizeof(screenRotation2));
sl@0
   320
            screenContext->CommitAttribute();
sl@0
   321
sl@0
   322
            err = screenContext->UpdateDisplay();   
sl@0
   323
            ASSERT_TRUE(err == KErrNone);
sl@0
   324
            }
sl@0
   325
sl@0
   326
        if (attributes.iSupportedRotations > 3)
sl@0
   327
            {
sl@0
   328
            INFO_PRINTF1(_L("Rotate screen 270 degree"));
sl@0
   329
            // Rotate screen 270 degree and test
sl@0
   330
            TUint32 screenRotation3 = COpenWFC_RI_Display::EScreenRotate270;
sl@0
   331
            screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   332
                                    &screenRotation3,
sl@0
   333
                                    sizeof(screenRotation3));
sl@0
   334
            screenContext->CommitAttribute();
sl@0
   335
sl@0
   336
            err = screenContext->UpdateDisplay();   
sl@0
   337
            ASSERT_TRUE(err == KErrNone);
sl@0
   338
            }
sl@0
   339
        
sl@0
   340
        // Set screen back to rotation 0 
sl@0
   341
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   342
                                    &screenRotation0,
sl@0
   343
                                    sizeof(screenRotation0));
sl@0
   344
        screenContext->CommitAttribute();
sl@0
   345
        err = screenContext->UpdateDisplay();   
sl@0
   346
        ASSERT_TRUE(err == KErrNone);    
sl@0
   347
        }
sl@0
   348
    else
sl@0
   349
        {
sl@0
   350
        INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
sl@0
   351
        }
sl@0
   352
sl@0
   353
    CleanupStack::PopAndDestroy(screenContext);
sl@0
   354
	}
sl@0
   355
sl@0
   356
/**
sl@0
   357
@SYMTestCaseID			GRAPHICS_OPENWFC_SCREENINTERFACE_0102
sl@0
   358
@SYMTestCaseDesc        Create a stream, display on screen, then rotate the screen, not involving scaling
sl@0
   359
@SYMREQ                 
sl@0
   360
@SYMPREQ                REQ 417-54885
sl@0
   361
@SYMTestType            Unit Test           
sl@0
   362
@SYMTestPriority        Medium      
sl@0
   363
@SYMTestPurpose         Verify screen rotation works  
sl@0
   364
@SYMTestActions 
sl@0
   365
                        Create a screen context
sl@0
   366
                        Set display attributes 
sl@0
   367
                        Create a stream of the size (screenHeight, screenWidth)
sl@0
   368
                        Fill the stream
sl@0
   369
                        Associates the stream with the topmost display layer
sl@0
   370
                        Update the screen
sl@0
   371
                        Rotate the screen 90 degrees
sl@0
   372
                        Update the screen
sl@0
   373
@SYMTestExpectedResults
sl@0
   374
                        Methods should complete without error.
sl@0
   375
                        The stream should be properly displayed on screen
sl@0
   376
 **/		
sl@0
   377
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()
sl@0
   378
	{
sl@0
   379
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0102L()"));
sl@0
   380
    LOG((" *** CTestScreenInterface test 0102L"));
sl@0
   381
 
sl@0
   382
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   383
    CleanupStack::PushL(screenContext);
sl@0
   384
    
sl@0
   385
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   386
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   387
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   388
sl@0
   389
    if (attributes.iSupportedRotations > 1)
sl@0
   390
        {    
sl@0
   391
        INFO_PRINTF2(_L("Number of supported rotations: %i "), attributes.iSupportedRotations);
sl@0
   392
        TUint32 screenRotation0 = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   393
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   394
                                &screenRotation0,
sl@0
   395
                                sizeof(screenRotation0));
sl@0
   396
        screenContext->CommitAttribute();
sl@0
   397
sl@0
   398
        TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   399
        SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalHeight,attributes.iNormalWidth), 
sl@0
   400
                                                iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   401
                                                surface, iContiguous, 1);
sl@0
   402
    
sl@0
   403
        ASSERT_FALSE((*ns).IsNull());
sl@0
   404
        iUtility->FillStreamL(ns, KRgbRed);
sl@0
   405
    
sl@0
   406
        TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   407
        ASSERT_TRUE(err == KErrNone);
sl@0
   408
sl@0
   409
        err = screenContext->UpdateDisplay();   
sl@0
   410
        ASSERT_TRUE(err == KErrNone);
sl@0
   411
sl@0
   412
        INFO_PRINTF1(_L("Rotate screen 90 degree"));
sl@0
   413
        // Rotate screen 90 degree and test
sl@0
   414
        TUint32 screenRotation1 = COpenWFC_RI_Display::EScreenRotate90;
sl@0
   415
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   416
                                &screenRotation1,
sl@0
   417
                                sizeof(screenRotation1));
sl@0
   418
        screenContext->CommitAttribute();
sl@0
   419
sl@0
   420
        err = screenContext->UpdateDisplay();   
sl@0
   421
        ASSERT_TRUE(err == KErrNone);    
sl@0
   422
        }
sl@0
   423
    else
sl@0
   424
        {
sl@0
   425
        INFO_PRINTF1(_L("Screen rotation is not supported. Test skipped."));
sl@0
   426
        }
sl@0
   427
sl@0
   428
    CleanupStack::PopAndDestroy(screenContext);
sl@0
   429
	}
sl@0
   430
sl@0
   431
/**
sl@0
   432
@SYMTestCaseID			GRAPHICS_OPENWFC_SCREENINTERFACE_0103
sl@0
   433
@SYMTestCaseDesc		Create a stream, fill the stream several times and display on screen
sl@0
   434
@SYMREQ					
sl@0
   435
@SYMPREQ                REQ 417-54885
sl@0
   436
@SYMTestType            Unit Test			
sl@0
   437
@SYMTestPriority        High				
sl@0
   438
@SYMTestPurpose	        Check displaying stream repeatedly	
sl@0
   439
@SYMTestActions	
sl@0
   440
                        Create a screen context
sl@0
   441
                        Set display attributes 
sl@0
   442
                        Create a screen size stream 
sl@0
   443
                        Fill the stream 
sl@0
   444
                        Associates the stream with the topmost display layer
sl@0
   445
                        Update the screen
sl@0
   446
                        Repeat filling the stream, associate with toplayer and update several times
sl@0
   447
                        Destory the screen context                       
sl@0
   448
@SYMTestExpectedResults
sl@0
   449
                        Methods should complete without error.
sl@0
   450
                        Each time, the stream should be properly displayed on screen
sl@0
   451
 **/
sl@0
   452
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()
sl@0
   453
	{
sl@0
   454
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0103L()"));
sl@0
   455
    LOG((" *** CTestScreenInterface test 0103L"));
sl@0
   456
 
sl@0
   457
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   458
    CleanupStack::PushL(screenContext);
sl@0
   459
    
sl@0
   460
    TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   461
    screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   462
                                &screenRotation,
sl@0
   463
                                sizeof(screenRotation));
sl@0
   464
    screenContext->CommitAttribute();
sl@0
   465
sl@0
   466
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   467
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   468
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   469
    
sl@0
   470
    TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   471
    SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   472
                                                iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   473
                                                surface, iContiguous, 1);
sl@0
   474
    ASSERT_FALSE((*ns).IsNull());
sl@0
   475
sl@0
   476
    iUtility->FillStreamL(ns, KRgbYellow);    
sl@0
   477
    TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   478
    ASSERT_TRUE(err == KErrNone);    
sl@0
   479
    err = screenContext->UpdateDisplay();    
sl@0
   480
    ASSERT_TRUE(err == KErrNone);
sl@0
   481
    User::After(KDelay);
sl@0
   482
sl@0
   483
    iUtility->FillStreamL(ns, KRgbRed);    
sl@0
   484
    err = screenContext->SetTopLayerSurface(ns);
sl@0
   485
    ASSERT_TRUE(err == KErrNone);    
sl@0
   486
    err = screenContext->UpdateDisplay();    
sl@0
   487
    ASSERT_TRUE(err == KErrNone);
sl@0
   488
    User::After(KDelay);
sl@0
   489
    
sl@0
   490
    iUtility->FillStreamL(ns, KRgbGreen);    
sl@0
   491
    err = screenContext->SetTopLayerSurface(ns);
sl@0
   492
    ASSERT_TRUE(err == KErrNone);    
sl@0
   493
    err = screenContext->UpdateDisplay();    
sl@0
   494
    ASSERT_TRUE(err == KErrNone);
sl@0
   495
    User::After(KDelay);
sl@0
   496
    
sl@0
   497
    iUtility->FillStreamL(ns, KRgbYellow);    
sl@0
   498
    err = screenContext->SetTopLayerSurface(ns);
sl@0
   499
    ASSERT_TRUE(err == KErrNone);    
sl@0
   500
    err = screenContext->UpdateDisplay();    
sl@0
   501
    ASSERT_TRUE(err == KErrNone);
sl@0
   502
    User::After(KDelay);
sl@0
   503
sl@0
   504
    iUtility->FillStreamL(ns, KRgbRed);    
sl@0
   505
    err = screenContext->SetTopLayerSurface(ns);
sl@0
   506
    ASSERT_TRUE(err == KErrNone);    
sl@0
   507
    err = screenContext->UpdateDisplay();    
sl@0
   508
    ASSERT_TRUE(err == KErrNone);
sl@0
   509
    User::After(KDelay);
sl@0
   510
sl@0
   511
    // Set a non-topmost layer
sl@0
   512
    err = screenContext->SetLayerSurface(1, ns);
sl@0
   513
    ASSERT_TRUE(err == KErrArgument);    
sl@0
   514
    
sl@0
   515
    CleanupStack::PopAndDestroy(screenContext);    
sl@0
   516
	}
sl@0
   517
sl@0
   518
/**
sl@0
   519
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0104
sl@0
   520
@SYMTestCaseDesc        Display all display attributes
sl@0
   521
@SYMREQ                 
sl@0
   522
@SYMPREQ                REQ 417-54885
sl@0
   523
@SYMTestType            Unit Test
sl@0
   524
@SYMTestPriority        High
sl@0
   525
@SYMTestPurpose         Check display attributes 
sl@0
   526
@SYMTestActions 
sl@0
   527
                        Create a screen context
sl@0
   528
                        Set display attributes 
sl@0
   529
                        Get all display attribtues
sl@0
   530
                        Destory the screen context                       
sl@0
   531
@SYMTestExpectedResults
sl@0
   532
                        Methods should complete without error.
sl@0
   533
                        Display attributes should be correct
sl@0
   534
 **/
sl@0
   535
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()
sl@0
   536
    {
sl@0
   537
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0104L()"));
sl@0
   538
    LOG((" *** CTestScreenInterface test 0104L"));
sl@0
   539
 
sl@0
   540
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   541
    CleanupStack::PushL(screenContext);
sl@0
   542
    
sl@0
   543
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   544
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   545
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   546
 
sl@0
   547
    INFO_PRINTF1(_L("Printing attribute values: "));
sl@0
   548
    INFO_PRINTF2(_L("EScreenAttributeSupportedRotation: %i "), attributes.iSupportedRotations);
sl@0
   549
    INFO_PRINTF2(_L("EScreenAttributeCurrentRotation: 0x%x "), attributes.iCurrentRotation);
sl@0
   550
    INFO_PRINTF2(_L("EScreenAttributeDefaultRotation: 0x%x "), attributes.iDefaultRotation);
sl@0
   551
    INFO_PRINTF2(_L("EScreenAttributeBytesPerPixel: %i "), attributes.iBytesPerPixel);
sl@0
   552
    INFO_PRINTF2(_L("EScreenAttributeFlippedHeight: %i "), attributes.iFlippedHeight);
sl@0
   553
    INFO_PRINTF2(_L("EScreenAttributeFlippedWidth: %i "), attributes.iFlippedWidth);
sl@0
   554
    INFO_PRINTF2(_L("EScreenAttributeFlippedStride: %i "), attributes.iFlippedStride);
sl@0
   555
    INFO_PRINTF2(_L("EScreenAttributeNormalHeight: %i "), attributes.iNormalHeight);
sl@0
   556
    INFO_PRINTF2(_L("EScreenAttributeNormalWidth: %i "), attributes.iNormalWidth);
sl@0
   557
    INFO_PRINTF2(_L("EScreenAttributeNormalStride: %i "), attributes.iNormalStride);
sl@0
   558
    INFO_PRINTF2(_L("EScreenAttributePixelFormat: 0x%x "), attributes.iPixelFormat);
sl@0
   559
    
sl@0
   560
    CleanupStack::PopAndDestroy(screenContext);    
sl@0
   561
    }
sl@0
   562
sl@0
   563
/**
sl@0
   564
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0105
sl@0
   565
@SYMTestCaseDesc        Create a screen size stream of non-fastpathable pixel format and display on screen
sl@0
   566
@SYMREQ                 
sl@0
   567
@SYMPREQ                REQ 417-54885
sl@0
   568
@SYMTestType            Unit Test - Negative Test        
sl@0
   569
@SYMTestPriority        High        
sl@0
   570
@SYMTestPurpose         Verify a COpenWFC_RI_Display object can be properly created and a stream can be displayed on screen 
sl@0
   571
@SYMTestActions         
sl@0
   572
                        Create a screen context
sl@0
   573
                        Set display attributes 
sl@0
   574
                        Create a screen size stream based on the display attributes with a non-fastpathable pixelformat
sl@0
   575
                        Fill the stream
sl@0
   576
                        Associate the stream with the topmost display layer
sl@0
   577
@SYMTestExpectedResults 
sl@0
   578
                        Test should pass.
sl@0
   579
                        SetTopLayerSurface should return KErrNotSupported.
sl@0
   580
 **/        
sl@0
   581
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()
sl@0
   582
    {
sl@0
   583
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0105L()"));
sl@0
   584
    LOG((" *** CTestScreenInterface test 0105L"));
sl@0
   585
    
sl@0
   586
    if (!iNonFastpathablePixelFormat)
sl@0
   587
        {
sl@0
   588
        INFO_PRINTF1(_L("No non-fastpathable format specified - negative test cannot be run."));
sl@0
   589
        User::Leave(KErrTEFUnitInconclusive);
sl@0
   590
        }
sl@0
   591
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   592
    CleanupStack::PushL(screenContext);
sl@0
   593
     
sl@0
   594
    TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   595
    screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   596
                                 &screenRotation,
sl@0
   597
                                 sizeof(screenRotation));
sl@0
   598
    screenContext->CommitAttribute();
sl@0
   599
sl@0
   600
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   601
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   602
                                 sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   603
     
sl@0
   604
    TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   605
    SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   606
                                                 iNonFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   607
                                                 surface, iContiguous, 1);
sl@0
   608
    ASSERT_FALSE((*ns).IsNull());
sl@0
   609
sl@0
   610
    iUtility->FillStreamL(ns, KRgbGreen);
sl@0
   611
     
sl@0
   612
    ASSERT_TRUE(KErrNotSupported == screenContext->SetTopLayerSurface(ns));
sl@0
   613
     
sl@0
   614
    CleanupStack::PopAndDestroy(screenContext);
sl@0
   615
    }
sl@0
   616
sl@0
   617
/**
sl@0
   618
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0106
sl@0
   619
@SYMTestCaseDesc        Create a stream, display on screen and repeat for a number of times
sl@0
   620
@SYMREQ                 
sl@0
   621
@SYMPREQ                REQ 417-54885
sl@0
   622
@SYMTestType            Unit Test           
sl@0
   623
@SYMTestPriority        High        
sl@0
   624
@SYMTestPurpose         Check stream display repeatedly
sl@0
   625
@SYMTestActions 
sl@0
   626
                        Create a screen context
sl@0
   627
                        Set display attributes 
sl@0
   628
                        Create a stream 
sl@0
   629
                        Fill the stream
sl@0
   630
                        Associates the stream with the topmost display layer
sl@0
   631
                        Update the screen
sl@0
   632
                        Destory the screen context
sl@0
   633
                        Repeat the above actions for a number of times in a for loop
sl@0
   634
@SYMTestExpectedResults
sl@0
   635
                        Methods should complete without error.
sl@0
   636
                        Each time, the stream should be properly displayed on screen
sl@0
   637
 **/        
sl@0
   638
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()
sl@0
   639
    {
sl@0
   640
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0106L()"));
sl@0
   641
    LOG((" *** CTestScreenInterface test 0106L"));
sl@0
   642
 
sl@0
   643
    SymbianStreamType ns = NULL;
sl@0
   644
    const TInt loopMaxNum = 10;
sl@0
   645
    
sl@0
   646
    for (TInt i = 0; i < loopMaxNum; ++i)
sl@0
   647
        {
sl@0
   648
        //INFO_PRINTF2(_L("Create screen context and stream loop: %i"), i);
sl@0
   649
sl@0
   650
        COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   651
        CleanupStack::PushL(screenContext);
sl@0
   652
    
sl@0
   653
        TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   654
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   655
                                &screenRotation,
sl@0
   656
                                sizeof(screenRotation));
sl@0
   657
        screenContext->CommitAttribute();
sl@0
   658
sl@0
   659
        COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   660
        screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   661
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   662
    
sl@0
   663
        if(ns == NULL)
sl@0
   664
            {
sl@0
   665
            TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   666
            ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   667
                                                iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   668
                                                surface, iContiguous, 1);
sl@0
   669
            ASSERT_FALSE((*ns).IsNull());
sl@0
   670
            }
sl@0
   671
    
sl@0
   672
        if(i%3 == 0)
sl@0
   673
            {
sl@0
   674
            iUtility->FillStreamL(ns, KRgbRed);
sl@0
   675
            }
sl@0
   676
        else if (i%3 == 1)
sl@0
   677
            {
sl@0
   678
            iUtility->FillStreamL(ns, KRgbGreen);                
sl@0
   679
            }
sl@0
   680
            else
sl@0
   681
                {
sl@0
   682
                iUtility->FillStreamL(ns, KRgbBlue);        
sl@0
   683
                }
sl@0
   684
    
sl@0
   685
        TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   686
        ASSERT_TRUE(err == KErrNone);
sl@0
   687
    
sl@0
   688
        err = screenContext->UpdateDisplay();   
sl@0
   689
        ASSERT_TRUE(err == KErrNone);
sl@0
   690
sl@0
   691
        CleanupStack::PopAndDestroy(screenContext);   
sl@0
   692
        
sl@0
   693
        User::After(KDelay);
sl@0
   694
        }
sl@0
   695
    }
sl@0
   696
sl@0
   697
/**
sl@0
   698
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0107
sl@0
   699
@SYMTestCaseDesc        Simple Non Trivial Attributes
sl@0
   700
@SYMREQ                 
sl@0
   701
@SYMPREQ                REQ 417-54885
sl@0
   702
@SYMTestType            Unit Test           
sl@0
   703
@SYMTestPriority        High        
sl@0
   704
@SYMTestPurpose         Check that simple non-trivial attributes are accepted by SetTopLayerSurface.
sl@0
   705
                        Note this test does not pass in "real" attributes, so the result is predictable.
sl@0
   706
@SYMTestActions 
sl@0
   707
                        Create a screen context
sl@0
   708
                        Set display attributes 
sl@0
   709
                        Create a fastpathable stream 
sl@0
   710
                        Fill the stream
sl@0
   711
                        Associate the stream with the topmost display layer 
sl@0
   712
                            and NULL Non Trivial Atrributes
sl@0
   713
                        Update the screen
sl@0
   714
                        Associate the stream with the topmost display layer 
sl@0
   715
                            and empty Non Trivial Atrributes
sl@0
   716
                        Update the screen
sl@0
   717
                        Associate the stream with the topmost display layer 
sl@0
   718
                            and wrong Non Trivial Atrributes
sl@0
   719
                        This should fail
sl@0
   720
                        Destory the screen context
sl@0
   721
@SYMTestExpectedResults
sl@0
   722
                        SetTopLayerSurface should not fail, except for wrong attribute.
sl@0
   723
                        SetTopLayerSurface should not crash or panic.
sl@0
   724
 **/        
sl@0
   725
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()
sl@0
   726
    {
sl@0
   727
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0107L()"));
sl@0
   728
    LOG((" *** CTestScreenInterface test 0107L"));
sl@0
   729
    
sl@0
   730
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   731
    CleanupStack::PushL(screenContext);
sl@0
   732
    
sl@0
   733
    TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   734
    screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   735
                             &screenRotation,
sl@0
   736
                             sizeof(screenRotation));
sl@0
   737
    screenContext->CommitAttribute();
sl@0
   738
    
sl@0
   739
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   740
    screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   741
                             sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   742
    
sl@0
   743
    TSurfaceId surface = TSurfaceId::CreateNullId();
sl@0
   744
    SymbianStreamType ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   745
                                             iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   746
                                             surface, iContiguous, 1);
sl@0
   747
    ASSERT_FALSE((*ns).IsNull());
sl@0
   748
    
sl@0
   749
    iUtility->FillStreamL(ns, KRgbGreen);
sl@0
   750
    
sl@0
   751
    TInt err = screenContext->SetTopLayerSurface(ns,NULL);
sl@0
   752
    ASSERT_FALSE(err);
sl@0
   753
    screenContext->UpdateDisplay();
sl@0
   754
    
sl@0
   755
    TInt emptyList=0;
sl@0
   756
    err = screenContext->SetTopLayerSurface(ns,&emptyList);
sl@0
   757
    ASSERT_FALSE(err);
sl@0
   758
    screenContext->UpdateDisplay();
sl@0
   759
    
sl@0
   760
    TInt wrongList=-1;
sl@0
   761
    err = screenContext->SetTopLayerSurface(ns,&wrongList);
sl@0
   762
    ASSERT_TRUE(err);
sl@0
   763
    
sl@0
   764
    //Calling UpdateDisplay should fall-back to the previous setting of top layer surface
sl@0
   765
    screenContext->UpdateDisplay();
sl@0
   766
   
sl@0
   767
    CleanupStack::PopAndDestroy(screenContext);
sl@0
   768
   }
sl@0
   769
sl@0
   770
/**
sl@0
   771
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0108
sl@0
   772
@SYMTestCaseDesc        Test getting and setting attributes
sl@0
   773
@SYMREQ                 
sl@0
   774
@SYMPREQ                REQ 417-54885
sl@0
   775
@SYMTestType            Unit Test           
sl@0
   776
@SYMTestPriority        High        
sl@0
   777
@SYMTestPurpose         Check getting and setting attibutes with good and bad values
sl@0
   778
@SYMTestActions 
sl@0
   779
                        Create a screen context
sl@0
   780
                        Get and set attributes with good and bad values
sl@0
   781
                        Destory the screen context
sl@0
   782
@SYMTestExpectedResults
sl@0
   783
                        GetAttribute should always succeed with all valid TScreenAttribute values 
sl@0
   784
                        and appropriate attribute size 
sl@0
   785
                        SetAttribute should succeed for modifying the current rotation
sl@0
   786
                        Invalid valued for getting and setting attributes should return correct error code
sl@0
   787
 **/        
sl@0
   788
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()
sl@0
   789
    {
sl@0
   790
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0108L()"));
sl@0
   791
    LOG((" *** CTestScreenInterface test 0108L"));
sl@0
   792
sl@0
   793
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   794
    CleanupStack::PushL(screenContext);
sl@0
   795
    
sl@0
   796
    COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   797
    TInt err;
sl@0
   798
    
sl@0
   799
    for(TUint ii = COpenWFC_RI_Display::EScreenAttributeInvalid; ii <= COpenWFC_RI_Display::EScreenAttributeScreenGeometry; ++ii)
sl@0
   800
        {        
sl@0
   801
        if(ii == COpenWFC_RI_Display::EScreenAttributeScreenGeometry)
sl@0
   802
            {
sl@0
   803
            err = screenContext->GetAttribute(ii, &attributes, 
sl@0
   804
                             sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));    
sl@0
   805
            }
sl@0
   806
        else
sl@0
   807
            {
sl@0
   808
            err = screenContext->GetAttribute(ii, &attributes, 
sl@0
   809
                             sizeof(COpenWFC_RI_Display::TScreenAttribute));
sl@0
   810
            }
sl@0
   811
        
sl@0
   812
        if(ii == COpenWFC_RI_Display::EScreenAttributeInvalid)
sl@0
   813
            {
sl@0
   814
            ASSERT_TRUE(err == KErrNotSupported);
sl@0
   815
            }
sl@0
   816
        else
sl@0
   817
            {
sl@0
   818
            ASSERT_TRUE(err == KErrNone);
sl@0
   819
            }        
sl@0
   820
        }
sl@0
   821
    
sl@0
   822
    TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   823
    err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, &screenRotation, 
sl@0
   824
                    sizeof(screenRotation));
sl@0
   825
    // The only parameter that can be modified is the current rotation
sl@0
   826
    ASSERT_TRUE(err == KErrNone);
sl@0
   827
sl@0
   828
    err = screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeSupportedRotation, &screenRotation, 
sl@0
   829
                    sizeof(screenRotation));
sl@0
   830
    ASSERT_TRUE(err == KErrNotSupported);
sl@0
   831
sl@0
   832
    // Set attribute to NULL
sl@0
   833
    err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, NULL, 
sl@0
   834
                     sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));    
sl@0
   835
    ASSERT_TRUE(err == KErrArgument);
sl@0
   836
sl@0
   837
    // Set attribute size to be 0
sl@0
   838
    err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, &attributes, 0);    
sl@0
   839
    ASSERT_TRUE(err == KErrArgument);
sl@0
   840
sl@0
   841
    // Set attribute == NULL
sl@0
   842
    err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeBytesPerPixel, NULL, 
sl@0
   843
                     sizeof(COpenWFC_RI_Display::TScreenAttribute));    
sl@0
   844
    ASSERT_TRUE(err != KErrNone);
sl@0
   845
sl@0
   846
    // Set attribute with wrong size
sl@0
   847
    err = screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   848
                     sizeof(COpenWFC_RI_Display::TScreenAttribute));    
sl@0
   849
    ASSERT_TRUE(err != KErrNone);
sl@0
   850
sl@0
   851
    CleanupStack::PopAndDestroy(screenContext);
sl@0
   852
    }
sl@0
   853
sl@0
   854
/**
sl@0
   855
@SYMTestCaseID          GRAPHICS_OPENWFC_SCREENINTERFACE_0109
sl@0
   856
@SYMTestCaseDesc        Create a stream, display on screen and repeat for a number of times
sl@0
   857
@SYMREQ                 
sl@0
   858
@SYMPREQ                REQ 417-54885
sl@0
   859
@SYMTestType            Unit Test           
sl@0
   860
@SYMTestPriority        High        
sl@0
   861
@SYMTestPurpose         Check stream display repeatedly
sl@0
   862
@SYMTestActions 
sl@0
   863
                        Create a screen context
sl@0
   864
                        Set display attributes 
sl@0
   865
                        Repeat the below actions for a number of times in a for loop
sl@0
   866
                        Create a stream 
sl@0
   867
                        Fill the stream
sl@0
   868
                        Associates the stream with the topmost display layer
sl@0
   869
                        Update the screen
sl@0
   870
                        Finally
sl@0
   871
                        Destory the screen context
sl@0
   872
                        
sl@0
   873
@SYMTestExpectedResults
sl@0
   874
                        Methods should complete without error.
sl@0
   875
                        Each time, the stream should be properly displayed on screen
sl@0
   876
                        The streams should be destroyed in a timely manner after they stop being displayed
sl@0
   877
 **/ 
sl@0
   878
sl@0
   879
void CTestScreenInterface::GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()
sl@0
   880
    {
sl@0
   881
    INFO_PRINTF1(_L("GRAPHICS_OPENWFC_SCREENINTERFACE_0109L()"));
sl@0
   882
    LOG((" *** CTestScreenInterface test 0106L"));
sl@0
   883
    _LIT(KDirectPost, "DirectPost");
sl@0
   884
    TBool   directPost; //If DirectPost is not defined then the exact order of buffer releasing cannot be asserted.
sl@0
   885
    TBool definedDirectPost = iConfig.GetBool(KImageSectionName, KDirectPost, directPost);
sl@0
   886
    TInt offset;
sl@0
   887
    TInt error;
sl@0
   888
    TSurfaceId surface;
sl@0
   889
    SymbianStreamType ns = NULL;
sl@0
   890
    TSurfaceId prevsurface = TSurfaceId::CreateNullId();
sl@0
   891
sl@0
   892
    COpenWFC_RI_Display* screenContext = COpenWFC_RI_Display::NewL(KDefaultScreenNumber);
sl@0
   893
    CleanupStack::PushL(screenContext);
sl@0
   894
    
sl@0
   895
    for (TInt i = 0; i < 10; ++i)
sl@0
   896
        {
sl@0
   897
        //INFO_PRINTF2(_L("Create  stream loop: %i"), i);
sl@0
   898
    
sl@0
   899
        TUint32 screenRotation = COpenWFC_RI_Display::EScreenRotate0;
sl@0
   900
        screenContext->SetAttribute(COpenWFC_RI_Display::EScreenAttributeCurrentRotation, 
sl@0
   901
                                &screenRotation,
sl@0
   902
                                sizeof(screenRotation));
sl@0
   903
        screenContext->CommitAttribute();
sl@0
   904
sl@0
   905
        COpenWFC_RI_Display::TScreenGeometryAttribute attributes;
sl@0
   906
        screenContext->GetAttribute(COpenWFC_RI_Display::EScreenAttributeScreenGeometry, &attributes, 
sl@0
   907
                                sizeof(COpenWFC_RI_Display::TScreenGeometryAttribute));
sl@0
   908
    
sl@0
   909
        surface = TSurfaceId::CreateNullId();
sl@0
   910
        ns=iUtility->CreateStreamL(TSize(attributes.iNormalWidth,attributes.iNormalHeight), 
sl@0
   911
                                            iFastpathablePixelFormat, attributes.iNormalStride, 
sl@0
   912
                                            surface, iContiguous, 2);
sl@0
   913
        ASSERT_FALSE((*ns).IsNull());
sl@0
   914
    
sl@0
   915
        if(i%3 == 0)
sl@0
   916
            {
sl@0
   917
            iUtility->FillStreamL(ns, KRgbRed);
sl@0
   918
            }
sl@0
   919
        else if (i%3 == 1)
sl@0
   920
            {
sl@0
   921
            iUtility->FillStreamL(ns, KRgbGreen);                
sl@0
   922
            }
sl@0
   923
            else
sl@0
   924
                {
sl@0
   925
                iUtility->FillStreamL(ns, KRgbBlue);        
sl@0
   926
                }
sl@0
   927
    
sl@0
   928
        
sl@0
   929
        if (!prevsurface.IsNull())
sl@0
   930
            {
sl@0
   931
            error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
sl@0
   932
            ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
sl@0
   933
            }
sl@0
   934
        TInt err = screenContext->SetTopLayerSurface(ns);
sl@0
   935
        ASSERT_TRUE(err == KErrNone);
sl@0
   936
        //GetBufferOffset is a safe way to check if the surface is still alive
sl@0
   937
        if (!prevsurface.IsNull())
sl@0
   938
            {
sl@0
   939
            error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
sl@0
   940
            ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
sl@0
   941
            }
sl@0
   942
    
sl@0
   943
        err = screenContext->UpdateDisplay();   
sl@0
   944
        ASSERT_TRUE(err == KErrNone);
sl@0
   945
sl@0
   946
        User::After(KMinimalDelay);
sl@0
   947
        
sl@0
   948
        error=iUtility->Manager().GetBufferOffset(surface,0,offset);
sl@0
   949
        ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
sl@0
   950
        
sl@0
   951
        if (!prevsurface.IsNull())
sl@0
   952
            {
sl@0
   953
            error=iUtility->Manager().GetBufferOffset(prevsurface,0,offset);
sl@0
   954
            ASSERT_TRUE(error);   //previous surface should definitely be deleted by now
sl@0
   955
            }
sl@0
   956
        iUtility->DestroyStream(ns);
sl@0
   957
        error=iUtility->Manager().GetBufferOffset(surface,0,offset);
sl@0
   958
        ASSERT_TRUE(definedDirectPost ? error == (directPost?KErrNone:KErrArgument) :1);
sl@0
   959
        prevsurface=surface;
sl@0
   960
        
sl@0
   961
        User::After(KDelay);
sl@0
   962
        }
sl@0
   963
    CleanupStack::PopAndDestroy(screenContext);   
sl@0
   964
    
sl@0
   965
    if (!prevsurface.IsNull())
sl@0
   966
        {
sl@0
   967
        error=iUtility->Manager().GetBufferOffset(surface,0,offset);
sl@0
   968
        ASSERT_TRUE(error);   //previous surface should definitely be deleted by now
sl@0
   969
        }
sl@0
   970
    }
sl@0
   971