|
1 // Copyright (c) 2003-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 // TE_ETELISVLINEINFO.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TE_EtelIsvbase.h" |
|
19 #include "TE_EtelIsvCallFunc.h" |
|
20 #include "TE_EtelIsvStress.h" |
|
21 #include "TE_EtelIsvPhoneSettings.h" |
|
22 #include "TE_EtelIsvNetworkInfo.h" |
|
23 |
|
24 /** |
|
25 * |
|
26 @SYMTestCaseID Etel3rdParty 27.1, TestStress |
|
27 @SYMTestCaseDesc Stress Test 3rd party APIs |
|
28 @SYMFssID SGL.GT0166.054 v1.3 A2_Telephony_Functional_Specification.doc, |
|
29 * REQ 2116.4.2, 2116.4.3, 2116.4.3, 2116.4.4, 2116.4.6, 2116.3.2 |
|
30 */ |
|
31 |
|
32 |
|
33 CTestStress::CTestStress(TInt& aCallCount) |
|
34 /** Each test step initialises it's own name |
|
35 */ |
|
36 : iCallCount(aCallCount) |
|
37 { |
|
38 // store the name of this test case |
|
39 // this is the name that is used by the script file |
|
40 SetTestStepName(_L("TestStress")); |
|
41 } |
|
42 |
|
43 |
|
44 |
|
45 enum TVerdict CTestStress::doTestStepL() |
|
46 { |
|
47 /** |
|
48 This performs some simple stress testing using multiple clients. |
|
49 */ |
|
50 TTestData testData1; |
|
51 TTestData testData2; |
|
52 TBuf<100> testbuf1; |
|
53 TBuf<100> testbuf2; |
|
54 |
|
55 // |
|
56 //Test repeated concurrent calls to GetPhoneId() and GetSignalStrength() from separate clients |
|
57 // |
|
58 SetTestNumber(35); |
|
59 |
|
60 testData1.iTestStep = this; |
|
61 testData1.iApiToTest = EGetPhoneIdAPI; |
|
62 testData1.iClientId = 1; |
|
63 testData1.iTestSuccess = EFalse; |
|
64 testData1.iRepCount = 4; |
|
65 |
|
66 |
|
67 testData2.iTestStep = this; |
|
68 testData2.iApiToTest = EGetSignalStrengthAPI; |
|
69 testData2.iClientId = 2; |
|
70 testData2.iTestSuccess = EFalse; |
|
71 testData2.iRepCount = 4; |
|
72 |
|
73 testbuf1 = _L("Get Phone Id"); |
|
74 testbuf2 = _L("Get Signal Strength"); |
|
75 |
|
76 RunTestL(testData1,testData2,testbuf1, testbuf2); |
|
77 |
|
78 // |
|
79 //Test repeated concurrent calls to DialNewCall() and GetPhoneId() from separate clients |
|
80 // |
|
81 testData1.iTestStep = this; |
|
82 testData1.iApiToTest = EGetNetworkInfoAPI; |
|
83 testData1.iClientId = 1; |
|
84 testData1.iTestSuccess = EFalse; |
|
85 testData1.iRepCount = 4; |
|
86 |
|
87 |
|
88 testData2.iTestStep = this; |
|
89 testData2.iApiToTest = EDialNewCallAPI; |
|
90 testData2.iClientId = 2; |
|
91 testData2.iTestSuccess = EFalse; |
|
92 testData2.iRepCount = 4; |
|
93 |
|
94 testbuf1 = _L("Get Network Info"); |
|
95 testbuf2 = _L("Dial New Call"); |
|
96 |
|
97 RunTestL(testData1,testData2,testbuf1, testbuf2); |
|
98 |
|
99 iMyAsyncOneShot = CMyAsyncOneShot::NewL(); |
|
100 iMyAsyncOneShot->StartOneShot(); |
|
101 CActiveScheduler::Start(); |
|
102 |
|
103 return TestStepResult(); |
|
104 } |
|
105 |
|
106 void CTestStress::RunTestL(TTestData& aTestData1, TTestData& aTestData2,const TDes& aTestName1,const TDes& aTestName2) |
|
107 /** |
|
108 Launch threads and wait for them to complete. Check the success status of the result. |
|
109 */ |
|
110 { |
|
111 const TInt KStackSize=0x8000; |
|
112 const TInt KHeapSize=0x8000; |
|
113 const TInt KMaxHeapSize=0x80000; |
|
114 |
|
115 _LIT(KClient1ThreadName,"ClientThread1"); |
|
116 _LIT(KClient2ThreadName,"ClientThread2"); |
|
117 |
|
118 RThread t1; |
|
119 RThread t2; |
|
120 |
|
121 TInt res1=t1.Create(KClient1ThreadName,StartThreadFunction, |
|
122 KStackSize,KHeapSize,KMaxHeapSize,&aTestData1); |
|
123 |
|
124 TInt res2=t2.Create(KClient2ThreadName,StartThreadFunction, |
|
125 KStackSize,KHeapSize,KMaxHeapSize,&aTestData2); |
|
126 |
|
127 TRequestStatus reqStatus1; |
|
128 TRequestStatus reqStatus2; |
|
129 TBool req1Complete=EFalse; |
|
130 TBool req2Complete=EFalse; |
|
131 |
|
132 if (res1==KErrNone && res2==KErrNone) |
|
133 { |
|
134 t1.Resume(); |
|
135 t2.Resume(); |
|
136 t1.Logon(reqStatus1); |
|
137 t2.Logon(reqStatus2); |
|
138 |
|
139 while ( req1Complete==EFalse || req2Complete==EFalse) |
|
140 { |
|
141 User::WaitForAnyRequest(); |
|
142 if (reqStatus1 != KRequestPending && req1Complete==EFalse) |
|
143 { |
|
144 TInt res1=reqStatus1.Int(); |
|
145 TEST1(res1 == KErrNone,ETrue); |
|
146 TEST1(aTestData1.iTestSuccess != EFalse,ETrue); |
|
147 INFO_PRINTF4(_L("%S ClientId=%d TestSuccess = %d"), &aTestName1, aTestData1.iClientId, aTestData1.iTestSuccess); |
|
148 req1Complete=ETrue; |
|
149 } |
|
150 if (reqStatus2 != KRequestPending && req2Complete==EFalse) |
|
151 { |
|
152 TInt res2=reqStatus2.Int(); |
|
153 TEST1(res2 == KErrNone,ETrue); |
|
154 TEST1(aTestData2.iTestSuccess != EFalse,ETrue); |
|
155 INFO_PRINTF4(_L("%S ClientId=%d TestSuccess = %d"), &aTestName2, aTestData2.iClientId, aTestData2.iTestSuccess); |
|
156 req2Complete=ETrue; |
|
157 } |
|
158 } |
|
159 |
|
160 } |
|
161 |
|
162 t1.Close(); |
|
163 t2.Close(); |
|
164 } |
|
165 |
|
166 TInt CTestStress::StartThreadFunction(TAny* aThreadData) |
|
167 /** |
|
168 Thread has started. Check which API thread function is to be tested and set it going. |
|
169 */ |
|
170 { |
|
171 CTrapCleanup* cleanup; |
|
172 if ((cleanup=CTrapCleanup::New())==NULL) |
|
173 return KErrGeneral; |
|
174 |
|
175 CActiveScheduler* activeScheduler=new CActiveScheduler(); |
|
176 if(activeScheduler==NULL) |
|
177 return KErrNoMemory; |
|
178 CActiveScheduler::Install(activeScheduler); |
|
179 |
|
180 TTestData* testData = static_cast<TTestData*>(aThreadData); |
|
181 |
|
182 TInt ret = KErrNone; |
|
183 if(testData->iApiToTest == EGetPhoneIdAPI) |
|
184 { |
|
185 TRAP(ret,GetPhoneIdThreadFunctionL(testData)); |
|
186 } |
|
187 else if(testData->iApiToTest == EGetSignalStrengthAPI) |
|
188 { |
|
189 TRAP(ret,GetSignalStrengthThreadFunctionL(testData)); |
|
190 } |
|
191 else if(testData->iApiToTest == EDialNewCallAPI ) |
|
192 { |
|
193 TRAP(ret,MakeCallHangupThreadFunctionL(testData)); |
|
194 } |
|
195 else if(testData->iApiToTest == EGetNetworkInfoAPI ) |
|
196 { |
|
197 TRAP(ret,GetCurrentNetworkInfoThreadFunctionL(testData)); |
|
198 } |
|
199 else |
|
200 { |
|
201 ret = KErrNotFound; |
|
202 } |
|
203 |
|
204 delete activeScheduler; |
|
205 delete cleanup; |
|
206 |
|
207 return ret; |
|
208 } |
|
209 |
|
210 TInt CTestStress::GetPhoneIdThreadFunctionL(TTestData* aTestData) |
|
211 /** |
|
212 Thread function which repeatedly calls GetPhoneId() |
|
213 */ |
|
214 { |
|
215 //Open a new client |
|
216 CTelephony* telephony = CTelephony::NewLC(); |
|
217 |
|
218 //expected data |
|
219 _LIT16(manufacturerid, "PSION"); |
|
220 _LIT16(modelid, "666"); |
|
221 _LIT16(serialid, "1234567890"); |
|
222 CTelephony::TPhoneIdV1 ExpectedPhoneId; |
|
223 ExpectedPhoneId.iManufacturer=manufacturerid; |
|
224 ExpectedPhoneId.iModel=modelid; |
|
225 ExpectedPhoneId.iSerialNumber=serialid; |
|
226 TRequestStatus expStat=KErrNone; |
|
227 CTelephony::TPhoneIdV1Pckg ExpectedPhoneIdPckg(ExpectedPhoneId); |
|
228 |
|
229 CTestGetPhoneIdAct* GetPhoneIdAct = CTestGetPhoneIdAct::NewLC(aTestData->iTestStep, telephony, EFalse); |
|
230 |
|
231 for(int i = 0; i < aTestData->iRepCount; i++) |
|
232 { |
|
233 //start GetPhoneId |
|
234 GetPhoneIdAct->GetPhoneId(ExpectedPhoneIdPckg, expStat); |
|
235 CActiveScheduler::Start(); |
|
236 |
|
237 //have to perform the etst oursleves as cannot use test execute macros in threads!! |
|
238 aTestData->iTestSuccess = ETrue; |
|
239 if(GetPhoneIdAct->iStatus != KErrNone) |
|
240 { |
|
241 aTestData->iTestSuccess = EFalse; |
|
242 } |
|
243 if(GetPhoneIdAct->iPhoneId.iManufacturer != ExpectedPhoneId.iManufacturer) |
|
244 { |
|
245 aTestData->iTestSuccess = EFalse; |
|
246 } |
|
247 if(GetPhoneIdAct->iPhoneId.iModel != ExpectedPhoneId.iModel) |
|
248 { |
|
249 aTestData->iTestSuccess = EFalse; |
|
250 } |
|
251 if(GetPhoneIdAct->iPhoneId.iSerialNumber != ExpectedPhoneId.iSerialNumber) |
|
252 { |
|
253 aTestData->iTestSuccess = EFalse; |
|
254 } |
|
255 if(aTestData->iTestSuccess == EFalse) |
|
256 { |
|
257 break; //test failed. |
|
258 } |
|
259 } |
|
260 |
|
261 CleanupStack::PopAndDestroy(GetPhoneIdAct); //GetPhoneIdAct |
|
262 CleanupStack::PopAndDestroy(telephony); //telephony |
|
263 return KErrNone; |
|
264 } |
|
265 |
|
266 TInt CTestStress::GetSignalStrengthThreadFunctionL(TTestData* aTestData) |
|
267 /** |
|
268 Thread function which repeatedly calls GetSignalStrength() |
|
269 */ |
|
270 { |
|
271 //Open a new client |
|
272 CTelephony* telephony = CTelephony::NewLC(); |
|
273 |
|
274 //Set expected result values |
|
275 TRequestStatus expStat=KErrNone; |
|
276 CTelephony::TSignalStrengthV1 ExpSignalStrength; |
|
277 ExpSignalStrength.iBar=3; |
|
278 ExpSignalStrength.iSignalStrength=-51; |
|
279 CTelephony::TSignalStrengthV1Pckg expSignalStrengthPckg(ExpSignalStrength); |
|
280 |
|
281 CTestGetSignalStrengthAct* GetSignalStrengthAct = CTestGetSignalStrengthAct::NewLC(aTestData->iTestStep, telephony, EFalse); |
|
282 |
|
283 //start get signal strength |
|
284 for(int i = 0; i < aTestData->iRepCount; i++) |
|
285 { |
|
286 GetSignalStrengthAct->GetSignalStrength(expSignalStrengthPckg, expStat); |
|
287 CActiveScheduler::Start(); |
|
288 |
|
289 aTestData->iTestSuccess = ETrue; |
|
290 |
|
291 if(GetSignalStrengthAct->iStatus != KErrNone) |
|
292 { |
|
293 aTestData->iTestSuccess = EFalse; |
|
294 } |
|
295 if(GetSignalStrengthAct->iSignalStrength.iBar != ExpSignalStrength.iBar) |
|
296 { |
|
297 aTestData->iTestSuccess = EFalse; |
|
298 } |
|
299 if(GetSignalStrengthAct->iSignalStrength.iSignalStrength != ExpSignalStrength.iSignalStrength) |
|
300 { |
|
301 aTestData->iTestSuccess = EFalse; |
|
302 } |
|
303 if(aTestData->iTestSuccess == EFalse) |
|
304 { |
|
305 break; //test failed. |
|
306 } |
|
307 } |
|
308 |
|
309 CleanupStack::PopAndDestroy(GetSignalStrengthAct); //GetSignalStrengthAct |
|
310 CleanupStack::PopAndDestroy(telephony); //telephony |
|
311 return KErrNone; |
|
312 } |
|
313 |
|
314 TInt CTestStress::MakeCallHangupThreadFunctionL(TTestData* aTestData) |
|
315 /** |
|
316 Thread function which repeatedly initiates a call and hangups |
|
317 */ |
|
318 { |
|
319 _LIT(KGoodNumber,"1789"); |
|
320 |
|
321 //Open a new client |
|
322 CTelephony* telephony = CTelephony::NewLC(); |
|
323 |
|
324 //Set the call parameters for call |
|
325 CTelephony::TCallParamsV1 callParams1; |
|
326 callParams1.iIdRestrict = CTelephony::ESendMyId; |
|
327 CTelephony::TCallParamsV1Pckg callParamsPckg1(callParams1); |
|
328 |
|
329 TTestCallParams testCallParams1; |
|
330 testCallParams1.iLine = CTelephony::EVoiceLine; |
|
331 testCallParams1.iCallParamsV1Pckg = &callParamsPckg1; |
|
332 testCallParams1.iTelAddress.iTelNumber = KGoodNumber; |
|
333 testCallParams1.iExpStat = KErrNone; |
|
334 |
|
335 CTelephony::TCallStatusV1 status; |
|
336 CTelephony::TCallStatusV1Pckg statusPckg(status); |
|
337 |
|
338 // Create active DialNewCallAct objects |
|
339 CTestDialNewCallAct* testDialNewCallAct1 = CTestDialNewCallAct::NewLC(aTestData->iTestStep, telephony, EFalse); |
|
340 CTestHangupAct* testHangupAct1 = CTestHangupAct::NewLC(aTestData->iTestStep, telephony, EFalse); |
|
341 |
|
342 for(int i = 0; i < aTestData->iRepCount; i++) |
|
343 { |
|
344 //dial a new call |
|
345 testDialNewCallAct1->TestDialNewCall(testCallParams1); |
|
346 CActiveScheduler::Start(); |
|
347 |
|
348 aTestData->iTestSuccess = ETrue; |
|
349 if(testDialNewCallAct1->iStatus != KErrNone) |
|
350 { |
|
351 aTestData->iTestSuccess = EFalse; |
|
352 } |
|
353 |
|
354 TInt err = telephony->GetLineStatus(testCallParams1.iLine, statusPckg); |
|
355 if(err != KErrNone) |
|
356 { |
|
357 aTestData->iTestSuccess = EFalse; |
|
358 } |
|
359 if(status.iStatus != CTelephony::EStatusConnected) |
|
360 { |
|
361 aTestData->iTestSuccess = EFalse; |
|
362 } |
|
363 |
|
364 //hangup the call |
|
365 testHangupAct1->TestHangup(testCallParams1); |
|
366 CActiveScheduler::Start(); |
|
367 |
|
368 err = telephony->GetLineStatus(testCallParams1.iLine, statusPckg); |
|
369 if(err != KErrNone) |
|
370 { |
|
371 aTestData->iTestSuccess = EFalse; |
|
372 } |
|
373 if(status.iStatus != CTelephony::EStatusIdle) |
|
374 { |
|
375 aTestData->iTestSuccess = EFalse; |
|
376 } |
|
377 |
|
378 if(aTestData->iTestSuccess == EFalse) |
|
379 { |
|
380 break; //test failed. |
|
381 } |
|
382 } |
|
383 |
|
384 CleanupStack::PopAndDestroy(testHangupAct1); //testHangupAct1 |
|
385 CleanupStack::PopAndDestroy(testDialNewCallAct1); //testDialNewCallAct1 |
|
386 CleanupStack::PopAndDestroy(telephony); //telephony |
|
387 return KErrNone; |
|
388 } |
|
389 |
|
390 TInt CTestStress::GetCurrentNetworkInfoThreadFunctionL(TTestData* aTestData) |
|
391 /** |
|
392 Thread function which repeatedly calls GetCurrentNetworkInfo() |
|
393 */ |
|
394 { |
|
395 // Set up the expected value to be the same as that provisioned in |
|
396 // the SIM TSY config.txt file. |
|
397 _LIT16(KCountrycode, "ABCD"); |
|
398 _LIT16(KNetworkid, "Network0"); |
|
399 |
|
400 // Need to test display tag |
|
401 _LIT16(KDisplaytag, "Vodafone"); |
|
402 _LIT16(KShortname, "Voda"); |
|
403 _LIT16(KLongname, "Vodafone_UK"); |
|
404 |
|
405 //Open a new client |
|
406 CTelephony* telephony = CTelephony::NewLC(); |
|
407 |
|
408 CTelephony::TNetworkInfoV1 ExpectedNetworkInfo; |
|
409 ExpectedNetworkInfo.iCountryCode=KCountrycode; |
|
410 ExpectedNetworkInfo.iNetworkId=KNetworkid; |
|
411 ExpectedNetworkInfo.iDisplayTag=KDisplaytag; |
|
412 ExpectedNetworkInfo.iShortName=KShortname; |
|
413 ExpectedNetworkInfo.iLongName=KLongname; |
|
414 ExpectedNetworkInfo.iMode=CTelephony::ENetworkModeGsm; |
|
415 ExpectedNetworkInfo.iStatus = CTelephony::ENetworkStatusCurrent; |
|
416 ExpectedNetworkInfo.iBandInfo=CTelephony::EBandUnknown; |
|
417 ExpectedNetworkInfo.iCdmaSID.SetLength(0); |
|
418 ExpectedNetworkInfo.iAccess = CTelephony::ENetworkAccessGsm; |
|
419 ExpectedNetworkInfo.iAreaKnown = EFalse; |
|
420 ExpectedNetworkInfo.iLocationAreaCode = 0; |
|
421 ExpectedNetworkInfo.iCellId = 0; |
|
422 |
|
423 TRequestStatus ExpStat=KErrNone; |
|
424 |
|
425 // Create an active object and push it onto the clean up stack |
|
426 CTestGetCurrentNetworkInfoAct* GetCurrentNetworkInfoAct = CTestGetCurrentNetworkInfoAct::NewLC(aTestData->iTestStep, telephony, EFalse); |
|
427 |
|
428 for(int i = 0; i < aTestData->iRepCount; i++) |
|
429 { |
|
430 GetCurrentNetworkInfoAct->TestGetCurrentNetworkInfo(ExpectedNetworkInfo, ExpStat); |
|
431 CActiveScheduler::Start(); |
|
432 |
|
433 aTestData->iTestSuccess = ETrue; |
|
434 if(GetCurrentNetworkInfoAct->iStatus != KErrNone) |
|
435 { |
|
436 aTestData->iTestSuccess = EFalse; |
|
437 } |
|
438 if(GetCurrentNetworkInfoAct->iNetworkInfo.iCountryCode != ExpectedNetworkInfo.iCountryCode ) |
|
439 { |
|
440 aTestData->iTestSuccess = EFalse; |
|
441 } |
|
442 |
|
443 if(GetCurrentNetworkInfoAct->iNetworkInfo.iNetworkId != ExpectedNetworkInfo.iNetworkId ) |
|
444 { |
|
445 aTestData->iTestSuccess = EFalse; |
|
446 } |
|
447 |
|
448 if(GetCurrentNetworkInfoAct->iNetworkInfo.iDisplayTag != ExpectedNetworkInfo.iDisplayTag ) |
|
449 { |
|
450 aTestData->iTestSuccess = EFalse; |
|
451 } |
|
452 |
|
453 if(GetCurrentNetworkInfoAct->iNetworkInfo.iShortName != ExpectedNetworkInfo.iShortName ) |
|
454 { |
|
455 aTestData->iTestSuccess = EFalse; |
|
456 } |
|
457 |
|
458 if(GetCurrentNetworkInfoAct->iNetworkInfo.iLongName!= ExpectedNetworkInfo.iLongName ) |
|
459 { |
|
460 aTestData->iTestSuccess = EFalse; |
|
461 } |
|
462 |
|
463 if(aTestData->iTestSuccess == EFalse) |
|
464 { |
|
465 break; //test failed. |
|
466 } |
|
467 } |
|
468 |
|
469 CleanupStack::PopAndDestroy(GetCurrentNetworkInfoAct); //GetCurrentNetworkInfoAct |
|
470 CleanupStack::PopAndDestroy(telephony); //telephony |
|
471 return KErrNone; |
|
472 } |
|
473 |
|
474 |
|
475 /** |
|
476 * Simple pre-amble that doesn't open CTelephony. |
|
477 */ |
|
478 TVerdict CTestFailedOpen::doTestStepPreambleL() |
|
479 { |
|
480 // |
|
481 // Just mark the heap and create an Active Scheduler... |
|
482 // |
|
483 __UHEAP_MARK; |
|
484 |
|
485 iScheduler = new(ELeave) CActiveScheduler; |
|
486 CActiveScheduler::Install(iScheduler); |
|
487 |
|
488 return TestStepResult(); |
|
489 } // CTestFailedOpen::doTestStepPreambleL |
|
490 |
|
491 |
|
492 /** |
|
493 * Test of opening CTelephony without a phone being available. |
|
494 */ |
|
495 enum TVerdict CTestFailedOpen::doTestStepL() |
|
496 { |
|
497 // |
|
498 // Set the SIMTSY config to be invalid and open CTelephony. |
|
499 // |
|
500 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, |
|
501 KPSSimTsyTestNumber, 999)); |
|
502 |
|
503 TRAPD(leaveCode, iTelephony = CTelephony::NewL()); |
|
504 TEST1(leaveCode == KErrNotFound, ETrue); |
|
505 |
|
506 delete iTelephony; |
|
507 iTelephony = NULL; |
|
508 |
|
509 return TestStepResult(); |
|
510 } // CTestFailedOpen::doTestStepL |
|
511 |
|
512 |
|
513 /** |
|
514 * Simple post-amble that deletes the Active Scheduler. |
|
515 */ |
|
516 TVerdict CTestFailedOpen::doTestStepPostambleL() |
|
517 { |
|
518 delete iScheduler; |
|
519 |
|
520 __UHEAP_MARKEND; |
|
521 |
|
522 return TestStepResult(); |
|
523 } // CTestFailedOpen::doTestStepPostambleL |