|
1 /** |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Utility functions of smsprot |
|
16 * contains the class definition of CSmsStackTestUtils and 3 active objects for receiving and |
|
17 * enumerating sms messages. |
|
18 * |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @file |
|
26 */ |
|
27 |
|
28 #ifndef __TSMSPTESTUTILS_H__ |
|
29 #define __TSMSPTESTUTILS_H__ |
|
30 |
|
31 #include <e32test.h> |
|
32 #include <es_sock.h> |
|
33 #include <mmlist.h> |
|
34 #include <gsmupdu.h> |
|
35 #include <smsuact.h> |
|
36 #include <smsuaddr.h> |
|
37 #include "logwrap.h" |
|
38 #include "logeng.h" |
|
39 #include <test/testexecuteserverbase.h> |
|
40 #include <logsmspdudata.h> |
|
41 #include <commsdat_partner.h> |
|
42 |
|
43 class CTestStep; |
|
44 class RFs; |
|
45 class CSmsMessage; |
|
46 class CLogEvent; |
|
47 class CSmsPduDatabase; |
|
48 class CTestConfig; |
|
49 class CTestConfigSection; |
|
50 |
|
51 const TInt KActiveObjectPriority = CActive::EPriorityStandard; |
|
52 _LIT(KGmsSmsConfigFileDir,"sms"); |
|
53 _LIT(KSimTsyConfigFileName,"c:\\config.txt"); |
|
54 |
|
55 |
|
56 class CSmsStackTestUtils : public CBase |
|
57 { |
|
58 public: |
|
59 |
|
60 //Factory |
|
61 IMPORT_C static CSmsStackTestUtils* NewL(CTestStep* aTestStep, RFs& aFs); |
|
62 IMPORT_C ~CSmsStackTestUtils(); |
|
63 |
|
64 ///SmsProt.Prt Test Utils, more below |
|
65 IMPORT_C void GetLogEventL(CLogEvent& aLogEvent, TInt aLogServerId); |
|
66 IMPORT_C TLogId AddLogEventL(CSmsMessage& aSmsMessage,TLogSmsPduData& aSmsPDUData); |
|
67 IMPORT_C void DisableLogging(); |
|
68 IMPORT_C void EnableLogging(); |
|
69 IMPORT_C void SendSmsAndChangeBearerL(CSmsMessage* aSms, RSocket& aSocket, RMobileSmsMessaging::TMobileSmsBearer aBearer); |
|
70 |
|
71 ///GSMU.dll Test Utils |
|
72 IMPORT_C CSmsMessage* CreateSmsMessageLC(CSmsPDU::TSmsPDUType aType, const TDesC& aDestination, const TDesC& aMessage); |
|
73 CArrayFixFlat<TGsmSms>* EncodeMessageLC(CSmsMessage& aMessage) const; |
|
74 |
|
75 ///Config File Utils |
|
76 IMPORT_C void CopyConfigFileL(const TDesC& aFromSmsConfigFile, CSmsPduDatabase* aPduDb=NULL); |
|
77 IMPORT_C void AddSmsRxL(CTestConfig& aConfigFile, TInt aTestNumber, CSmsMessage& aMessage, const TDesC& aServiceCenter) const; |
|
78 IMPORT_C void AddSmsTxL(CTestConfig& aConfigFile, TInt aTestNumber, CSmsMessage& aMessage, const TDesC& aServiceCenter, TInt aMsgRef = 0, CSmsMessage* aSubmitReport = NULL, TInt aExpectedError = KErrNone) const; |
|
79 IMPORT_C CTestConfigSection& GetSectionL(CTestConfig& aConfig, TInt aTestNumber) const; |
|
80 |
|
81 ///PDU utils |
|
82 IMPORT_C HBufC8* ConvertToHexLC(const TDesC8& aDes) const; |
|
83 IMPORT_C TSmsFirstOctet FirstDeliverOctet(TBool aMMS, TBool aRP, TBool aUDHI, TBool aSRI); |
|
84 IMPORT_C void DeliverWithoutUserDataL(TGsmSms& aPdu, TSmsFirstOctet aFO, const TGsmSmsTelNumber& aOA, TSmsProtocolIdentifier aPID, TSmsDataCodingScheme aDCS, const TTime& aSCTS, TInt aUTCOffset); |
|
85 IMPORT_C void AppendUserDataL(TGsmSms& aPdu, const CSmsUserData& aUD, TInt aUDL = KErrNotFound); |
|
86 IMPORT_C void PrintAndTestDecodeL(const TGsmSms& aPdu, TSmsDataCodingScheme aExpectedDCS, TSmsProtocolIdentifier aExpectedPID, const CSmsUserData& aExpectedUD, TBool aIsMobileTerminated, TInt aExpectedError); |
|
87 IMPORT_C void CompareUDL(const CSmsPDU& aPDU, const CSmsUserData& aUD); |
|
88 IMPORT_C void ComparePIDL(const CSmsPDU& aPDU, TSmsProtocolIdentifier aPID); |
|
89 IMPORT_C void CompareDCSL(const CSmsPDU& aPdu, TSmsDataCodingScheme aDCS); |
|
90 |
|
91 ///Socket utils |
|
92 IMPORT_C void OpenSmsSocketLC(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddr& aSmsAddr); |
|
93 IMPORT_C void OpenSmsSocketLC(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddrFamily aFamily); |
|
94 IMPORT_C void OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddr& aSmsAddr); |
|
95 IMPORT_C void OpenSmsSocketL(RSocketServ& aSocketServer, RSocket& aSocket, TSmsAddrFamily aFamily); |
|
96 IMPORT_C void WaitForInitializeL(); |
|
97 |
|
98 ///SMS Parameter utils |
|
99 IMPORT_C TInt StoreParamsL(CMobilePhoneSmspList& aSmspList, RSocket& aSocket, TBool aCancelAfterRequest); |
|
100 IMPORT_C TInt RetrieveParamsL(CMobilePhoneSmspList& aSmspList, RSocket& aSocket, TBool aCancelAfterRequest); |
|
101 IMPORT_C void MakeParametersReadRequestL(RSocket& aSocket); |
|
102 IMPORT_C void StoreParamsLeaveIfErrorL(CMobilePhoneSmspList& aSmspList,RSocket& aSocket); |
|
103 IMPORT_C TInt TestParameters(CMobilePhoneSmspList& aLeft,CMobilePhoneSmspList& aRight); |
|
104 IMPORT_C TInt TestPhoneNumbers(const RMobilePhone::TMobileAddress& aLeftNumber,const RMobilePhone::TMobileAddress& aRightNumber); |
|
105 IMPORT_C void PrintSmspEntry(RMobileSmsMessaging::TMobileSmspEntryV1& aEntryToTsy); |
|
106 IMPORT_C void PrintSmspList(CMobilePhoneSmspList& aSmspList); |
|
107 |
|
108 //Unit Tests |
|
109 //TSmsServiceCenterTimeStamp |
|
110 IMPORT_C void CreateTSmsServiceCenterTimeStampL(); |
|
111 IMPORT_C void DecodeTSmsServiceCenterTimeStampL(); |
|
112 IMPORT_C void EncodeTSmsServiceCenterTimeStampL(); |
|
113 |
|
114 //TSmsValidityPerdiod |
|
115 IMPORT_C void CreateTSmsValidityPeriodL(); |
|
116 IMPORT_C void DecodeTSmsValidityPeriodL(); |
|
117 IMPORT_C void EncodeTSmsValidityPeriodL(); |
|
118 |
|
119 IMPORT_C void ChangeBearerL(RMobileSmsMessaging::TMobileSmsBearer aBearer); |
|
120 IMPORT_C void GetBearerL(RMobileSmsMessaging::TMobileSmsBearer& aBearer); |
|
121 |
|
122 private: |
|
123 |
|
124 CSmsStackTestUtils(CTestStep* aTestStep, RFs& aFs); |
|
125 void ConstructL(); |
|
126 |
|
127 public: |
|
128 |
|
129 CTestStep* iTestStep; |
|
130 RFs& iFs; |
|
131 CCnvCharacterSetConverter* iCharConv; |
|
132 }; |
|
133 |
|
134 class CTestGetSmsList : public CSmsuActiveBase |
|
135 /** |
|
136 * This active object is used to enumerate the messages from |
|
137 * the sms message store on a socket |
|
138 */ |
|
139 { |
|
140 public: |
|
141 IMPORT_C static CTestGetSmsList* NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& iTestUtils); |
|
142 void Start();//not used |
|
143 IMPORT_C void GetSmsList(TRequestStatus& aStatus); |
|
144 TInt iRemainingMessages; |
|
145 TPckgBuf<TUint> iMessageCount; |
|
146 protected: |
|
147 IMPORT_C CTestGetSmsList(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& iTestUtils); |
|
148 void ConstructL(); |
|
149 void DoRunL(); |
|
150 void DoCancel(); |
|
151 protected: |
|
152 RSocketServ& iSocketServer; |
|
153 RSocket iSocket; |
|
154 enum TTestGetSmsListState |
|
155 { |
|
156 EEnuming, |
|
157 EReading |
|
158 } iState; |
|
159 |
|
160 CSmsStackTestUtils& iTestUtils; |
|
161 }; |
|
162 |
|
163 class CTestReceiveMessages : public CSmsuActiveBase |
|
164 /** |
|
165 * This active object is used receive sms messages |
|
166 * from a socket |
|
167 * |
|
168 */ |
|
169 { |
|
170 public: |
|
171 IMPORT_C static CTestReceiveMessages* NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils); |
|
172 void Start(); |
|
173 IMPORT_C void Receive(TRequestStatus& aStatus, TInt aNumberOfMessages); |
|
174 IMPORT_C void Receive(); |
|
175 TInt NumberReceived(); |
|
176 protected: |
|
177 IMPORT_C CTestReceiveMessages(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils); |
|
178 void ConstructL(); |
|
179 void DoRunL(); |
|
180 void DoCancel(); |
|
181 protected: |
|
182 RSocketServ& iSocketServer; |
|
183 RSocket iSocket; |
|
184 TPckgBuf<TUint> iMessageBuf; |
|
185 TInt iNumberOfReceivedMessages; |
|
186 TInt iNumberOfMessagesToReceive; |
|
187 enum TTestReceiveMessagesState |
|
188 { |
|
189 EReceiving, |
|
190 EReceived |
|
191 } iState; |
|
192 CSmsStackTestUtils& iTestUtils; |
|
193 }; |
|
194 |
|
195 class CTestReceiveEnumerateMessages : public CSmsuActiveBase |
|
196 /** |
|
197 * This class defines an active object use to control 2 active objects |
|
198 * CTestReceiveMessages and CTestGetSmsList |
|
199 */ |
|
200 { |
|
201 public: |
|
202 IMPORT_C static CTestReceiveEnumerateMessages* NewL(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils); |
|
203 IMPORT_C void Start(TInt aEnumExpected, TInt aRecvExpected, TInt aRecvInitial); |
|
204 IMPORT_C ~CTestReceiveEnumerateMessages(); |
|
205 protected: |
|
206 IMPORT_C CTestReceiveEnumerateMessages(TInt aPriority, RSocketServ& aSocketServer, CSmsStackTestUtils& aTestUtils); |
|
207 // TInt RunError(TInt aError); |
|
208 void ConstructL(); |
|
209 void DoRunL(); |
|
210 void DoCancel(); |
|
211 void Complete(TInt); |
|
212 protected: |
|
213 CTestReceiveMessages* iReceiver; |
|
214 CTestGetSmsList* iEnumerator; |
|
215 RSocketServ& iSocketServer; |
|
216 TInt iEnumExpected, iRecvExpected , iRecvInitial; |
|
217 enum TTestReceiveEnumerateMessagesState |
|
218 { |
|
219 ERecvInitial, |
|
220 EEnumerating, |
|
221 ESecondReceiving, |
|
222 ETryingToReceiveOneMore |
|
223 } iState; |
|
224 CSmsStackTestUtils& iTestUtils; |
|
225 }; |
|
226 |
|
227 |
|
228 #endif //__TSMSPTESTUTILS_H__ |
|
229 |
|
230 |