|
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 <e32std.h> |
|
21 #include <rmemchunk.h> |
|
22 |
|
23 #include "test04defaultheapfreecheck.h" |
|
24 |
|
25 TVerdict CTest14DefaultHeapFreeCheck::doTestStepL () |
|
26 { |
|
27 #if defined ( _DEBUG ) |
|
28 __UHEAP_MARK; |
|
29 |
|
30 //-------------- step 1 |
|
31 CleanupStack::PushL ( CreateChunkMgrL ( KMinHeapSize ) ); |
|
32 RMemoryAllocator allocator ( iChkMgr ); |
|
33 |
|
34 TBuf8<1000> *aDes1; |
|
35 CleanupStack::PushL ( aDes1 = new ( ELeave ) TBuf8<1000> ); |
|
36 aDes1->SetLength ( 1000 ); |
|
37 |
|
38 //-------------- step 2: Set User heap to fail at the next alloc |
|
39 User::__DbgSetAllocFail ( RHeap::EUser, RHeap::EFailNext, 0 ); |
|
40 |
|
41 //-------------- step 2 -------------------- |
|
42 RMemChunk chunk; |
|
43 TInt ret = chunk.Alloc ( 1000, allocator ); |
|
44 if ( ret != KErrNone ) |
|
45 { |
|
46 User::__DbgSetAllocFail ( RHeap::EUser, RHeap::ENone, 0 ); |
|
47 User::Leave ( EFail ); |
|
48 } |
|
49 |
|
50 //-------------- step 3 Cleanup |
|
51 chunk.Free (); |
|
52 |
|
53 User::__DbgSetAllocFail ( RHeap::EUser, RHeap::ENone, 0 ); |
|
54 |
|
55 CleanupStack::PopAndDestroy ( aDes1 ); |
|
56 CleanupStack::PopAndDestroy ( iChkMgr ); |
|
57 |
|
58 __UHEAP_MARKEND; |
|
59 return EPass; |
|
60 #else |
|
61 return EPass; |
|
62 #endif |
|
63 } |