|
1 // Copyright (c) 2005-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 "Te_SimCallOOMTest.h" |
|
17 |
|
18 CSimCallOOMTest::CSimCallOOMTest() |
|
19 { |
|
20 SetTestStepName(_L("CallOOMTest")); |
|
21 } |
|
22 |
|
23 TVerdict CSimCallOOMTest::doTestStepL() |
|
24 { |
|
25 INFO_PRINTF1(_L("BeginCallOOMTest")); |
|
26 |
|
27 CreateConfigFileL(_L("c:\\config3.txt")); |
|
28 SetTestNumberL(0); |
|
29 |
|
30 TInt ret = iPhone.Open(iTelServer,KPhoneName); |
|
31 INFO_PRINTF2(_L("Result: %d"),ret); |
|
32 TESTL(ret == KErrNone); |
|
33 INFO_PRINTF1(_L("Opened phone object")); |
|
34 |
|
35 iTelServer.SetPriorityClient(); |
|
36 |
|
37 TESTL(iPhone.Initialise()==KErrNone); |
|
38 INFO_PRINTF1(_L("Opened phone object")); |
|
39 |
|
40 TESTL(iLine.Open(iPhone,KVoiceLineName)==KErrNone); |
|
41 INFO_PRINTF1(_L("Opened Line object")); |
|
42 |
|
43 TName callName; |
|
44 TESTL(iCall.OpenNewCall(iLine,callName)==KErrNone); |
|
45 INFO_PRINTF1(_L("Opened Call object")); |
|
46 |
|
47 iLine.Close(); |
|
48 iCall.Close(); |
|
49 |
|
50 TESTL(iLine.Open(iPhone,KVoiceLineName)==KErrNone); |
|
51 INFO_PRINTF1(_L("Opened Line object")); |
|
52 |
|
53 TName callName2; |
|
54 TInt error = iCall.OpenNewCall(iLine,callName2); |
|
55 TESTL(error==KErrNone); |
|
56 INFO_PRINTF1(_L("Opened Call object")); |
|
57 |
|
58 #ifdef _DEBUG |
|
59 TRequestStatus stat; |
|
60 TBool oomAvailable = EFalse; |
|
61 TInt failure(0); |
|
62 const TInt KMaxTests = 1000; |
|
63 _LIT(KEmergencyNo, "01632960000"); |
|
64 |
|
65 while (!oomAvailable && failure < KMaxTests) |
|
66 { |
|
67 INFO_PRINTF2(_L("Failing alloc %d. Making Call... "),failure); |
|
68 |
|
69 iTelServer.__DbgFailNext(failure); |
|
70 |
|
71 // Check that the heap is balanced at the same level before and |
|
72 // after all attempts at emergency call. |
|
73 iTelServer.__DbgMarkHeap(); |
|
74 iCall.DialEmergencyCall(stat, KEmergencyNo); |
|
75 User::WaitForRequest(stat); |
|
76 INFO_PRINTF2(_L("result=%d... "), stat.Int()); |
|
77 |
|
78 if (stat.Int()!=KErrNone) |
|
79 { |
|
80 INFO_PRINTF2(_L("Failing after %d Allocs"),failure); |
|
81 iTelServer.__DbgMarkEnd(0); |
|
82 } |
|
83 else |
|
84 { |
|
85 INFO_PRINTF2(_L("Passing after %d Allocs"),failure); |
|
86 } |
|
87 |
|
88 iTelServer.__DbgFailNextAvailable(oomAvailable); |
|
89 |
|
90 TInt ret = iCall.HangUp(); |
|
91 INFO_PRINTF2(_L("HangUp result=%d"), ret); |
|
92 |
|
93 if (ret!=KErrNone) |
|
94 { |
|
95 iCall.HangUp();//if hang up unsuceessfull call again without heap fail |
|
96 } |
|
97 |
|
98 // Test for the end of the test. Not perfect (doesn't demonstrate |
|
99 // that there wasn't an OOM situation that was handled quietly |
|
100 // such that the call/hangup still worked) but I think it's all we |
|
101 // can do. |
|
102 |
|
103 if ( stat!=KErrNone || ret!=KErrNone) |
|
104 { |
|
105 INFO_PRINTF3(_L("OOM testing complete. Call status is %d and hang-up return is %d"),stat.Int(),ret); |
|
106 break; |
|
107 } |
|
108 |
|
109 |
|
110 failure++; |
|
111 } |
|
112 |
|
113 // Resetting the heap to flush any FailNext there might be hanging around. |
|
114 iTelServer.__DbgFailNext(0); |
|
115 |
|
116 iCall.DialEmergencyCall(stat, KEmergencyNo);//use this to make the previous memory failure happen |
|
117 User::WaitForRequest(stat); |
|
118 iCall.HangUp(); |
|
119 |
|
120 // KMaxTests is used to stop the above while statement looping |
|
121 // indefinitely. If KMaxTests is reached then we can guess that something |
|
122 // has gone wrong and the test should be failed. |
|
123 TESTL(failure < KMaxTests); |
|
124 #else |
|
125 INFO_PRINTF1(_L("TestDisabled on release build")); |
|
126 #endif // _DEBUG |
|
127 INFO_PRINTF1(_L("Closing objects...")); |
|
128 iCall.Close(); |
|
129 iLine.Close(); |
|
130 iPhone.Close(); |
|
131 ASSERT(RThread().RequestCount()==0); |
|
132 |
|
133 return TestStepResult(); |
|
134 } |
|
135 |