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_mmenstore.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestEnStore::CTestEnStore()
|
|
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("TestEnStore"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestEnStore::doTestStepL()
|
|
32 |
//
|
|
33 |
// Test Emergency Number Functions
|
|
34 |
//
|
|
35 |
{
|
|
36 |
iTestCount=1;
|
|
37 |
INFO_PRINTF1(_L(""));
|
|
38 |
INFO_PRINTF1(_L("Test Mobile Emergency Number Storage Functionality"));
|
|
39 |
// LOGTEXT(_L8("Test Mobile Emergency Number Storage Functionality"));
|
|
40 |
|
|
41 |
RMobilePhone mmPhone;
|
|
42 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
43 |
TEST(ret==KErrNone);
|
|
44 |
|
|
45 |
RMobileENStore enStore;
|
|
46 |
ret=enStore.Open(mmPhone);
|
|
47 |
TEST(ret==KErrNone);
|
|
48 |
|
|
49 |
TRequestStatus reqStatus;
|
|
50 |
|
|
51 |
// Get Network store information
|
|
52 |
|
|
53 |
// asynchronous
|
|
54 |
|
|
55 |
RMobilePhoneStore::TMobilePhoneStoreInfoV1 asyncInfo;
|
|
56 |
RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg asyncInfoPckg(asyncInfo);
|
|
57 |
enStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
58 |
User::WaitForRequest(reqStatus);
|
|
59 |
TEST(reqStatus.Int()==KErrNone);
|
|
60 |
ValidateENInfo(asyncInfo);
|
|
61 |
|
|
62 |
// asynchronous & cancel
|
|
63 |
|
|
64 |
enStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
65 |
enStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
|
|
66 |
User::WaitForRequest(reqStatus);
|
|
67 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
68 |
if (reqStatus.Int()==KErrCancel)
|
|
69 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::GetInfo (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
70 |
else
|
|
71 |
{
|
|
72 |
ValidateENInfo(asyncInfo);
|
|
73 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::GetInfo (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
74 |
}
|
|
75 |
|
|
76 |
// test.Next(_L("OK: RMobileNetworkStore's Get Info"));
|
|
77 |
|
|
78 |
// Read one entry
|
|
79 |
|
|
80 |
RMobileENStore::TMobileENEntryV1 asyncEntry1;
|
|
81 |
|
|
82 |
// asynchronous
|
|
83 |
|
|
84 |
asyncEntry1.iIndex = DMMTSY_EN_STORE_INDEX1;
|
|
85 |
RMobileENStore::TMobileENEntryV1Pckg asyncEntry1Pckg(asyncEntry1);
|
|
86 |
|
|
87 |
enStore.Read(reqStatus,asyncEntry1Pckg);
|
|
88 |
User::WaitForRequest(reqStatus);
|
|
89 |
TEST(reqStatus.Int()==KErrNone);
|
|
90 |
|
|
91 |
ValidateENRead(asyncEntry1);
|
|
92 |
|
|
93 |
|
|
94 |
// cancel
|
|
95 |
|
|
96 |
asyncEntry1.iIndex = DMMTSY_EN_STORE_INDEX1;
|
|
97 |
enStore.Read(reqStatus, asyncEntry1Pckg);
|
|
98 |
enStore.CancelAsyncRequest(EMobilePhoneStoreRead);
|
|
99 |
User::WaitForRequest(reqStatus);
|
|
100 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
101 |
if (reqStatus.Int()==KErrCancel)
|
|
102 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Read (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
103 |
else
|
|
104 |
{
|
|
105 |
ValidateENRead(asyncEntry1);
|
|
106 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Read (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
107 |
}
|
|
108 |
|
|
109 |
// test.Next(_L("OK: RMobileENStore's Read Entry"));
|
|
110 |
|
|
111 |
// Write one entry
|
|
112 |
|
|
113 |
RMobileENStore::TMobileENEntryV1 entry2;
|
|
114 |
RMobileENStore::TMobileENEntryV1Pckg entry2Pckg(entry2);
|
|
115 |
|
|
116 |
InitENEntry(entry2);
|
|
117 |
|
|
118 |
// asynchronous
|
|
119 |
|
|
120 |
entry2.iIndex=DMMTSY_EN_STORE_INDEX2;
|
|
121 |
enStore.Write(reqStatus, entry2Pckg);
|
|
122 |
User::WaitForRequest(reqStatus);
|
|
123 |
TEST(reqStatus.Int()==KErrNone);
|
|
124 |
|
|
125 |
// aynchronous & cancel
|
|
126 |
|
|
127 |
enStore.Write(reqStatus, entry2Pckg);
|
|
128 |
enStore.CancelAsyncRequest(EMobilePhoneStoreWrite);
|
|
129 |
User::WaitForRequest(reqStatus);
|
|
130 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
131 |
|
|
132 |
if (reqStatus.Int()==KErrCancel)
|
|
133 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Write (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
134 |
else
|
|
135 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Write (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
136 |
|
|
137 |
// test.Next(_L("OK: RMobileENStore's Write Entry"));
|
|
138 |
|
|
139 |
// Delete one entry
|
|
140 |
|
|
141 |
// asynchronous
|
|
142 |
|
|
143 |
enStore.Delete(reqStatus, DMMTSY_EN_STORE_INDEX1);
|
|
144 |
User::WaitForRequest(reqStatus);
|
|
145 |
TEST(reqStatus.Int()==KErrNone);
|
|
146 |
|
|
147 |
// cancel
|
|
148 |
|
|
149 |
enStore.Delete(reqStatus, DMMTSY_EN_STORE_INDEX1);
|
|
150 |
enStore.CancelAsyncRequest(EMobilePhoneStoreDelete);
|
|
151 |
User::WaitForRequest(reqStatus);
|
|
152 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
153 |
|
|
154 |
if (reqStatus.Int()==KErrCancel)
|
|
155 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Delete (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
156 |
else
|
|
157 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::Delete (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
158 |
|
|
159 |
// Delete all entries
|
|
160 |
|
|
161 |
// asynchronous
|
|
162 |
|
|
163 |
enStore.DeleteAll(reqStatus);
|
|
164 |
User::WaitForRequest(reqStatus);
|
|
165 |
TEST(reqStatus.Int()==KErrNone);
|
|
166 |
|
|
167 |
// asynchronous & cancel
|
|
168 |
|
|
169 |
enStore.DeleteAll(reqStatus);
|
|
170 |
enStore.CancelAsyncRequest(EMobilePhoneStoreDeleteAll);
|
|
171 |
User::WaitForRequest(reqStatus);
|
|
172 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
173 |
if (reqStatus.Int()==KErrCancel)
|
|
174 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::DeleteAll (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
175 |
else
|
|
176 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::DeleteAll (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
177 |
|
|
178 |
// test.Next(_L("OK: RMobileENStore's Delete Entries"));
|
|
179 |
|
|
180 |
|
|
181 |
// Notify Entry Changed
|
|
182 |
|
|
183 |
// asynchronous
|
|
184 |
TInt index;
|
|
185 |
|
|
186 |
TUint32 event;
|
|
187 |
enStore.NotifyStoreEvent(reqStatus, event, index);
|
|
188 |
User::WaitForRequest(reqStatus);
|
|
189 |
TEST(reqStatus.Int()==KErrNone);
|
|
190 |
TEST(index==DMMTSY_EN_STORE_INDEX2);
|
|
191 |
TEST(event==DMMTSY_EN_STORE_EVENT);
|
|
192 |
|
|
193 |
// asynchronous & cancel
|
|
194 |
|
|
195 |
enStore.NotifyStoreEvent(reqStatus, event, index);
|
|
196 |
enStore.CancelAsyncRequest(EMobilePhoneStoreNotifyStoreEvent);
|
|
197 |
User::WaitForRequest(reqStatus);
|
|
198 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
199 |
if (reqStatus.Int()==KErrCancel)
|
|
200 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::NotifyStoreEvent (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
201 |
else
|
|
202 |
{
|
|
203 |
TEST(index==DMMTSY_EN_STORE_INDEX2);
|
|
204 |
TEST(event==DMMTSY_EN_STORE_EVENT);
|
|
205 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::NotifyStoreEvent (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
206 |
}
|
|
207 |
|
|
208 |
// test.Next(_L("OK: RMobileENStore's Notify Store Event change"));
|
|
209 |
|
|
210 |
// Read all Network entries
|
|
211 |
|
|
212 |
//Test deletion of list object whilst async request in progress
|
|
213 |
CRetrieveMobilePhoneENList* retrieve=CRetrieveMobilePhoneENList::NewL(enStore);
|
|
214 |
retrieve->Start(reqStatus);
|
|
215 |
delete retrieve;
|
|
216 |
retrieve = NULL;
|
|
217 |
User::WaitForRequest(reqStatus);
|
|
218 |
TEST(reqStatus == KErrCancel);
|
|
219 |
|
|
220 |
// Get Network list using asynchronous AO version
|
|
221 |
|
|
222 |
CTestGetENList* getENList=CTestGetENList::NewLC(enStore, this);
|
|
223 |
getENList->Start();
|
|
224 |
CActiveScheduler::Start();
|
|
225 |
|
|
226 |
// Lets just ensure that the same retrieve object can be used to retrieve more than one list
|
|
227 |
|
|
228 |
getENList->Start();
|
|
229 |
CActiveScheduler::Start();
|
|
230 |
|
|
231 |
|
|
232 |
// I only need to delete the retrieval object because the destructor
|
|
233 |
// of this will also delete the list object.
|
|
234 |
|
|
235 |
|
|
236 |
// Now test the cancelling
|
|
237 |
getENList->Start();
|
|
238 |
|
|
239 |
CTestCanceller* cancelGetENList = getENList->RetrieveCancelPtr();
|
|
240 |
cancelGetENList->Call();
|
|
241 |
|
|
242 |
CActiveScheduler::Start();
|
|
243 |
TBool cancelled = (getENList->iStatus == KErrCancel);
|
|
244 |
|
|
245 |
// Lets just ensure that a object can be used to retrieve a list after a previous transaction
|
|
246 |
// had been cancelled.
|
|
247 |
|
|
248 |
getENList->Start();
|
|
249 |
CActiveScheduler::Start();
|
|
250 |
|
|
251 |
if (cancelled)
|
|
252 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::ReadAll (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
253 |
else
|
|
254 |
INFO_PRINTF2(_L("Test %d - RMobileENStore::ReadAll (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
255 |
|
|
256 |
|
|
257 |
CleanupStack::PopAndDestroy(); // getENList
|
|
258 |
|
|
259 |
// test.Next(_L("OK: RMobileENStore's Read All Entries"));
|
|
260 |
|
|
261 |
enStore.Close();
|
|
262 |
mmPhone.Close();
|
|
263 |
INFO_PRINTF1(_L(""));
|
|
264 |
|
|
265 |
return TestStepResult();
|
|
266 |
};
|
|
267 |
|
|
268 |
void CTestEnStore::ValidateENInfo(const RMobilePhoneStore::TMobilePhoneStoreInfoV1 &aInfo)
|
|
269 |
{
|
|
270 |
TEST(aInfo.iName.Compare(DMMTSY_EN_STORE_NAME) == 0);
|
|
271 |
TEST(aInfo.iType==DMMTSY_EN_STORE_TYPE);
|
|
272 |
TEST(aInfo.iTotalEntries==DMMTSY_EN_STORE_ENTRIES);
|
|
273 |
TEST(aInfo.iUsedEntries==DMMTSY_EN_STORE_USED);
|
|
274 |
TEST(aInfo.iCaps==DMMTSY_EN_STORE_CAPS);
|
|
275 |
TEST(aInfo.ExtensionId()==RMobilePhoneStore::KETelMobilePhoneStoreV1);
|
|
276 |
}
|
|
277 |
|
|
278 |
void CTestEnStore::ValidateENEntry(const RMobileENStore::TMobileENEntryV1 &aEntry)
|
|
279 |
{
|
|
280 |
TEST(aEntry.iNetworkSpecific == DMMTSY_EN_STORE_NS);
|
|
281 |
TEST(aEntry.iMode == DMMTSY_EN_STORE_MODE);
|
|
282 |
TEST(aEntry.iCountryCode.Compare(DMMTSY_EN_STORE_CC) == 0);
|
|
283 |
TEST(aEntry.iIdentity.Compare(DMMTSY_EN_STORE_ID) == 0);
|
|
284 |
TEST(aEntry.iNumber.Compare(DMMTSY_EN_STORE_NUM) == 0);
|
|
285 |
TEST(aEntry.iAlphaId.Compare(DMMTSY_EN_STORE_AMBULANCE_ID) == 0);
|
|
286 |
TEST(aEntry.iCallType == DMMTSY_EN_STORE_CALL_TYPE);
|
|
287 |
}
|
|
288 |
|
|
289 |
void CTestEnStore::ValidateENRead(const RMobileENStore::TMobileENEntryV1 &aEntry)
|
|
290 |
{
|
|
291 |
ValidateENEntry(aEntry);
|
|
292 |
}
|
|
293 |
|
|
294 |
void CTestEnStore::InitENEntry(RMobileENStore::TMobileENEntryV1& aEntry)
|
|
295 |
{
|
|
296 |
aEntry.iNetworkSpecific = DMMTSY_EN_STORE_NS;
|
|
297 |
aEntry.iMode = DMMTSY_EN_STORE_MODE;
|
|
298 |
aEntry.iCountryCode = DMMTSY_EN_STORE_CC;
|
|
299 |
aEntry.iIdentity = DMMTSY_EN_STORE_ID;
|
|
300 |
aEntry.iNumber = DMMTSY_EN_STORE_NUM;
|
|
301 |
aEntry.iAlphaId = DMMTSY_EN_STORE_AMBULANCE_ID;
|
|
302 |
aEntry.iCallType = DMMTSY_EN_STORE_CALL_TYPE;
|
|
303 |
}
|
|
304 |
|
|
305 |
/**************************************************************/
|
|
306 |
//
|
|
307 |
// Testing asynchronous retrieve of EN list
|
|
308 |
//
|
|
309 |
/**************************************************************/
|
|
310 |
|
|
311 |
CTestEnStore::CTestGetENList* CTestEnStore::CTestGetENList::NewLC(RMobilePhoneStore& aStore, CTestEnStore* aTestEnStore)
|
|
312 |
{
|
|
313 |
CTestGetENList* r=new(ELeave) CTestGetENList(aStore, aTestEnStore);
|
|
314 |
CleanupStack::PushL(r);
|
|
315 |
r->ConstructL();
|
|
316 |
return r;
|
|
317 |
}
|
|
318 |
|
|
319 |
CTestEnStore::CTestGetENList::CTestGetENList(RMobilePhoneStore& aStore, CTestEnStore* aTestEnStore)
|
|
320 |
: CActive(EPriorityNormal), iStore(aStore), iTestEnStore(aTestEnStore)
|
|
321 |
{}
|
|
322 |
|
|
323 |
|
|
324 |
void CTestEnStore::CTestGetENList::ConstructL()
|
|
325 |
{
|
|
326 |
CActiveScheduler::Add(this);
|
|
327 |
iRetrieve=CRetrieveMobilePhoneENList::NewL(iStore);
|
|
328 |
iCanceller=new (ELeave) CTestCanceller(this);
|
|
329 |
}
|
|
330 |
|
|
331 |
CTestEnStore::CTestGetENList::~CTestGetENList()
|
|
332 |
{
|
|
333 |
delete iRetrieve;
|
|
334 |
delete iCanceller;
|
|
335 |
}
|
|
336 |
|
|
337 |
void CTestEnStore::CTestGetENList::Start()
|
|
338 |
{
|
|
339 |
iRetrieve->Start(iStatus);
|
|
340 |
TRequestStatus tmpStatus;
|
|
341 |
iRetrieve->Start(tmpStatus);
|
|
342 |
User::WaitForRequest(tmpStatus);
|
|
343 |
iTestEnStore->TEST(tmpStatus.Int() == KErrInUse);
|
|
344 |
SetActive();
|
|
345 |
}
|
|
346 |
|
|
347 |
CTestCanceller* CTestEnStore::CTestGetENList::RetrieveCancelPtr()
|
|
348 |
{
|
|
349 |
return iCanceller;
|
|
350 |
}
|
|
351 |
|
|
352 |
void CTestEnStore::CTestGetENList::RunL()
|
|
353 |
{
|
|
354 |
TInt ret=iStatus.Int();
|
|
355 |
|
|
356 |
User::LeaveIfError(ret);
|
|
357 |
ret=CheckResults();
|
|
358 |
User::LeaveIfError(ret);
|
|
359 |
|
|
360 |
CActiveScheduler::Stop();
|
|
361 |
}
|
|
362 |
|
|
363 |
|
|
364 |
void CTestEnStore::CTestGetENList::DoCancel()
|
|
365 |
{
|
|
366 |
iRetrieve->Cancel();
|
|
367 |
}
|
|
368 |
|
|
369 |
|
|
370 |
TInt CTestEnStore::CTestGetENList::CheckResults()
|
|
371 |
{
|
|
372 |
TInt ret=KErrNone;
|
|
373 |
|
|
374 |
CMobilePhoneENList* enList=NULL;
|
|
375 |
TInt leaveCode=KErrNone;
|
|
376 |
TRAP(leaveCode, enList=iRetrieve->RetrieveListL(););
|
|
377 |
|
|
378 |
if (enList)
|
|
379 |
{
|
|
380 |
iTestEnStore->TEST(enList->Enumerate()==DMMTSY_EN_STORE_COUNT);
|
|
381 |
|
|
382 |
// Get each detected network entry
|
|
383 |
RMobileENStore::TMobileENEntryV1 entry;
|
|
384 |
|
|
385 |
for (TInt i=0; i<DMMTSY_EN_STORE_COUNT; ++i)
|
|
386 |
{
|
|
387 |
TRAP(ret,entry=enList->GetEntryL(i));
|
|
388 |
if (ret != KErrNone)
|
|
389 |
break;
|
|
390 |
switch(i)
|
|
391 |
{
|
|
392 |
case 0:
|
|
393 |
{
|
|
394 |
iTestEnStore->ValidateENEntry(entry);
|
|
395 |
iTestEnStore->TEST(entry.iIndex==DMMTSY_EN_STORE_INDEX1);
|
|
396 |
break;
|
|
397 |
}
|
|
398 |
case 1:
|
|
399 |
{
|
|
400 |
iTestEnStore->ValidateENEntry(entry);
|
|
401 |
iTestEnStore->TEST(entry.iIndex==DMMTSY_EN_STORE_INDEX2);
|
|
402 |
break;
|
|
403 |
}
|
|
404 |
default:
|
|
405 |
break;
|
|
406 |
}
|
|
407 |
}
|
|
408 |
// now free-up enList
|
|
409 |
delete enList;
|
|
410 |
}
|
|
411 |
|
|
412 |
return ret;
|
|
413 |
}
|