|
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_SimPhBkTestStepBase.h" |
|
17 #include "Te_SimPhBkConstants.h" |
|
18 |
|
19 TVerdict CSimPhBkTestStepBase::doTestStepPreambleL() |
|
20 { |
|
21 __UHEAP_MARK; |
|
22 |
|
23 TInt ret = iTelServer.Connect(); |
|
24 if (ret!=KErrNone) |
|
25 { |
|
26 INFO_PRINTF1(_L("Failed to connect to telephony server")); |
|
27 User::Leave(ret); |
|
28 } |
|
29 ret=iTelServer.LoadPhoneModule(KSimtsyName); |
|
30 if (ret!=KErrNone) |
|
31 { |
|
32 INFO_PRINTF1(_L("Failed to load phone module")); |
|
33 iTelServer.Close(); |
|
34 User::Leave(ret); |
|
35 } |
|
36 |
|
37 ret=iPhone.Open(iTelServer,KPhoneName) ; |
|
38 if (ret!=KErrNone) |
|
39 { |
|
40 INFO_PRINTF1(_L("Failed to open phone module")); |
|
41 iTelServer.UnloadPhoneModule(KSimtsyName); |
|
42 iTelServer.Close(); |
|
43 User::Leave(ret); |
|
44 } |
|
45 ret=iPhone.Initialise(); |
|
46 if (ret!=KErrNone) |
|
47 { |
|
48 INFO_PRINTF1(_L("Failed to initialise the phone")); |
|
49 iPhone.Close(); |
|
50 iTelServer.UnloadPhoneModule(KSimtsyName); |
|
51 iTelServer.Close(); |
|
52 User::Leave(ret); |
|
53 } |
|
54 |
|
55 RPhone::TCaps phoneCaps; |
|
56 ret = iPhone.GetCaps(phoneCaps) ; |
|
57 if ((KErrNone != ret) || !(phoneCaps.iFlags & RPhone::KCapsVoice)) |
|
58 { |
|
59 INFO_PRINTF2(_L("This phone does not support Voice Calls (caps=0x%x)"), phoneCaps.iFlags); |
|
60 iPhone.Close(); |
|
61 iTelServer.UnloadPhoneModule(KSimtsyName); |
|
62 iTelServer.Close(); |
|
63 User::Leave(ret); |
|
64 } |
|
65 |
|
66 return TestStepResult(); |
|
67 } |
|
68 |
|
69 TVerdict CSimPhBkTestStepBase::doTestStepPostambleL() |
|
70 { |
|
71 iPhone.Close(); |
|
72 iTelServer.UnloadPhoneModule(KSimtsyName); |
|
73 iTelServer.Close(); |
|
74 |
|
75 __UHEAP_MARKEND; |
|
76 return TestStepResult(); |
|
77 } |
|
78 |
|
79 void CSimPhBkTestStepBase::CleanUp(TAny *aPtr) |
|
80 /** |
|
81 * Calls iLine.Close() & iCall.Close in leave case. |
|
82 * @param this poiter pass cleanup stack when calls the function |
|
83 */ |
|
84 { |
|
85 CSimPhBkTestStepBase* ptr = ((CSimPhBkTestStepBase*)aPtr) ; |
|
86 ptr->iCall.Close() ; |
|
87 ptr->iLine.Close() ; |
|
88 } |
|
89 |
|
90 CSimPhBkTestStepBase::operator TCleanupItem() |
|
91 /** |
|
92 * Makes TCleanupItem from current instance of CTestSimPhBkStep |
|
93 */ |
|
94 { |
|
95 return TCleanupItem(CSimPhBkTestStepBase::CleanUp,this); |
|
96 } |
|
97 |
|
98 TInt CSimPhBkTestStepBase::ClearPhoneBookL(const TDesC& aPhoneBookName) |
|
99 /** |
|
100 * This function deletes the first 15 entries in the specified Phone Book. |
|
101 * It is called by the clearPhoneBooks() function. |
|
102 * @test GT83-TPHBK-008.00 Test deleting an individual phonebook entry from a ME-based phonebook of abbreviated dialling numbers. |
|
103 * @test GT83-TPHBK-002.06 GT83-AT-070 Test closing an ICC-based phonebook of abbreviated dialling numbers |
|
104 */ |
|
105 { |
|
106 TRequestStatus aStatus; |
|
107 RMobilePhoneBookStore thePhBk; |
|
108 TInt ret=thePhBk.Open(iPhone,aPhoneBookName); |
|
109 CHECKPOINT(ret, KErrNone, _L("GT83-TPHBK-001.00")) ; |
|
110 |
|
111 if (ret!=KErrNone) |
|
112 return ret; |
|
113 |
|
114 INFO_PRINTF2(_L("Deleting %S phonebook 15 first entries..."), &aPhoneBookName); |
|
115 TInt i; |
|
116 for (i=1; i<=15; i++) |
|
117 { |
|
118 thePhBk.Delete(aStatus, i); |
|
119 User::WaitForRequest(aStatus); |
|
120 if (aStatus!=KErrNone && aStatus!=KErrNotFound) |
|
121 { |
|
122 //it's checked by "if" |
|
123 CHECKPOINT(1, KErrNone, _L("GT83-TPHBK-008.00")) ; |
|
124 break; |
|
125 } |
|
126 } |
|
127 |
|
128 thePhBk.Close(); |
|
129 CHECKPOINT(ret, KErrNone, _L("GT83-TPHBK-002.00")) ; |
|
130 return ret; |
|
131 } |
|
132 |
|
133 void CSimPhBkTestStepBase::CheckPhoneBookInfoL(RMobilePhoneStore::TMobilePhoneStoreInfoV1& aInfo) |
|
134 /** |
|
135 * This function is called by the testPhoneInfo() function. It checks |
|
136 * the validity of the information in the TPhoneBookInfo struct. |
|
137 */ |
|
138 { |
|
139 TESTL(aInfo.iTotalEntries>0); |
|
140 |
|
141 // A phone book containing the recently dialled calls (RO) |
|
142 if (!aInfo.iName.Compare(KETelMeDialledPhoneBook())) |
|
143 { |
|
144 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
145 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); // But we should be able to read |
|
146 INFO_PRINTF1(_L("\"DIALLED_CALLS\" tested RO successfully")); |
|
147 } |
|
148 |
|
149 // A phone book containing missed calls. (RO) |
|
150 else if (!aInfo.iName.Compare(KETelMeMissedPhoneBook())) |
|
151 { |
|
152 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
153 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
154 INFO_PRINTF1(_L("\"MISSED_CALLS\" tested RO successfully")); |
|
155 } |
|
156 |
|
157 //A phone book containing received calls (RO) |
|
158 else if (!aInfo.iName.Compare(KETelMeReceivedPhoneBook())) |
|
159 { |
|
160 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
161 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
162 INFO_PRINTF1(_L("\"RECEIVED_CALLS\" tested RO successfully")); |
|
163 } |
|
164 |
|
165 // A ME based phone book of abbreviated dialling numbers (RW) |
|
166 else if (!aInfo.iName.Compare(KETelMeAdnPhoneBook())) |
|
167 { |
|
168 iMESupported=ETrue; |
|
169 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
170 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
171 INFO_PRINTF1(_L("\"ME_PHONEBOOK\" tested RW successfully")); |
|
172 } |
|
173 |
|
174 //A phone book containing voice mailbox numbers (RO) |
|
175 else if (!aInfo.iName.Compare(KETelIccVoiceMailBox())) |
|
176 { |
|
177 iMESupported=ETrue; |
|
178 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
179 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
180 INFO_PRINTF1(_L("\"VOICE_MAILBOX\" tested RO successfully")); |
|
181 } |
|
182 |
|
183 //A SIM based phone book of abbreviated dialling numbers (RW) |
|
184 else if (!aInfo.iName.Compare(KETelIccAdnPhoneBook())) |
|
185 { |
|
186 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
187 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
188 INFO_PRINTF1(_L("\"SIM_PHONEBOOK\" tested RW successfully")); |
|
189 } |
|
190 |
|
191 |
|
192 //A combination of ME and SIM based phone books (RO) |
|
193 else if (!aInfo.iName.Compare(KETelCombinedAdnPhoneBook())) |
|
194 { |
|
195 iMTSupported=ETrue; |
|
196 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
197 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
198 INFO_PRINTF1(_L("\"COMBINED_SIM_ME\" tested RO successfully")); |
|
199 } |
|
200 |
|
201 //A phone book containing the fixed dialling list(RO) |
|
202 else if (!aInfo.iName.Compare(KETelIccFdnPhoneBook())) |
|
203 { |
|
204 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
205 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
206 INFO_PRINTF1(_L("\"FIXED_DIAL_NUM\" tested RO successfully")); |
|
207 } |
|
208 |
|
209 //A phone book containing service dialling number list (RO) |
|
210 else if (!aInfo.iName.Compare(KETelIccSdnPhoneBook())) |
|
211 { |
|
212 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
213 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
214 INFO_PRINTF1(_L("\"SERV_DIAL_NUM\" tested RO successfully")); |
|
215 } |
|
216 |
|
217 //A phone book containing the barred dialling numbers (RO) |
|
218 else if (!aInfo.iName.Compare(KETelIccBdnPhoneBook())) |
|
219 { |
|
220 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess); |
|
221 TESTL(aInfo.iCaps & RMobilePhoneStore::KCapsReadAccess); |
|
222 INFO_PRINTF1(_L("\"BARRED_DIAL_NUM\" tested RO successfully")); |
|
223 } |
|
224 } |
|
225 |
|
226 void CSimPhBkTestStepBase::WriteBatchOfEntriesToThePhoneL() |
|
227 /** |
|
228 * This function writes 15 entries to the phone. |
|
229 * @test GT83-TPHBK-001.06 Test opening an ICC-based phonebook of abbreviated dialling numbers |
|
230 * @test GT83-TPHBK-002.06 Test closing an ICC-based phonebook of abbreviated dialling numbers |
|
231 * @test GT83-TPHBK-007.06 "Test writing a single phonebook entry to a specified location in an ICC-based phonebook containing voice mailbox numbers, where the location is empty" |
|
232 */ |
|
233 { |
|
234 TInt ret=KErrNone; |
|
235 TRequestStatus aStatus; |
|
236 RMobilePhoneBookStore simPhBk; |
|
237 TBuf8<KPBDataClientBuf> pbData; // Client reserved space for phonebook data |
|
238 CPhoneBookBuffer* pbBuffer=new(ELeave) CPhoneBookBuffer(); |
|
239 |
|
240 pbBuffer->Set(&pbData); // Set it to point to the Client buffer |
|
241 ret=simPhBk.Open(iPhone, KETelIccAdnPhoneBook()); |
|
242 CHECKPOINT(ret, KErrNone, _L("GT83-TPHBK-001.06")) ; |
|
243 |
|
244 // Create array of names and numbers |
|
245 const TText16* names[]={(TText16*)KAnnText.iBuf, (TText16*)KMattSText.iBuf, (TText16*)KAndyText.iBuf, |
|
246 (TText16*)KMattMText.iBuf,(TText16*)KPaulText.iBuf, (TText16*)KMumAndDadText.iBuf, |
|
247 (TText16*)KSymbolText.iBuf,(TText16*)KHenrikText.iBuf,(TText16*)KHenrikSVText.iBuf, |
|
248 (TText16*)KMikaelText.iBuf,(TText16*)KIngeText.iBuf,(TText16*)KPatrickText.iBuf, |
|
249 (TText16*)KPontusText.iBuf,(TText16*)KAndersText.iBuf,(TText16*)KHajText.iBuf}; |
|
250 |
|
251 const TText16* numbers[]={(TText16*)KAnnPhoneNum.iBuf, (TText16*)KMattSPhoneNum.iBuf, (TText16*)KAndyPhoneNum.iBuf, |
|
252 (TText16*)KMattMPhoneNum.iBuf, (TText16*)KPaulPhoneNum.iBuf, (TText16*)KMumAndDadPhoneNum.iBuf, |
|
253 (TText16*)KSymbolPhoneNum.iBuf,(TText16*)KHenrikPhoneNum.iBuf,(TText16*)KHenrikSVPhoneNum.iBuf, |
|
254 (TText16*)KMikaelPhoneNum.iBuf,(TText16*)KIngePhoneNum.iBuf,(TText16*)KPatrickPhoneNum.iBuf, |
|
255 (TText16*)KPontusPhoneNum.iBuf,(TText16*)KAndersPhoneNum.iBuf,(TText16*)KHajPhoneNum.iBuf}; |
|
256 |
|
257 |
|
258 // Write the entries to the SIM Phone Book |
|
259 TInt size(KPPBEntriesNum); |
|
260 TInt i(0), index(0); |
|
261 |
|
262 TBuf<KBufSize> entryNumber(numbers[0]); |
|
263 TBuf<KBufSize> entryName(names[0]); |
|
264 |
|
265 for (i=1; i<=size; ++i) |
|
266 { |
|
267 //first reset the following three local buffers to delete any existing data |
|
268 entryNumber.FillZ(); |
|
269 entryNumber.Zero(); |
|
270 entryName.FillZ(); |
|
271 entryName.Zero(); |
|
272 pbData.FillZ(); |
|
273 pbData.Zero(); |
|
274 |
|
275 entryNumber=numbers[i-1]; |
|
276 entryName=names[i-1]; |
|
277 |
|
278 // convert number into TLV format and append it to allocated buffer |
|
279 ret=pbBuffer->PutTagAndValue((TUint8)RMobilePhoneBookStore::ETagPBNumber, entryNumber); |
|
280 TESTL(ret == KErrNone) ; |
|
281 |
|
282 // convert type into TLV format and append it to allocated buffer |
|
283 ret=pbBuffer->PutTagAndValue((TUint8)RMobilePhoneBookStore::ETagPBTonNpi, (TUint8)RMobilePhone::EUnknownNumber); |
|
284 TESTL(ret == KErrNone) ; |
|
285 |
|
286 // convert text into TLV format and append it to allocated buffer |
|
287 ret=pbBuffer->PutTagAndValue((TUint8)RMobilePhoneBookStore::ETagPBText, entryName); |
|
288 TESTL(ret == KErrNone) ; |
|
289 |
|
290 index=RMobilePhoneStore::TMobilePhoneStoreEntryV1::KIndexNotUsed; |
|
291 // Note that KIndexNotUsed cannot be used anymore to write to next available phonebook slot |
|
292 simPhBk.Write(aStatus, pbData, index); |
|
293 User::WaitForRequest(aStatus); |
|
294 |
|
295 if (aStatus!=KErrNone) // First write request should fail |
|
296 { |
|
297 // This time client needs to specify the phonebook slot |
|
298 index=i; |
|
299 simPhBk.Write(aStatus, pbData, index); |
|
300 User::WaitForRequest(aStatus); |
|
301 CHECKPOINT(aStatus.Int(), KErrNone, _L("GT83-TPHBK-007.06")) ; |
|
302 } |
|
303 } // end for |
|
304 |
|
305 simPhBk.Close(); |
|
306 delete pbBuffer; |
|
307 } |