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