|
1 // Copyright (c) 2000-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 "pushtests.h" |
|
17 #include "dummywapstack.h" |
|
18 #include "wappushmsggen.h" |
|
19 #include <push/cwappushmsgutils.h> |
|
20 #include <commdb.h> |
|
21 |
|
22 |
|
23 |
|
24 /** set test name to 'Service Initiation Application' |
|
25 * @param void |
|
26 * @return string |
|
27 * string represents test name |
|
28 */ |
|
29 const TDesC& CWapPushSIAMessageTest::TestName() |
|
30 { |
|
31 _LIT(KTextSIAMessageTest, "Service Intiation Application"); |
|
32 return KTextSIAMessageTest; |
|
33 } |
|
34 |
|
35 /** |
|
36 * set the number of test messages to use |
|
37 */ |
|
38 void CWapPushSIAMessageTest::NumberTestCasesToRun() |
|
39 { |
|
40 iNumberOfTestCases = 3; |
|
41 } |
|
42 |
|
43 /** build different test messages to test specific SIA |
|
44 * handling of messages. |
|
45 * @param TInt |
|
46 * the number of test messages to create and use |
|
47 * @return void |
|
48 */ |
|
49 void CWapPushSIAMessageTest::PrepareTestMessageL(TInt aTestCase) |
|
50 { |
|
51 static TBool setup = ETrue; |
|
52 if (setup) |
|
53 { |
|
54 SetupAddressL(); |
|
55 setup = EFalse; |
|
56 } |
|
57 |
|
58 // this set of test messages adds a test message |
|
59 const TUint8 KSIAMessageHeader[] = |
|
60 { |
|
61 0xB4, //Content type "application/vnd.wap.sia" |
|
62 0x92, // Date |
|
63 0x04, // length of field |
|
64 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
65 0x90, |
|
66 0x6a, |
|
67 0xd0, |
|
68 0x94, // Expires |
|
69 0x04, // length of field |
|
70 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
71 0x9a, |
|
72 0x6a, |
|
73 0xd0, |
|
74 0xAF, //X-Wap-Application-ID |
|
75 0x82 // Short int - 0x02 represent x-wap-application:push.ua |
|
76 }; |
|
77 iHeadersBuf.Append(KSIAMessageHeader, sizeof(KSIAMessageHeader)); |
|
78 |
|
79 iBodyBuf.Delete(0,KBufferSize); |
|
80 //iBodyBuf.Zero(); |
|
81 |
|
82 // NOTE: tests for valid address require address in COMMDB |
|
83 |
|
84 switch (aTestCase) |
|
85 { |
|
86 case 0 : // normal SIA message with single valid address |
|
87 { |
|
88 const TUint8 SIA[]= |
|
89 { |
|
90 0x00, // version |
|
91 0x02, // AppIdListLen |
|
92 0x44, // Application Id List |
|
93 0x44, |
|
94 0x1B, // ContactPointsLen |
|
95 // Contact Points |
|
96 0xD7, // bearer flag and port flag and address len |
|
97 0x0A, // bearer Type (CSD) |
|
98 0x0B, // port number |
|
99 0x84, // = 2948 |
|
100 0x68, // address - "http://www.symbian.com/" (as text) |
|
101 0x74, |
|
102 0x74, |
|
103 0x70, |
|
104 0x3A, |
|
105 0x2F, |
|
106 0x2F, |
|
107 0x77, |
|
108 0x77, |
|
109 0x77, |
|
110 0x2E, |
|
111 0x73, |
|
112 0x79, |
|
113 0x6D, |
|
114 0x62, |
|
115 0x69, |
|
116 0x61, |
|
117 0x6E, |
|
118 0x2E, |
|
119 0x63, |
|
120 0x6F, |
|
121 0x6D, |
|
122 0x2F |
|
123 }; |
|
124 iBodyBuf.Append(SIA, sizeof(SIA)); |
|
125 } |
|
126 break; |
|
127 case 1 : // normal SIA message but no port or bearer ( valid ) |
|
128 { |
|
129 const TUint8 SIA[]= |
|
130 { |
|
131 0x00, // version |
|
132 0x02, // AppIdListLen |
|
133 0x44, // Application Id List |
|
134 0x44, |
|
135 0x18, // ContactPointsLen |
|
136 // Contact Points |
|
137 0x17, // no bearer flag or port flag only address len |
|
138 // no bearer or port specified |
|
139 0x68, // address - "http://www.symbian.com/" (as text) |
|
140 0x74, |
|
141 0x74, |
|
142 0x70, |
|
143 0x3A, |
|
144 0x2F, |
|
145 0x2F, |
|
146 0x77, |
|
147 0x77, |
|
148 0x77, |
|
149 0x2E, |
|
150 0x73, |
|
151 0x79, |
|
152 0x6D, |
|
153 0x62, |
|
154 0x69, |
|
155 0x61, |
|
156 0x6E, |
|
157 0x2E, |
|
158 0x63, |
|
159 0x6F, |
|
160 0x6D, |
|
161 0x2F |
|
162 }; |
|
163 iBodyBuf.Append(SIA, sizeof(SIA)); |
|
164 } |
|
165 break; |
|
166 case 2 : // SIA message with no contact points specified (error) |
|
167 { |
|
168 const TUint8 SIA[]= |
|
169 { |
|
170 0x00, // version |
|
171 0x02, // AppIdListLen |
|
172 0x44, // Application Id List |
|
173 0x44, |
|
174 0x00 // ContactPointsLen == 0 |
|
175 // No Contact Points |
|
176 }; |
|
177 iBodyBuf.Append(SIA, sizeof(SIA)); |
|
178 } |
|
179 break; |
|
180 case 3 : // normal SIA message with three addresses - 3rd valid |
|
181 break; |
|
182 case 4 : // SIA message with incorrect contact point (error) |
|
183 break; |
|
184 default: |
|
185 // do nothing |
|
186 break; |
|
187 } |
|
188 |
|
189 } |
|
190 |
|
191 /** confirm the message has been stored. |
|
192 * Writes the number of stored messages found to the log file - if present. |
|
193 * @param void |
|
194 * @return TBool |
|
195 * returns ETrue if messages found |
|
196 * returns EFalse if no messages found |
|
197 */ |
|
198 TBool CWapPushSIAMessageTest::ConfirmMessagesSavedL() |
|
199 { |
|
200 // no messages to save.... |
|
201 return EFalse; |
|
202 } |
|
203 |
|
204 /** |
|
205 * Prime the commdb with address and security port settings. |
|
206 * |
|
207 */ |
|
208 void CWapPushSIAMessageTest::SetupAddressL() |
|
209 { |
|
210 CCommsDatabase *db = CCommsDatabase::NewL(EDatabaseTypeUnspecified); |
|
211 CleanupStack::PushL(db); |
|
212 |
|
213 CCommsDbTableView* waptable; |
|
214 |
|
215 TPtrC tableName(WAP_IP_BEARER); |
|
216 TPtrC columnName(WAP_GATEWAY_ADDRESS); |
|
217 // TPtrC SecurityCol(WAP_SECURITY); |
|
218 _LIT(address, "http://www.symbian.com/"); |
|
219 |
|
220 TBuf<30> KTestAddress(address); |
|
221 //TBool secure = ETrue; |
|
222 |
|
223 waptable = db->OpenTableLC(tableName); |
|
224 |
|
225 TUint32 recordId; |
|
226 TInt ret; |
|
227 ret = waptable->InsertRecord(recordId); |
|
228 waptable->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID),recordId); |
|
229 if (ret == KErrNone) |
|
230 { |
|
231 // void WriteTextL(const TDesC& aColumn, const TDesC& aValue); |
|
232 waptable->WriteTextL(columnName, KTestAddress); |
|
233 // void WriteBoolL(const TDesC& aColumn, const TBool& aValue); |
|
234 |
|
235 // leave Security field unset - shd be NULL ? (= EFalse) |
|
236 |
|
237 // TInt PutRecordChanges(TBool aHidden = EFalse, TBool aReadOnly = EFalse); |
|
238 waptable->PutRecordChanges(); |
|
239 } |
|
240 |
|
241 CleanupStack::PopAndDestroy(2); // db, view |
|
242 } |