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