|
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 // |
|
15 |
|
16 #include <f32file.h> |
|
17 |
|
18 #include "TE_EtelBase.h" |
|
19 #include "TE_Etelmemberfn.h" |
|
20 #include "../../DSTD/DSTD.H" |
|
21 |
|
22 CTestMemberFnSetGet::CTestMemberFnSetGet() |
|
23 /** Each test step initialises it's own name |
|
24 */ |
|
25 { |
|
26 SetTestStepName(_L("TestMemberFnSetGet")); |
|
27 } |
|
28 |
|
29 enum TVerdict CTestMemberFnSetGet::doTestStepL() |
|
30 { |
|
31 INFO_PRINTF1(_L("Test Set and Get Functions")); |
|
32 RTelServer server; |
|
33 TInt ret = server.Connect(); |
|
34 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
35 TESTCHECK(ret, KErrNone); |
|
36 ret=server.LoadPhoneModule(DSTD_MODULE_NAME); |
|
37 TESTCHECK(ret, KErrNone); |
|
38 |
|
39 RTestPhone phone; |
|
40 ret = phone.Open(server,DSTD_PHONE_NAME); |
|
41 |
|
42 TRequestStatus reqStatus; |
|
43 TBufC8<20> set(DSTD_NARROW); |
|
44 TBuf8<20> get; |
|
45 TBuf16<20> get2; |
|
46 TBuf16<20> get21; |
|
47 TBuf16<20> get22; |
|
48 TBufC16<20> set2(DSTD_UNICODE); |
|
49 |
|
50 // |
|
51 // Execute the following tests using extended error codes. Only TestNarrowSetAndGet() |
|
52 // has actually been converted to use the extended errors. All other should work as |
|
53 // normal anyway. |
|
54 // |
|
55 ret = server.SetExtendedErrorGranularity(RTelServer::EErrorExtended); |
|
56 TESTCHECK(ret, KErrNone); |
|
57 |
|
58 phone.TestNarrowSetAndGet(reqStatus, set, get); |
|
59 User::WaitForRequest(reqStatus); |
|
60 TESTCHECK(reqStatus.Int(), KErrLicenseeSpecificOkay); |
|
61 TESTCHECKSTR(get, DSTD_NARROW); |
|
62 |
|
63 phone.TestUnicodeSetAndNarrowGet(reqStatus, get, set2); |
|
64 User::WaitForRequest(reqStatus); |
|
65 TESTCHECK(reqStatus.Int(), KErrNone); |
|
66 TESTCHECKSTR(get, DSTD_NARROW); |
|
67 |
|
68 phone.TestNarrowSetAndUnicodeGet(reqStatus, set, get2); |
|
69 User::WaitForRequest(reqStatus); |
|
70 TESTCHECK(reqStatus.Int(), KErrNone); |
|
71 TESTCHECKSTR(get2, DSTD_UNICODE); |
|
72 |
|
73 phone.TestUnicodeSetAndGet(reqStatus, set2, get2); |
|
74 User::WaitForRequest(reqStatus); |
|
75 TESTCHECK(reqStatus.Int(), KErrNone); |
|
76 TESTCHECKSTR(get2, DSTD_UNICODE); |
|
77 |
|
78 phone.TestDoubleUnicodeGet(reqStatus, get21, get22); |
|
79 User::WaitForRequest(reqStatus); |
|
80 TESTCHECK(reqStatus.Int(), KErrNone); |
|
81 TESTCHECKSTR(get21, DSTD_UNICODE); |
|
82 TESTCHECKSTR(get22, DSTD_UNICODE); |
|
83 |
|
84 ret = server.SetExtendedErrorGranularity(RTelServer::EErrorBasic); |
|
85 TESTCHECK(ret, KErrNone); |
|
86 |
|
87 phone.Close(); |
|
88 ret=server.UnloadPhoneModule(DSTD_MODULE_NAME); |
|
89 TESTCHECK(ret, KErrNone); |
|
90 ServerClose(server); |
|
91 |
|
92 return TestStepResult(); |
|
93 } |
|
94 |
|
95 |
|
96 CTestPhoneMemberFn::CTestPhoneMemberFn() |
|
97 /** Each test step initialises it's own name |
|
98 */ |
|
99 { |
|
100 SetTestStepName(_L("TestPhoneMemberFn")); |
|
101 } |
|
102 |
|
103 enum TVerdict CTestPhoneMemberFn::doTestStepL() |
|
104 { |
|
105 INFO_PRINTF1(_L("Test Phone Device Member Functions")); |
|
106 |
|
107 RTelServer server; |
|
108 TInt ret = server.Connect(); //open server |
|
109 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
110 TESTCHECK(ret, KErrNone); |
|
111 ret=server.LoadPhoneModule(DSTD_MODULE_NAME); |
|
112 TESTCHECK(ret, KErrNone); |
|
113 RPhone phone; |
|
114 ret = phone.Open(server,DSTD_PHONE_NAME); //open phone |
|
115 RPhone::TLineInfo iLineInfo; |
|
116 ret=phone.GetLineInfo(0,iLineInfo); |
|
117 TESTCHECK(ret, KErrNone); |
|
118 |
|
119 RPhone::TCaps phoneCaps; |
|
120 ret=phone.GetCaps(phoneCaps); |
|
121 TESTCHECK(ret, KErrNone); |
|
122 RPhone::TStatus phoneStatus; |
|
123 ret=phone.GetStatus(phoneStatus); |
|
124 TESTCHECK(ret, KErrNone); |
|
125 TInt lineCount; |
|
126 ret=phone.EnumerateLines(lineCount); |
|
127 TESTCHECK(ret, KErrNone); |
|
128 TESTCHECK(lineCount, DSTD_NUMBER_OF_LINES); |
|
129 RPhone::TLineInfo lineInfo; |
|
130 ret=phone.GetLineInfo(0,lineInfo); |
|
131 TESTCHECK(ret, KErrNone); |
|
132 RPhone::TModemDetection detection; |
|
133 TRequestStatus phoneDetectionStatus; |
|
134 |
|
135 phone.NotifyModemDetected(phoneDetectionStatus,detection);//REQUEST 1 |
|
136 User::WaitForRequest(phoneDetectionStatus);//FINISH REQUEST 1 |
|
137 |
|
138 phone.NotifyModemDetected(phoneDetectionStatus,detection);//REQUEST 2 |
|
139 User::WaitForRequest(phoneDetectionStatus);//FINISH REQUEST 2 |
|
140 phone.NotifyModemDetectedCancel(); |
|
141 |
|
142 phone.Close(); //close phone |
|
143 ServerClose(server); //close server |
|
144 |
|
145 return TestStepResult(); |
|
146 } |
|
147 |
|
148 CTestLineMemberFn::CTestLineMemberFn() |
|
149 /** Each test step initialises it's own name |
|
150 */ |
|
151 { |
|
152 SetTestStepName(_L("TestLineMemberFn")); |
|
153 } |
|
154 |
|
155 enum TVerdict CTestLineMemberFn::doTestStepL() |
|
156 { |
|
157 INFO_PRINTF1(_L("Test Line Member Functions")); |
|
158 |
|
159 RTelServer server; |
|
160 TInt ret = server.Connect(); |
|
161 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
162 TESTCHECK(ret, KErrNone); |
|
163 ret=server.LoadPhoneModule(DSTD_MODULE_NAME); |
|
164 TESTCHECK(ret, KErrNone); |
|
165 RPhone phone; |
|
166 ret = phone.Open(server,DSTD_PHONE_NAME); |
|
167 TESTCHECK(ret, KErrNone); |
|
168 |
|
169 RLine line; |
|
170 ret = line.Open(phone,DSTD_LINE_NAME); |
|
171 TESTCHECK(ret, KErrNone); |
|
172 |
|
173 RLine::TCaps lineCaps; |
|
174 ret=line.GetCaps(lineCaps); |
|
175 TESTCHECK(ret, KErrNone); |
|
176 RCall::TStatus lineStatus; |
|
177 ret=line.GetStatus(lineStatus); |
|
178 TESTCHECK(ret, KErrNone); |
|
179 RCall::THookStatus hookStatus; |
|
180 ret=line.GetHookStatus(hookStatus); |
|
181 TESTCHECK(ret, KErrNone); |
|
182 TInt callCount; |
|
183 ret=line.EnumerateCall(callCount); |
|
184 TESTCHECK(ret, KErrNone); |
|
185 RLine::TCallInfo callInfo; |
|
186 ret=line.GetCallInfo(0,callInfo); |
|
187 TESTCHECK(ret, KErrNone); |
|
188 |
|
189 TRequestStatus notifyIncomingCallStatus; |
|
190 TName name; |
|
191 line.NotifyIncomingCall(notifyIncomingCallStatus,name); //Request 1 |
|
192 User::WaitForRequest(notifyIncomingCallStatus); //Request 1 completed |
|
193 line.NotifyIncomingCall(notifyIncomingCallStatus,name); //Request 2 |
|
194 User::WaitForRequest(notifyIncomingCallStatus); //Request 2 completed |
|
195 line.NotifyIncomingCallCancel(); |
|
196 |
|
197 TRequestStatus notifyHookChangeStatus; |
|
198 RCall::THookStatus hookStatusAsyn; |
|
199 line.NotifyHookChange(notifyHookChangeStatus,hookStatusAsyn);//Request 3 |
|
200 User::WaitForRequest(notifyHookChangeStatus);//Request 3 completed |
|
201 line.NotifyHookChange(notifyHookChangeStatus,hookStatusAsyn);//Request 4 |
|
202 User::WaitForRequest(notifyHookChangeStatus);//Request 4 completed |
|
203 line.NotifyHookChangeCancel(); |
|
204 |
|
205 TRequestStatus notifyStatusChangeStatus; |
|
206 RCall::TStatus lineStatusAsyn; |
|
207 line.NotifyStatusChange(notifyStatusChangeStatus,lineStatusAsyn);//Request 5 |
|
208 User::WaitForRequest(notifyStatusChangeStatus);//Request 5 completed |
|
209 line.NotifyStatusChange(notifyStatusChangeStatus,lineStatusAsyn);//Request 6 |
|
210 User::WaitForRequest(notifyStatusChangeStatus);//Request 6 completed |
|
211 line.NotifyStatusChangeCancel(); |
|
212 |
|
213 line.Close(); |
|
214 phone.Close(); |
|
215 server.UnloadPhoneModule(DSTD_MODULE_NAME); |
|
216 ServerClose(server); |
|
217 |
|
218 return TestStepResult(); |
|
219 } |
|
220 |
|
221 CTestCallMemberFn::CTestCallMemberFn() |
|
222 /** Each test step initialises it's own name |
|
223 */ |
|
224 { |
|
225 SetTestStepName(_L("TestCallMemberFn")); |
|
226 } |
|
227 |
|
228 enum TVerdict CTestCallMemberFn::doTestStepL() |
|
229 { |
|
230 INFO_PRINTF1(_L("Test Call Member Functions")); |
|
231 |
|
232 RTelServer server; |
|
233 TInt ret = server.Connect(); |
|
234 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
235 TESTCHECK(ret, KErrNone); |
|
236 ret=server.LoadPhoneModule(DSTD_MODULE_NAME); |
|
237 TESTCHECK(ret, KErrNone); |
|
238 |
|
239 RCall call; |
|
240 ret = call.OpenNewCall(server,DSTD_CALL_FULLNAME); |
|
241 TESTCHECK(ret, KErrNone); |
|
242 |
|
243 RCall::TStatus callStatus; |
|
244 TRequestStatus callRequestStatus; |
|
245 ret=call.GetStatus(callStatus); |
|
246 TESTCHECK(ret, KErrNone); |
|
247 RCall::TCaps callCaps; |
|
248 ret=call.GetCaps(callCaps); |
|
249 TESTCHECK(ret, KErrNone); |
|
250 RCall::TBearerService callBearerService; |
|
251 ret=call.GetBearerServiceInfo(callBearerService); |
|
252 TESTCHECK(ret, KErrNone); |
|
253 |
|
254 RCall::THookStatus hookStatus; |
|
255 call.NotifyHookChange(callRequestStatus,hookStatus);//Request 1 |
|
256 User::WaitForRequest(callRequestStatus);//Completed Request 1 |
|
257 call.NotifyHookChange(callRequestStatus,hookStatus);//Request 2 |
|
258 User::WaitForRequest(callRequestStatus);//Completed Request 2 |
|
259 call.NotifyHookChangeCancel(); |
|
260 |
|
261 call.NotifyStatusChange(callRequestStatus,callStatus);//Request 3 |
|
262 User::WaitForRequest(callRequestStatus);//Completed Request 3 |
|
263 call.NotifyStatusChange( callRequestStatus,callStatus);//Request 4 |
|
264 User::WaitForRequest(callRequestStatus);//Completed Request 4 |
|
265 call.NotifyStatusChangeCancel(); |
|
266 |
|
267 // User::WaitForRequest(callRequestStatus); //Request already completed |
|
268 TInt dum = (callRequestStatus==KErrCancel || callRequestStatus==KErrNone); |
|
269 TESTCHECK(dum, TRUE); |
|
270 |
|
271 RCall::TCallParams callParams; |
|
272 RCall::TCallParamsPckg callParamsPckg(callParams); |
|
273 |
|
274 TDummyString dialString=DACQ_PHONE_NUMBER_TO_DIAL; |
|
275 TRequestStatus dialStatus; |
|
276 call.Dial(dialStatus,callParamsPckg,dialString); //Request 5 |
|
277 call.DialCancel(); |
|
278 User::WaitForRequest(dialStatus);//Completed request 5 |
|
279 |
|
280 ret=call.Dial(callParamsPckg,dialString); |
|
281 TESTCHECK(ret, KErrNone); |
|
282 call.DialCancel(); |
|
283 |
|
284 ret=call.Connect(callParamsPckg); |
|
285 TESTCHECK(ret, KErrNone); |
|
286 TRequestStatus connectStatus; |
|
287 call.Connect(connectStatus,callParamsPckg);//Request 6 |
|
288 User::WaitForRequest(connectStatus);//Completed request 6 |
|
289 call.ConnectCancel(); |
|
290 |
|
291 ret=call.AnswerIncomingCall(callParamsPckg); |
|
292 TESTCHECK(ret, KErrNone); |
|
293 TRequestStatus answerStatus; |
|
294 call.AnswerIncomingCall(answerStatus,callParamsPckg);//Request 7 |
|
295 User::WaitForRequest(answerStatus);//Completed request 7 |
|
296 call.AnswerIncomingCallCancel(); |
|
297 |
|
298 ret=call.HangUp(); // call becomes Unowned |
|
299 TESTCHECK(ret, KErrNone); |
|
300 |
|
301 RCall::TCommPort port; |
|
302 ret=call.LoanDataPort(port); |
|
303 TESTCHECK(ret, KErrNone); |
|
304 ret=call.RecoverDataPort(); |
|
305 TESTCHECK(ret, KErrNone); |
|
306 ret=call.Dial(callParamsPckg,DACQ_PHONE_NUMBER_TO_DIAL); |
|
307 TESTCHECK(ret, KErrNone); |
|
308 ret=call.TransferOwnership(); |
|
309 TESTCHECK(ret, KErrEtelNoClientInterestedInThisCall); |
|
310 |
|
311 TRequestStatus acquireStatus; |
|
312 call.AcquireOwnership(acquireStatus);//request 8 |
|
313 User::WaitForRequest(acquireStatus);//completed request 8 |
|
314 call.AcquireOwnership(acquireStatus);//request 9 |
|
315 User::WaitForRequest(acquireStatus);//Completed request 9 |
|
316 call.AcquireOwnershipCancel(); |
|
317 RCall::TOwnershipStatus ownerStatus; |
|
318 ret=call.GetOwnershipStatus(ownerStatus); |
|
319 TESTCHECK(ret, KErrNone); |
|
320 |
|
321 TDummyString8 params; |
|
322 ret=call.GetCallParams(params); |
|
323 TESTCHECK(ret, KErrNone); |
|
324 |
|
325 RCall::TFaxSessionSettings getSettings; |
|
326 ret=call.GetFaxSettings(getSettings); |
|
327 TESTCHECK(ret, KErrNone); |
|
328 TESTCHECKSTR(getSettings.iFaxId, DACQ_MYFAX); |
|
329 |
|
330 RCall::TFaxSessionSettings setSettings; |
|
331 setSettings.iFaxId=DACQ_MYFAX; |
|
332 ret=call.SetFaxSettings(setSettings); |
|
333 TESTCHECK(ret, KErrNone); |
|
334 |
|
335 //test sending file handle to server |
|
336 RFs fs; |
|
337 ret = fs.Connect(); |
|
338 TESTCHECK(ret, KErrNone); |
|
339 CleanupClosePushL(fs); |
|
340 fs.ShareProtected(); |
|
341 TDriveUnit driveUnit(EDriveC); |
|
342 //create private path for this process; |
|
343 fs.CreatePrivatePath(driveUnit); |
|
344 TPath path; |
|
345 TFileName fname; |
|
346 fs.PrivatePath(path); |
|
347 |
|
348 TDriveName drive=driveUnit.Name(); |
|
349 fname.Insert(0, drive); |
|
350 |
|
351 _LIT(KHeaderFile, "TestHeaderFile.txt"); |
|
352 fname.Append(path); |
|
353 fname.Append(KHeaderFile); |
|
354 |
|
355 RFile file; |
|
356 CleanupClosePushL(fs); |
|
357 |
|
358 file.Replace(fs, fname, EFileWrite); |
|
359 file.Write(DACQ_MFAXFILE); |
|
360 |
|
361 ret = call.AdoptFaxSharedHeaderFile(file); |
|
362 TESTCHECK(ret, KErrNone); |
|
363 |
|
364 CleanupStack::PopAndDestroy();//file |
|
365 CleanupStack::PopAndDestroy();//fs |
|
366 |
|
367 // Test the retrieval of the reference count |
|
368 // Simulate two clients opening an handle on the same call objects |
|
369 // from two different servers. |
|
370 |
|
371 RCall callA; |
|
372 TName name; |
|
373 ret = callA.OpenNewCall(server,DSTD_CALL_FULLNAME,name); |
|
374 TESTCHECK(ret, KErrNone); |
|
375 |
|
376 TInt countA=0; |
|
377 countA=callA.ReferenceCount(); |
|
378 TESTCHECK(countA, 1); |
|
379 |
|
380 RTelServer server2; |
|
381 |
|
382 ret = server2.Connect(); |
|
383 TESTCHECK(ret, KErrNone); |
|
384 ret = server2.LoadPhoneModule(DSTD_MODULE_NAME); |
|
385 TESTCHECK(ret, KErrNone); |
|
386 |
|
387 TName callname = DSTD_CALL_FULLNAME; |
|
388 callname.Append(name); |
|
389 RCall callB; |
|
390 ret = callB.OpenExistingCall(server2,callname); |
|
391 TESTCHECK(ret, KErrNone); |
|
392 |
|
393 countA=callA.ReferenceCount(); |
|
394 TESTCHECK(countA, 2); |
|
395 |
|
396 TInt countB=0; |
|
397 countB=callB.ReferenceCount(); |
|
398 TESTCHECK(countB, 2); |
|
399 |
|
400 INFO_PRINTF1(_L("Test Reference Count getter successful")); |
|
401 |
|
402 call.Close(); |
|
403 callA.Close(); |
|
404 ServerClose(server); |
|
405 callB.Close(); |
|
406 ServerClose(server2); |
|
407 return TestStepResult(); |
|
408 } |
|
409 |
|
410 CTestFaxMemberFn::CTestFaxMemberFn() |
|
411 /** Each test step initialises it's own name |
|
412 */ |
|
413 { |
|
414 SetTestStepName(_L("TestFaxMemberFn")); |
|
415 } |
|
416 |
|
417 enum TVerdict CTestFaxMemberFn::doTestStepL() |
|
418 { |
|
419 INFO_PRINTF1(_L("Test Fax Member Functions")); |
|
420 |
|
421 RTelServer server; |
|
422 TInt ret = server.Connect(); |
|
423 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
424 TESTCHECK(ret, KErrNone); |
|
425 ret=server.LoadPhoneModule(DSTD_MODULE_NAME); |
|
426 TESTCHECK(ret, KErrNone); |
|
427 |
|
428 RCall call; |
|
429 ret = call.OpenNewCall(server,DSTD_CALL_FULLNAME); |
|
430 TESTCHECK(ret, KErrNone); |
|
431 RFax fax; |
|
432 ret=fax.Open(call); |
|
433 TESTCHECK(ret, KErrNone); |
|
434 |
|
435 TRequestStatus readFaxStatus; |
|
436 TAcqFaxBuf buf=DACQ_FAX_BUF_DATA; |
|
437 |
|
438 fax.Read(readFaxStatus,buf); |
|
439 User::WaitForRequest(readFaxStatus); |
|
440 // Check result .... |
|
441 TESTCHECKSTR(buf, DACQ_FAX_BUF_DATA); |
|
442 |
|
443 TRequestStatus writeFaxStatus; |
|
444 TAcqFaxBuf writeBuf=DACQ_FAX_BUF_DATA; |
|
445 fax.Write(writeFaxStatus,writeBuf); |
|
446 User::WaitForRequest(writeFaxStatus); |
|
447 |
|
448 TRequestStatus waitForEndOfPageStatus; |
|
449 fax.WaitForEndOfPage(waitForEndOfPageStatus); |
|
450 User::WaitForRequest(waitForEndOfPageStatus); |
|
451 |
|
452 RFax::TProgress progress; |
|
453 ret=fax.GetProgress(progress); |
|
454 |
|
455 // |
|
456 // Call returns KErrNotFound with no phone available or KErrNone when a phone is |
|
457 // present. If the watches are not present, then the phone will not be available. |
|
458 // |
|
459 TESTCHECKCONDITION(ret==KErrNotFound || ret==KErrNone); |
|
460 |
|
461 /* TRequestStatus progressNotificationStatus; |
|
462 fax.ProgressNotification(progressNotificationStatus,progress); |
|
463 User::WaitForRequest(progressNotificationStatus); |
|
464 |
|
465 // Cancels |
|
466 fax.ProgressNotification(progressNotificationStatus,progress); |
|
467 ret=fax.ProgressNotificationCancel(); |
|
468 TESTCHECK(ret, KErrNone); |
|
469 */ fax.Read(readFaxStatus,buf); |
|
470 ret=fax.TerminateFaxSession(); |
|
471 TESTCHECK(ret, KErrNone); |
|
472 fax.Write(writeFaxStatus,writeBuf); |
|
473 ret=fax.TerminateFaxSession(); |
|
474 TESTCHECK(ret, KErrNone); |
|
475 fax.WaitForEndOfPage(waitForEndOfPageStatus); |
|
476 ret=fax.TerminateFaxSession(); |
|
477 TESTCHECK(ret, KErrNone); |
|
478 |
|
479 fax.Close(); |
|
480 call.Close(); |
|
481 ret=server.UnloadPhoneModule(DSTD_MODULE_NAME); |
|
482 TESTCHECK(ret, KErrNone); |
|
483 |
|
484 ServerClose(server); |
|
485 |
|
486 return TestStepResult(); |
|
487 } |
|
488 |