15 |
15 |
16 /** |
16 /** |
17 @file |
17 @file |
18 */ |
18 */ |
19 |
19 |
|
20 #include "TE_SMSEMSPRTBASE.h" |
|
21 |
20 #include <commsdattypesv1_1.h> |
22 #include <commsdattypesv1_1.h> |
21 #include "metadatabase.h" |
23 #include <sacls.h> |
|
24 #include <metadatabase.h> |
22 |
25 |
23 #include "TE_SMSEMSPRTBASE.h" |
26 #include "smsstacktestconsts.h" |
24 #include <sacls.h> |
|
25 |
|
26 #if defined (__WINS__) |
|
27 #define PDD_NAME _L("ECDRV") |
|
28 #define PDD_NAME2 _L("ECDRV") |
|
29 #define LDD_NAME _L("ECOMM") |
|
30 #else |
|
31 #define PDD_NAME _L("EUART1") |
|
32 #define LDD_NAME _L("ECOMM") |
|
33 #endif |
|
34 |
27 |
35 using namespace CommsDat; |
28 using namespace CommsDat; |
36 |
29 |
37 CSmsMessage* CSmsEmsPrtTestStep::ConfigCreateSmsMessageLC(const TDesC& aDes, |
|
38 TSmsDataCodingScheme::TSmsAlphabet aAlphabet) |
|
39 { |
|
40 _LIT(KRadiolinjaSC,"+358508771010"); // Radiolinja SC |
|
41 _LIT(KPekka,"+358408415528"); // Pekka's telephone number |
|
42 |
|
43 // Set destination and SC numbers |
|
44 iTelephoneNumber=KPekka; |
|
45 iServiceCenterNumber=KRadiolinjaSC; |
|
46 |
|
47 CSmsMessage* smsMessage = CreateSmsMessageL(aDes, aAlphabet); |
|
48 CleanupStack::PushL(smsMessage); |
|
49 return smsMessage; |
|
50 } |
|
51 |
|
52 CSmsMessage* CSmsEmsPrtTestStep::CreateSmsMessageL(const TDesC& aDes, TSmsDataCodingScheme::TSmsAlphabet aAlphabet, CSmsPDU::TSmsPDUType aType) |
|
53 /** |
|
54 * Create a uninitialised SMS message |
|
55 * @param aDes contains text that will be inserted to the pdu |
|
56 * @param aAlphabet describes the alphabet of the pdu |
|
57 * @return CSmsMessage* :Pointer to the created CSmsMessage object. |
|
58 */ |
|
59 { |
|
60 CSmsBuffer* buffer=CSmsBuffer::NewL(); |
|
61 CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, aType, buffer); |
|
62 CleanupStack::PushL(smsMessage); |
|
63 |
|
64 TSmsUserDataSettings smsSettings; |
|
65 smsSettings.SetAlphabet(aAlphabet); |
|
66 smsSettings.SetTextCompressed(EFalse); |
|
67 smsMessage->SetUserDataSettingsL(smsSettings); |
|
68 |
|
69 smsMessage->SetToFromAddressL(iTelephoneNumber); |
|
70 smsMessage->SmsPDU().SetServiceCenterAddressL(iServiceCenterNumber); |
|
71 buffer->InsertL(0,aDes); |
|
72 CleanupStack::Pop(smsMessage); |
|
73 return smsMessage; |
|
74 } |
|
75 |
|
76 TBool CSmsEmsPrtTestStep::SendReceiveMsgL(CSmsMessage& aMsg) |
|
77 { |
|
78 // Send SMS |
|
79 SendSmsL(&aMsg,iSocket); |
|
80 |
|
81 CSmsMessage* rxMsg; |
|
82 |
|
83 // Now receive and compare |
|
84 INFO_PRINTF1(_L("waiting for incoming SMS...") ); |
|
85 WaitForRecvL(iSocket); |
|
86 rxMsg = RecvSmsL(iSocket); |
|
87 |
|
88 CleanupStack::PushL(rxMsg); |
|
89 TBool comp = EmsTestUtils::CompareEmsMsgL(aMsg, *rxMsg); |
|
90 TEST(comp); |
|
91 |
|
92 // compare OK |
|
93 INFO_PRINTF1(_L("Sent and received PDUs compare OK...")); |
|
94 |
|
95 // Now make sure the received message is valid - this can be |
|
96 // tested by ensuring that NumMessagePDUsL can be called without |
|
97 // leaving |
|
98 rxMsg->NumMessagePDUsL(); |
|
99 |
|
100 CleanupStack::PopAndDestroy(rxMsg); |
|
101 |
|
102 // return the result of the comparison |
|
103 return comp; |
|
104 } |
|
105 |
|
106 void CSmsEmsPrtTestStep::SendSmsL(const CSmsMessage* aSms, RSocket& aSocket) |
|
107 /** |
|
108 * Stream aSms out to the socket server |
|
109 * @param aSms contains the sms tpdu that will be streamed to the sms stack |
|
110 * @param aSocket is used to stream the aSms to the sms stack |
|
111 * @leave Leaves if streaming the message to the socket server doesn't succeed |
|
112 * @leave Leaves if sending is completed with error code |
|
113 */ |
|
114 { |
|
115 TBool tryAgain = ETrue; |
|
116 TInt sendTry (0); |
|
117 TRequestStatus status = KErrNone; |
|
118 |
|
119 while (tryAgain && sendTry < 3) |
|
120 { |
|
121 RSmsSocketWriteStream writestream(aSocket); |
|
122 TRAPD(ret,writestream << *aSms); |
|
123 |
|
124 TRAP(ret,writestream.CommitL()); |
|
125 |
|
126 TPckgBuf<TUint> sbuf; |
|
127 aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv); |
|
128 User::WaitForRequest(status); |
|
129 INFO_PRINTF2(_L("SendSmsL - sendSmsMessage returned %d"),status.Int()); |
|
130 if (status.Int() ) |
|
131 { |
|
132 tryAgain = ETrue; |
|
133 INFO_PRINTF1(_L("Try again... ")); |
|
134 sendTry++; |
|
135 } |
|
136 else tryAgain = EFalse; |
|
137 } |
|
138 |
|
139 TEST(status.Int() == KErrNone); |
|
140 |
|
141 PrintMessageL(aSms); |
|
142 } |
|
143 |
|
144 void CSmsEmsPrtTestStep::PrintMessageL(const CSmsMessage* aSms) |
|
145 /** |
|
146 * Print the content of SMS to the console |
|
147 */ |
|
148 { |
|
149 CSmsBuffer& smsbuffer = (CSmsBuffer&)aSms->Buffer(); |
|
150 const TInt len = smsbuffer.Length(); |
|
151 HBufC* hbuf = HBufC::NewL(len); |
|
152 TPtr ptr = hbuf->Des(); |
|
153 smsbuffer.Extract(ptr,0,len); |
|
154 INFO_PRINTF1(_L("SMS contains...")); |
|
155 |
|
156 for (TInt j = 0; j < len; j++) |
|
157 ptr[j]=IsCharDisplayable((TText8)ptr[j]); |
|
158 |
|
159 |
|
160 INFO_PRINTF1(ptr); |
|
161 INFO_PRINTF1(_L("")); |
|
162 |
|
163 delete hbuf; |
|
164 } |
|
165 |
|
166 TText8 CSmsEmsPrtTestStep::IsCharDisplayable( const TText8 aChar ) |
|
167 { |
|
168 if(( aChar >= 0x20) && (aChar <= 0x80)) |
|
169 return aChar; |
|
170 else |
|
171 return '.'; |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 void CSmsEmsPrtTestStep::WaitForRecvL(RSocket& aSocket) |
|
177 /** |
|
178 * Wait for an Sms to be received |
|
179 * @param aSocket The status is return to this socket |
|
180 * @leave Leaves if receiving is completed with error code |
|
181 */ |
|
182 { |
|
183 TPckgBuf<TUint> sbuf; |
|
184 sbuf()=KSockSelectRead; |
|
185 TRequestStatus status; |
|
186 aSocket.Ioctl(KIOctlSelect,status,&sbuf,KSOLSocket); |
|
187 User::WaitForRequest(status); |
|
188 TEST(status.Int() == KErrNone); |
|
189 } |
|
190 |
|
191 CSmsMessage* CSmsEmsPrtTestStep::RecvSmsL(RSocket& aSocket, TInt aIoctl) |
|
192 /** |
|
193 * Receive an Sms |
|
194 * @param aSocket is used to stream the sms message from the socket server |
|
195 * @return CSmsMessage* :Sms message from Sms stack |
|
196 * @leave Leaves if streaming the message from the socket server doesn't succeed |
|
197 */ |
|
198 { |
|
199 CSmsBuffer* buffer=CSmsBuffer::NewL(); |
|
200 CSmsMessage* smsMessage=CSmsMessage::NewL(iFs, CSmsPDU::ESmsSubmit,buffer); |
|
201 CleanupStack::PushL(smsMessage); |
|
202 |
|
203 RSmsSocketReadStream readstream(aSocket); |
|
204 TRAPD(ret,readstream >> *smsMessage); |
|
205 TEST(ret == KErrNone); |
|
206 |
|
207 TPckgBuf<TUint> sbuf; |
|
208 TRequestStatus status; |
|
209 aSocket.Ioctl(aIoctl, status, &sbuf, KSolSmsProv); |
|
210 User::WaitForRequest(status); |
|
211 |
|
212 CleanupStack::Pop(smsMessage); |
|
213 return smsMessage; |
|
214 } |
|
215 |
|
216 void CSmsEmsPrtTestStep::PrepareRegTestL() |
|
217 /** |
|
218 * Run a specified test. |
|
219 * The test number is passed via property KUidPSSimTsyCategory. This will notify the SIM tsy |
|
220 * SIM tsy uses test number to parse correct script from config.txt |
|
221 * @param aTestNumber The test number corresponding the test case |
|
222 */ |
|
223 { |
|
224 RProperty testNumberProperty; |
|
225 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
226 CleanupClosePushL(testNumberProperty); |
|
227 |
|
228 TRequestStatus status; |
|
229 testNumberProperty.Subscribe(status); |
|
230 TInt testNumber = GetTestNumber(); |
|
231 User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNumber)); |
|
232 User::WaitForRequest(status); |
|
233 TEST(status.Int() == KErrNone); |
|
234 TInt testNumberCheck; |
|
235 User::LeaveIfError(testNumberProperty.Get(testNumberCheck)); |
|
236 if (testNumber != testNumberCheck) |
|
237 User::Leave(KErrNotFound); |
|
238 |
|
239 CleanupStack::PopAndDestroy(&testNumberProperty); |
|
240 |
|
241 INFO_PRINTF1(_L("Connecting to SocketServer ...")); |
|
242 TInt ret=iSocketServ.Connect(KSocketMessageSlots); |
|
243 TEST(ret == KErrNone); |
|
244 |
|
245 INFO_PRINTF1(_L("Deleting segmentation and reassembly stores...")); |
|
246 |
|
247 // delete segmentation and reassembly store files before the test |
|
248 _LIT(KReassemblyStoreName,"C:\\Private\\101F7989\\sms\\smsreast.dat"); |
|
249 _LIT(KSegmentationStoreName,"C:\\Private\\101F7989\\sms\\smssegst.dat"); |
|
250 |
|
251 iFs.Delete(KReassemblyStoreName); |
|
252 iFs.Delete(KSegmentationStoreName); |
|
253 } |
|
254 |
|
255 void CSmsEmsPrtTestStep::EndRegTest() |
|
256 /** |
|
257 * Closes objects used at test harness |
|
258 */ |
|
259 { |
|
260 INFO_PRINTF1(_L("Closing Reg Test")); |
|
261 User::After(2000000); //Wait a couple of seconds to avoid closing the SMS stack too early |
|
262 iSocketServ.Close(); |
|
263 User::After(2000000); //Wait a couple of seconds to avoid closing the SMS stack too early |
|
264 } |
|
265 |
|
266 TVerdict CSmsEmsPrtTestStep::doTestStepPreambleL() |
30 TVerdict CSmsEmsPrtTestStep::doTestStepPreambleL() |
267 { |
31 { |
268 __UHEAP_MARK; |
32 //base class preamble - marks the heap |
|
33 CSmsBaseTestStep::doTestStepPreambleL(); |
|
34 |
|
35 iSmsStackTestUtils->OpenSmsSocketL(iSocketServer, iSocket, ESmsAddrRecvAny); |
269 |
36 |
270 User::LeaveIfError(iFs.Connect()); |
37 // Set destination and SC numbers |
271 |
38 iTelephoneNumber=KPekka; |
272 TRAPD(ret, ParseSettingsFromFileL()); |
39 iServiceCenterNumber=KRadiolinjaSC; |
273 if (ret != KErrNone) |
|
274 INFO_PRINTF2(_L("ParseSettingsFromFileL [err=%d]"), ret); |
|
275 |
|
276 iSmsStackTestUtils = CSmsStackTestUtils::NewL(this, iFs); |
|
277 |
|
278 PrepareRegTestL() ; |
|
279 |
|
280 iSmsStackTestUtils->OpenSmsSocketL(iSocketServ, iSocket, ESmsAddrRecvAny); |
|
281 |
|
282 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
283 CMDBSession* db = CMDBSession::NewL(KCDVersion1_2); |
|
284 #else |
|
285 CMDBSession* db = CMDBSession::NewL(KCDVersion1_1); |
|
286 #endif |
|
287 CleanupStack::PushL(db); |
|
288 |
|
289 CMDBField<TUint32>* smsReceiveModeField = new(ELeave) CMDBField<TUint32>(KCDTIdSMSReceiveMode); |
|
290 CleanupStack::PushL(smsReceiveModeField); |
|
291 *smsReceiveModeField = RMobileSmsMessaging::EReceiveUnstoredClientAck; |
|
292 smsReceiveModeField->SetRecordId(1); //it's GlobalSettingsRecord |
|
293 smsReceiveModeField->ModifyL(*db); |
|
294 |
|
295 CleanupStack::PopAndDestroy(smsReceiveModeField); |
|
296 CleanupStack::PopAndDestroy(db); |
|
297 |
|
298 return TestStepResult(); |
40 return TestStepResult(); |
299 } |
41 } |
300 |
42 |
301 TVerdict CSmsEmsPrtTestStep::doTestStepPostambleL() |
43 TVerdict CSmsEmsPrtTestStep::doTestStepPostambleL() |
302 { |
44 { |
303 iSocket.Close(); |
45 iSocket.Close(); |
304 |
46 |
305 EndRegTest() ; |
47 //base class postamble - unmarks the heap |
306 |
48 CSmsBaseTestStep::doTestStepPostambleL(); |
307 delete iSmsStackTestUtils; |
|
308 iSmsStackTestUtils = NULL; |
|
309 |
|
310 iFs.Close(); |
|
311 |
|
312 __UHEAP_MARKEND; |
|
313 |
49 |
314 return TestStepResult(); |
50 return TestStepResult(); |
315 } |
51 } |
316 |
52 |
317 TInt CSmsEmsPrtTestStep::CommInit() |
53 TBool CSmsEmsPrtTestStep::SendReceiveMsgL(CSmsMessage& aMsg) |
318 { |
54 { |
319 RFs fs; |
55 // Send SMS |
320 TInt err=fs.Connect(); // make sure the FileServer is alive (only needed for WINS test code) |
56 SendSmsL(&aMsg,iSocket); |
321 fs.Close(); |
|
322 |
57 |
323 INFO_PRINTF1(_L("CommInit: Loading PDD ") ); |
58 CSmsMessage* rxMsg; |
324 INFO_PRINTF1(PDD_NAME); |
|
325 INFO_PRINTF1(_L("")); |
|
326 err=User::LoadPhysicalDevice(PDD_NAME); |
|
327 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
328 return(err); |
|
329 |
59 |
330 INFO_PRINTF1(_L("CommInit: Loading LDD ") ); |
60 // Now receive and compare |
331 INFO_PRINTF1(LDD_NAME); |
61 WaitForRecvL(iSocket); |
332 INFO_PRINTF1(_L("")); |
62 rxMsg = RecvSmsL(iSocket); |
333 err=User::LoadLogicalDevice(LDD_NAME ); |
|
334 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
335 return(err); |
|
336 |
63 |
337 INFO_PRINTF1(_L("CommInit: Starting C32 ") ); |
64 CleanupStack::PushL(rxMsg); |
|
65 TBool comp = EmsTestUtils::CompareEmsMsgL(aMsg, *rxMsg); |
|
66 TEST(comp); |
338 |
67 |
339 err = StartC32(); |
68 // compare OK |
340 return (err == KErrNone || err == KErrAlreadyExists) ? KErrNone : err; |
69 INFO_PRINTF1(_L("Sent and received PDUs compare OK...")); |
341 } |
|
342 |
70 |
343 void CSmsEmsPrtTestStep::CreateCommDBL() |
71 // Now make sure the received message is valid - this can be |
344 /** |
72 // tested by ensuring that NumMessagePDUsL can be called without |
345 * @test Create a special CommDb Database for this test harness. |
73 // leaving |
346 */ |
74 rxMsg->NumMessagePDUsL(); |
347 { |
|
348 INFO_PRINTF1(_L("Creating of the commdb for the TE_SmsEmsPrt") ); |
|
349 |
75 |
350 |
76 CleanupStack::PopAndDestroy(rxMsg); |
351 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
352 CMDBSession* db = CMDBSession::NewL(KCDVersion1_2); |
|
353 #else |
|
354 CMDBSession* db = CMDBSession::NewL(KCDVersion1_1); |
|
355 #endif |
|
356 CleanupStack::PushL(db); |
|
357 db->OpenTransactionL(); |
|
358 CMDBRecordSet<CCDModemBearerRecord>* modemBearerRecordSet = new(ELeave) CMDBRecordSet<CCDModemBearerRecord>(KCDTIdModemBearerRecord); |
|
359 CleanupStack::PushL(modemBearerRecordSet); |
|
360 modemBearerRecordSet->LoadL(*db); |
|
361 |
77 |
362 _LIT(KDummy0, "DUMMY::0"); |
78 // return the result of the comparison |
363 _LIT(KDummy, "DUMMY"); |
79 return comp; |
364 _LIT(KSim, "SIM"); |
80 } |
365 |
|
366 RPointerArray<CCDModemBearerRecord>& resultSet = (RPointerArray<CCDModemBearerRecord>&) modemBearerRecordSet->iRecords; |
|
367 |
|
368 CCDModemBearerRecord *modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord)); |
|
369 CleanupStack::PushL(modemRecord); |
|
370 |
|
371 for (TInt i=0; i<resultSet.Count(); i++) |
|
372 { |
|
373 modemRecord = resultSet[i]; |
|
374 modemRecord->iPortName = KDummy0; |
|
375 modemRecord->iCsyName = KDummy; |
|
376 modemRecord->iTsyName = KSim; |
|
377 modemRecord->iMessageCentreNumber = iServiceCenterNumber; |
|
378 modemRecord->ModifyL(*db); |
|
379 modemRecord = NULL; |
|
380 } |
|
381 db->CommitTransactionL(); |
|
382 resultSet.Close(); |
|
383 CleanupStack::PopAndDestroy(2); |
|
384 CleanupStack::PopAndDestroy(db); |
|
385 } |
|
386 |
|
387 |
|
388 // Here are the section names |
|
389 _LIT8(KSetupTelNumbers, "Defaults"); |
|
390 |
|
391 // Here are the item names |
|
392 _LIT8(KServiceCenter, "ServiceCenter"); |
|
393 _LIT8(KTelefoneNumber, "TelephoneNumber"); |
|
394 |
|
395 void CSmsEmsPrtTestStep::ParseSettingsFromFileL() |
|
396 { |
|
397 CTestConfig* configFile = CTestConfig::NewLC(iFs,KGmsSmsConfigFileDir,KGmsSmsConfigFileName); |
|
398 const CTestConfigSection* cfgFile = configFile->Section(KSetupTelNumbers); |
|
399 if (cfgFile == NULL) |
|
400 User::Leave(KErrNotFound); |
|
401 |
|
402 const CTestConfigItem* item = cfgFile->Item(KServiceCenter,0); |
|
403 if (item == NULL) |
|
404 User::Leave(KErrNotFound); |
|
405 |
|
406 iServiceCenterNumber.Copy(item->Value()); |
|
407 |
|
408 item = cfgFile->Item(KTelefoneNumber,0); |
|
409 if (item == NULL) |
|
410 User::Leave(KErrNotFound); |
|
411 |
|
412 iTelephoneNumber.Copy(item->Value()); |
|
413 |
|
414 // beginning of the destruction |
|
415 CleanupStack::PopAndDestroy(configFile);//configFile |
|
416 } |
|