24
|
1 |
// Copyright (c) 1997-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 |
// This file implements OOM voice call scenarios.
|
|
15 |
// See CDataCall.cpp for fully documented test scenario.
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
/**
|
|
20 |
@file
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <e32test.h>
|
|
24 |
#include <mmretrieve.h>
|
|
25 |
#include <etelmm.h>
|
|
26 |
#include "Te_Loopbackcoomvoicecall.h"
|
|
27 |
#include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint
|
|
28 |
|
|
29 |
const TInt KETelServerShutdownGuardPeriod=500000;
|
|
30 |
|
|
31 |
//
|
|
32 |
// Test-side class
|
|
33 |
// With the assistance of the base class, this class must start the emulator
|
|
34 |
// and drive the ETel API.
|
|
35 |
//
|
|
36 |
CTestDriveOOMVoiceCall* CTestDriveOOMVoiceCall::NewL(const TScriptList aScriptListEntry)
|
|
37 |
{
|
|
38 |
CTestDriveOOMVoiceCall* aA = new(ELeave) CTestDriveOOMVoiceCall(aScriptListEntry);
|
|
39 |
CleanupStack::PushL(aA);
|
|
40 |
aA->ConstructL();
|
|
41 |
CleanupStack::Pop();
|
|
42 |
return aA;
|
|
43 |
}
|
|
44 |
|
|
45 |
CTestDriveOOMVoiceCall::CTestDriveOOMVoiceCall(const TScriptList aScriptListEntry) :
|
|
46 |
iScriptListEntry(aScriptListEntry)
|
|
47 |
{}
|
|
48 |
|
|
49 |
TInt CTestDriveOOMVoiceCall::RunTestL()
|
|
50 |
{
|
|
51 |
iCurrentScript = iScriptListEntry;
|
|
52 |
return StartEmulatorL();
|
|
53 |
}
|
|
54 |
|
|
55 |
void CTestDriveOOMVoiceCall::CloseDown()
|
|
56 |
{
|
|
57 |
iPhone2.Close();
|
|
58 |
iPhone.Close();
|
|
59 |
iServer2.Close();
|
|
60 |
iServer.Close();
|
|
61 |
}
|
|
62 |
|
|
63 |
void CTestDriveOOMVoiceCall::OpenUpL()
|
|
64 |
{
|
|
65 |
TESTL(iServer.Connect()==KErrNone);
|
|
66 |
TESTL(iServer.LoadPhoneModule(MODULE_NAME)==KErrNone);
|
|
67 |
TESTL(iServer2.Connect()==KErrNone);
|
|
68 |
TESTL(iPhone.Open(iServer, PHONE_NAME)==KErrNone);
|
|
69 |
TESTL(iPhone2.Open(iServer, PHONE_NAME)==KErrNone);
|
|
70 |
}
|
|
71 |
|
|
72 |
TInt CTestDriveOOMVoiceCall::DriveETelApiL()
|
|
73 |
//
|
|
74 |
// This function contains the real meat of the Client-side test code
|
|
75 |
//
|
|
76 |
{
|
|
77 |
CloseDown();
|
|
78 |
User::After(KETelServerShutdownGuardPeriod);
|
|
79 |
|
|
80 |
TInt n=1;
|
|
81 |
for(;;n++)
|
|
82 |
{
|
|
83 |
INFO_PRINTF2(_L("Fail After %d allocs... "),n);
|
|
84 |
TInt res=DoTestL(n);
|
|
85 |
INFO_PRINTF2(_L("Result=%d"),res);
|
|
86 |
if(res==KErrNone)
|
|
87 |
break;
|
|
88 |
RestartScript();
|
|
89 |
User::After(KETelServerShutdownGuardPeriod);
|
|
90 |
}
|
|
91 |
|
|
92 |
OpenUpL();
|
|
93 |
TerminateScript();
|
|
94 |
return KErrNone;
|
|
95 |
}
|
|
96 |
|
|
97 |
TInt CTestDriveOOMVoiceCall::DoTestL(TInt aAllocFailNumber)
|
|
98 |
{
|
|
99 |
_LIT(KPhoneModule,"MM");
|
|
100 |
_LIT(KPhoneName, "GsmPhone1");
|
|
101 |
_LIT(KLineName, "Voice");
|
|
102 |
|
|
103 |
RTelServer telServer;
|
|
104 |
TInt ret=telServer.Connect();
|
|
105 |
if(ret!=KErrNone)
|
|
106 |
return ret;
|
|
107 |
|
|
108 |
telServer.__DbgFailNext(aAllocFailNumber);
|
|
109 |
|
|
110 |
ret=telServer.LoadPhoneModule(KPhoneModule);
|
|
111 |
if(ret!=KErrNone)
|
|
112 |
{
|
|
113 |
telServer.Close();
|
|
114 |
return ret;
|
|
115 |
}
|
|
116 |
|
|
117 |
RMobilePhone mobilePhone;
|
|
118 |
ret=mobilePhone.Open(telServer, KPhoneName);
|
|
119 |
if(ret!=KErrNone)
|
|
120 |
{
|
|
121 |
mobilePhone.Close();
|
|
122 |
telServer.Close();
|
|
123 |
return ret;
|
|
124 |
}
|
|
125 |
|
|
126 |
RLine line;
|
|
127 |
INFO_PRINTF1(_L("Opening Voice Line"));
|
|
128 |
ret=line.Open(mobilePhone,KLineName);
|
|
129 |
if(ret!=KErrNone)
|
|
130 |
{
|
|
131 |
line.Close();
|
|
132 |
mobilePhone.Close();
|
|
133 |
telServer.Close();
|
|
134 |
return ret;
|
|
135 |
}
|
|
136 |
|
|
137 |
INFO_PRINTF1(_L("Opening New Voice Call"));
|
|
138 |
RCall call;
|
|
139 |
ret=call.OpenNewCall(line);
|
|
140 |
if(ret!=KErrNone)
|
|
141 |
{
|
|
142 |
call.Close();
|
|
143 |
line.Close();
|
|
144 |
mobilePhone.Close();
|
|
145 |
telServer.Close();
|
|
146 |
return ret;
|
|
147 |
}
|
|
148 |
|
|
149 |
INFO_PRINTF1(_L("Initialise the Phone..."));
|
|
150 |
|
|
151 |
TRequestStatus reqStatus;
|
|
152 |
RMobilePhone::TMMTableSettings tableSettings;
|
|
153 |
tableSettings.iLocId=KInternetAccessPoint;
|
|
154 |
RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
|
|
155 |
mobilePhone.InitialiseMM(reqStatus, tableSettingsPckg);
|
|
156 |
User::WaitForRequest(reqStatus);
|
|
157 |
TESTL(reqStatus == KErrNone);
|
|
158 |
|
|
159 |
if(reqStatus!=KErrNone)
|
|
160 |
{
|
|
161 |
call.Close();
|
|
162 |
line.Close();
|
|
163 |
mobilePhone.Close();
|
|
164 |
telServer.Close();
|
|
165 |
return ret;
|
|
166 |
}
|
|
167 |
|
|
168 |
INFO_PRINTF1(_L("Dial a number..."));
|
|
169 |
_LIT(KDialString, "+1234");
|
|
170 |
ret=call.Dial(KDialString);
|
|
171 |
if(ret!=KErrNone)
|
|
172 |
{
|
|
173 |
call.Close();
|
|
174 |
line.Close();
|
|
175 |
mobilePhone.Close();
|
|
176 |
telServer.Close();
|
|
177 |
return ret;
|
|
178 |
}
|
|
179 |
|
|
180 |
INFO_PRINTF1(_L("Hangup a call..."));
|
|
181 |
ret=call.HangUp();
|
|
182 |
if(ret!=KErrNone)
|
|
183 |
{
|
|
184 |
call.Close();
|
|
185 |
line.Close();
|
|
186 |
mobilePhone.Close();
|
|
187 |
telServer.Close();
|
|
188 |
return ret;
|
|
189 |
}
|
|
190 |
|
|
191 |
INFO_PRINTF1(_L("Close the call, line & iPhone..."));
|
|
192 |
call.Close();
|
|
193 |
line.Close();
|
|
194 |
mobilePhone.Close();
|
|
195 |
|
|
196 |
return KErrNone;
|
|
197 |
}
|
|
198 |
|
|
199 |
//
|
|
200 |
// Emulator-side class
|
|
201 |
// With the assistance of the base class, this class must run the designated script
|
|
202 |
//
|
|
203 |
CTestOOMVoiceCall* CTestOOMVoiceCall::NewL(const TScript* aScript)
|
|
204 |
{
|
|
205 |
CTestOOMVoiceCall* aA = new(ELeave) CTestOOMVoiceCall(aScript);
|
|
206 |
CleanupStack::PushL(aA);
|
|
207 |
aA->ConstructL();
|
|
208 |
CleanupStack::Pop();
|
|
209 |
return aA;
|
|
210 |
}
|
|
211 |
|
|
212 |
CTestOOMVoiceCall::CTestOOMVoiceCall(const TScript* aScript) : iScript(aScript)
|
|
213 |
{}
|
|
214 |
|
|
215 |
void CTestOOMVoiceCall::ConstructL()
|
|
216 |
{
|
|
217 |
CATScriptEng::ConstructL();
|
|
218 |
}
|
|
219 |
|
|
220 |
TInt CTestOOMVoiceCall::Start()
|
|
221 |
{
|
|
222 |
StartScript(iScript);
|
|
223 |
return KErrNone;
|
|
224 |
}
|
|
225 |
|
|
226 |
void CTestOOMVoiceCall::SpecificAlgorithmL(TInt /* aParam */)
|
|
227 |
{
|
|
228 |
}
|
|
229 |
|
|
230 |
void CTestOOMVoiceCall::Complete(TInt aError)
|
|
231 |
{
|
|
232 |
iReturnValue = aError;
|
|
233 |
CActiveScheduler::Stop();
|
|
234 |
}
|