24
|
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 <e32test.h>
|
|
17 |
|
|
18 |
#include "TE_EtelMMTestStepBase.h"
|
|
19 |
#include "TE_mmnamstore.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestNamStore::CTestNamStore()
|
|
23 |
/** Each test step initialises it's own name
|
|
24 |
*/
|
|
25 |
{
|
|
26 |
// store the name of this test case
|
|
27 |
// this is the name that is used by the script file
|
|
28 |
SetTestStepName(_L("TestNamStore"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestNamStore::doTestStepL()
|
|
32 |
{
|
|
33 |
//
|
|
34 |
// Test Nam Storage Functions
|
|
35 |
//
|
|
36 |
iTestCount=1;
|
|
37 |
INFO_PRINTF1(_L(""));
|
|
38 |
INFO_PRINTF1(_L("Test Mobile NAM Storage Functionality"));
|
|
39 |
// LOGTEXT(_L8("Test Mobile NAM Storage Functionality"));
|
|
40 |
|
|
41 |
RMobilePhone mmPhone;
|
|
42 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
43 |
TEST(ret==KErrNone);
|
|
44 |
|
|
45 |
RMobileNamStore namStore;
|
|
46 |
ret=namStore.Open(mmPhone);
|
|
47 |
TEST(ret==KErrNone);
|
|
48 |
|
|
49 |
TRequestStatus reqStatus;
|
|
50 |
|
|
51 |
|
|
52 |
// Get NAM store information
|
|
53 |
|
|
54 |
// asynchronous
|
|
55 |
|
|
56 |
RMobileNamStore::TMobileNamStoreInfoV1 asyncInfo;
|
|
57 |
RMobileNamStore::TMobileNamStoreInfoV1Pckg asyncInfoPckg(asyncInfo);
|
|
58 |
namStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
59 |
User::WaitForRequest(reqStatus);
|
|
60 |
TEST(reqStatus.Int()==KErrNone);
|
|
61 |
ValidateNamInfo(asyncInfo);
|
|
62 |
|
|
63 |
// asynchronous & cancel
|
|
64 |
|
|
65 |
namStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
66 |
namStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
|
|
67 |
User::WaitForRequest(reqStatus);
|
|
68 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
69 |
if (reqStatus.Int()==KErrCancel)
|
|
70 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::GetInfo (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
71 |
else
|
|
72 |
{
|
|
73 |
ValidateNamInfo(asyncInfo);
|
|
74 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::GetInfo (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
75 |
}
|
|
76 |
|
|
77 |
// test.Next(_L("OK: RMobileNamStore's Get Info"));
|
|
78 |
|
|
79 |
// Read one entry
|
|
80 |
|
|
81 |
RMobileNamStore::TMobileNamEntryV1 asyncEntry1;
|
|
82 |
|
|
83 |
// asynchronous
|
|
84 |
|
|
85 |
asyncEntry1.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
86 |
RMobileNamStore::TMobileNamEntryV1Pckg asyncEntry1Pckg(asyncEntry1);
|
|
87 |
|
|
88 |
namStore.Read(reqStatus,asyncEntry1Pckg);
|
|
89 |
User::WaitForRequest(reqStatus);
|
|
90 |
TEST(reqStatus.Int()==KErrNone);
|
|
91 |
|
|
92 |
ValidateNamRead(asyncEntry1);
|
|
93 |
|
|
94 |
|
|
95 |
// cancel
|
|
96 |
|
|
97 |
asyncEntry1.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
98 |
namStore.Read(reqStatus, asyncEntry1Pckg);
|
|
99 |
namStore.CancelAsyncRequest(EMobilePhoneStoreRead);
|
|
100 |
User::WaitForRequest(reqStatus);
|
|
101 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
102 |
if (reqStatus.Int()==KErrCancel)
|
|
103 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Read (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
104 |
else
|
|
105 |
{
|
|
106 |
ValidateNamRead(asyncEntry1);
|
|
107 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Read (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
108 |
}
|
|
109 |
|
|
110 |
// test.Next(_L("OK: RMobileNamStore's Read Entry"));
|
|
111 |
|
|
112 |
// Write one entry
|
|
113 |
|
|
114 |
RMobileNamStore::TMobileNamEntryV1 entry2;
|
|
115 |
RMobileNamStore::TMobileNamEntryV1Pckg entry2Pckg(entry2);
|
|
116 |
|
|
117 |
InitNamEntry(entry2);
|
|
118 |
|
|
119 |
// asynchronous
|
|
120 |
|
|
121 |
entry2.iIndex=DMMTSY_NAM_STORE_INDEX2;
|
|
122 |
namStore.Write(reqStatus, entry2Pckg);
|
|
123 |
User::WaitForRequest(reqStatus);
|
|
124 |
TEST(reqStatus.Int()==KErrNone);
|
|
125 |
|
|
126 |
// aynchronous & cancel
|
|
127 |
|
|
128 |
namStore.Write(reqStatus, entry2Pckg);
|
|
129 |
namStore.CancelAsyncRequest(EMobilePhoneStoreWrite);
|
|
130 |
User::WaitForRequest(reqStatus);
|
|
131 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
132 |
|
|
133 |
if (reqStatus.Int()==KErrCancel)
|
|
134 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Write (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
135 |
else
|
|
136 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Write (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
137 |
|
|
138 |
// test.Next(_L("OK: RMobileNamStore's Write Entry"));
|
|
139 |
|
|
140 |
// Delete one entry
|
|
141 |
|
|
142 |
// asynchronous
|
|
143 |
|
|
144 |
namStore.Delete(reqStatus, DMMTSY_NAM_STORE_INDEX1);
|
|
145 |
User::WaitForRequest(reqStatus);
|
|
146 |
TEST(reqStatus.Int()==KErrNone);
|
|
147 |
|
|
148 |
// cancel
|
|
149 |
|
|
150 |
namStore.Delete(reqStatus, DMMTSY_NAM_STORE_INDEX1);
|
|
151 |
namStore.CancelAsyncRequest(EMobilePhoneStoreDelete);
|
|
152 |
User::WaitForRequest(reqStatus);
|
|
153 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
154 |
|
|
155 |
if (reqStatus.Int()==KErrCancel)
|
|
156 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Delete (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
157 |
else
|
|
158 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Delete (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
159 |
|
|
160 |
// Delete all entries
|
|
161 |
|
|
162 |
// asynchronous
|
|
163 |
|
|
164 |
namStore.DeleteAll(reqStatus);
|
|
165 |
User::WaitForRequest(reqStatus);
|
|
166 |
TEST(reqStatus.Int()==KErrNone);
|
|
167 |
|
|
168 |
// asynchronous & cancel
|
|
169 |
|
|
170 |
namStore.DeleteAll(reqStatus);
|
|
171 |
namStore.CancelAsyncRequest(EMobilePhoneStoreDeleteAll);
|
|
172 |
User::WaitForRequest(reqStatus);
|
|
173 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
174 |
if (reqStatus.Int()==KErrCancel)
|
|
175 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::DeleteAll (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
176 |
else
|
|
177 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::DeleteAll (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
178 |
|
|
179 |
// test.Next(_L("OK: RMobileNamStore's Delete Entries"));
|
|
180 |
|
|
181 |
|
|
182 |
// Notify Entry Changed
|
|
183 |
|
|
184 |
// asynchronous
|
|
185 |
TInt index;
|
|
186 |
|
|
187 |
TUint32 event;
|
|
188 |
namStore.NotifyStoreEvent(reqStatus, event, index);
|
|
189 |
User::WaitForRequest(reqStatus);
|
|
190 |
TEST(reqStatus.Int()==KErrNone);
|
|
191 |
TEST(index==DMMTSY_NAM_STORE_INDEX2);
|
|
192 |
TEST(event==DMMTSY_NAM_STORE_EVENT);
|
|
193 |
|
|
194 |
// asychronous & cancel
|
|
195 |
|
|
196 |
namStore.NotifyStoreEvent(reqStatus, event, index);
|
|
197 |
namStore.CancelAsyncRequest(EMobilePhoneStoreNotifyStoreEvent);
|
|
198 |
User::WaitForRequest(reqStatus);
|
|
199 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
200 |
if (reqStatus.Int()==KErrCancel)
|
|
201 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::NotifyStoreEvent (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
202 |
else
|
|
203 |
{
|
|
204 |
TEST(index==DMMTSY_NAM_STORE_INDEX2);
|
|
205 |
TEST(event==DMMTSY_NAM_STORE_EVENT);
|
|
206 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::NotifyStoreEvent (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
207 |
}
|
|
208 |
|
|
209 |
// test.Next(_L("OK: RMobileNamStore's Notify Store Event change"));
|
|
210 |
|
|
211 |
|
|
212 |
// Read all NAM entries
|
|
213 |
|
|
214 |
//Test deletion of list object whilst async request in progress
|
|
215 |
CRetrieveMobilePhoneNamList* retrieve=CRetrieveMobilePhoneNamList::NewL(namStore);
|
|
216 |
retrieve->Start(reqStatus,DMMTSY_NAM_STORE_NAMID);
|
|
217 |
delete retrieve;
|
|
218 |
retrieve = NULL;
|
|
219 |
User::WaitForRequest(reqStatus);
|
|
220 |
TEST(reqStatus == KErrCancel);
|
|
221 |
|
|
222 |
// Get NAM list using asynchronous AO version
|
|
223 |
CTestGetNamList* getNamList=CTestGetNamList::NewLC(namStore, this);
|
|
224 |
getNamList->Start();
|
|
225 |
CActiveScheduler::Start();
|
|
226 |
|
|
227 |
// Ensure that the same object can be used to retrieve more than one list
|
|
228 |
|
|
229 |
getNamList->Start();
|
|
230 |
CActiveScheduler::Start();
|
|
231 |
|
|
232 |
// I only need to delete the retrieval object because the destructor
|
|
233 |
// of this will also delete the list object.
|
|
234 |
CleanupStack::PopAndDestroy(); // getNamList
|
|
235 |
|
|
236 |
// Now test the cancelling
|
|
237 |
|
|
238 |
getNamList=CTestGetNamList::NewLC(namStore, this);
|
|
239 |
getNamList->Start();
|
|
240 |
|
|
241 |
CTestCanceller* cancelGetNamList = getNamList->RetrieveCancelPtr();
|
|
242 |
cancelGetNamList->Call();
|
|
243 |
|
|
244 |
CActiveScheduler::Start();
|
|
245 |
TBool cancelled = (getNamList->iStatus == KErrCancel);
|
|
246 |
|
|
247 |
// Ensure that an object which has just been cancelled can be susbsequently used to retrieve
|
|
248 |
// a list.
|
|
249 |
|
|
250 |
getNamList->Start();
|
|
251 |
CActiveScheduler::Start();
|
|
252 |
|
|
253 |
if (cancelled)
|
|
254 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::ReadAll (sync & async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
255 |
else
|
|
256 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::ReadAll (sync & async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
257 |
|
|
258 |
|
|
259 |
CleanupStack::PopAndDestroy(); // getNamList
|
|
260 |
|
|
261 |
// test.Next(_L("OK: RMobileNamStore's Read All Entries"));
|
|
262 |
|
|
263 |
// Test Set SetActiveNam
|
|
264 |
|
|
265 |
namStore.SetActiveNam(reqStatus,DMMTSY_NAM_STORE_NAMID);
|
|
266 |
User::WaitForRequest(reqStatus);
|
|
267 |
TEST(reqStatus.Int() == KErrNone);
|
|
268 |
|
|
269 |
namStore.SetActiveNam(reqStatus,DMMTSY_NAM_STORE_NAMID);
|
|
270 |
namStore.CancelAsyncRequest(EMobileNamStoreSetActiveNam);
|
|
271 |
User::WaitForRequest(reqStatus);
|
|
272 |
TEST(reqStatus.Int() == KErrNone || reqStatus.Int()==KErrCancel);
|
|
273 |
if (reqStatus.Int()==KErrCancel)
|
|
274 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::SetActiveNam (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
275 |
else
|
|
276 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::SetActiveNam (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
// Storing a new version of the list
|
|
282 |
|
|
283 |
// asynchronous
|
|
284 |
|
|
285 |
RMobileNamStore::TMobileNamEntryV1 storeEntry;
|
|
286 |
|
|
287 |
CMobilePhoneNamList* namList = CMobilePhoneNamList::NewL();
|
|
288 |
CleanupStack::PushL(namList);
|
|
289 |
|
|
290 |
InitNamEntry(storeEntry);
|
|
291 |
storeEntry.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
292 |
|
|
293 |
namList->AddEntryL(storeEntry);
|
|
294 |
storeEntry.iIndex = DMMTSY_NAM_STORE_INDEX2;
|
|
295 |
namList->AddEntryL(storeEntry);
|
|
296 |
|
|
297 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namList);
|
|
298 |
User::WaitForRequest(reqStatus);
|
|
299 |
TEST(reqStatus.Int()==KErrNone);
|
|
300 |
|
|
301 |
// asynchronous & cancel
|
|
302 |
|
|
303 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namList);
|
|
304 |
namStore.CancelAsyncRequest(EMobileNamStoreStoreAll);
|
|
305 |
User::WaitForRequest(reqStatus);
|
|
306 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
307 |
cancelled = (reqStatus.Int()==KErrCancel);
|
|
308 |
|
|
309 |
// Lets just test that we can perform a Store operation after the previous store was cancelled
|
|
310 |
|
|
311 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namList);
|
|
312 |
User::WaitForRequest(reqStatus);
|
|
313 |
TEST(reqStatus.Int()==KErrNone);
|
|
314 |
|
|
315 |
if (cancelled)
|
|
316 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::StoreAll (sync & async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
317 |
else
|
|
318 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::StoreAll (sync & async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
319 |
|
|
320 |
CleanupStack::PopAndDestroy(); // namList
|
|
321 |
|
|
322 |
// test.Next(_L("OK: RMobileNamStore's Store All Entries"));
|
|
323 |
|
|
324 |
|
|
325 |
// Test Nam store with V4 Nam entries
|
|
326 |
|
|
327 |
|
|
328 |
// Read one entry
|
|
329 |
RMobileNamStore::TMobileNamEntryV4 asyncEntryV4_1;
|
|
330 |
|
|
331 |
// asynchronous
|
|
332 |
|
|
333 |
asyncEntryV4_1.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
334 |
RMobileNamStore::TMobileNamEntryV4Pckg asyncEntry1PckgV4_1(asyncEntryV4_1);
|
|
335 |
|
|
336 |
namStore.Read(reqStatus,asyncEntry1PckgV4_1);
|
|
337 |
User::WaitForRequest(reqStatus);
|
|
338 |
TEST(reqStatus.Int()==KErrNone);
|
|
339 |
|
|
340 |
ValidateNamRead(asyncEntryV4_1);
|
|
341 |
|
|
342 |
// cancel
|
|
343 |
|
|
344 |
asyncEntryV4_1.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
345 |
namStore.Read(reqStatus, asyncEntry1PckgV4_1);
|
|
346 |
namStore.CancelAsyncRequest(EMobilePhoneStoreRead);
|
|
347 |
User::WaitForRequest(reqStatus);
|
|
348 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
349 |
if (reqStatus.Int()==KErrCancel)
|
|
350 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Read (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
351 |
else
|
|
352 |
{
|
|
353 |
ValidateNamRead(asyncEntryV4_1);
|
|
354 |
SetTestStepResult(EInconclusive);
|
|
355 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Read (async & cancel (Request Not Cancelled)) inconclusive"), iTestCount++);
|
|
356 |
}
|
|
357 |
|
|
358 |
// Write one entry
|
|
359 |
|
|
360 |
RMobileNamStore::TMobileNamEntryV4 entryV4_2;
|
|
361 |
RMobileNamStore::TMobileNamEntryV4Pckg entryV4_2Pckg(entryV4_2);
|
|
362 |
|
|
363 |
InitNamEntry(entryV4_2);
|
|
364 |
|
|
365 |
// asynchronous
|
|
366 |
|
|
367 |
entryV4_2.iIndex=DMMTSY_NAM_STORE_INDEX2;
|
|
368 |
namStore.Write(reqStatus, entryV4_2Pckg);
|
|
369 |
User::WaitForRequest(reqStatus);
|
|
370 |
TEST(reqStatus.Int()==KErrNone);
|
|
371 |
|
|
372 |
// aynchronous & cancel
|
|
373 |
|
|
374 |
namStore.Write(reqStatus, entryV4_2Pckg);
|
|
375 |
namStore.CancelAsyncRequest(EMobilePhoneStoreWrite);
|
|
376 |
User::WaitForRequest(reqStatus);
|
|
377 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
378 |
|
|
379 |
if (reqStatus.Int()==KErrCancel)
|
|
380 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Write (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
381 |
else
|
|
382 |
{
|
|
383 |
SetTestStepResult(EInconclusive);
|
|
384 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::Write (async & cancel (Request Not Cancelled)) inconclusive"), iTestCount++);
|
|
385 |
}
|
|
386 |
|
|
387 |
// Read all NAM entries
|
|
388 |
|
|
389 |
// Test deletion of list object whilst async request in progress
|
|
390 |
CRetrieveMobilePhoneNamList* retrieveV4=CRetrieveMobilePhoneNamList::NewL(namStore);
|
|
391 |
retrieveV4->StartV4(reqStatus,DMMTSY_NAM_STORE_NAMID);
|
|
392 |
delete retrieveV4;
|
|
393 |
retrieveV4 = NULL;
|
|
394 |
User::WaitForRequest(reqStatus);
|
|
395 |
TEST(reqStatus == KErrCancel);
|
|
396 |
|
|
397 |
// Get NAM list using asynchronous AO version
|
|
398 |
CTestGetNamListV4* getNamListV4=CTestGetNamListV4::NewLC(namStore, this);
|
|
399 |
getNamListV4->Start();
|
|
400 |
CActiveScheduler::Start();
|
|
401 |
|
|
402 |
// Ensure that the same object can be used to retrieve more than one list
|
|
403 |
|
|
404 |
getNamListV4->Start();
|
|
405 |
CActiveScheduler::Start();
|
|
406 |
|
|
407 |
// I only need to delete the retrieval object because the destructor
|
|
408 |
// of this will also delete the list object.
|
|
409 |
CleanupStack::PopAndDestroy(getNamListV4);
|
|
410 |
|
|
411 |
// Now test the cancelling
|
|
412 |
|
|
413 |
getNamListV4=CTestGetNamListV4::NewLC(namStore, this);
|
|
414 |
getNamListV4->Start();
|
|
415 |
|
|
416 |
CTestCanceller* cancelGetNamListV4 = getNamListV4->RetrieveCancelPtr();
|
|
417 |
cancelGetNamListV4->Call();
|
|
418 |
|
|
419 |
CActiveScheduler::Start();
|
|
420 |
cancelled = (getNamListV4->iStatus == KErrCancel);
|
|
421 |
|
|
422 |
// Ensure that an object which has just been cancelled can be susbsequently used to retrieve
|
|
423 |
// a list.
|
|
424 |
|
|
425 |
getNamListV4->Start();
|
|
426 |
CActiveScheduler::Start();
|
|
427 |
|
|
428 |
if (cancelled)
|
|
429 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::ReadAll (sync & async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
430 |
else
|
|
431 |
{
|
|
432 |
SetTestStepResult(EInconclusive);
|
|
433 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::ReadAll (sync & async & cancel (Request Not Cancelled)) inconclusive"), iTestCount++);
|
|
434 |
}
|
|
435 |
|
|
436 |
CleanupStack::PopAndDestroy(getNamListV4);
|
|
437 |
|
|
438 |
// Storing a new version of the list
|
|
439 |
|
|
440 |
// asynchronous
|
|
441 |
|
|
442 |
RMobileNamStore::TMobileNamEntryV4 storeEntryV4;
|
|
443 |
|
|
444 |
CMobilePhoneNamListV4* namListV4 = CMobilePhoneNamListV4::NewL();
|
|
445 |
CleanupStack::PushL(namListV4);
|
|
446 |
|
|
447 |
InitNamEntry(storeEntryV4);
|
|
448 |
storeEntryV4.iIndex = DMMTSY_NAM_STORE_INDEX1;
|
|
449 |
|
|
450 |
namListV4->AddEntryL(storeEntryV4);
|
|
451 |
storeEntryV4.iIndex = DMMTSY_NAM_STORE_INDEX2;
|
|
452 |
namListV4->AddEntryL(storeEntryV4);
|
|
453 |
|
|
454 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namListV4);
|
|
455 |
User::WaitForRequest(reqStatus);
|
|
456 |
TEST(reqStatus.Int()==KErrNone);
|
|
457 |
|
|
458 |
// asynchronous & cancel
|
|
459 |
|
|
460 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namListV4);
|
|
461 |
namStore.CancelAsyncRequest(EMobileNamStoreStoreAllV4);
|
|
462 |
User::WaitForRequest(reqStatus);
|
|
463 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
464 |
cancelled = (reqStatus.Int()==KErrCancel);
|
|
465 |
|
|
466 |
// Lets just test that we can perform a Store operation after the previous store was cancelled
|
|
467 |
|
|
468 |
namStore.StoreAllL(reqStatus, DMMTSY_NAM_STORE_NAMID, namListV4);
|
|
469 |
User::WaitForRequest(reqStatus);
|
|
470 |
TEST(reqStatus.Int()==KErrNone);
|
|
471 |
|
|
472 |
if (cancelled)
|
|
473 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::StoreAll (sync & async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
474 |
else
|
|
475 |
{
|
|
476 |
SetTestStepResult(EInconclusive);
|
|
477 |
INFO_PRINTF2(_L("Test %d - RMobileNamStore::StoreAll (sync & async & cancel (Request Not Cancelled)) inconclusive"), iTestCount++);
|
|
478 |
}
|
|
479 |
CleanupStack::PopAndDestroy(namListV4);
|
|
480 |
|
|
481 |
// Test retrieving both V1 and V4 NAM lists, one after the other
|
|
482 |
|
|
483 |
CTestGetNamListSimultaneous* getNamListSimultaneous=CTestGetNamListSimultaneous::NewLC(namStore, this);
|
|
484 |
getNamListSimultaneous->Start();
|
|
485 |
CActiveScheduler::Start();
|
|
486 |
|
|
487 |
// I only need to delete the retrieval object because the destructor
|
|
488 |
// of this will also delete the list object.
|
|
489 |
CleanupStack::PopAndDestroy(getNamListSimultaneous);
|
|
490 |
|
|
491 |
namStore.Close();
|
|
492 |
mmPhone.Close();
|
|
493 |
INFO_PRINTF1(_L(""));
|
|
494 |
|
|
495 |
return TestStepResult();
|
|
496 |
}
|
|
497 |
|
|
498 |
void CTestNamStore::ValidateNamInfo(const RMobileNamStore::TMobileNamStoreInfoV1 &aInfo)
|
|
499 |
{
|
|
500 |
TEST(aInfo.iName.Compare(DMMTSY_NAM_STORE_NAME) == 0);
|
|
501 |
TEST(aInfo.iType==DMMTSY_NAM_STORE_TYPE);
|
|
502 |
TEST(aInfo.iTotalEntries==DMMTSY_NAM_STORE_ENTRIES);
|
|
503 |
TEST(aInfo.iUsedEntries==DMMTSY_NAM_STORE_USED);
|
|
504 |
TEST(aInfo.iCaps==DMMTSY_NAM_STORE_CAPS);
|
|
505 |
TEST(aInfo.iNamCount == DMMTSY_NAM_STORE_COUNT);
|
|
506 |
TEST(aInfo.iActiveNam == DMMTSY_NAM_STORE_ACTIVE);
|
|
507 |
TEST(aInfo.ExtensionId()==RMobilePhoneStore::KETelMobileNamStoreV1);
|
|
508 |
}
|
|
509 |
|
|
510 |
void CTestNamStore::ValidateNamEntry(const RMobileNamStore::TMobileNamEntryV1 &aEntry)
|
|
511 |
{
|
|
512 |
TEST(aEntry.iNamId == DMMTSY_NAM_STORE_NAMID);
|
|
513 |
TEST(aEntry.iParamIdentifier == DMMTSY_NAM_STORE_PARAM);
|
|
514 |
TEST(aEntry.iData.Compare(DMMTSY_NAM_STORE_DATA) == 0);
|
|
515 |
}
|
|
516 |
|
|
517 |
|
|
518 |
void CTestNamStore::ValidateNamEntry(const RMobileNamStore::TMobileNamEntryV4 &aEntry)
|
|
519 |
{
|
|
520 |
TEST(aEntry.iNamId == DMMTSY_NAM_STORE_NAMID);
|
|
521 |
TEST(aEntry.iParamIdentifier == DMMTSY_NAM_STORE_PARAM);
|
|
522 |
TEST(aEntry.iData.Compare(DMMTSY_NAM_STORE_DATA_V4) == 0);
|
|
523 |
}
|
|
524 |
|
|
525 |
void CTestNamStore::ValidateNamRead(const RMobileNamStore::TMobileNamEntryV1 &aEntry)
|
|
526 |
{
|
|
527 |
ValidateNamEntry(aEntry);
|
|
528 |
}
|
|
529 |
|
|
530 |
void CTestNamStore::ValidateNamRead(const RMobileNamStore::TMobileNamEntryV4 &aEntry)
|
|
531 |
{
|
|
532 |
ValidateNamEntry(aEntry);
|
|
533 |
}
|
|
534 |
|
|
535 |
void CTestNamStore::InitNamEntry(RMobileNamStore::TMobileNamEntryV1& aEntry)
|
|
536 |
{
|
|
537 |
aEntry.iNamId = DMMTSY_NAM_STORE_NAMID;
|
|
538 |
aEntry.iParamIdentifier = DMMTSY_NAM_STORE_PARAM;
|
|
539 |
aEntry.iData = DMMTSY_NAM_STORE_DATA;
|
|
540 |
}
|
|
541 |
|
|
542 |
void CTestNamStore::InitNamEntry(RMobileNamStore::TMobileNamEntryV4& aEntry)
|
|
543 |
{
|
|
544 |
aEntry.iNamId = DMMTSY_NAM_STORE_NAMID;
|
|
545 |
aEntry.iParamIdentifier = DMMTSY_NAM_STORE_PARAM;
|
|
546 |
aEntry.iData = DMMTSY_NAM_STORE_DATA_V4;
|
|
547 |
}
|
|
548 |
|
|
549 |
/**************************************************************/
|
|
550 |
//
|
|
551 |
// Testing asynchronous retrieve of NAM list
|
|
552 |
//
|
|
553 |
/**************************************************************/
|
|
554 |
|
|
555 |
CTestNamStore::CTestGetNamList* CTestNamStore::CTestGetNamList::NewLC(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
556 |
{
|
|
557 |
CTestGetNamList* r=new(ELeave) CTestGetNamList(aStore, aTestNamStore);
|
|
558 |
CleanupStack::PushL(r);
|
|
559 |
r->ConstructL();
|
|
560 |
return r;
|
|
561 |
}
|
|
562 |
|
|
563 |
CTestNamStore::CTestGetNamListV4* CTestNamStore::CTestGetNamListV4::NewLC(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
564 |
{
|
|
565 |
CTestGetNamListV4* r=new(ELeave) CTestGetNamListV4(aStore, aTestNamStore);
|
|
566 |
CleanupStack::PushL(r);
|
|
567 |
r->ConstructL();
|
|
568 |
return r;
|
|
569 |
}
|
|
570 |
|
|
571 |
CTestNamStore::CTestGetNamListSimultaneous* CTestNamStore::CTestGetNamListSimultaneous::NewLC(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
572 |
{
|
|
573 |
CTestGetNamListSimultaneous* r=new(ELeave) CTestGetNamListSimultaneous(aStore, aTestNamStore);
|
|
574 |
CleanupStack::PushL(r);
|
|
575 |
r->ConstructL();
|
|
576 |
return r;
|
|
577 |
}
|
|
578 |
|
|
579 |
CTestNamStore::CTestGetNamList::CTestGetNamList(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
580 |
: CActive(EPriorityNormal), iStore(aStore), iTestNamStore(aTestNamStore)
|
|
581 |
{}
|
|
582 |
|
|
583 |
CTestNamStore::CTestGetNamListV4::CTestGetNamListV4(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
584 |
: CActive(EPriorityNormal), iStore(aStore), iTestNamStore(aTestNamStore)
|
|
585 |
{}
|
|
586 |
|
|
587 |
CTestNamStore::CTestGetNamListSimultaneous::CTestGetNamListSimultaneous(RMobilePhoneStore& aStore, CTestNamStore* aTestNamStore)
|
|
588 |
: CActive(EPriorityNormal), iStore(aStore), iTestNamStore(aTestNamStore)
|
|
589 |
{}
|
|
590 |
|
|
591 |
void CTestNamStore::CTestGetNamList::ConstructL()
|
|
592 |
{
|
|
593 |
CActiveScheduler::Add(this);
|
|
594 |
iRetrieve=CRetrieveMobilePhoneNamList::NewL(iStore);
|
|
595 |
iCanceller=new (ELeave) CTestCanceller(this);
|
|
596 |
}
|
|
597 |
|
|
598 |
void CTestNamStore::CTestGetNamListV4::ConstructL()
|
|
599 |
{
|
|
600 |
CActiveScheduler::Add(this);
|
|
601 |
iRetrieve=CRetrieveMobilePhoneNamList::NewL(iStore);
|
|
602 |
iCanceller=new (ELeave) CTestCanceller(this);
|
|
603 |
}
|
|
604 |
|
|
605 |
void CTestNamStore::CTestGetNamListSimultaneous::ConstructL()
|
|
606 |
{
|
|
607 |
CActiveScheduler::Add(this);
|
|
608 |
iRetrieve=CRetrieveMobilePhoneNamList::NewL(iStore);
|
|
609 |
iCanceller=new (ELeave) CTestCanceller(this);
|
|
610 |
}
|
|
611 |
|
|
612 |
CTestNamStore::CTestGetNamList::~CTestGetNamList()
|
|
613 |
{
|
|
614 |
delete iRetrieve;
|
|
615 |
delete iCanceller;
|
|
616 |
}
|
|
617 |
|
|
618 |
CTestNamStore::CTestGetNamListV4::~CTestGetNamListV4()
|
|
619 |
{
|
|
620 |
delete iRetrieve;
|
|
621 |
delete iCanceller;
|
|
622 |
}
|
|
623 |
|
|
624 |
CTestNamStore::CTestGetNamListSimultaneous::~CTestGetNamListSimultaneous()
|
|
625 |
{
|
|
626 |
delete iRetrieve;
|
|
627 |
delete iCanceller;
|
|
628 |
}
|
|
629 |
|
|
630 |
void CTestNamStore::CTestGetNamList::Start()
|
|
631 |
{
|
|
632 |
iRetrieve->Start(iStatus,DMMTSY_NAM_STORE_NAMID);
|
|
633 |
TRequestStatus tmpStatus;
|
|
634 |
iRetrieve->Start(tmpStatus,DMMTSY_NAM_STORE_NAMID);
|
|
635 |
User::WaitForRequest(tmpStatus);
|
|
636 |
iTestNamStore->TEST(tmpStatus.Int() == KErrInUse);
|
|
637 |
SetActive();
|
|
638 |
}
|
|
639 |
|
|
640 |
void CTestNamStore::CTestGetNamListV4::Start()
|
|
641 |
{
|
|
642 |
iRetrieve->StartV4(iStatus,DMMTSY_NAM_STORE_NAMID);
|
|
643 |
TRequestStatus tmpStatus;
|
|
644 |
iRetrieve->StartV4(tmpStatus,DMMTSY_NAM_STORE_NAMID);
|
|
645 |
User::WaitForRequest(tmpStatus);
|
|
646 |
iTestNamStore->TEST(tmpStatus.Int() == KErrInUse);
|
|
647 |
SetActive();
|
|
648 |
}
|
|
649 |
|
|
650 |
void CTestNamStore::CTestGetNamListSimultaneous::Start()
|
|
651 |
{
|
|
652 |
iRetrieve->Start(iStatus,DMMTSY_NAM_STORE_NAMID);
|
|
653 |
TRequestStatus tmpStatus;
|
|
654 |
iRetrieve->StartV4(tmpStatus,DMMTSY_NAM_STORE_NAMID);
|
|
655 |
User::WaitForRequest(tmpStatus);
|
|
656 |
iTestNamStore->TEST(tmpStatus.Int() == KErrInUse);
|
|
657 |
SetActive();
|
|
658 |
}
|
|
659 |
|
|
660 |
CTestCanceller* CTestNamStore::CTestGetNamList::RetrieveCancelPtr()
|
|
661 |
{
|
|
662 |
return iCanceller;
|
|
663 |
}
|
|
664 |
|
|
665 |
CTestCanceller* CTestNamStore::CTestGetNamListV4::RetrieveCancelPtr()
|
|
666 |
{
|
|
667 |
return iCanceller;
|
|
668 |
}
|
|
669 |
|
|
670 |
void CTestNamStore::CTestGetNamList::RunL()
|
|
671 |
{
|
|
672 |
TInt ret=iStatus.Int();
|
|
673 |
|
|
674 |
User::LeaveIfError(ret);
|
|
675 |
ret=CheckResults();
|
|
676 |
User::LeaveIfError(ret);
|
|
677 |
|
|
678 |
CActiveScheduler::Stop();
|
|
679 |
}
|
|
680 |
|
|
681 |
void CTestNamStore::CTestGetNamListV4::RunL()
|
|
682 |
{
|
|
683 |
TInt ret=iStatus.Int();
|
|
684 |
|
|
685 |
User::LeaveIfError(ret);
|
|
686 |
ret=CheckResults();
|
|
687 |
User::LeaveIfError(ret);
|
|
688 |
|
|
689 |
CActiveScheduler::Stop();
|
|
690 |
}
|
|
691 |
|
|
692 |
void CTestNamStore::CTestGetNamListSimultaneous::RunL()
|
|
693 |
{
|
|
694 |
TInt ret=iStatus.Int();
|
|
695 |
|
|
696 |
User::LeaveIfError(ret);
|
|
697 |
ret=CheckResults();
|
|
698 |
User::LeaveIfError(ret);
|
|
699 |
|
|
700 |
CActiveScheduler::Stop();
|
|
701 |
}
|
|
702 |
|
|
703 |
void CTestNamStore::CTestGetNamList::DoCancel()
|
|
704 |
{
|
|
705 |
iRetrieve->Cancel();
|
|
706 |
}
|
|
707 |
|
|
708 |
void CTestNamStore::CTestGetNamListV4::DoCancel()
|
|
709 |
{
|
|
710 |
iRetrieve->Cancel();
|
|
711 |
}
|
|
712 |
|
|
713 |
void CTestNamStore::CTestGetNamListSimultaneous::DoCancel()
|
|
714 |
{
|
|
715 |
iRetrieve->Cancel();
|
|
716 |
}
|
|
717 |
|
|
718 |
TInt CTestNamStore::CTestGetNamList::CheckResults()
|
|
719 |
{
|
|
720 |
TInt ret=KErrNone;
|
|
721 |
|
|
722 |
CMobilePhoneNamList* namList=NULL;
|
|
723 |
TInt leaveCode=KErrNone;
|
|
724 |
TRAP(leaveCode, namList=iRetrieve->RetrieveListL(););
|
|
725 |
|
|
726 |
if (namList)
|
|
727 |
{
|
|
728 |
iTestNamStore->TEST(namList->Enumerate()==DMMTSY_NAM_STORE_COUNT);
|
|
729 |
|
|
730 |
// Get each detected network entry
|
|
731 |
RMobileNamStore::TMobileNamEntryV1 entry;
|
|
732 |
|
|
733 |
for (TInt i=0; i<DMMTSY_NAM_STORE_COUNT; ++i)
|
|
734 |
{
|
|
735 |
TRAP(ret,entry=namList->GetEntryL(i));
|
|
736 |
if (ret != KErrNone)
|
|
737 |
break;
|
|
738 |
|
|
739 |
switch(i)
|
|
740 |
{
|
|
741 |
case 0:
|
|
742 |
{
|
|
743 |
iTestNamStore->ValidateNamEntry(entry);
|
|
744 |
iTestNamStore->TEST(entry.iIndex==DMMTSY_NAM_STORE_INDEX1);
|
|
745 |
break;
|
|
746 |
}
|
|
747 |
case 1:
|
|
748 |
{
|
|
749 |
iTestNamStore->ValidateNamEntry(entry);
|
|
750 |
iTestNamStore->TEST(entry.iIndex==DMMTSY_NAM_STORE_INDEX2);
|
|
751 |
break;
|
|
752 |
}
|
|
753 |
default:
|
|
754 |
break;
|
|
755 |
}
|
|
756 |
}
|
|
757 |
delete namList;
|
|
758 |
}
|
|
759 |
|
|
760 |
return ret;
|
|
761 |
}
|
|
762 |
|
|
763 |
TInt CTestNamStore::CTestGetNamListV4::CheckResults()
|
|
764 |
{
|
|
765 |
TInt ret=KErrNone;
|
|
766 |
|
|
767 |
CMobilePhoneNamListV4* namList=NULL;
|
|
768 |
TInt leaveCode=KErrNone;
|
|
769 |
TRAP(leaveCode, namList=iRetrieve->RetrieveListV4L(););
|
|
770 |
|
|
771 |
if (namList)
|
|
772 |
{
|
|
773 |
iTestNamStore->TEST(namList->Enumerate()==DMMTSY_NAM_STORE_COUNT);
|
|
774 |
|
|
775 |
// Get each detected network entry
|
|
776 |
RMobileNamStore::TMobileNamEntryV4 entry;
|
|
777 |
|
|
778 |
for (TInt i=0; i<DMMTSY_NAM_STORE_COUNT; ++i)
|
|
779 |
{
|
|
780 |
TRAP(ret,entry=namList->GetEntryL(i));
|
|
781 |
if (ret != KErrNone)
|
|
782 |
break;
|
|
783 |
|
|
784 |
switch(i)
|
|
785 |
{
|
|
786 |
case 0:
|
|
787 |
{
|
|
788 |
iTestNamStore->ValidateNamEntry(entry);
|
|
789 |
iTestNamStore->TEST(entry.iIndex==DMMTSY_NAM_STORE_INDEX1);
|
|
790 |
break;
|
|
791 |
}
|
|
792 |
case 1:
|
|
793 |
{
|
|
794 |
iTestNamStore->ValidateNamEntry(entry);
|
|
795 |
iTestNamStore->TEST(entry.iIndex==DMMTSY_NAM_STORE_INDEX2);
|
|
796 |
break;
|
|
797 |
}
|
|
798 |
default:
|
|
799 |
break;
|
|
800 |
}
|
|
801 |
}
|
|
802 |
delete namList;
|
|
803 |
}
|
|
804 |
|
|
805 |
return ret;
|
|
806 |
}
|
|
807 |
|
|
808 |
TInt CTestNamStore::CTestGetNamListSimultaneous::CheckResults()
|
|
809 |
{
|
|
810 |
TInt ret=KErrNone;
|
|
811 |
|
|
812 |
CMobilePhoneNamList* namListV1=NULL;
|
|
813 |
TInt leaveCode=KErrNone;
|
|
814 |
TRAP(leaveCode, namListV1=iRetrieve->RetrieveListL(););
|
|
815 |
|
|
816 |
if (namListV1)
|
|
817 |
{
|
|
818 |
iTestNamStore->TEST(namListV1->Enumerate()==DMMTSY_NAM_STORE_COUNT);
|
|
819 |
|
|
820 |
// Get each detected network entry
|
|
821 |
RMobileNamStore::TMobileNamEntryV1 entryV1;
|
|
822 |
|
|
823 |
for (TInt i=0; i<DMMTSY_NAM_STORE_COUNT; ++i)
|
|
824 |
{
|
|
825 |
TRAP(ret,entryV1=namListV1->GetEntryL(i));
|
|
826 |
if (ret != KErrNone)
|
|
827 |
break;
|
|
828 |
|
|
829 |
switch(i)
|
|
830 |
{
|
|
831 |
case 0:
|
|
832 |
{
|
|
833 |
iTestNamStore->ValidateNamEntry(entryV1);
|
|
834 |
iTestNamStore->TEST(entryV1.iIndex==DMMTSY_NAM_STORE_INDEX1);
|
|
835 |
break;
|
|
836 |
}
|
|
837 |
case 1:
|
|
838 |
{
|
|
839 |
iTestNamStore->ValidateNamEntry(entryV1);
|
|
840 |
iTestNamStore->TEST(entryV1.iIndex==DMMTSY_NAM_STORE_INDEX2);
|
|
841 |
break;
|
|
842 |
}
|
|
843 |
default:
|
|
844 |
break;
|
|
845 |
}
|
|
846 |
}
|
|
847 |
delete namListV1;
|
|
848 |
}
|
|
849 |
|
|
850 |
return ret;
|
|
851 |
}
|