|
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 // This file implements simple SMS Storage Delete tests. |
|
15 // See CDataCall.cpp for fully documented test scenario. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 |
|
23 #include <e32test.h> |
|
24 #include <mmretrieve.h> |
|
25 #include <etelmm.h> |
|
26 #include "Te_LoopBackCSmsdelete.h" |
|
27 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint |
|
28 |
|
29 |
|
30 #define DMMTSY_SMS_MESSAGE_PDU2 _L8("22221234567899876543212222") |
|
31 #define DMMTSY_SMS_STORE_INDEX2 (45) |
|
32 // |
|
33 // Test-side class |
|
34 // With the assistance of the base class, this class must start the emulator |
|
35 // and drive the ETel API. |
|
36 // |
|
37 CTestDriveSmsDelete* CTestDriveSmsDelete::NewL(const TScriptList aScriptListEntry) |
|
38 { |
|
39 CTestDriveSmsDelete* aA = new (ELeave) CTestDriveSmsDelete(aScriptListEntry); |
|
40 CleanupStack::PushL(aA); |
|
41 aA->ConstructL(); |
|
42 CleanupStack::Pop(); |
|
43 return (aA); |
|
44 } |
|
45 |
|
46 CTestDriveSmsDelete::CTestDriveSmsDelete(const TScriptList aScriptListEntry) : |
|
47 iScriptListEntry(aScriptListEntry) |
|
48 {} |
|
49 |
|
50 CTestDriveSmsDelete::~CTestDriveSmsDelete() |
|
51 {} |
|
52 |
|
53 TInt CTestDriveSmsDelete::RunTestL() |
|
54 { |
|
55 iCurrentScript = iScriptListEntry; |
|
56 return StartEmulatorL(); |
|
57 } |
|
58 |
|
59 TInt CTestDriveSmsDelete::DriveETelApiL() |
|
60 // |
|
61 // This function contains the real meat of the Client-side test code |
|
62 // |
|
63 { |
|
64 RMobileSmsMessaging sms; |
|
65 RMobileSmsStore smsSimStore; |
|
66 |
|
67 INFO_PRINTF1(_L("Initialising the Phone...\n")); |
|
68 TRequestStatus reqStatus; |
|
69 |
|
70 RMobilePhone::TMMTableSettings tableSettings; |
|
71 tableSettings.iLocId=KInternetAccessPoint; |
|
72 RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings); |
|
73 iPhone.InitialiseMM(reqStatus, tableSettingsPckg); |
|
74 |
|
75 User::WaitForRequest(reqStatus); |
|
76 TESTL(reqStatus == KErrNone); |
|
77 |
|
78 INFO_PRINTF1(_L("Opening SMS Messaging...\n")); |
|
79 TESTL(sms.Open(iPhone) == KErrNone); |
|
80 |
|
81 INFO_PRINTF1(_L("Opening SMS SIM Storage...\n")); |
|
82 TESTL(smsSimStore.Open(sms, KETelCombinedSmsStore) == KErrNone); |
|
83 |
|
84 TestSmsDeleteL(smsSimStore); |
|
85 |
|
86 INFO_PRINTF1(_L("End of Sms Delete tests\n")); |
|
87 |
|
88 smsSimStore.Close(); |
|
89 sms.Close(); |
|
90 |
|
91 return (KErrNone); |
|
92 } |
|
93 |
|
94 |
|
95 void CTestDriveSmsDelete::TestSmsDeleteL(RMobileSmsStore& aSmsSimStore) |
|
96 { |
|
97 |
|
98 // Get SMS store information |
|
99 TRequestStatus Status1,Status2; |
|
100 RMobilePhoneStore::TMobilePhoneStoreInfoV1 asyncInfo; |
|
101 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg asyncInfoPckg(asyncInfo); |
|
102 |
|
103 // asynchronous |
|
104 INFO_PRINTF1(_L("Mobile Phone SMS Store Info\n")); |
|
105 aSmsSimStore.GetInfo(Status1, asyncInfoPckg); |
|
106 User::WaitForRequest(Status1); |
|
107 INFO_PRINTF2(_L("SMS GetInfo Status before Write = %d\n "),Status1.Int()); |
|
108 |
|
109 if(Status1==KErrNone) |
|
110 { |
|
111 INFO_PRINTF1(_L("Mobile Phone SMS Store Info Before Write\n")); |
|
112 asyncInfo=asyncInfoPckg(); |
|
113 DisplayPhoneStoreInfo(asyncInfo); |
|
114 } |
|
115 |
|
116 INFO_PRINTF1(_L("Mobile Phone SMS Store Write\n")); |
|
117 |
|
118 RMobileSmsStore::TMobileGsmSmsEntryV1 entry1; |
|
119 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg entry1Pckg(entry1); |
|
120 entry1.iMsgData = DMMTSY_SMS_MESSAGE_PDU2; |
|
121 |
|
122 aSmsSimStore.Write(Status2, entry1Pckg); |
|
123 |
|
124 User::WaitForRequest(Status2); |
|
125 TESTL(Status2==KErrNone); |
|
126 INFO_PRINTF2(_L("SMS Write Status = %d\n "),Status2.Int()); |
|
127 |
|
128 aSmsSimStore.GetInfo(Status1, asyncInfoPckg); |
|
129 User::WaitForRequest(Status1); |
|
130 |
|
131 |
|
132 INFO_PRINTF2(_L("SMS GetInfo Status After Write = %d\n "),Status1.Int()); |
|
133 |
|
134 if(Status1==KErrNone) |
|
135 { |
|
136 INFO_PRINTF1(_L("Mobile Phone SMS Store Info After Write\n")); |
|
137 asyncInfo=asyncInfoPckg(); |
|
138 DisplayPhoneStoreInfo(asyncInfo); |
|
139 } |
|
140 |
|
141 INFO_PRINTF1(_L("SMS Delete - \n ")); |
|
142 aSmsSimStore.Delete(Status2,1); |
|
143 User::WaitForRequest(Status2); |
|
144 TESTL(Status2==KErrNone); |
|
145 INFO_PRINTF2(_L("SMS Delete Status = %d\n "),Status2.Int()); |
|
146 |
|
147 INFO_PRINTF1(_L("Mobile Phone SMS Store Info After Delete\n")); |
|
148 |
|
149 aSmsSimStore.GetInfo(Status1, asyncInfoPckg); |
|
150 User::WaitForRequest(Status1); |
|
151 INFO_PRINTF2(_L("SMS GetInfo Status After delete = %d\n "),Status1.Int()); |
|
152 |
|
153 if(Status1==KErrNone) |
|
154 { |
|
155 INFO_PRINTF1(_L("Mobile Phone SMS Store Info After Write\n")); |
|
156 asyncInfo=asyncInfoPckg(); |
|
157 DisplayPhoneStoreInfo(asyncInfo); |
|
158 } |
|
159 |
|
160 |
|
161 } |
|
162 |
|
163 |
|
164 void CTestDriveSmsDelete::DisplayPhoneStoreInfo(RMobilePhoneStore::TMobilePhoneStoreInfoV1& aStoreInfo) |
|
165 { |
|
166 INFO_PRINTF1(_L("Mobile Phone Store Info:\n")); |
|
167 INFO_PRINTF2(_L(" Name = %S\n"), &aStoreInfo.iName);\ |
|
168 |
|
169 switch (aStoreInfo.iType) |
|
170 { |
|
171 case RMobilePhoneStore::EPhoneStoreTypeUnknown: |
|
172 INFO_PRINTF1(_L(" Type = Unknown\n")); |
|
173 break; |
|
174 case RMobilePhoneStore::EShortMessageStore: |
|
175 INFO_PRINTF1(_L(" Type = Short Message\n")); |
|
176 break; |
|
177 case RMobilePhoneStore::ENamStore: |
|
178 INFO_PRINTF1(_L(" Type = NAM\n")); |
|
179 break; |
|
180 case RMobilePhoneStore::EPhoneBookStore: |
|
181 INFO_PRINTF1(_L(" Type = Phonebook\n")); |
|
182 break; |
|
183 case RMobilePhoneStore::EEmergencyNumberStore: |
|
184 INFO_PRINTF1(_L(" Type = Emergency Number\n")); |
|
185 break; |
|
186 case RMobilePhoneStore::EOwnNumberStore: |
|
187 INFO_PRINTF1(_L(" Type = Own Number\n")); |
|
188 break; |
|
189 default: |
|
190 INFO_PRINTF2(_L(" Type = %d\n"), aStoreInfo.iType); |
|
191 break; |
|
192 } |
|
193 |
|
194 INFO_PRINTF2(_L(" Total Entries = %d\n"), aStoreInfo.iTotalEntries); |
|
195 INFO_PRINTF2(_L(" Used Entries = %d\n"), aStoreInfo.iUsedEntries); |
|
196 |
|
197 |
|
198 // display the caps for the base class RMobilePhoneStore |
|
199 INFO_PRINTF2(_L(" SMS Store Capabilities = 0x%x\n"), aStoreInfo.iCaps); |
|
200 INFO_PRINTF1(_L(" Phone Store Capabilities:\n")); |
|
201 if (aStoreInfo.iCaps & static_cast<TUint32>(RMobilePhoneStore::KCapsWholeStore)) |
|
202 INFO_PRINTF1(_L(" Whole Store Supported\n")); |
|
203 if (aStoreInfo.iCaps & RMobilePhoneStore::KCapsIndividualEntry) |
|
204 INFO_PRINTF1(_L(" Individual Entry Supported\n")); |
|
205 if (aStoreInfo.iCaps & RMobilePhoneStore::KCapsReadAccess) |
|
206 INFO_PRINTF1(_L(" Read Access Supported\n")); |
|
207 if (aStoreInfo.iCaps & RMobilePhoneStore::KCapsWriteAccess) |
|
208 INFO_PRINTF1(_L(" Write Access Supported\n")); |
|
209 if (aStoreInfo.iCaps & RMobilePhoneStore::KCapsDeleteAll) |
|
210 INFO_PRINTF1(_L(" Delete All Supported\n")); |
|
211 if (aStoreInfo.iCaps & RMobilePhoneStore::KCapsNotifyEvent) |
|
212 INFO_PRINTF1(_L(" Notify Event Supported\n")); |
|
213 |
|
214 // display the caps for the derived class RMobileSmsStore |
|
215 // these caps use the same variable as the base class |
|
216 INFO_PRINTF1(_L(" SMS Store Capabilities:\n")); |
|
217 if (aStoreInfo.iCaps & RMobileSmsStore::KCapsUnreadMessages) |
|
218 INFO_PRINTF1(_L(" Unread Messages Supported\n")); |
|
219 if (aStoreInfo.iCaps & RMobileSmsStore::KCapsReadMessages) |
|
220 INFO_PRINTF1(_L(" Read Messages Supported\n")); |
|
221 if (aStoreInfo.iCaps & RMobileSmsStore::KCapsSentMessages) |
|
222 INFO_PRINTF1(_L(" Sent Messages Supported\n")); |
|
223 if (aStoreInfo.iCaps & RMobileSmsStore::KCapsUnsentMessages) |
|
224 INFO_PRINTF1(_L(" Unsent Messages Supported\n")); |
|
225 if (aStoreInfo.iCaps & RMobileSmsStore::KCapsGsmMessages) |
|
226 INFO_PRINTF1(_L(" GSM Messages Supported\n")); |
|
227 |
|
228 } |
|
229 |
|
230 |
|
231 // |
|
232 // Emulator-side class |
|
233 // With the assistance of the base class, this class must run the designated script |
|
234 // |
|
235 CTestSmsDelMess* CTestSmsDelMess::NewL(const TScript* aScript) |
|
236 { |
|
237 CTestSmsDelMess* aA = new (ELeave) CTestSmsDelMess(aScript); |
|
238 CleanupStack::PushL(aA); |
|
239 aA->ConstructL(); |
|
240 CleanupStack::Pop(); |
|
241 return (aA); |
|
242 } |
|
243 |
|
244 CTestSmsDelMess::CTestSmsDelMess(const TScript* aScript) : |
|
245 iScript(aScript) |
|
246 {} |
|
247 |
|
248 void CTestSmsDelMess::ConstructL() |
|
249 { |
|
250 CATScriptEng::ConstructL(); |
|
251 } |
|
252 |
|
253 CTestSmsDelMess::~CTestSmsDelMess() |
|
254 {} |
|
255 |
|
256 TInt CTestSmsDelMess::Start() |
|
257 { |
|
258 StartScript(iScript); |
|
259 return (KErrNone); |
|
260 } |
|
261 |
|
262 void CTestSmsDelMess::SpecificAlgorithmL(TInt /* aParam */) |
|
263 { |
|
264 } |
|
265 |
|
266 void CTestSmsDelMess::Complete(TInt aError) |
|
267 { |
|
268 iReturnValue = aError; |
|
269 CActiveScheduler::Stop(); |
|
270 } |