|
1 // Copyright (c) 2008-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 |
|
17 |
|
18 /** |
|
19 @file The TEFUnit test suite for PhonebookOnControl in the Common TSY. |
|
20 */ |
|
21 |
|
22 #include "cctsyphonebookonfu.h" |
|
23 #include <etel.h> |
|
24 #include <et_clsvr.h> |
|
25 #include <ctsy/mmtsy_names.h> |
|
26 #include <ctsy/serviceapi/mmtsy_ipcdefs.h> |
|
27 #include <test/tmockltsydata.h> |
|
28 #include <ctsy/serviceapi/gsmerror.h> |
|
29 #include <ctsy/ltsy/mltsydispatchphonebookoninterface.h> |
|
30 #include "mockltsyindicatorids.h" |
|
31 #include "listretrieverao.h" |
|
32 |
|
33 CTestSuite* CCTsyPhonebookOnFU::CreateSuiteL(const TDesC& aName) |
|
34 { |
|
35 SUB_SUITE; |
|
36 |
|
37 //add use-case tests |
|
38 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUseCase0001L); |
|
39 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUseCase0002L); |
|
40 |
|
41 //add other unit tests |
|
42 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0001L); |
|
43 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0002L); |
|
44 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0003L); |
|
45 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0004L); |
|
46 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0005L); |
|
47 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0006L); |
|
48 ADD_TEST_STEP_ISO_CPP(CCTsyPhonebookOnFU, TestUnit0007L); |
|
49 |
|
50 END_SUITE; |
|
51 } |
|
52 |
|
53 |
|
54 void CCTsyPhonebookOnFU::GenerateONList3L(CMobilePhoneONList* aONList) |
|
55 /* |
|
56 * Create a list of 3 ON entries |
|
57 * @param aONList The list to be returned. |
|
58 * |
|
59 */ |
|
60 { |
|
61 RMobileONStore::TMobileONEntryV1 writeEntry; |
|
62 |
|
63 writeEntry.iMode = RMobilePhone::ENetworkModeGsm; |
|
64 writeEntry.iService = RMobilePhone::ETelephony; |
|
65 writeEntry.iNumber.iTypeOfNumber = RMobilePhone::EAlphanumericNumber; |
|
66 writeEntry.iNumber.iNumberPlan = RMobilePhone::EDataNumberPlan; |
|
67 |
|
68 for (TInt i=0; i<3; i++) |
|
69 { |
|
70 writeEntry.iNumber.iTelNumber.Format(KText,i+1); |
|
71 writeEntry.iText.Format(KNumber,i+1); |
|
72 writeEntry.iIndex = i+1; |
|
73 aONList->AddEntryL(writeEntry); |
|
74 } |
|
75 } |
|
76 |
|
77 |
|
78 void CCTsyPhonebookOnFU::StoreAllL(RMobileONStore& aOnStore) |
|
79 /* |
|
80 * Store all entries into the ON Storage. |
|
81 * |
|
82 * @param aOnStore The ON storage where the entries will be stored. |
|
83 */ |
|
84 { |
|
85 TRequestStatus reqStatus; |
|
86 |
|
87 RBuf8 completeData; |
|
88 CleanupClosePushL(completeData); |
|
89 |
|
90 TRequestStatus notifyStatus; |
|
91 TUint32 notifyEvent; |
|
92 TInt notifyIndex; |
|
93 |
|
94 RBuf8 expectEntryData; |
|
95 CleanupClosePushL(expectEntryData); |
|
96 |
|
97 CMobilePhoneONList* onList = CMobilePhoneONList::NewL(); |
|
98 CleanupStack::PushL(onList); |
|
99 |
|
100 |
|
101 GenerateONList3L(onList); |
|
102 TInt size = onList->Enumerate(); |
|
103 |
|
104 TMockLtsyData1<TInt> sizeLTsyData(size); |
|
105 completeData.Close(); |
|
106 sizeLTsyData.SerialiseL(completeData); |
|
107 |
|
108 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
109 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
110 |
|
111 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId); |
|
112 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrNone, completeData); |
|
113 |
|
114 RMobileONStore::TMobileONEntryV1 writeEntry[3]; |
|
115 for (TInt i=0; i<size; i++) |
|
116 { |
|
117 writeEntry[i]=onList->GetEntryL(i); |
|
118 |
|
119 TMockLtsyData1<RMobileONStore::TMobileONEntryV1> entryLTsyData(writeEntry[i]); |
|
120 expectEntryData.Close(); |
|
121 entryLTsyData.SerialiseL(expectEntryData); |
|
122 |
|
123 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, expectEntryData); |
|
124 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, KErrNone); |
|
125 } |
|
126 |
|
127 aOnStore.NotifyStoreEvent(notifyStatus, notifyEvent, notifyIndex); |
|
128 |
|
129 aOnStore.StoreAllL(reqStatus, onList); |
|
130 User::WaitForRequest(reqStatus); |
|
131 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
132 |
|
133 User::WaitForRequest(notifyStatus); |
|
134 |
|
135 TUint32 tempEventStoreAll = RMobilePhoneStore::KStoreDoRefresh; |
|
136 ASSERT_EQUALS(notifyEvent, tempEventStoreAll); |
|
137 |
|
138 AssertMockLtsyStatusL(); |
|
139 |
|
140 CleanupStack::PopAndDestroy(3, &completeData); // onList, expectEntryData, completeData |
|
141 } |
|
142 |
|
143 void CCTsyPhonebookOnFU::ReadAllL(RMobileONStore& aOnStore) |
|
144 /* |
|
145 * Read all entries from the ON Storage. |
|
146 * |
|
147 * @param aAsyncRetrieveList |
|
148 * @param aActiveRetriever |
|
149 */ |
|
150 { |
|
151 TInt size = 3; |
|
152 |
|
153 RBuf8 completeData; |
|
154 CleanupClosePushL(completeData); |
|
155 |
|
156 RBuf8 expectReadData; |
|
157 CleanupClosePushL(expectReadData); |
|
158 |
|
159 TMockLtsyData1<TInt> sizeReadAllLTsyData(size); |
|
160 completeData.Close(); |
|
161 sizeReadAllLTsyData.SerialiseL(completeData); |
|
162 |
|
163 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId); |
|
164 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId, KErrNone, completeData); |
|
165 |
|
166 TInt location[3]; |
|
167 TBuf<RMobileONStore::KOwnNumberTextSize> name[3]; |
|
168 TBuf<KPBStoreNumSize> telNumber[3]; |
|
169 |
|
170 for (TInt i=0; i<size; i++) |
|
171 { |
|
172 TInt index = i+1; |
|
173 |
|
174 location[i] = index; |
|
175 name[i].Format(KText,index); |
|
176 telNumber[i].Format(KNumber,index); |
|
177 |
|
178 TMockLtsyData1<TInt> locationLTsyData(location[i]); |
|
179 expectReadData.Close(); |
|
180 locationLTsyData.SerialiseL(expectReadData); |
|
181 |
|
182 TMockLtsyData3< TInt, TBuf<RMobileONStore::KOwnNumberTextSize>, TBuf<KPBStoreNumSize> > readLTsyDataComplete(location[i], name[i], telNumber[i]); |
|
183 completeData.Close(); |
|
184 readLTsyDataComplete.SerialiseL(completeData); |
|
185 |
|
186 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, expectReadData); |
|
187 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, KErrNone, completeData); |
|
188 } |
|
189 |
|
190 CGetONListAO* getOnListAO = CGetONListAO::NewLC(aOnStore); |
|
191 |
|
192 getOnListAO->TestRetrieveL(); |
|
193 ASSERT_EQUALS(KErrNone, getOnListAO->RetrieveLastError()); |
|
194 |
|
195 CMobilePhoneONList* list = getOnListAO->RetrieveListL(); |
|
196 |
|
197 for (TInt j=0; j< size; j++) |
|
198 { |
|
199 RMobileONStore::TMobileONEntryV1 readEntry=list->GetEntryL(j); |
|
200 ASSERT_EQUALS(location[j], readEntry.iIndex); |
|
201 ASSERT_EQUALS(name[j], readEntry.iText); |
|
202 ASSERT_EQUALS(telNumber[j], readEntry.iNumber.iTelNumber); |
|
203 } |
|
204 |
|
205 AssertMockLtsyStatusL(); |
|
206 |
|
207 CActiveScheduler::Install(NULL); |
|
208 |
|
209 CleanupStack::PopAndDestroy(3, &completeData); // getOnListAO, expectReadData, completeData |
|
210 } |
|
211 |
|
212 |
|
213 |
|
214 // |
|
215 // Use-case tests |
|
216 // |
|
217 |
|
218 /** |
|
219 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UC0001 |
|
220 @SYMComponent telephony_ctsy |
|
221 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::GetInfo(), RMobileONStore::Write(), RMobileONStore::Read(), RMobileONStore::Delete() |
|
222 @SYMTestPriority High |
|
223 @SYMTestActions Invokes RMobileONStore::GetInfo(), RMobileONStore::Write(), RMobileONStore::Read(), RMobileONStore::Delete() |
|
224 @SYMTestExpectedResults Pass |
|
225 @SYMTestType CT |
|
226 */ |
|
227 void CCTsyPhonebookOnFU::TestUseCase0001L() |
|
228 { |
|
229 OpenEtelServerL(EUseExtendedError); |
|
230 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
231 OpenPhoneL(); |
|
232 |
|
233 RMobileONStore onStore; |
|
234 TInt ret = onStore.Open(iPhone); |
|
235 ASSERT_EQUALS(ret, KErrNone); |
|
236 CleanupClosePushL(onStore); |
|
237 |
|
238 RBuf8 expectData; |
|
239 CleanupClosePushL(expectData); |
|
240 |
|
241 RBuf8 completeData; |
|
242 CleanupClosePushL(completeData); |
|
243 |
|
244 TRequestStatus reqStatus; |
|
245 |
|
246 TRequestStatus notifyStatus; |
|
247 TUint32 notifyEvent; |
|
248 TInt notifyIndex; |
|
249 |
|
250 //------------------------------------------------------------------------- |
|
251 // TEST A: getinfo |
|
252 //------------------------------------------------------------------------- |
|
253 |
|
254 RMobileONStore::TMobileONStoreInfoV1 onStoreInfoV1; |
|
255 TPckg<RMobileONStore::TMobileONStoreInfoV1> pckgInfoV1(onStoreInfoV1); |
|
256 |
|
257 TInt numOfEntries = 0; |
|
258 TInt usedEntries = 0; |
|
259 TInt maxNameLen = 25; |
|
260 TInt maxNumLen = 20; |
|
261 |
|
262 TMockLtsyData4<TInt, TInt, TInt, TInt> onStoreInfoReturn(numOfEntries, usedEntries, maxNameLen, maxNumLen); |
|
263 completeData.Close(); |
|
264 onStoreInfoReturn.SerialiseL(completeData); |
|
265 |
|
266 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId); |
|
267 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrNone, completeData); |
|
268 |
|
269 onStore.GetInfo(reqStatus, pckgInfoV1); |
|
270 User::WaitForRequest(reqStatus); |
|
271 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
272 ASSERT_EQUALS(onStoreInfoV1.iTotalEntries, numOfEntries); |
|
273 ASSERT_EQUALS(onStoreInfoV1.iUsedEntries, usedEntries); |
|
274 ASSERT_EQUALS(onStoreInfoV1.iTextLen, maxNameLen); |
|
275 ASSERT_EQUALS(onStoreInfoV1.iNumberLen, maxNumLen); |
|
276 |
|
277 AssertMockLtsyStatusL(); |
|
278 |
|
279 //------------------------------------------------------------------------- |
|
280 // TEST B: write |
|
281 //------------------------------------------------------------------------- |
|
282 TInt location = 1; |
|
283 |
|
284 RMobileONStore::TMobileONEntryV1 writeEntry1; |
|
285 |
|
286 writeEntry1.iMode = RMobilePhone::ENetworkModeGsm; |
|
287 writeEntry1.iService = RMobilePhone::ETelephony; |
|
288 writeEntry1.iNumber.iTypeOfNumber = RMobilePhone::EAlphanumericNumber; |
|
289 writeEntry1.iNumber.iNumberPlan = RMobilePhone::EDataNumberPlan; |
|
290 writeEntry1.iNumber.iTelNumber.Copy(KNumber1); |
|
291 writeEntry1.iText.Copy(KText1); |
|
292 writeEntry1.iIndex = location; |
|
293 |
|
294 TPckg<RMobileONStore::TMobileONEntryV1> pckgWriteEntry1(writeEntry1); |
|
295 |
|
296 TMockLtsyData1<RMobileONStore::TMobileONEntryV1> writeLTsyData1(writeEntry1); |
|
297 expectData.Close(); |
|
298 writeLTsyData1.SerialiseL(expectData); |
|
299 |
|
300 TMockLtsyData1<TInt> writeLTsyDataComplete(location); |
|
301 completeData.Close(); |
|
302 writeLTsyDataComplete.SerialiseL(completeData); |
|
303 |
|
304 |
|
305 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, expectData); |
|
306 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, KErrNone, completeData); |
|
307 |
|
308 onStore.NotifyStoreEvent(notifyStatus, notifyEvent, notifyIndex); |
|
309 |
|
310 onStore.Write(reqStatus, pckgWriteEntry1); |
|
311 User::WaitForRequest(reqStatus); |
|
312 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
313 ASSERT_EQUALS(writeEntry1.iIndex, location); |
|
314 |
|
315 User::WaitForRequest(notifyStatus); |
|
316 TUint32 tempEventEntryAdded = RMobilePhoneStore::KStoreEntryAdded; |
|
317 ASSERT_EQUALS(notifyEvent, tempEventEntryAdded); |
|
318 ASSERT_EQUALS(notifyIndex, location); |
|
319 |
|
320 AssertMockLtsyStatusL(); |
|
321 |
|
322 //------------------------------------------------------------------------- |
|
323 // TEST C: read |
|
324 //------------------------------------------------------------------------- |
|
325 |
|
326 RMobileONStore::TMobileONEntryV1 readEntry; |
|
327 readEntry.iIndex = location; |
|
328 TPckg<RMobileONStore::TMobileONEntryV1> pckgReadEntry(readEntry); |
|
329 |
|
330 TBuf<RMobileONStore::KOwnNumberTextSize> name; |
|
331 name.Copy(KText1); |
|
332 TBuf<KPBStoreNumSize> telNumber; |
|
333 telNumber.Copy(KNumber1); |
|
334 |
|
335 TMockLtsyData1<TInt> readLTsyData(location); |
|
336 expectData.Close(); |
|
337 readLTsyData.SerialiseL(expectData); |
|
338 |
|
339 TMockLtsyData3< TInt, TBuf<RMobileONStore::KOwnNumberTextSize>, TBuf<KPBStoreNumSize> > readLTsyDataComplete(location, name, telNumber); |
|
340 completeData.Close(); |
|
341 readLTsyDataComplete.SerialiseL(completeData); |
|
342 |
|
343 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, expectData); |
|
344 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, KErrNone, completeData); |
|
345 |
|
346 onStore.Read(reqStatus, pckgReadEntry); |
|
347 User::WaitForRequest(reqStatus); |
|
348 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
349 ASSERT_EQUALS(location, readEntry.iIndex); |
|
350 ASSERT_EQUALS(name, readEntry.iText); |
|
351 ASSERT_EQUALS(telNumber, readEntry.iNumber.iTelNumber); |
|
352 |
|
353 AssertMockLtsyStatusL(); |
|
354 |
|
355 //------------------------------------------------------------------------- |
|
356 // TEST D: delete |
|
357 //------------------------------------------------------------------------- |
|
358 |
|
359 TMockLtsyData1<TInt> deleteLTsyData(location); |
|
360 expectData.Close(); |
|
361 deleteLTsyData.SerialiseL(expectData); |
|
362 |
|
363 |
|
364 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, expectData); |
|
365 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, KErrNone); |
|
366 |
|
367 onStore.NotifyStoreEvent(notifyStatus, notifyEvent, notifyIndex); |
|
368 |
|
369 onStore.Delete(reqStatus, location); |
|
370 User::WaitForRequest(reqStatus); |
|
371 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
372 |
|
373 User::WaitForRequest(notifyStatus); |
|
374 |
|
375 TUint32 tempEventEntryDeleted = RMobilePhoneStore::KStoreEntryDeleted; |
|
376 ASSERT_EQUALS(notifyEvent, tempEventEntryDeleted); |
|
377 ASSERT_EQUALS(notifyIndex, location); |
|
378 |
|
379 AssertMockLtsyStatusL(); |
|
380 |
|
381 CleanupStack::PopAndDestroy(4, this); // completeData, expectData, onStore, this |
|
382 } |
|
383 |
|
384 /** |
|
385 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UC0002 |
|
386 @SYMComponent telephony_ctsy |
|
387 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::GetInfo(), RMobileONStore::StoreAll, CRetrieveMobilePhoneONList::Start(), RMobileONStore::DeleteAll() |
|
388 @SYMTestPriority High |
|
389 @SYMTestActions Invokes RMobileONStore::GetInfo(), RMobileONStore::StoreAll, CRetrieveMobilePhoneONList::Start(), RMobileONStore::DeleteAll() |
|
390 @SYMTestExpectedResults Pass |
|
391 @SYMTestType CT |
|
392 */ |
|
393 void CCTsyPhonebookOnFU::TestUseCase0002L() |
|
394 { |
|
395 OpenEtelServerL(EUseExtendedError); |
|
396 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
397 OpenPhoneL(); |
|
398 |
|
399 RMobileONStore onStore; |
|
400 TInt ret = onStore.Open(iPhone); |
|
401 ASSERT_EQUALS(ret, KErrNone); |
|
402 CleanupClosePushL(onStore); |
|
403 |
|
404 RBuf8 completeData; |
|
405 CleanupClosePushL(completeData); |
|
406 |
|
407 TRequestStatus reqStatus; |
|
408 |
|
409 TRequestStatus notifyStatus; |
|
410 TUint32 notifyEvent; |
|
411 TInt notifyIndex; |
|
412 |
|
413 //------------------------------------------------------------------------- |
|
414 // TEST A: getinfo |
|
415 //------------------------------------------------------------------------- |
|
416 |
|
417 RMobileONStore::TMobileONStoreInfoV1 onStoreInfoV1; |
|
418 TPckg<RMobileONStore::TMobileONStoreInfoV1> pckgInfoV1(onStoreInfoV1); |
|
419 |
|
420 TInt numOfEntries = 3; |
|
421 TInt usedEntries = 3; |
|
422 TInt nameLen = 25; |
|
423 TInt numLen = 20; |
|
424 |
|
425 TMockLtsyData4<TInt, TInt, TInt, TInt> onStoreInfoReturn(numOfEntries, usedEntries, nameLen, numLen); |
|
426 completeData.Close(); |
|
427 onStoreInfoReturn.SerialiseL(completeData); |
|
428 |
|
429 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId); |
|
430 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrNone, completeData); |
|
431 |
|
432 onStore.GetInfo(reqStatus, pckgInfoV1); |
|
433 User::WaitForRequest(reqStatus); |
|
434 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
435 ASSERT_EQUALS(onStoreInfoV1.iTotalEntries, numOfEntries); |
|
436 ASSERT_EQUALS(onStoreInfoV1.iUsedEntries, usedEntries); |
|
437 ASSERT_EQUALS(onStoreInfoV1.iTextLen, nameLen); |
|
438 ASSERT_EQUALS(onStoreInfoV1.iNumberLen, numLen); |
|
439 |
|
440 AssertMockLtsyStatusL(); |
|
441 |
|
442 //------------------------------------------------------------------------- |
|
443 // TEST B: storeall |
|
444 //------------------------------------------------------------------------- |
|
445 StoreAllL(onStore); |
|
446 |
|
447 //------------------------------------------------------------------------- |
|
448 // TEST C: readall |
|
449 //------------------------------------------------------------------------- |
|
450 |
|
451 ReadAllL(onStore); |
|
452 |
|
453 //------------------------------------------------------------------------- |
|
454 // TEST D: deleteall |
|
455 //------------------------------------------------------------------------- |
|
456 |
|
457 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
458 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
459 |
|
460 onStore.NotifyStoreEvent(notifyStatus, notifyEvent, notifyIndex); |
|
461 |
|
462 onStore.DeleteAll(reqStatus); |
|
463 User::WaitForRequest(reqStatus); |
|
464 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
465 |
|
466 User::WaitForRequest(notifyStatus); |
|
467 |
|
468 TUint32 tempEventDeleteAll = RMobilePhoneStore::KStoreEmpty; |
|
469 ASSERT_EQUALS(notifyEvent, tempEventDeleteAll); |
|
470 |
|
471 AssertMockLtsyStatusL(); |
|
472 |
|
473 CleanupStack::PopAndDestroy(3, this); // completeData, onStore, this |
|
474 } |
|
475 |
|
476 |
|
477 // |
|
478 // Other unit tests |
|
479 // |
|
480 |
|
481 /** |
|
482 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0001 |
|
483 @SYMComponent telephony_ctsy |
|
484 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::GetInfo() |
|
485 @SYMTestPriority High |
|
486 @SYMTestActions Invokes RMobileONStore::GetInfo() |
|
487 @SYMTestExpectedResults Pass |
|
488 @SYMTestType UT |
|
489 */ |
|
490 void CCTsyPhonebookOnFU::TestUnit0001L() |
|
491 { |
|
492 OpenEtelServerL(EUseExtendedError); |
|
493 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
494 OpenPhoneL(); |
|
495 |
|
496 RMobileONStore onStore; |
|
497 TInt ret = onStore.Open(iPhone); |
|
498 ASSERT_EQUALS(ret, KErrNone); |
|
499 CleanupClosePushL(onStore); |
|
500 |
|
501 RBuf8 data; |
|
502 CleanupClosePushL(data); |
|
503 |
|
504 TRequestStatus reqStatus; |
|
505 |
|
506 RMobileONStore::TMobileONStoreInfoV1 onStoreInfoV1; |
|
507 TPckg<RMobileONStore::TMobileONStoreInfoV1> pckgInfoV1(onStoreInfoV1); |
|
508 |
|
509 TInt numOfEntries = 100; |
|
510 TInt usedEntries = 10; |
|
511 TInt maxNameLen = 25; |
|
512 TInt maxNumLen = 20; |
|
513 |
|
514 TMockLtsyData4<TInt, TInt, TInt, TInt> onStoreInfoReturn(numOfEntries, usedEntries, maxNameLen, maxNumLen); |
|
515 data.Close(); |
|
516 onStoreInfoReturn.SerialiseL(data); |
|
517 |
|
518 //------------------------------------------------------------------------- |
|
519 // TEST A: failure to dispatch request to LTSY |
|
520 //------------------------------------------------------------------------- |
|
521 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrNotSupported); |
|
522 |
|
523 onStore.GetInfo(reqStatus, pckgInfoV1); |
|
524 |
|
525 User::WaitForRequest(reqStatus); |
|
526 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
527 |
|
528 AssertMockLtsyStatusL(); |
|
529 |
|
530 //------------------------------------------------------------------------- |
|
531 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
532 //------------------------------------------------------------------------- |
|
533 |
|
534 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId); |
|
535 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrGeneral, data); |
|
536 |
|
537 onStore.GetInfo(reqStatus, pckgInfoV1); |
|
538 |
|
539 User::WaitForRequest(reqStatus); |
|
540 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
541 |
|
542 AssertMockLtsyStatusL(); |
|
543 |
|
544 //------------------------------------------------------------------------- |
|
545 // TEST C: Successful completion request of |
|
546 // RMobileONStore::GetInfo when result is not cached. |
|
547 //------------------------------------------------------------------------- |
|
548 |
|
549 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId); |
|
550 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrNone, data); |
|
551 |
|
552 onStore.GetInfo(reqStatus, pckgInfoV1); |
|
553 User::WaitForRequest(reqStatus); |
|
554 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
555 ASSERT_EQUALS(onStoreInfoV1.iTotalEntries, numOfEntries); |
|
556 ASSERT_EQUALS(onStoreInfoV1.iUsedEntries, usedEntries); |
|
557 ASSERT_EQUALS(onStoreInfoV1.iTextLen, maxNameLen); |
|
558 ASSERT_EQUALS(onStoreInfoV1.iNumberLen, maxNumLen); |
|
559 |
|
560 AssertMockLtsyStatusL(); |
|
561 |
|
562 //------------------------------------------------------------------------- |
|
563 // TEST D: Unsolicited completion of RMobileONStore::GetInfo |
|
564 // from LTSY. |
|
565 //------------------------------------------------------------------------- |
|
566 |
|
567 TRequestStatus mockLtsyStatus; |
|
568 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
569 |
|
570 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetInfo::KLtsyDispatchPhonebookOnStoreGetInfoApiId, KErrNone, data); |
|
571 |
|
572 User::WaitForRequest(mockLtsyStatus); |
|
573 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
574 AssertMockLtsyStatusL(); |
|
575 |
|
576 CleanupStack::PopAndDestroy(3, this); // data, onStore, this |
|
577 |
|
578 } |
|
579 |
|
580 /** |
|
581 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0002 |
|
582 @SYMComponent telephony_ctsy |
|
583 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::Write() |
|
584 @SYMTestPriority High |
|
585 @SYMTestActions Invokes RMobileONStore::Write() |
|
586 @SYMTestExpectedResults Pass |
|
587 @SYMTestType UT |
|
588 */ |
|
589 void CCTsyPhonebookOnFU::TestUnit0002L() |
|
590 { |
|
591 OpenEtelServerL(EUseExtendedError); |
|
592 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
593 OpenPhoneL(); |
|
594 |
|
595 RMobileONStore onStore; |
|
596 TInt ret = onStore.Open(iPhone); |
|
597 ASSERT_EQUALS(ret, KErrNone); |
|
598 CleanupClosePushL(onStore); |
|
599 |
|
600 RBuf8 expectData; |
|
601 CleanupClosePushL(expectData); |
|
602 |
|
603 RBuf8 completeData; |
|
604 CleanupClosePushL(completeData); |
|
605 |
|
606 TRequestStatus reqStatus; |
|
607 |
|
608 TInt location = 10; |
|
609 |
|
610 RMobileONStore::TMobileONEntryV1 writeEntry1; |
|
611 |
|
612 writeEntry1.iMode = RMobilePhone::ENetworkModeGsm; |
|
613 writeEntry1.iService = RMobilePhone::ETelephony; |
|
614 writeEntry1.iNumber.iTypeOfNumber = RMobilePhone::EAlphanumericNumber; |
|
615 writeEntry1.iNumber.iNumberPlan = RMobilePhone::EDataNumberPlan; |
|
616 writeEntry1.iNumber.iTelNumber.Format(KNumber,111); |
|
617 writeEntry1.iText.Format(KText,111); |
|
618 writeEntry1.iIndex = location; |
|
619 |
|
620 TPckg<RMobileONStore::TMobileONEntryV1> pckgWriteEntry1(writeEntry1); |
|
621 |
|
622 TMockLtsyData1<RMobileONStore::TMobileONEntryV1> writeLTsyData1(writeEntry1); |
|
623 expectData.Close(); |
|
624 writeLTsyData1.SerialiseL(expectData); |
|
625 |
|
626 TMockLtsyData1<TInt> writeLTsyDataComplete(location); |
|
627 completeData.Close(); |
|
628 writeLTsyDataComplete.SerialiseL(completeData); |
|
629 |
|
630 //------------------------------------------------------------------------- |
|
631 // TEST A: failure to dispatch request to LTSY |
|
632 //------------------------------------------------------------------------- |
|
633 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, expectData, KErrNotSupported); |
|
634 |
|
635 onStore.Write(reqStatus, pckgWriteEntry1); |
|
636 User::WaitForRequest(reqStatus); |
|
637 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
638 |
|
639 AssertMockLtsyStatusL(); |
|
640 |
|
641 //------------------------------------------------------------------------- |
|
642 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
643 //------------------------------------------------------------------------- |
|
644 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, expectData); |
|
645 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, KErrGeneral, completeData); |
|
646 |
|
647 onStore.Write(reqStatus, pckgWriteEntry1); |
|
648 |
|
649 User::WaitForRequest(reqStatus); |
|
650 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
651 |
|
652 AssertMockLtsyStatusL(); |
|
653 |
|
654 //------------------------------------------------------------------------- |
|
655 // TEST C: Successful completion request of |
|
656 // RMobileONStore::Write when result is not cached. |
|
657 //------------------------------------------------------------------------- |
|
658 |
|
659 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, expectData); |
|
660 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, KErrNone, completeData); |
|
661 |
|
662 onStore.Write(reqStatus, pckgWriteEntry1); |
|
663 User::WaitForRequest(reqStatus); |
|
664 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
665 ASSERT_EQUALS(writeEntry1.iIndex, location); |
|
666 |
|
667 AssertMockLtsyStatusL(); |
|
668 |
|
669 //------------------------------------------------------------------------- |
|
670 // TEST D: Unsolicited completion of RMobileONStore::Write |
|
671 // from LTSY. |
|
672 //------------------------------------------------------------------------- |
|
673 |
|
674 TRequestStatus mockLtsyStatus; |
|
675 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
676 |
|
677 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, KErrNone, completeData); |
|
678 |
|
679 User::WaitForRequest(mockLtsyStatus); |
|
680 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
681 AssertMockLtsyStatusL(); |
|
682 |
|
683 //------------------------------------------------------------------------- |
|
684 // TEST E: additional test with index = -1 |
|
685 //------------------------------------------------------------------------- |
|
686 |
|
687 RMobileONStore::TMobileONEntryV1 writeEntry2; |
|
688 TPckg<RMobileONStore::TMobileONEntryV1> pckgWriteEntry2(writeEntry2); |
|
689 |
|
690 writeEntry2.iMode = RMobilePhone::ENetworkModeGsm; |
|
691 writeEntry2.iService = RMobilePhone::ETelephony; |
|
692 writeEntry2.iNumber.iTypeOfNumber = RMobilePhone::EAlphanumericNumber; |
|
693 writeEntry2.iNumber.iNumberPlan = RMobilePhone::EDataNumberPlan; |
|
694 writeEntry2.iNumber.iTelNumber.Format(KNumber,123); |
|
695 writeEntry2.iText.Format(KText,123); |
|
696 writeEntry2.iIndex = -1; |
|
697 |
|
698 TMockLtsyData1<RMobileONStore::TMobileONEntryV1> writeLTsyData2(writeEntry2); |
|
699 expectData.Close(); |
|
700 writeLTsyData2.SerialiseL(expectData); |
|
701 |
|
702 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, expectData); |
|
703 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWrite::KLtsyDispatchPhonebookOnStoreWriteApiId, KErrNone, completeData); |
|
704 |
|
705 onStore.Write(reqStatus, pckgWriteEntry2); |
|
706 User::WaitForRequest(reqStatus); |
|
707 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
708 ASSERT_EQUALS(writeEntry2.iIndex, location); |
|
709 |
|
710 AssertMockLtsyStatusL(); |
|
711 |
|
712 CleanupStack::PopAndDestroy(4, this); // completeData, expectData, onStore, this |
|
713 |
|
714 } |
|
715 |
|
716 /** |
|
717 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0003 |
|
718 @SYMComponent telephony_ctsy |
|
719 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::Read() |
|
720 @SYMTestPriority High |
|
721 @SYMTestActions Invokes RMobileONStore::Read() |
|
722 @SYMTestExpectedResults Pass |
|
723 @SYMTestType UT |
|
724 */ |
|
725 void CCTsyPhonebookOnFU::TestUnit0003L() |
|
726 { |
|
727 OpenEtelServerL(EUseExtendedError); |
|
728 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
729 OpenPhoneL(); |
|
730 |
|
731 RMobileONStore onStore; |
|
732 TInt ret = onStore.Open(iPhone); |
|
733 ASSERT_EQUALS(ret, KErrNone); |
|
734 CleanupClosePushL(onStore); |
|
735 |
|
736 RBuf8 expectData; |
|
737 CleanupClosePushL(expectData); |
|
738 |
|
739 RBuf8 completeData; |
|
740 CleanupClosePushL(completeData); |
|
741 |
|
742 TRequestStatus reqStatus; |
|
743 |
|
744 TInt location = 10; |
|
745 |
|
746 RMobileONStore::TMobileONEntryV1 readEntry; |
|
747 readEntry.iIndex = location; |
|
748 TPckg<RMobileONStore::TMobileONEntryV1> pckgReadEntry(readEntry); |
|
749 |
|
750 _LIT(KName, "My number"); |
|
751 _LIT(KTelNumber, "1234567"); |
|
752 |
|
753 TBuf<RMobileONStore::KOwnNumberTextSize> name; |
|
754 name.Copy(KName); |
|
755 TBuf<KPBStoreNumSize> telNumber; |
|
756 telNumber.Copy(KTelNumber); |
|
757 |
|
758 |
|
759 TMockLtsyData1<TInt> readLTsyData(location); |
|
760 expectData.Close(); |
|
761 readLTsyData.SerialiseL(expectData); |
|
762 |
|
763 TMockLtsyData3< TInt, TBuf<RMobileONStore::KOwnNumberTextSize>, TBuf<KPBStoreNumSize> > readLTsyDataComplete(location, name, telNumber); |
|
764 completeData.Close(); |
|
765 readLTsyDataComplete.SerialiseL(completeData); |
|
766 |
|
767 //------------------------------------------------------------------------- |
|
768 // TEST A: failure to dispatch request to LTSY |
|
769 //------------------------------------------------------------------------- |
|
770 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, expectData, KErrNotSupported); |
|
771 |
|
772 onStore.Read(reqStatus, pckgReadEntry); |
|
773 User::WaitForRequest(reqStatus); |
|
774 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
775 |
|
776 AssertMockLtsyStatusL(); |
|
777 |
|
778 //------------------------------------------------------------------------- |
|
779 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
780 //------------------------------------------------------------------------- |
|
781 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, expectData); |
|
782 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, KErrGeneral, completeData); |
|
783 |
|
784 onStore.Read(reqStatus, pckgReadEntry); |
|
785 |
|
786 User::WaitForRequest(reqStatus); |
|
787 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
788 |
|
789 AssertMockLtsyStatusL(); |
|
790 |
|
791 //------------------------------------------------------------------------- |
|
792 // TEST C: Successful completion request of |
|
793 // RMobileONStore::Read when result is not cached. |
|
794 //------------------------------------------------------------------------- |
|
795 |
|
796 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, expectData); |
|
797 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, KErrNone, completeData); |
|
798 |
|
799 onStore.Read(reqStatus, pckgReadEntry); |
|
800 User::WaitForRequest(reqStatus); |
|
801 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
802 ASSERT_EQUALS(location, readEntry.iIndex); |
|
803 ASSERT_EQUALS(name, readEntry.iText); |
|
804 ASSERT_EQUALS(telNumber, readEntry.iNumber.iTelNumber); |
|
805 |
|
806 AssertMockLtsyStatusL(); |
|
807 |
|
808 //------------------------------------------------------------------------- |
|
809 // TEST D: Unsolicited completion of RMobileONStore::Read |
|
810 // from LTSY. |
|
811 //------------------------------------------------------------------------- |
|
812 |
|
813 TRequestStatus mockLtsyStatus; |
|
814 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
815 |
|
816 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreRead::KLtsyDispatchPhonebookOnStoreReadApiId, KErrNone, completeData); |
|
817 |
|
818 User::WaitForRequest(mockLtsyStatus); |
|
819 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
820 AssertMockLtsyStatusL(); |
|
821 |
|
822 CleanupStack::PopAndDestroy(4, this); // completeData, expectData, onStore, this |
|
823 |
|
824 } |
|
825 |
|
826 /** |
|
827 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0004 |
|
828 @SYMComponent telephony_ctsy |
|
829 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::Delete() |
|
830 @SYMTestPriority High |
|
831 @SYMTestActions Invokes RMobileONStore::Delete() |
|
832 @SYMTestExpectedResults Pass |
|
833 @SYMTestType UT |
|
834 */ |
|
835 void CCTsyPhonebookOnFU::TestUnit0004L() |
|
836 { |
|
837 OpenEtelServerL(EUseExtendedError); |
|
838 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
839 OpenPhoneL(); |
|
840 |
|
841 RMobileONStore onStore; |
|
842 TInt ret = onStore.Open(iPhone); |
|
843 ASSERT_EQUALS(ret, KErrNone); |
|
844 CleanupClosePushL(onStore); |
|
845 |
|
846 RBuf8 expectData; |
|
847 CleanupClosePushL(expectData); |
|
848 |
|
849 TRequestStatus reqStatus; |
|
850 |
|
851 TInt index = 10; |
|
852 TMockLtsyData1<TInt> deleteLTsyData(index); |
|
853 expectData.Close(); |
|
854 deleteLTsyData.SerialiseL(expectData); |
|
855 |
|
856 //------------------------------------------------------------------------- |
|
857 // TEST A: failure to dispatch request to LTSY |
|
858 //------------------------------------------------------------------------- |
|
859 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, expectData, KErrNotSupported); |
|
860 |
|
861 onStore.Delete(reqStatus, index); |
|
862 User::WaitForRequest(reqStatus); |
|
863 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
864 |
|
865 AssertMockLtsyStatusL(); |
|
866 |
|
867 //------------------------------------------------------------------------- |
|
868 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
869 //------------------------------------------------------------------------- |
|
870 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, expectData); |
|
871 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, KErrGeneral); |
|
872 |
|
873 onStore.Delete(reqStatus, index); |
|
874 User::WaitForRequest(reqStatus); |
|
875 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
876 |
|
877 AssertMockLtsyStatusL(); |
|
878 |
|
879 //------------------------------------------------------------------------- |
|
880 // TEST C: Successful completion request of |
|
881 // RMobileONStore::Delete when result is not cached. |
|
882 //------------------------------------------------------------------------- |
|
883 |
|
884 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, expectData); |
|
885 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, KErrNone); |
|
886 |
|
887 onStore.Delete(reqStatus, index); |
|
888 User::WaitForRequest(reqStatus); |
|
889 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
890 AssertMockLtsyStatusL(); |
|
891 |
|
892 //------------------------------------------------------------------------- |
|
893 // TEST D: Unsolicited completion of RMobileONStore::Delete |
|
894 // from LTSY. |
|
895 //------------------------------------------------------------------------- |
|
896 |
|
897 TRequestStatus mockLtsyStatus; |
|
898 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
899 |
|
900 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteEntry::KLtsyDispatchPhonebookOnStoreDeleteEntryApiId, KErrNone); |
|
901 |
|
902 User::WaitForRequest(mockLtsyStatus); |
|
903 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
904 AssertMockLtsyStatusL(); |
|
905 |
|
906 CleanupStack::PopAndDestroy(3, this); // expectData, onStore, this |
|
907 |
|
908 } |
|
909 |
|
910 /** |
|
911 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0005 |
|
912 @SYMComponent telephony_ctsy |
|
913 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::StoreAllL() |
|
914 @SYMTestPriority High |
|
915 @SYMTestActions Invokes RMobileONStore::StoreAllL() |
|
916 @SYMTestExpectedResults Pass |
|
917 @SYMTestType UT |
|
918 */ |
|
919 void CCTsyPhonebookOnFU::TestUnit0005L() |
|
920 { |
|
921 OpenEtelServerL(EUseExtendedError); |
|
922 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
923 OpenPhoneL(); |
|
924 |
|
925 RMobileONStore onStore; |
|
926 TInt ret = onStore.Open(iPhone); |
|
927 ASSERT_EQUALS(ret, KErrNone); |
|
928 CleanupClosePushL(onStore); |
|
929 |
|
930 RBuf8 expectEntryData1; |
|
931 CleanupClosePushL(expectEntryData1); |
|
932 |
|
933 RBuf8 completeData; |
|
934 CleanupClosePushL(completeData); |
|
935 |
|
936 TRequestStatus reqStatus; |
|
937 |
|
938 CMobilePhoneONList* onList = CMobilePhoneONList::NewL(); |
|
939 CleanupStack::PushL(onList); |
|
940 |
|
941 GenerateONList3L(onList); |
|
942 TInt size=onList->Enumerate(); |
|
943 RMobileONStore::TMobileONEntryV1 entry = onList->GetEntryL(0); |
|
944 |
|
945 TMockLtsyData1<RMobileONStore::TMobileONEntryV1> entryLTsyData1(entry); |
|
946 expectEntryData1.Close(); |
|
947 entryLTsyData1.SerialiseL(expectEntryData1); |
|
948 |
|
949 TMockLtsyData1<TInt> sizeLTsyData(size); |
|
950 completeData.Close(); |
|
951 sizeLTsyData.SerialiseL(completeData); |
|
952 |
|
953 //------------------------------------------------------------------------- |
|
954 // TEST A: failure to dispatch request to LTSY |
|
955 //------------------------------------------------------------------------- |
|
956 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
957 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
958 |
|
959 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrNotSupported); |
|
960 |
|
961 onStore.StoreAllL(reqStatus, onList); |
|
962 User::WaitForRequest(reqStatus); |
|
963 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
964 |
|
965 //second step test |
|
966 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
967 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
968 |
|
969 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId); |
|
970 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrNone, completeData); |
|
971 |
|
972 //write1 |
|
973 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, expectEntryData1, KErrNotSupported); |
|
974 |
|
975 onStore.StoreAllL(reqStatus, onList); |
|
976 User::WaitForRequest(reqStatus); |
|
977 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
978 |
|
979 AssertMockLtsyStatusL(); |
|
980 |
|
981 //------------------------------------------------------------------------- |
|
982 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
983 //------------------------------------------------------------------------- |
|
984 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
985 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
986 |
|
987 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId); |
|
988 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrGeneral, completeData); |
|
989 |
|
990 onStore.StoreAllL(reqStatus, onList); |
|
991 |
|
992 User::WaitForRequest(reqStatus); |
|
993 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
994 |
|
995 //second step test |
|
996 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
997 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
998 |
|
999 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId); |
|
1000 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrNone, completeData); |
|
1001 |
|
1002 //write1 |
|
1003 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, expectEntryData1); |
|
1004 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, KErrGeneral); |
|
1005 |
|
1006 onStore.StoreAllL(reqStatus, onList); |
|
1007 |
|
1008 User::WaitForRequest(reqStatus); |
|
1009 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
1010 |
|
1011 AssertMockLtsyStatusL(); |
|
1012 |
|
1013 //------------------------------------------------------------------------- |
|
1014 // TEST C: Successful completion request of |
|
1015 // RMobileONStore::StoreAllL when result is not cached. |
|
1016 //------------------------------------------------------------------------- |
|
1017 |
|
1018 StoreAllL(onStore); |
|
1019 |
|
1020 //------------------------------------------------------------------------- |
|
1021 // TEST D: Unsolicited completion of RMobileONStore::StoreAllL |
|
1022 // from LTSY. |
|
1023 //------------------------------------------------------------------------- |
|
1024 |
|
1025 TRequestStatus mockLtsyStatus; |
|
1026 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
1027 |
|
1028 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetStoreSize::KLtsyDispatchPhonebookOnStoreGetStoreSizeApiId, KErrNone, completeData); |
|
1029 |
|
1030 User::WaitForRequest(mockLtsyStatus); |
|
1031 |
|
1032 //second step test |
|
1033 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
1034 |
|
1035 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreWriteEntry::KLtsyDispatchPhonebookOnStoreWriteEntryApiId, KErrNone); |
|
1036 |
|
1037 User::WaitForRequest(mockLtsyStatus); |
|
1038 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
1039 AssertMockLtsyStatusL(); |
|
1040 |
|
1041 CleanupStack::PopAndDestroy(5, this); // onList, completeData, expectEntryData1, onStore, this |
|
1042 |
|
1043 } |
|
1044 |
|
1045 /** |
|
1046 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0006 |
|
1047 @SYMComponent telephony_ctsy |
|
1048 @SYMTestCaseDesc Test support in CTSY for RMobileONStore::DeleteAll() |
|
1049 @SYMTestPriority High |
|
1050 @SYMTestActions Invokes RMobileONStore::DeleteAll() |
|
1051 @SYMTestExpectedResults Pass |
|
1052 @SYMTestType UT |
|
1053 */ |
|
1054 void CCTsyPhonebookOnFU::TestUnit0006L() |
|
1055 { |
|
1056 OpenEtelServerL(EUseExtendedError); |
|
1057 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
1058 OpenPhoneL(); |
|
1059 |
|
1060 RMobileONStore onStore; |
|
1061 TInt ret = onStore.Open(iPhone); |
|
1062 ASSERT_EQUALS(ret, KErrNone); |
|
1063 CleanupClosePushL(onStore); |
|
1064 |
|
1065 TRequestStatus reqStatus; |
|
1066 |
|
1067 //------------------------------------------------------------------------- |
|
1068 // TEST A: failure to dispatch request to LTSY |
|
1069 //------------------------------------------------------------------------- |
|
1070 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNotSupported); |
|
1071 |
|
1072 onStore.DeleteAll(reqStatus); |
|
1073 |
|
1074 User::WaitForRequest(reqStatus); |
|
1075 ASSERT_EQUALS(KErrNotSupported, reqStatus.Int()); |
|
1076 |
|
1077 AssertMockLtsyStatusL(); |
|
1078 |
|
1079 //------------------------------------------------------------------------- |
|
1080 // TEST B: failure on completion of pending request from LTSY->CTSY |
|
1081 //------------------------------------------------------------------------- |
|
1082 |
|
1083 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
1084 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrGeneral); |
|
1085 |
|
1086 onStore.DeleteAll(reqStatus); |
|
1087 |
|
1088 User::WaitForRequest(reqStatus); |
|
1089 ASSERT_EQUALS(KErrGeneral, reqStatus.Int()); |
|
1090 |
|
1091 AssertMockLtsyStatusL(); |
|
1092 |
|
1093 //------------------------------------------------------------------------- |
|
1094 // TEST C: Successful completion request of |
|
1095 // RMobileONStore::DeleteAll when result is not cached. |
|
1096 //------------------------------------------------------------------------- |
|
1097 |
|
1098 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId); |
|
1099 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
1100 |
|
1101 onStore.DeleteAll(reqStatus); |
|
1102 |
|
1103 User::WaitForRequest(reqStatus); |
|
1104 ASSERT_EQUALS(reqStatus.Int(), KErrNone); |
|
1105 |
|
1106 AssertMockLtsyStatusL(); |
|
1107 |
|
1108 //------------------------------------------------------------------------- |
|
1109 // TEST D: Unsolicited completion of RMobileONStore::DeleteAll |
|
1110 // from LTSY. |
|
1111 //------------------------------------------------------------------------- |
|
1112 |
|
1113 TRequestStatus mockLtsyStatus; |
|
1114 iMockLTSY.NotifyTerminated(mockLtsyStatus); |
|
1115 |
|
1116 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreDeleteAll::KLtsyDispatchPhonebookOnStoreDeleteAllApiId, KErrNone); |
|
1117 |
|
1118 User::WaitForRequest(mockLtsyStatus); |
|
1119 ASSERT_EQUALS(KErrNone, mockLtsyStatus.Int()); |
|
1120 AssertMockLtsyStatusL(); |
|
1121 |
|
1122 CleanupStack::PopAndDestroy(2, this); // onStore, this |
|
1123 |
|
1124 } |
|
1125 |
|
1126 /** |
|
1127 @SYMTestCaseID BA-CTSYD-DIS-PHONEBOOKON-UN0007 |
|
1128 @SYMComponent telephony_ctsy |
|
1129 @SYMTestCaseDesc Test support in CTSY for CRetrieveMobilePhoneONList::Start() |
|
1130 @SYMTestPriority High |
|
1131 @SYMTestActions Invokes CRetrieveMobilePhoneONList::Start() |
|
1132 @SYMTestExpectedResults Pass |
|
1133 @SYMTestType UT |
|
1134 */ |
|
1135 void CCTsyPhonebookOnFU::TestUnit0007L() |
|
1136 { |
|
1137 |
|
1138 OpenEtelServerL(EUseExtendedError); |
|
1139 CleanupStack::PushL(TCleanupItem(Cleanup,this)); |
|
1140 OpenPhoneL(); |
|
1141 |
|
1142 RMobileONStore onStore; |
|
1143 TInt err = onStore.Open(iPhone); |
|
1144 ASSERT_EQUALS(KErrNone, err); |
|
1145 CleanupClosePushL(onStore); |
|
1146 |
|
1147 RBuf8 expectData; |
|
1148 CleanupClosePushL(expectData); |
|
1149 |
|
1150 RBuf8 completeData; |
|
1151 CleanupClosePushL(completeData); |
|
1152 |
|
1153 RBuf8 completeEntryData1; |
|
1154 CleanupClosePushL(completeEntryData1); |
|
1155 |
|
1156 TInt size = 3; |
|
1157 TMockLtsyData1<TInt> sizeLTsyData(size); |
|
1158 completeData.Close(); |
|
1159 sizeLTsyData.SerialiseL(completeData); |
|
1160 |
|
1161 TInt location; |
|
1162 TBuf<RMobileONStore::KOwnNumberTextSize> name; |
|
1163 TBuf<KPBStoreNumSize> telNumber; |
|
1164 |
|
1165 location = 1; |
|
1166 name.Copy(KText1); |
|
1167 telNumber.Copy(KNumber1); |
|
1168 |
|
1169 TMockLtsyData1<TInt> locationLTsyData1(location); |
|
1170 expectData.Close(); |
|
1171 locationLTsyData1.SerialiseL(expectData); |
|
1172 |
|
1173 TMockLtsyData3< TInt, TBuf<RMobileONStore::KOwnNumberTextSize>, TBuf<KPBStoreNumSize> > readLTsyDataComplete1(location, name, telNumber); |
|
1174 completeEntryData1.Close(); |
|
1175 readLTsyDataComplete1.SerialiseL(completeEntryData1); |
|
1176 |
|
1177 CGetONListAO* getOnListAO = CGetONListAO::NewLC(onStore); |
|
1178 |
|
1179 //------------------------------------------------------------------------- |
|
1180 // TEST A: failure to dispatch request to LTSY |
|
1181 //------------------------------------------------------------------------- |
|
1182 |
|
1183 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId, KErrNotSupported); |
|
1184 |
|
1185 getOnListAO->TestRetrieveL(); |
|
1186 ASSERT_EQUALS(KErrNotSupported, getOnListAO->RetrieveLastError()); |
|
1187 |
|
1188 |
|
1189 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId); |
|
1190 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId, KErrNone, completeData); |
|
1191 |
|
1192 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, expectData, KErrNotSupported); |
|
1193 |
|
1194 getOnListAO->TestRetrieveL(); |
|
1195 ASSERT_EQUALS(KErrNotSupported, getOnListAO->RetrieveLastError()); |
|
1196 |
|
1197 //------------------------------------------------------------------------- |
|
1198 // TEST B2: failure on completion of pending request from LTSY->CTSY |
|
1199 //------------------------------------------------------------------------- |
|
1200 |
|
1201 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId); |
|
1202 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId, KErrGeneral, completeData); |
|
1203 |
|
1204 getOnListAO->TestRetrieveL(); |
|
1205 ASSERT_EQUALS(KErrGeneral, getOnListAO->RetrieveLastError()); |
|
1206 |
|
1207 |
|
1208 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId); |
|
1209 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreGetReadStoreSize::KLtsyDispatchPhonebookOnStoreGetReadStoreSizeApiId, KErrNone, completeData); |
|
1210 |
|
1211 iMockLTSY.ExpectL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, expectData); |
|
1212 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, KErrGeneral, completeEntryData1); |
|
1213 |
|
1214 getOnListAO->TestRetrieveL(); |
|
1215 ASSERT_EQUALS(KErrGeneral, getOnListAO->RetrieveLastError()); |
|
1216 CleanupStack::PopAndDestroy(1, getOnListAO); |
|
1217 |
|
1218 //------------------------------------------------------------------------- |
|
1219 // TEST C: Successful completion request of |
|
1220 // CRetrieveMobilePhoneONList::Start when result is not cached. |
|
1221 //------------------------------------------------------------------------- |
|
1222 |
|
1223 ReadAllL(onStore); |
|
1224 |
|
1225 //------------------------------------------------------------------------- |
|
1226 // TEST E: Unsolicited completion of CAsyncRetrieveStoreList::Start |
|
1227 // from LTSY. |
|
1228 //------------------------------------------------------------------------- |
|
1229 |
|
1230 TRequestStatus requestStatus; |
|
1231 |
|
1232 iMockLTSY.NotifyTerminated(requestStatus); |
|
1233 |
|
1234 iMockLTSY.CompleteL(MLtsyDispatchPhonebookOnStoreReadEntry::KLtsyDispatchPhonebookOnStoreReadEntryApiId, KErrNone, completeEntryData1); |
|
1235 |
|
1236 User::WaitForRequest(requestStatus); |
|
1237 |
|
1238 ASSERT_EQUALS(KErrNone, requestStatus.Int()); |
|
1239 AssertMockLtsyStatusL(); |
|
1240 |
|
1241 CleanupStack::PopAndDestroy(5, this); // completeEntryData1, completeData, expectData, |
|
1242 // onStore, this |
|
1243 |
|
1244 } |
|
1245 |