|
1 // Copyright (c) 2005-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 "Te_SimSmsReceiveModesTest.h" |
|
17 |
|
18 CSimSmsReceiveModesTest::CSimSmsReceiveModesTest() |
|
19 { |
|
20 SetTestStepName(_L("SmsReceiveModesTest")); |
|
21 } |
|
22 |
|
23 TVerdict CSimSmsReceiveModesTest::doTestStepL() |
|
24 { |
|
25 INFO_PRINTF1(_L("BeginSmsReceiveModesTest")); |
|
26 |
|
27 CreateConfigFileL(_L("c:\\config3.txt")); |
|
28 SetTestNumberL(2); |
|
29 |
|
30 TInt ret = iPhone.Open(iTelServer,KPhoneName); |
|
31 INFO_PRINTF2(_L("Result: %d"),ret); |
|
32 TESTL(ret == KErrNone); |
|
33 INFO_PRINTF1(_L("Opened phone object")); |
|
34 TESTL(iSmsMessaging.Open(iPhone)==KErrNone); |
|
35 INFO_PRINTF1(_L("Opened SMS Messaging object")); |
|
36 |
|
37 INFO_PRINTF1(_L("Testing Retrieving SMS Messaging Store Informtion")); |
|
38 TRequestStatus stat0, statNotif, statStore, statReceive; |
|
39 RMobilePhoneStore::TMobilePhoneStoreInfoV1 storeInfo; |
|
40 RMobilePhoneStore::TMobilePhoneStoreInfoV1Pckg storeInfoPckg(storeInfo); |
|
41 iSmsMessaging.GetMessageStoreInfo(stat0,0,storeInfoPckg); |
|
42 User::WaitForRequest(stat0); |
|
43 TESTL(storeInfo.iUsedEntries==1); |
|
44 TESTL(iSmsStore.Open(iSmsMessaging,storeInfo.iName)==KErrNone); |
|
45 INFO_PRINTF1(_L("Opened SMS Store object")); |
|
46 |
|
47 INFO_PRINTF1(_L("Testing GetCaps")); |
|
48 RMobileSmsMessaging::TMobileSmsCapsV1 caps; |
|
49 RMobileSmsMessaging::TMobileSmsCapsV1Pckg capsPckg(caps); |
|
50 iSmsMessaging.GetCaps(capsPckg); |
|
51 TESTL(caps.iSmsMode==RMobileSmsMessaging::KCapsGsmSms); |
|
52 TESTL(caps.iSmsControl==KSmsMessagingCaps); |
|
53 |
|
54 RMobileSmsMessaging::TMobileSmsReceiveMode rxMode; |
|
55 iSmsMessaging.GetReceiveMode(rxMode); |
|
56 TESTL(rxMode==RMobileSmsMessaging::EReceiveUnstoredClientAck); |
|
57 |
|
58 rxMode = RMobileSmsMessaging::EReceiveStored; |
|
59 iSmsMessaging.SetReceiveMode(stat0,rxMode); |
|
60 User::WaitForRequest(stat0); |
|
61 TESTL(stat0==KErrNone); |
|
62 |
|
63 TUint32 event; |
|
64 TInt index; |
|
65 iSmsStore.NotifyStoreEvent(statNotif,event,index); |
|
66 |
|
67 INFO_PRINTF1(_L("Testing SMS PDU Retrieval")); |
|
68 TSmsPdu smsPdu; |
|
69 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib; |
|
70 RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPckg(attrib); |
|
71 iSmsMessaging.ReceiveMessage(stat0,smsPdu,attribPckg); |
|
72 INFO_PRINTF1(_L("1st receive Request sent")); |
|
73 |
|
74 //test message received #1 |
|
75 User::WaitForRequest(stat0); |
|
76 INFO_PRINTF1(_L("Message 1 received")); |
|
77 User::WaitForRequest(statNotif); |
|
78 INFO_PRINTF1(_L("Message added to store")); |
|
79 |
|
80 TESTL(smsPdu.Length()==sizeof(KTestPduRx1)); |
|
81 TInt i; |
|
82 for(i=0;i<smsPdu.Length();i++) |
|
83 TESTL(smsPdu[i]==KTestPduRx1[i]); |
|
84 TESTL(attrib.iGsmServiceCentre.iTelNumber==KScaNumber1); |
|
85 TESTL(attrib.iGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber); |
|
86 TESTL(attrib.iGsmServiceCentre.iNumberPlan==RMobilePhone::EIsdnNumberPlan); |
|
87 TESTL(attrib.iStatus==RMobileSmsMessaging::EMtMessageStored); |
|
88 TESTL(attrib.iStoreIndex==2); |
|
89 TESTL(attrib.iStore==KSmsStoreName); |
|
90 |
|
91 TESTL(event & RMobilePhoneStore::KStoreEntryAdded);//store added |
|
92 TESTL(event & RMobilePhoneStore::KStoreFull); |
|
93 INFO_PRINTF2(_L("1 message added to store at index %d"), index); |
|
94 |
|
95 //check message was stored |
|
96 RMobileSmsStore::TMobileGsmSmsEntryV1 smsEntryforRead; |
|
97 smsEntryforRead.iIndex=2; |
|
98 RMobileSmsStore::TMobileGsmSmsEntryV1Pckg smsEntryforReadPckg(smsEntryforRead); |
|
99 INFO_PRINTF1(_L("Testing SMS Store Read")); |
|
100 iSmsStore.Read(statStore, smsEntryforReadPckg); |
|
101 User::WaitForRequest(statStore); |
|
102 |
|
103 //receive 2nd phone stored message but no memory |
|
104 iSmsStore.NotifyStoreEvent(statNotif,event,index); |
|
105 iSmsMessaging.ReceiveMessage(stat0,smsPdu,attribPckg); |
|
106 INFO_PRINTF1(_L("2nd receive Request sent")); |
|
107 |
|
108 User::After(5000000L);//wait here for message to be discarded in tsy because store is full |
|
109 iSmsStore.Delete(statStore, 2);//delete message at index2 |
|
110 User::WaitForRequest(statStore); |
|
111 INFO_PRINTF1(_L("Message 2 deleted")); |
|
112 TESTL(statStore==KErrNone); |
|
113 |
|
114 //test message received #2 |
|
115 User::WaitForRequest(stat0); |
|
116 INFO_PRINTF1(_L("Message 2 received")); |
|
117 TESTL(stat0==KErrNone); |
|
118 User::WaitForRequest(statNotif); |
|
119 |
|
120 for(i=0;i<smsPdu.Length();i++) |
|
121 TESTL(smsPdu[i]==KTestPduRx2[i]); |
|
122 TESTL(attrib.iGsmServiceCentre.iTelNumber==KScaNumber2); |
|
123 TESTL(attrib.iGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber); |
|
124 TESTL(attrib.iGsmServiceCentre.iNumberPlan==RMobilePhone::EIsdnNumberPlan); |
|
125 TESTL(attrib.iStatus==RMobileSmsMessaging::EMtMessageStored); |
|
126 //We wont be notified of store event as message store full |
|
127 |
|
128 //set to new receive mode |
|
129 rxMode = RMobileSmsMessaging::EReceiveUnstoredPhoneAck; |
|
130 iSmsMessaging.SetReceiveMode(stat0,rxMode); |
|
131 User::WaitForRequest(stat0); |
|
132 TESTL(stat0==KErrNone); |
|
133 |
|
134 INFO_PRINTF1(_L("Testing getReceiveMode")); |
|
135 iSmsMessaging.GetReceiveMode(rxMode); |
|
136 TESTL(rxMode==RMobileSmsMessaging::EReceiveUnstoredPhoneAck); |
|
137 |
|
138 iSmsMessaging.ReceiveMessage(stat0,smsPdu,attribPckg); |
|
139 INFO_PRINTF1(_L("3rd receive Request sent")); |
|
140 |
|
141 //test message 3 |
|
142 User::WaitForRequest(stat0); |
|
143 TESTL(stat0==KErrNone); |
|
144 INFO_PRINTF1(_L("Message 3 received")); |
|
145 for(i=0;i<smsPdu.Length();i++) |
|
146 TESTL(smsPdu[i]==KTestPduRx3[i]); |
|
147 TESTL(attrib.iGsmServiceCentre.iTelNumber==KScaNumber3); |
|
148 TESTL(attrib.iGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber); |
|
149 TESTL(attrib.iGsmServiceCentre.iNumberPlan==RMobilePhone::EIsdnNumberPlan); |
|
150 TESTL(attrib.iStatus==RMobileSmsMessaging::EMtMessageUnstoredPhoneAck); |
|
151 |
|
152 //test change receive mode in invalid smsTx state |
|
153 rxMode = RMobileSmsMessaging::EReceiveUnstoredClientAck; |
|
154 iSmsMessaging.SetReceiveMode(stat0,rxMode); |
|
155 User::WaitForRequest(stat0); |
|
156 TESTL(stat0==KErrNone); |
|
157 iSmsMessaging.ReceiveMessage(statReceive,smsPdu,attribPckg); |
|
158 INFO_PRINTF1(_L("4th receive Request sent")); |
|
159 |
|
160 User::After(3000000L); |
|
161 rxMode = RMobileSmsMessaging::EReceiveUnstoredPhoneAck; |
|
162 iSmsMessaging.SetReceiveMode(stat0,rxMode); |
|
163 User::WaitForRequest(stat0); |
|
164 TESTL(stat0==KErrNotSupported);//can't change mode in this state |
|
165 |
|
166 rxMode = RMobileSmsMessaging::EReceiveStored; |
|
167 iSmsMessaging.SetReceiveMode(stat0,rxMode); |
|
168 User::WaitForRequest(stat0); |
|
169 TESTL(stat0==KErrNotSupported);//can't change mode in this state |
|
170 |
|
171 User::WaitForRequest(statReceive); |
|
172 |
|
173 iSmsStore.Close(); |
|
174 iSmsMessaging.Close(); |
|
175 iPhone.Close(); |
|
176 ASSERT(RThread().RequestCount()==0); |
|
177 |
|
178 return TestStepResult(); |
|
179 } |
|
180 |