graphicshwdrivers/surfacemgr/test/src/tsurfacemanager.cpp
branchbug235_bringup_0
changeset 147 af143508cc47
parent 0 5d03bc08d59c
child 164 25ffed67c7ef
equal deleted inserted replaced
146:4d1fe4a7ce83 147:af143508cc47
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19  @file
    19  @file
    20  @test
    20  @test
    21  @internalComponent - Internal Symbian test code
    21  @internalComponent - Internal Symbian test code
    22 */
    22 */
    23 
    23 
       
    24 
    24 #include "tsurfacemanager.h"
    25 #include "tsurfacemanager.h"
    25 #include <e32base.h>
    26 #include <e32base.h>
    26 #include <e32cons.h>
    27 #include <e32cons.h>
    27 #include <e32test.h>
    28 #include <e32test.h>
    28 #include <e32std.h>
    29 #include <e32std.h>
    29 #include <e32cmn.h>	  
    30 #include <e32cmn.h>	  
    30 #include <hal.h>
    31 #include <hal.h>
    31 #include <e32def_private.h>
    32 #include <e32def_private.h>
       
    33 #include <graphics/surface_hints.h>
       
    34 
       
    35 using namespace surfaceHints;
    32 
    36 
    33 const TInt KCountLimit = 10000;
    37 const TInt KCountLimit = 10000;
    34 
    38 
    35 CTSurfaceManager::CTSurfaceManager(CTestStep* aStep):
    39 CTSurfaceManager::CTSurfaceManager(CTestStep* aStep):
    36 	CTGraphicsBase(aStep)
    40 	CTGraphicsBase(aStep)
  1240 	// Test create surface doesn't return an error
  1244 	// Test create surface doesn't return an error
  1241 	SurfaceOperation(buf);
  1245 	SurfaceOperation(buf);
  1242 
  1246 
  1243 	//contiguous attribute is not valid on emulator
  1247 	//contiguous attribute is not valid on emulator
  1244 #ifndef __WINS__
  1248 #ifndef __WINS__
  1245 	TEST(iInfo.iContiguous == attributes.iContiguous);
  1249 	if(attributes.iContiguous)
       
  1250 	    TEST(iInfo.iContiguous == attributes.iContiguous);
       
  1251 	else
       
  1252 	    INFO_PRINTF1(_L("We didn't ask for contiguous memory so we don't care how it's going to be (can be contiguous or not)\n"));
  1246 #else
  1253 #else
  1247 	INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n"));
  1254 	INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n"));
  1248 #endif
  1255 #endif
  1249 	  
  1256 	  
  1250 	TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); 
  1257 	TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); 
  1367 	{	
  1374 	{	
  1368 	TEST(aAttributes.iSize==iInfo.iSize);
  1375 	TEST(aAttributes.iSize==iInfo.iSize);
  1369 	TEST(aAttributes.iBuffers==iInfo.iBuffers);
  1376 	TEST(aAttributes.iBuffers==iInfo.iBuffers);
  1370 	TEST(aAttributes.iPixelFormat==iInfo.iPixelFormat);
  1377 	TEST(aAttributes.iPixelFormat==iInfo.iPixelFormat);
  1371 	TEST(aAttributes.iStride==iInfo.iStride);
  1378 	TEST(aAttributes.iStride==iInfo.iStride);
  1372 	TEST(aAttributes.iContiguous==iInfo.iContiguous);
  1379     if(aAttributes.iContiguous)
       
  1380         TEST(iInfo.iContiguous == aAttributes.iContiguous);
       
  1381     else
       
  1382         INFO_PRINTF1(_L("We didn't ask for contiguous memory so we don't care how it's going to be (can be contiguous or not)\n"));	
  1373 	TEST(aAttributes.iCacheAttrib==iInfo.iCacheAttrib);
  1383 	TEST(aAttributes.iCacheAttrib==iInfo.iCacheAttrib);
  1374 	
  1384 	
  1375 	//Test the chunk size is big enough to hold the surface when we create it 
  1385 	//Test the chunk size is big enough to hold the surface when we create it 
  1376 	//with the offset between buffers
  1386 	//with the offset between buffers
  1377 	if (aAttributes.iOffsetBetweenBuffers!=0)
  1387 	if (aAttributes.iOffsetBetweenBuffers!=0)
  3180 	TSurfaceId surfaceId;
  3190 	TSurfaceId surfaceId;
  3181 	TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId));
  3191 	TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId));
  3182 	
  3192 	
  3183 	//Add HintPair1
  3193 	//Add HintPair1
  3184 	RSurfaceManager::THintPair hintPair1;
  3194 	RSurfaceManager::THintPair hintPair1;
  3185 	hintPair1.iKey.iUid = 0x123257;
  3195 	hintPair1.Set(TUid::Uid(KSurfaceContent), EStillImage, ETrue);
  3186 	hintPair1.iValue = 300;
       
  3187 	hintPair1.iMutable = ETrue;
       
  3188 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair1));
  3196 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair1));
  3189 	
  3197 	
  3190 	RSurfaceManager::THintPair hintPairCheck1;
  3198 	RSurfaceManager::THintPair hintPairCheck1;
  3191 	hintPairCheck1.iKey.iUid = 0x123257;
  3199 	hintPairCheck1.iKey.iUid = KSurfaceContent;
  3192 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3200 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3193 	
  3201 	
  3194 	//Add HintPair2
  3202 	//Add HintPair2
  3195 	RSurfaceManager::THintPair hintPair2;
  3203 	RSurfaceManager::THintPair hintPair2;
  3196 	hintPair2.iKey.iUid = 0x123267;
  3204 	hintPair2.iKey.iUid = KSurfaceProtection;
  3197 	hintPair2.iValue = 100;
  3205 	hintPair2.iValue = EAllowAnalog | EAllowDigital;
  3198 	hintPair2.iMutable = EFalse;
  3206 	hintPair2.iMutable = EFalse;
  3199 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2));
  3207 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2));
  3200 		
  3208 		
  3201 	RSurfaceManager::THintPair hintPairCheck2;
  3209 	RSurfaceManager::THintPair hintPairCheck2;
  3202 	hintPairCheck2.iKey.iUid = 0x123267;
  3210 	hintPairCheck2.iKey.iUid = KSurfaceProtection;
  3203 	CheckHintPair(surfaceId, hintPairCheck2, hintPair2);
  3211 	CheckHintPair(surfaceId, hintPairCheck2, hintPair2);
  3204 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3212 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3205 
  3213 
  3206 	//Add HintPair3
  3214 	//Add HintPair3
  3207 	RSurfaceManager::THintPair hintPair3;
  3215 	RSurfaceManager::THintPair hintPair3;
  3208 	hintPair3.iKey.iUid = 0x123324;
  3216 	hintPair3.Set(TUid::Uid(KSurfaceCharacteristics), ENotPersistable, EFalse);
  3209 	hintPair3.iValue = 500;
       
  3210 	hintPair3.iMutable = ETrue;
       
  3211 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair3));
  3217 	TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair3));
  3212 	
  3218 	
  3213 	RSurfaceManager::THintPair hintPairCheck3;
  3219 	RSurfaceManager::THintPair hintPairCheck3;
  3214 	hintPairCheck3.iKey.iUid = 0x123324;
  3220 	hintPairCheck3.iKey.iUid = KSurfaceCharacteristics;
  3215 	CheckHintPair(surfaceId, hintPairCheck3, hintPair3);
  3221 	CheckHintPair(surfaceId, hintPairCheck3, hintPair3);
  3216 	CheckHintPair(surfaceId, hintPairCheck2, hintPair2);
  3222 	CheckHintPair(surfaceId, hintPairCheck2, hintPair2);
  3217 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3223 	CheckHintPair(surfaceId, hintPairCheck1, hintPair1);
  3218 	
  3224 	
  3219 	//Add HintPair4
  3225 	//Add HintPair4