servicediscoveryandcontrol/pnp/test/upnp/chunkmgr/ts_chunkmgr/src/test02allocdealloc.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @file
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <rmemchunk.h>
       
    21 
       
    22 #include "test02allocdealloc.h"
       
    23 
       
    24 TVerdict CTest02AllocDealloc::doTestStepL ( void )
       
    25 	{
       
    26 	__UHEAP_MARK;
       
    27 
       
    28 	//-------------- step 1 --------------------
       
    29 	CleanupStack::PushL ( CreateChunkMgrL ( KMinHeapSize ) );
       
    30 
       
    31 	TBool firstFail = EFalse;
       
    32 	TBool secondFail = EFalse;
       
    33 	
       
    34 	//-------------- step 2 --------------------
       
    35 	RMemChunk memChunk;
       
    36 	RMemoryAllocator allocator ( iChkMgr );
       
    37 	TInt ret = memChunk.Alloc ( 5000, allocator );
       
    38 	if ( ret != KErrNone )
       
    39 		{
       
    40 		firstFail = ETrue;
       
    41 		}
       
    42 	else
       
    43 		{
       
    44 		memChunk.Free ();
       
    45 		}
       
    46 	
       
    47 	//-------------- step 3 --------------------
       
    48 	TInt ret1 = memChunk.Alloc ( 0,  allocator );
       
    49 	if ( ret1 != KErrNone )
       
    50 		{
       
    51 		secondFail = ETrue;
       
    52 		}
       
    53 	else
       
    54 		{
       
    55 		/* // TODO uncomment this, once Length API is implemented.
       
    56 		
       
    57 		if ( memChunk.Length () != 0 )
       
    58 			{
       
    59 			secondFail = ETrue;
       
    60 			}
       
    61 		*/
       
    62 		memChunk.Free ();
       
    63 		}
       
    64 	
       
    65 	CleanupStack::PopAndDestroy ( iChkMgr );
       
    66 	
       
    67     __UHEAP_MARKEND;
       
    68     
       
    69     if ( firstFail || secondFail )
       
    70     	{
       
    71     	return EFail;
       
    72     	}
       
    73     
       
    74 	return EPass;		
       
    75 	}