24
|
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 |
// This file implements the main methods for the CTestBase class. Note that this class has
|
|
15 |
// at least two pure virtual functions which must be implemented by classes which inherit or
|
|
16 |
// derive from this class. The code in this file is responsible for starting the thread which
|
|
17 |
// acts as the Modem Emulator. This thread then is responsible for starting the processing of
|
|
18 |
// the proper script. The StartEmulator method is called by each test, typically in the RunTest
|
|
19 |
// method of the test code.
|
|
20 |
//
|
|
21 |
//
|
|
22 |
|
|
23 |
/**
|
|
24 |
@file
|
|
25 |
*/
|
|
26 |
|
|
27 |
#if defined (__WINS__)
|
|
28 |
#define PDD_NAME _L("ECDRV")
|
|
29 |
#define LDD_NAME _L("ECOMM")
|
|
30 |
#else
|
|
31 |
#define PDD_NAME _L("EUART1")
|
|
32 |
#define PDD2_NAME _L("EUART2")
|
|
33 |
#define LDD_NAME _L("ECOMM")
|
|
34 |
#endif
|
|
35 |
|
|
36 |
#include "Te_LoopbackTestStepBase.h"
|
|
37 |
#include "Te_LoopBackcrxmess.h"
|
|
38 |
#include "Te_LoopBackCNoPduRxMess.h"
|
|
39 |
#include "Te_LoopBackcsca.h"
|
|
40 |
#include "Te_LoopBackctxmess.h"
|
|
41 |
#include "Te_LoopBackcdatacall.h"
|
|
42 |
#include "Te_LoopBackcoddinits.h"
|
|
43 |
#include "Te_LoopBackcmessstor.h"
|
|
44 |
#include "Te_Loopbackcfailinits.h"
|
|
45 |
#include "Te_LoopBackcincall.h"
|
|
46 |
#include "Te_LoopBackcsmscancel.h"
|
|
47 |
#include "Te_LoopBackcshutdown.h"
|
|
48 |
#include "Te_LoopBackCSmsdelete.h"
|
|
49 |
#include "Te_LoopBackcssfax.h"
|
|
50 |
#include "Te_LoopBackcdatacallcancel.h"
|
|
51 |
#include "Te_Loopbackcfaxpremclose.h"
|
|
52 |
#include "Te_LoopBackctwofaxrx.h"
|
|
53 |
#include "Te_LoopBackcvoicecall.h"
|
|
54 |
#include "Te_LoopBackCDataCallCallBack.h"
|
|
55 |
#include "Te_LoopBackCDataCallRemoteHangupDial.h"
|
|
56 |
#include "Te_LoopBackCDataCallRemoteTerm.h"
|
|
57 |
#include "Te_LoopBackcphoneBook.h"
|
|
58 |
#include "Te_LoopBackCNetwork.h"
|
|
59 |
#include "Te_LoopBackCPhoneLine.h"
|
|
60 |
#include "Te_LoopBackCCalls.h"
|
|
61 |
#include "Te_LoopBackCNoCnmi.h"
|
|
62 |
#include "Te_LoopBackcnocmgf.h"
|
|
63 |
#include "Te_Loopbackcoomvoicecall.h"
|
|
64 |
#include "Te_LoopBackCDataCallDiffParam.h"
|
|
65 |
#include "Te_LoopBackCCbstParse.h"
|
|
66 |
#include "Te_LoopBackccgqreq_responses.h"
|
|
67 |
#include "Te_LoopBackCUnsolicited.h"
|
|
68 |
|
|
69 |
#define MODEM_EMULATOR _L("ModemEmulator")
|
|
70 |
|
|
71 |
TInt ResponderThread(TAny* aScriptNum);
|
|
72 |
|
|
73 |
const TInt KModEmStackSize=0x8000;
|
|
74 |
const TInt KModEmHeapSize=0x8000;
|
|
75 |
const TInt KModEmMaxHeapSize=0x80000;
|
|
76 |
|
|
77 |
|
|
78 |
CTestBase::CTestBase()
|
|
79 |
/**
|
|
80 |
* This method is the basic empty constructor for the CTestBase class.
|
|
81 |
*/
|
|
82 |
{
|
|
83 |
//
|
|
84 |
// Change this process and thread to a higher priority so that we can be in control
|
|
85 |
// when performing tests such as monitoring async request status values.
|
|
86 |
//
|
|
87 |
iOrgProcessPriority = RProcess().Priority();
|
|
88 |
iOrgThreadPriority = RThread().Priority();
|
|
89 |
|
|
90 |
RProcess().SetPriority(EPriorityHigh);
|
|
91 |
RThread().SetPriority(EPriorityMuchMore);
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
CTestBase::~CTestBase()
|
|
96 |
{
|
|
97 |
//
|
|
98 |
// Restore the process and thread priority...
|
|
99 |
//
|
|
100 |
RProcess().SetPriority(iOrgProcessPriority);
|
|
101 |
RThread().SetPriority(iOrgThreadPriority);
|
|
102 |
|
|
103 |
}
|
|
104 |
|
|
105 |
TVerdict CTestBase::doTestStepPreambleL( void )
|
|
106 |
/**
|
|
107 |
* This method connects two
|
|
108 |
* sessions to the RTelServer. It also loads the iPhone module (specified by the define
|
|
109 |
* MODULE_NAME) and opens two iPhone objects, one from each server. If any of these operations
|
|
110 |
* fail, this method leaves.
|
|
111 |
*
|
|
112 |
* @leave This method leaves if it is unable to connect to the RTelServer or if it is unable
|
|
113 |
* to load and open the phones.
|
|
114 |
*/
|
|
115 |
{
|
|
116 |
__UHEAP_MARK;
|
|
117 |
|
|
118 |
iTestScheduler=new (ELeave) CActiveScheduler;
|
|
119 |
CActiveScheduler::Install(iTestScheduler);
|
|
120 |
|
|
121 |
TInt ret = iServer.Connect();
|
|
122 |
ERR_PRINTF2(TRefByValue<const TDesC>(_L("First Server Connect Status = %d\n")), ret);
|
|
123 |
//User::LeaveIfError(ret);
|
|
124 |
if (ret)
|
|
125 |
{
|
|
126 |
delete iTestScheduler;
|
|
127 |
User::Leave(ret);
|
|
128 |
}
|
|
129 |
|
|
130 |
ret=iServer.LoadPhoneModule(MODULE_NAME);
|
|
131 |
ERR_PRINTF2(TRefByValue<const TDesC>(_L("LoadPhoneModuleError = %d\n")), ret);
|
|
132 |
//User::LeaveIfError(ret);
|
|
133 |
if (ret)
|
|
134 |
{
|
|
135 |
iServer.Close();
|
|
136 |
delete iTestScheduler;
|
|
137 |
User::Leave(ret);
|
|
138 |
}
|
|
139 |
|
|
140 |
ret = iServer2.Connect();
|
|
141 |
ERR_PRINTF2(TRefByValue<const TDesC>(_L("Second Server Connect Status = %d\n")), ret);
|
|
142 |
//User::LeaveIfError(ret);
|
|
143 |
if (ret)
|
|
144 |
{
|
|
145 |
iServer.UnloadPhoneModule(MODULE_NAME);
|
|
146 |
iServer.Close();
|
|
147 |
delete iTestScheduler;
|
|
148 |
User::Leave(ret);
|
|
149 |
}
|
|
150 |
|
|
151 |
//
|
|
152 |
// Open the "iPhone" object prior to the test
|
|
153 |
//
|
|
154 |
ret = iPhone.Open(iServer, PHONE_NAME);
|
|
155 |
ERR_PRINTF2(TRefByValue<const TDesC>(_L("First Phone Error Code = %d\n")), ret);
|
|
156 |
if (ret)
|
|
157 |
{
|
|
158 |
iPhone.Close();
|
|
159 |
iServer2.Close();
|
|
160 |
iServer.UnloadPhoneModule(MODULE_NAME);
|
|
161 |
iServer.Close();
|
|
162 |
delete iTestScheduler;
|
|
163 |
User::Leave(ret);
|
|
164 |
}
|
|
165 |
|
|
166 |
ret = iPhone2.Open(iServer, PHONE_NAME);
|
|
167 |
ERR_PRINTF2(TRefByValue<const TDesC>(_L("Second Phone Error Code = %d\n")), ret);
|
|
168 |
if (ret)
|
|
169 |
{
|
|
170 |
iPhone.Close();
|
|
171 |
iPhone2.Close();
|
|
172 |
iServer2.Close();
|
|
173 |
iServer.UnloadPhoneModule(MODULE_NAME);
|
|
174 |
iServer.Close();
|
|
175 |
delete iTestScheduler;
|
|
176 |
User::Leave(ret);
|
|
177 |
}
|
|
178 |
return TestStepResult();
|
|
179 |
}
|
|
180 |
|
|
181 |
TVerdict CTestBase::doTestStepPostambleL( void )
|
|
182 |
/**
|
|
183 |
* This method unloads the iPhone module and closes the phones and servers opened by the
|
|
184 |
* doTestStepPreambleL method.
|
|
185 |
*/
|
|
186 |
{
|
|
187 |
iPhone.Close();
|
|
188 |
iPhone2.Close();
|
|
189 |
iServer2.Close();
|
|
190 |
iServer.UnloadPhoneModule(MODULE_NAME);
|
|
191 |
iServer.Close();
|
|
192 |
delete iTestScheduler;
|
|
193 |
|
|
194 |
__UHEAP_MARKEND;
|
|
195 |
return TestStepResult();
|
|
196 |
}
|
|
197 |
|
|
198 |
TVerdict CTestBase::doTestStepL( void )
|
|
199 |
/**
|
|
200 |
*This method just wrap over 'old' RunTestL()
|
|
201 |
*/
|
|
202 |
{
|
|
203 |
|
|
204 |
if(RunTestL() != KErrNone || TestStepResult() == EFail)
|
|
205 |
SetTestStepResult(EFail);
|
|
206 |
return TestStepResult();
|
|
207 |
|
|
208 |
}
|
|
209 |
|
|
210 |
|
|
211 |
TInt CTestBase::StartEmulatorL()
|
|
212 |
//
|
|
213 |
// Create modem emulator thread, call function to drive ETel API and then wait for thread
|
|
214 |
// to complete.
|
|
215 |
//
|
|
216 |
/**
|
|
217 |
* This method is used by specific tests to start the modem emulation. The method
|
|
218 |
* starts a new thread in the current process with the entry point of ResponderThread. The
|
|
219 |
* responder thread is passed a pointer to the current script (iCurrentScript). If the modem
|
|
220 |
* emulator is already running, this code will attempt to wait and retry the thread
|
|
221 |
* creation. If it exceeds it's maximum retry limit, the requested test will not be run
|
|
222 |
* and an error code will be returned. A semaphore is created by StartEmulator for
|
|
223 |
* synchronization with the newly created thread.
|
|
224 |
*
|
|
225 |
* After the thread is created and the synchronization is complete, this method issues a Logon
|
|
226 |
* request to the thread to monitor for the death of the thread. If the Responder thread
|
|
227 |
* dies, an event will be received by the current thread. Then, StartEmulator calls the
|
|
228 |
* DriveETelAPI method associated with the specific test. DriveETelApiL is a pure virtual
|
|
229 |
* function within CTestBase.
|
|
230 |
*
|
|
231 |
* After the called DriveETelApiL this method exits,
|
|
232 |
*
|
|
233 |
* @return KErrNone
|
|
234 |
* @return KErrAlreadyExists is returned if the modem emulator exists and the retry limit
|
|
235 |
* expires.
|
|
236 |
* @return Variable depending on the return value from the test's DriveETelApiL method and
|
|
237 |
* thread monitoring.
|
|
238 |
*/
|
|
239 |
{
|
|
240 |
//RSemaphore s;
|
|
241 |
TInt res=KErrNone;
|
|
242 |
TThreadData threadData;
|
|
243 |
|
|
244 |
// setup data to pass to the Responder Thread when creating it.
|
|
245 |
// Note: because "threadData" is an automatic, it is assumed when the Responder Thread
|
|
246 |
// receives this data (passed by reference), is copied into thread specific storage
|
|
247 |
// by the Responder Thread before the semaphore is given back to this function to
|
|
248 |
// indicate the Responder Thread was created successfully.
|
|
249 |
threadData.iVariableDelay= iVariableDelay;
|
|
250 |
threadData.iScriptList = iCurrentScript;
|
|
251 |
threadData.iRestartReqStat=&iRestartReqStat;
|
|
252 |
|
|
253 |
res=iScriptThread.Create(MODEM_EMULATOR,ResponderThread,
|
|
254 |
KModEmStackSize,KModEmHeapSize,KModEmMaxHeapSize,&threadData);
|
|
255 |
if(res==KErrAlreadyExists)
|
|
256 |
{
|
|
257 |
for(TInt i=0;i<3;i++)
|
|
258 |
{
|
|
259 |
iScriptThread.Close();
|
|
260 |
User::After(1000000L);
|
|
261 |
res=iScriptThread.Create(MODEM_EMULATOR,ResponderThread,
|
|
262 |
KModEmStackSize,KModEmHeapSize,KModEmMaxHeapSize,&threadData);
|
|
263 |
if(res!=KErrAlreadyExists)
|
|
264 |
{
|
|
265 |
break;
|
|
266 |
}
|
|
267 |
}
|
|
268 |
}
|
|
269 |
|
|
270 |
TRequestStatus statusRequest;
|
|
271 |
|
|
272 |
if(res==KErrNone)
|
|
273 |
{
|
|
274 |
// Create a Rendezvous with the thread. This will be used
|
|
275 |
// to ensure that the thread has been started before continuing
|
|
276 |
TRequestStatus stat;
|
|
277 |
iScriptThread.Rendezvous(stat);
|
|
278 |
|
|
279 |
if (stat!=KRequestPending)
|
|
280 |
{
|
|
281 |
iScriptThread.Kill(KErrGeneral);
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
// Make the thread eligible for execution
|
|
286 |
iScriptThread.Logon(statusRequest);
|
|
287 |
iScriptThread.Resume();
|
|
288 |
}
|
|
289 |
|
|
290 |
// Wait for thread to complete the rendezvous
|
|
291 |
User::WaitForRequest(stat);
|
|
292 |
|
|
293 |
if (stat != KErrNone)
|
|
294 |
{
|
|
295 |
res=stat.Int();
|
|
296 |
return res;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
else
|
|
300 |
{
|
|
301 |
iScriptThread.Logon(statusRequest);
|
|
302 |
}
|
|
303 |
|
|
304 |
// Wait for the Restart Signal active object to be set.
|
|
305 |
for(;;)
|
|
306 |
{
|
|
307 |
if(iRestartReqStat)
|
|
308 |
{
|
|
309 |
break;
|
|
310 |
}
|
|
311 |
User::After(500000L);
|
|
312 |
}
|
|
313 |
|
|
314 |
res=DriveETelApiL();
|
|
315 |
|
|
316 |
if(res!=KErrNone)
|
|
317 |
{
|
|
318 |
iScriptThread.Close();
|
|
319 |
return res;
|
|
320 |
}
|
|
321 |
|
|
322 |
User::WaitForRequest(statusRequest);
|
|
323 |
iScriptThread.Close();
|
|
324 |
res=statusRequest.Int();
|
|
325 |
if(res==KErrCancel)
|
|
326 |
{
|
|
327 |
res=KErrNone; // Legitimate termination
|
|
328 |
}
|
|
329 |
|
|
330 |
return res;
|
|
331 |
}
|
|
332 |
|
|
333 |
void CTestBase::RestartScript()
|
|
334 |
{
|
|
335 |
__ASSERT_ALWAYS(iRestartReqStat!=NULL,User::Panic(_L("T_TsyLb Panic"),1));
|
|
336 |
TRequestStatus* reqStatus=iRestartReqStat;
|
|
337 |
iScriptThread.RequestComplete(reqStatus,KErrNone);
|
|
338 |
}
|
|
339 |
|
|
340 |
void CTestBase::TerminateScript()
|
|
341 |
{
|
|
342 |
iScriptThread.Terminate(KErrCancel);
|
|
343 |
}
|
|
344 |
|