|
1 // Copyright (c) 2006-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 // |
|
15 |
|
16 #include <e32base.h> |
|
17 #include "testutils.h" |
|
18 #include "tbmoomtester.h" |
|
19 |
|
20 _LIT(KTitle, "Bookmark OOM Tests"); |
|
21 |
|
22 LOCAL_D RTest gTest( KTitle() ); |
|
23 |
|
24 LOCAL_D CTestWrapper* gTestWrapper; |
|
25 |
|
26 |
|
27 LOCAL_C void StartOomTestL () |
|
28 { |
|
29 CBmOomTester* oomTester = CBmOomTester::NewL ( *gTestWrapper ); |
|
30 CleanupStack::PushL ( oomTester ); |
|
31 TRAPD ( err, oomTester->TestL () ); |
|
32 User::LeaveIfError ( err ); |
|
33 CleanupStack::PopAndDestroy ( oomTester ); |
|
34 } |
|
35 |
|
36 LOCAL_C void DoOomTestsL () |
|
37 { |
|
38 gTestWrapper->Next(_L("[Bookmark tests] OOM testing")); |
|
39 TInt ret = KErrNoMemory; |
|
40 TInt failAt = 0; |
|
41 while(ret != KErrNone) |
|
42 { |
|
43 failAt++; |
|
44 gTestWrapper->Tester().Printf(_L("OOM test step: %d\n"),failAt); |
|
45 |
|
46 __UHEAP_SETFAIL( RHeap::EDeterministic, failAt ); |
|
47 __UHEAP_MARK; |
|
48 TRAP( ret, StartOomTestL() ); |
|
49 __UHEAP_MARKEND; |
|
50 __UHEAP_RESET; |
|
51 |
|
52 gTestWrapper->TESTE(ret == KErrNoMemory || ret == KErrNone, ret); |
|
53 } |
|
54 } |
|
55 |
|
56 LOCAL_C void DoTestL () |
|
57 { |
|
58 gTestWrapper = CTestWrapper::NewLC ( gTest ); |
|
59 gTestWrapper->Start( _L( "@SYMTestCaseID IWS-APPPROTOCOLS-BOOKMARKS-TBOOKMARKOOM-0001 test" ) ); |
|
60 |
|
61 TRAPD ( err, DoOomTestsL () ); |
|
62 gTestWrapper->TESTE ( err == KErrNone, err ); |
|
63 |
|
64 gTestWrapper->End (); |
|
65 CleanupStack::PopAndDestroy ( gTestWrapper ); |
|
66 } |
|
67 |
|
68 GLDEF_C TInt E32Main() |
|
69 { |
|
70 __UHEAP_MARK; |
|
71 |
|
72 // Install exception handler |
|
73 CTrapCleanup* theCleanup = CTrapCleanup::New(); |
|
74 |
|
75 TRAPD( ret, DoTestL() ); |
|
76 gTest( ret == KErrNone ); |
|
77 |
|
78 delete theCleanup; |
|
79 |
|
80 __UHEAP_MARKEND; |
|
81 return KErrNone; |
|
82 } |
|
83 |