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_mmphonebookstore.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestPhonebookStore::CTestPhonebookStore()
|
|
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("TestPhonebookStore"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestPhonebookStore::doTestStepL()
|
|
32 |
//
|
|
33 |
// Test Phonebook Functions
|
|
34 |
//
|
|
35 |
{
|
|
36 |
iTestCount=1;
|
|
37 |
INFO_PRINTF1(_L(""));
|
|
38 |
INFO_PRINTF1(_L("Test Mobile Phone Book Number Storage Functionality"));
|
|
39 |
|
|
40 |
RMobilePhone mmPhone;
|
|
41 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
42 |
TEST(ret==KErrNone);
|
|
43 |
|
|
44 |
RMobilePhoneBookStore phoneBookStore;
|
|
45 |
ret=phoneBookStore.Open(mmPhone,DMMTSY_PHONEBOOK_STORE_NAME);
|
|
46 |
TEST(ret==KErrNone);
|
|
47 |
phoneBookStore.Close();
|
|
48 |
|
|
49 |
//Test the overloaded method also.
|
|
50 |
ret=phoneBookStore.Open(mmPhone,DMMTSY_PHONEBOOK_STORE_NAME, DMMTSY_PHONEBOOK_TYPE);
|
|
51 |
TEST(ret==KErrNone);
|
|
52 |
|
|
53 |
TRequestStatus reqStatus;
|
|
54 |
|
|
55 |
// Get Network store information
|
|
56 |
|
|
57 |
// asynchronous
|
|
58 |
|
|
59 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV1 asyncInfo;
|
|
60 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg asyncInfoPckg(asyncInfo);
|
|
61 |
phoneBookStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
62 |
User::WaitForRequest(reqStatus);
|
|
63 |
TEST(reqStatus.Int()==KErrNone);
|
|
64 |
ValidatePhoneBookInfo(asyncInfo);
|
|
65 |
|
|
66 |
// asynchronous & cancel
|
|
67 |
|
|
68 |
phoneBookStore.GetInfo(reqStatus, asyncInfoPckg);
|
|
69 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
|
|
70 |
User::WaitForRequest(reqStatus);
|
|
71 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
72 |
if (reqStatus.Int()==KErrCancel)
|
|
73 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
74 |
|
|
75 |
else
|
|
76 |
{
|
|
77 |
ValidatePhoneBookInfo(asyncInfo);
|
|
78 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
79 |
}
|
|
80 |
|
|
81 |
// asynchronous
|
|
82 |
|
|
83 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV2 asyncV2Info;
|
|
84 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV2Pckg asyncV2InfoPckg(asyncV2Info);
|
|
85 |
phoneBookStore.GetInfo(reqStatus, asyncV2InfoPckg);
|
|
86 |
User::WaitForRequest(reqStatus);
|
|
87 |
TEST(reqStatus.Int()==KErrNone);
|
|
88 |
ValidatePhoneBookInfo(asyncV2Info);
|
|
89 |
|
|
90 |
// asynchronous & cancel
|
|
91 |
|
|
92 |
phoneBookStore.GetInfo(reqStatus, asyncV2InfoPckg);
|
|
93 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
|
|
94 |
User::WaitForRequest(reqStatus);
|
|
95 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
96 |
if (reqStatus.Int()==KErrCancel)
|
|
97 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo V2Table (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
98 |
|
|
99 |
else
|
|
100 |
{
|
|
101 |
ValidatePhoneBookInfo(asyncV2Info);
|
|
102 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo V2Table (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
103 |
}
|
|
104 |
|
|
105 |
// asynchronous V5
|
|
106 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV5 asyncV5Info;
|
|
107 |
RMobilePhoneBookStore::TMobilePhoneBookInfoV5Pckg asyncV5InfoPckg(asyncV5Info);
|
|
108 |
phoneBookStore.GetInfo(reqStatus, asyncV5InfoPckg);
|
|
109 |
User::WaitForRequest(reqStatus);
|
|
110 |
TEST(reqStatus.Int()==KErrNone);
|
|
111 |
ValidatePhoneBookInfo(asyncV5Info);
|
|
112 |
|
|
113 |
// asynchronous V5 & cancel
|
|
114 |
phoneBookStore.GetInfo(reqStatus, asyncV5InfoPckg);
|
|
115 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneStoreGetInfo);
|
|
116 |
User::WaitForRequest(reqStatus);
|
|
117 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
118 |
if (reqStatus.Int()==KErrCancel)
|
|
119 |
{
|
|
120 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo V5Info (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
121 |
}
|
|
122 |
|
|
123 |
else
|
|
124 |
{
|
|
125 |
ValidatePhoneBookInfo(asyncV5Info);
|
|
126 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::GetInfo V5Info (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
127 |
}
|
|
128 |
|
|
129 |
// test.Next(_L("OK: RMobilePhoneBookStore's Get Info"));
|
|
130 |
|
|
131 |
// Read one entry
|
|
132 |
|
|
133 |
// asynchronous
|
|
134 |
|
|
135 |
TMobilePhoneBookData aPBData;
|
|
136 |
TInt index(DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
137 |
TInt numOfEntries(DMMTSY_PHONE_ONE_ENTRY);
|
|
138 |
|
|
139 |
phoneBookStore.Read(reqStatus,index,numOfEntries,aPBData);
|
|
140 |
User::WaitForRequest(reqStatus);
|
|
141 |
TEST(reqStatus.Int()==KErrNone);
|
|
142 |
|
|
143 |
ValidatePhoneBookRead(index,numOfEntries,aPBData);
|
|
144 |
|
|
145 |
// cancel
|
|
146 |
phoneBookStore.Read(reqStatus,index,numOfEntries,aPBData);
|
|
147 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneBookStoreRead);
|
|
148 |
User::WaitForRequest(reqStatus);
|
|
149 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
150 |
if (reqStatus.Int()==KErrCancel)
|
|
151 |
{
|
|
152 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Read (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
153 |
}
|
|
154 |
else
|
|
155 |
{
|
|
156 |
ValidatePhoneBookRead(index,numOfEntries,aPBData);
|
|
157 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Read (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
158 |
}
|
|
159 |
|
|
160 |
// test.Next(_L("OK: RMobilePhoneBookStore's Read Entry"));
|
|
161 |
|
|
162 |
// Write one entry
|
|
163 |
|
|
164 |
TMobilePhoneBookData aPBData2;
|
|
165 |
|
|
166 |
InitPhoneBookEntry(numOfEntries,aPBData2);
|
|
167 |
|
|
168 |
// asynchronous
|
|
169 |
|
|
170 |
index = DMMTSY_PHONEBOOK_STORE_INDEX2;
|
|
171 |
numOfEntries = DMMTSY_PHONE_ONE_ENTRY;
|
|
172 |
|
|
173 |
phoneBookStore.Write(reqStatus, aPBData2, index);
|
|
174 |
User::WaitForRequest(reqStatus);
|
|
175 |
TEST(reqStatus.Int()==KErrNone);
|
|
176 |
TEST(index==DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
177 |
|
|
178 |
// aynchronous & cancel
|
|
179 |
|
|
180 |
index=DMMTSY_PHONEBOOK_STORE_INDEX2;
|
|
181 |
phoneBookStore.Write(reqStatus, aPBData2, index);
|
|
182 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneBookStoreWrite);
|
|
183 |
User::WaitForRequest(reqStatus);
|
|
184 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
185 |
|
|
186 |
if (reqStatus.Int()==KErrCancel)
|
|
187 |
{
|
|
188 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Write (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
189 |
}
|
|
190 |
else
|
|
191 |
{
|
|
192 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Write (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
193 |
}
|
|
194 |
|
|
195 |
// test.Next(_L("OK: RMobilePhoneBookStore's Write Entry"));
|
|
196 |
|
|
197 |
// Delete one entry
|
|
198 |
|
|
199 |
// asynchronous
|
|
200 |
|
|
201 |
phoneBookStore.Delete(reqStatus, DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
202 |
User::WaitForRequest(reqStatus);
|
|
203 |
TEST(reqStatus.Int()==KErrNone);
|
|
204 |
|
|
205 |
// cancel
|
|
206 |
|
|
207 |
phoneBookStore.Delete(reqStatus, DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
208 |
phoneBookStore.CancelAsyncRequest(EMobilePhoneStoreDelete);
|
|
209 |
User::WaitForRequest(reqStatus);
|
|
210 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
211 |
|
|
212 |
if (reqStatus.Int()==KErrCancel)
|
|
213 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Delete (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
214 |
else
|
|
215 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Delete (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
216 |
|
|
217 |
// Get a number of Phonebook entries
|
|
218 |
|
|
219 |
// asynchronous
|
|
220 |
|
|
221 |
TMobilePhoneBookData aPBMultipleData;
|
|
222 |
index = DMMTSY_PHONEBOOK_STORE_INDEX1; // Starting index
|
|
223 |
numOfEntries = DMMTSY_PHONE_NUM_OF_ENTRIES; // Number of entries to be read
|
|
224 |
|
|
225 |
phoneBookStore.Read(reqStatus, index, numOfEntries, aPBMultipleData);
|
|
226 |
User::WaitForRequest(reqStatus);
|
|
227 |
TEST(reqStatus.Int()==KErrNone);
|
|
228 |
|
|
229 |
if (reqStatus.Int()==KErrCancel)
|
|
230 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Read (batch) (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
231 |
else
|
|
232 |
{
|
|
233 |
ValidatePhoneBookMultipleRead(index, numOfEntries, aPBMultipleData);
|
|
234 |
INFO_PRINTF2(_L("Test %d - RMobilePhoneBookStore::Read (batch)(async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
235 |
}
|
|
236 |
|
|
237 |
phoneBookStore.Close();
|
|
238 |
mmPhone.Close();
|
|
239 |
INFO_PRINTF1(_L(""));
|
|
240 |
|
|
241 |
return TestStepResult();
|
|
242 |
}
|
|
243 |
|
|
244 |
void CTestPhonebookStore::ValidatePhoneBookInfo(const RMobilePhoneBookStore::TMobilePhoneBookInfoV1 &aInfo)
|
|
245 |
{
|
|
246 |
TEST(aInfo.iName.Compare(DMMTSY_PHONEBOOK_STORE_NAME) == 0);
|
|
247 |
TEST(aInfo.iType == DMMTSY_PHONEBOOK_STORE_TYPE);
|
|
248 |
TEST(aInfo.iTotalEntries == DMMTSY_PHONEBOOK_STORE_ENTRIES);
|
|
249 |
TEST(aInfo.iUsedEntries == DMMTSY_PHONEBOOK_STORE_USED);
|
|
250 |
TEST(aInfo.iCaps == DMMTSY_PHONEBOOK_STORE_CAPS);
|
|
251 |
TEST(aInfo.iMaxNumLength == DMMTSY_PHONEBOOK_MAXNL);
|
|
252 |
TEST(aInfo.iMaxTextLength == DMMTSY_PHONEBOOK_MAXTL);
|
|
253 |
TEST(aInfo.iLocation == DMMTSY_PHONEBOOK_LOCATION);
|
|
254 |
TEST(aInfo.iChangeCounter == DMMTSY_PHONEBOOK_CHANGECOUNT);
|
|
255 |
TEST(aInfo.iIdentity == DMMTSY_PHONEBOOK_IDENTITY);
|
|
256 |
TEST(aInfo.ExtensionId()==RMobilePhoneStore::KETelMobilePhonebookStoreV1);
|
|
257 |
}
|
|
258 |
|
|
259 |
void CTestPhonebookStore::ValidatePhoneBookInfo(const RMobilePhoneBookStore::TMobilePhoneBookInfoV2 &aInfo)
|
|
260 |
{
|
|
261 |
TEST(aInfo.iName.Compare(DMMTSY_PHONEBOOK_STORE_NAME) == 0);
|
|
262 |
TEST(aInfo.iType == DMMTSY_PHONEBOOK_STORE_TYPE);
|
|
263 |
TEST(aInfo.iTotalEntries == DMMTSY_PHONEBOOK_STORE_ENTRIES);
|
|
264 |
TEST(aInfo.iUsedEntries == DMMTSY_PHONEBOOK_STORE_USED);
|
|
265 |
TEST(aInfo.iCaps == DMMTSY_PHONEBOOK_STORE_CAPS);
|
|
266 |
TEST(aInfo.iMaxNumLength == DMMTSY_PHONEBOOK_MAXNL);
|
|
267 |
TEST(aInfo.iMaxTextLength == DMMTSY_PHONEBOOK_MAXTL);
|
|
268 |
TEST(aInfo.iLocation == DMMTSY_PHONEBOOK_LOCATION);
|
|
269 |
TEST(aInfo.iChangeCounter == DMMTSY_PHONEBOOK_CHANGECOUNT);
|
|
270 |
TEST(aInfo.iIdentity == DMMTSY_PHONEBOOK_IDENTITY);
|
|
271 |
TEST(aInfo.iPhBkMode.Compare(DMMTSY_PHONEBOOK_TYPE) == 0);
|
|
272 |
}
|
|
273 |
|
|
274 |
void CTestPhonebookStore::ValidatePhoneBookInfo(const RMobilePhoneBookStore::TMobilePhoneBookInfoV5 &aInfo)
|
|
275 |
{
|
|
276 |
TEST(aInfo.iName.Compare(DMMTSY_PHONEBOOK_STORE_NAME) == 0);
|
|
277 |
TEST(aInfo.iType == DMMTSY_PHONEBOOK_STORE_TYPE);
|
|
278 |
TEST(aInfo.iTotalEntries == DMMTSY_PHONEBOOK_STORE_ENTRIES);
|
|
279 |
TEST(aInfo.iUsedEntries == DMMTSY_PHONEBOOK_STORE_USED);
|
|
280 |
TEST(aInfo.iCaps == DMMTSY_PHONEBOOK_STORE_CAPS);
|
|
281 |
TEST(aInfo.iMaxNumLength == DMMTSY_PHONEBOOK_MAXNL);
|
|
282 |
TEST(aInfo.iMaxTextLength == DMMTSY_PHONEBOOK_MAXTL);
|
|
283 |
TEST(aInfo.iLocation == DMMTSY_PHONEBOOK_LOCATION);
|
|
284 |
TEST(aInfo.iChangeCounter == DMMTSY_PHONEBOOK_CHANGECOUNT);
|
|
285 |
TEST(aInfo.iIdentity == DMMTSY_PHONEBOOK_IDENTITY);
|
|
286 |
TEST(aInfo.iPhBkMode.Compare(DMMTSY_PHONEBOOK_TYPE) == 0);
|
|
287 |
TEST(aInfo.iMaxSecondNames == DMMTSY_PHONEBOOK_MAXSECONDNAMES);
|
|
288 |
TEST(aInfo.iMaxTextLengthSecondName == DMMTSY_PHONEBOOK_MAXTEXTLENSECONDNAME);
|
|
289 |
TEST(aInfo.iMaxAdditionalNumbers == DMMTSY_PHONEBOOK_MAXADDNUM);
|
|
290 |
TEST(aInfo.iMaxTextLengthAdditionalNumber == DMMTSY_PHONEBOOK_MAXTEXTLENADDNUM);
|
|
291 |
TEST(aInfo.iMaxNumLengthAdditionalNumber == DMMTSY_PHONEBOOK_MAXNUMLENADDNUM);
|
|
292 |
TEST(aInfo.iMaxGroupNames == DMMTSY_PHONEBOOK_MAXGROUPNAMES);
|
|
293 |
TEST(aInfo.iMaxTextLengthGroupName == DMMTSY_PHONEBOOK_MAXTEXTLENGROUPNAME);
|
|
294 |
TEST(aInfo.iMaxEmailAddr == DMMTSY_PHONEBOOK_MAXEMAILADDR);
|
|
295 |
TEST(aInfo.iMaxTextLengthEmailAddr == DMMTSY_PHONEBOOK_MAXTEXTLENEMAILADDR);
|
|
296 |
}
|
|
297 |
|
|
298 |
void CTestPhonebookStore::ValidatePhoneBookRead(const TInt aIndex, const TInt aNumEntries, const TMobilePhoneBookData &aPBData)
|
|
299 |
{
|
|
300 |
TEST(aIndex == DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
301 |
TEST(aNumEntries == DMMTSY_PHONE_ONE_ENTRY);
|
|
302 |
TEST(aPBData.Compare(DMMTSY_PHONE_BOOK_DATA1) == 0);
|
|
303 |
}
|
|
304 |
|
|
305 |
void CTestPhonebookStore::InitPhoneBookEntry(TInt &aNumOfEntries, TMobilePhoneBookData &aPBData)
|
|
306 |
{
|
|
307 |
aNumOfEntries = DMMTSY_PHONE_ONE_ENTRY;
|
|
308 |
aPBData = DMMTSY_PHONE_BOOK_DATA2;
|
|
309 |
}
|
|
310 |
|
|
311 |
void CTestPhonebookStore::ValidatePhoneBookMultipleRead(const TInt aIndex, const TInt aNumEntries, const TMobilePhoneBookData &aPBData)
|
|
312 |
{
|
|
313 |
TEST(aIndex == DMMTSY_PHONEBOOK_STORE_INDEX1);
|
|
314 |
TEST(aNumEntries == DMMTSY_PHONE_NUM_OF_ENTRIES);
|
|
315 |
TEST(aPBData.Compare(DMMTSY_PHONE_BOOK_MULTIPLE_DATA) == 0);
|
|
316 |
}
|
|
317 |
|
|
318 |
|
|
319 |
|