24
|
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_SimSmsTxTest.h"
|
|
17 |
|
|
18 |
CSimSmsTxTest::CSimSmsTxTest()
|
|
19 |
{
|
|
20 |
SetTestStepName(_L("SmsTxTest"));
|
|
21 |
}
|
|
22 |
|
|
23 |
TVerdict CSimSmsTxTest::doTestStepL()
|
|
24 |
{
|
|
25 |
INFO_PRINTF1(_L("BeginSmsTxTest"));
|
|
26 |
|
|
27 |
CreateConfigFileL(_L("c:\\config2.txt"));
|
|
28 |
SetTestNumberL(0);
|
|
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 |
RMobileSmsMessaging::TMobileSmsCapsV1 caps;
|
|
38 |
RMobileSmsMessaging::TMobileSmsCapsV1Pckg capsPckg(caps);
|
|
39 |
iSmsMessaging.GetCaps(capsPckg);
|
|
40 |
TESTL(caps.iSmsMode==RMobileSmsMessaging::KCapsGsmSms);
|
|
41 |
TESTL(caps.iSmsControl==KSmsMessagingCaps);
|
|
42 |
|
|
43 |
TRequestStatus stat0, statReceive, statSend;
|
|
44 |
|
|
45 |
RMobileSmsMessaging::TMobileSmsReceiveMode rxMode;
|
|
46 |
rxMode = RMobileSmsMessaging::EReceiveUnstoredPhoneAck;
|
|
47 |
iSmsMessaging.SetReceiveMode(stat0,rxMode);
|
|
48 |
User::WaitForRequest(stat0);
|
|
49 |
TESTL(stat0==KErrNone);
|
|
50 |
|
|
51 |
TSmsPdu smsPdu;
|
|
52 |
RMobileSmsMessaging::TMobileSmsReceiveAttributesV1 attrib;
|
|
53 |
RMobileSmsMessaging::TMobileSmsReceiveAttributesV1Pckg attribPckg(attrib);
|
|
54 |
iSmsMessaging.ReceiveMessage(statReceive,smsPdu,attribPckg);
|
|
55 |
INFO_PRINTF1(_L("1st receive Request sent"));
|
|
56 |
|
|
57 |
RMobileSmsMessaging::TMobileSmsSendAttributesV1 attribSend;
|
|
58 |
RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg attribSendPckg(attribSend);
|
|
59 |
TSmsPdu smsPduSent;
|
|
60 |
smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA));
|
|
61 |
iSmsMessaging.SendMessage(statSend,smsPduSent,attribSendPckg);
|
|
62 |
INFO_PRINTF1(_L("1st Send Request sent"));
|
|
63 |
User::WaitForRequest(statSend);
|
|
64 |
CHECKPOINTL(statSend,KErrNone,CHP_SMS_CASE("C.11"));
|
|
65 |
INFO_PRINTF1(_L("Message 1s sent"));
|
|
66 |
|
|
67 |
//test sms sent atributes
|
|
68 |
TUint16 msgRef = 12;//test value
|
|
69 |
TESTL(attribSend.iMsgRef==msgRef);
|
|
70 |
|
|
71 |
|
|
72 |
TESTL(attribSend.iSubmitReport.Length()==sizeof(KTestSubmitReport));
|
|
73 |
for(TInt j =0;j<attribSend.iSubmitReport.Length();j++)
|
|
74 |
TESTL(attribSend.iSubmitReport[j]==KTestSubmitReport[j]);
|
|
75 |
|
|
76 |
//test message received 1
|
|
77 |
User::WaitForRequest(statReceive);
|
|
78 |
CHECKPOINTL(statReceive,KErrNone,CHP_SMS_CASE("C.6"));
|
|
79 |
|
|
80 |
INFO_PRINTF1(_L("Message 1r received"));
|
|
81 |
TESTL(smsPdu.Length()==sizeof(KTestPduA));
|
|
82 |
TInt i;
|
|
83 |
for(i=0;i<smsPdu.Length();i++)
|
|
84 |
TESTL(smsPdu[i]==KTestPduA[i]);
|
|
85 |
TESTL(attrib.iGsmServiceCentre.iTelNumber==KScaNumberA);
|
|
86 |
TESTL(attrib.iGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber);
|
|
87 |
TESTL(attrib.iGsmServiceCentre.iNumberPlan==RMobilePhone::EIsdnNumberPlan);
|
|
88 |
|
|
89 |
//request receive again
|
|
90 |
INFO_PRINTF1(_L("request receive a 2nd message"));
|
|
91 |
iSmsMessaging.ReceiveMessage(statReceive,smsPdu,attribPckg);
|
|
92 |
|
|
93 |
//send message 2
|
|
94 |
smsPduSent.Copy(KTestSendPduB,sizeof(KTestSendPduB));
|
|
95 |
iSmsMessaging.SendMessage(statSend,smsPduSent,attribSendPckg);
|
|
96 |
INFO_PRINTF1(_L("2nd Send Request sent"));
|
|
97 |
User::WaitForRequest(statSend);
|
|
98 |
TESTL(statSend==KErrCommsLineFail);//forced error
|
|
99 |
CHECKPOINTL(statSend,KErrCommsLineFail,CHP_SMS_CASE("C.12"));
|
|
100 |
INFO_PRINTF1(_L("Message 2s sent"));
|
|
101 |
|
|
102 |
//Receive has not completed yet need 1 more message sent
|
|
103 |
|
|
104 |
User::After(3000000L);
|
|
105 |
TESTL(statReceive!=KErrNone);
|
|
106 |
|
|
107 |
//send message 3
|
|
108 |
iSmsMessaging.SendMessage(statSend,smsPduSent,attribSendPckg);
|
|
109 |
INFO_PRINTF1(_L("3rd Send Request sent"));
|
|
110 |
User::WaitForRequest(statSend);
|
|
111 |
TESTL(statSend==KErrCorrupt);//different pdus
|
|
112 |
CHECKPOINTL(statSend,KErrCorrupt,CHP_SMS_CASE("C.13"));
|
|
113 |
INFO_PRINTF1(_L("Message 3s sent"));
|
|
114 |
|
|
115 |
//pDU retreival of message received 2
|
|
116 |
User::WaitForRequest(statReceive);
|
|
117 |
INFO_PRINTF1(_L("Message 2r received"));
|
|
118 |
|
|
119 |
TESTL(smsPdu.Length()==sizeof(KTestPduB));
|
|
120 |
for(i=0;i<smsPdu.Length();i++)
|
|
121 |
TESTL(smsPdu[i]==KTestPduB[i]);
|
|
122 |
TESTL(attrib.iGsmServiceCentre.iTelNumber==KScaNumberB);
|
|
123 |
TESTL(attrib.iGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber);
|
|
124 |
TESTL(attrib.iGsmServiceCentre.iNumberPlan==RMobilePhone::EIsdnNumberPlan);
|
|
125 |
|
|
126 |
//receive a 3rd message
|
|
127 |
iSmsMessaging.ReceiveMessage(statReceive,smsPdu,attribPckg);
|
|
128 |
INFO_PRINTF1(_L("3rd receive Request sent"));
|
|
129 |
User::WaitForRequest(statReceive);
|
|
130 |
INFO_PRINTF1(_L("Message 3r received"));
|
|
131 |
|
|
132 |
|
|
133 |
//the 4th message receive request doesn't complete as the config files specifies there are no more to trigger
|
|
134 |
iSmsMessaging.ReceiveMessage(statReceive,smsPdu,attribPckg);
|
|
135 |
INFO_PRINTF1(_L("4th receive Request sent"));
|
|
136 |
User::After(3000000L);//wait 3 sec
|
|
137 |
TESTL(statReceive!=KErrNone);
|
|
138 |
|
|
139 |
INFO_PRINTF1(_L("sending 4th message"));
|
|
140 |
iSmsMessaging.SendMessage(statSend,smsPduSent,attribSendPckg);
|
|
141 |
iSmsMessaging.CancelAsyncRequest(EMobileSmsMessagingSendMessage);
|
|
142 |
User::WaitForRequest(statSend);
|
|
143 |
TESTL(statSend==KErrCancel);
|
|
144 |
CHECKPOINTL(statSend,KErrCancel,CHP_SMS_CASE("C.14"));
|
|
145 |
INFO_PRINTF1(_L("Message 4s Cancelled"));
|
|
146 |
|
|
147 |
//Even if cancelled the SmsTx counter is incremented and incoming messages are triggered
|
|
148 |
User::WaitForRequest(statReceive);
|
|
149 |
TESTL(statReceive==KErrNone);
|
|
150 |
|
|
151 |
iSmsMessaging.Close();
|
|
152 |
iPhone.Close();
|
|
153 |
ASSERT(RThread().RequestCount()==0);
|
|
154 |
return TestStepResult();
|
|
155 |
}
|
|
156 |
|