|
1 // Copyright (c) 2006-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 <push/sislpushmsgutils.h> |
|
17 |
|
18 #include "pushtests.h" |
|
19 #include "dummywapstack.h" |
|
20 #include "wappushmsggen.h" |
|
21 #include <txtrich.h> |
|
22 #include <msvids.h> |
|
23 #include <push/csipushmsgentry.h> |
|
24 #include <escapeutils.h> |
|
25 |
|
26 //Hard coded SIC Text Msg elements |
|
27 _LIT(KSICHref, "http://wap.com.com" ); |
|
28 _LIT(KSICHref2, "www.com.com"); |
|
29 _LIT(KSICHref3, "http://www.xyz.com/email/123/abc.wml"); |
|
30 _LIT8( KSICText, "\xE2\x82\xAC\xE4\xBD\xA0\xE5\xA5\xBD\xEF\xBC\x81\x20\xE5\xB7\xA5\xE4\xBD\x9C\xE9\xA1\xBA\xE5\x88\xA9\x20\x48\x61\x76\x65\x20\x61\x20\x6E\x69\x63\x65\x20\x64\x61\x79" ); |
|
31 _LIT8(KSICText2, "You have 10 new e-mail's"); |
|
32 |
|
33 // In TDateTime, month and day's offset is 0. So minus 1 from day and month for cross checking. |
|
34 _LIT(KCreatedTime, "20060524:152315"); |
|
35 _LIT(KExpiresTime, "20080529:000000"); |
|
36 |
|
37 /** set the test name for this test case |
|
38 @param void |
|
39 @return string |
|
40 returns test name |
|
41 */ |
|
42 const TDesC& CWapPushSICMessageTest::TestName() |
|
43 { |
|
44 _LIT(KTextSICMessageTest,"Service Indication Content"); |
|
45 return KTextSICMessageTest; |
|
46 } |
|
47 |
|
48 |
|
49 /** specify the number of test messages to use */ |
|
50 void CWapPushSICMessageTest::NumberTestCasesToRun() |
|
51 { |
|
52 iNumberOfTestCases = 5; |
|
53 } |
|
54 |
|
55 |
|
56 /** create test messages to use where aTestCase represents the |
|
57 message index for multiple messages. |
|
58 Tests: 0 & 1- Chineese character encoding |
|
59 2- Message with Creation and Expires time |
|
60 |
|
61 @param aTestCase message index value for selecting a test message |
|
62 @return void |
|
63 */ |
|
64 void CWapPushSICMessageTest::PrepareTestMessageL(TInt aTestCase) |
|
65 { |
|
66 // create hardcoded SIC test message |
|
67 const TUint8 KMessageHeader[] = |
|
68 { |
|
69 0x03, // Content type text/plain |
|
70 0xAE, // Content type "application/vnd.wap.sic" |
|
71 0x81, // Accept-Charset Short int - 0x02 represent x-wap-application:push.ua |
|
72 0xEA // UTF-8 |
|
73 }; |
|
74 |
|
75 iHeadersBuf.Append(KMessageHeader, sizeof(KMessageHeader)); |
|
76 |
|
77 HBufC8* msg = NULL; |
|
78 switch ( aTestCase ) |
|
79 { |
|
80 case 0 : |
|
81 _LIT8 ( KMessage1, "\x02\x05\x6A\x00\x45\xC6\x0C\x03\x77\x61\x70\x2E\x63\x6F\x6D\x2E\x63\x6F\x6D\x00\x07\x01\x03\xE2\x82\xAC\xE4\xBD\xA0\xE5\xA5\xBD\xEF\xBC\x81\x20\xE5\xB7\xA5\xE4\xBD\x9C\xE9\xA1\xBA\xE5\x88\xA9\x20\x48\x61\x76\x65\x20\x61\x20\x6E\x69\x63\x65\x20\x64\x61\x79\x00\x01\x01" ); |
|
82 msg = KMessage1().AllocLC (); |
|
83 break; |
|
84 |
|
85 case 1: |
|
86 _LIT8 ( KMessage2, "\x02\x05\x6A\x00\x45\xC6\x0B\x03\x77\x77\x77\x2E\x63\x6F\x6D\x2E\x63\x6F\x6D\x00\x01\x03\xE2\x82\xAC\xE4\xBD\xA0\xE5\xA5\xBD\xEF\xBC\x81\x20\xE5\xB7\xA5\xE4\xBD\x9C\xE9\xA1\xBA\xE5\x88\xA9\x20\x48\x61\x76\x65\x20\x61\x20\x6E\x69\x63\x65\x20\x64\x61\x79\x00\x01\x01"); |
|
87 msg = KMessage2().AllocLC (); |
|
88 break; |
|
89 |
|
90 case 2: |
|
91 /** Original message in XML format |
|
92 <?xml version="1.0"?> |
|
93 <!DOCTYPE si PUBLIC "-//WAPFORUM//DTD SI 1.0//EN" |
|
94 "http://www.wapforum.org/DTD/si.dtd"> |
|
95 <si> |
|
96 <indication href=”http://www.xyz.com/email/123/abc.wml” |
|
97 created=”2006-06-25T15.23.15Z” |
|
98 si-expires=”2008-06-30T00.00.00Z”> |
|
99 You have 4 new e-mail's |
|
100 </indication> |
|
101 </si> |
|
102 */ |
|
103 _LIT8 ( KMessage3, "\x00\x05\x6A\x00\x45\xC6\x0D\x03\x78\x79\x7A\x00\x85\x03\x65\x6D\x61\x69\x6C\x2F\x31\x32\x33\x2F\x61\x62\x63\x2E\x77\x6D\x6C\x00\x0A\xC3\x07\x20\x06\x06\x25\x15\x23\x15\x10\xC3\x04\x20\x08\x06\x30\x01\x03\x59\x6F\x75\x20\x68\x61\x76\x65\x20\x31\x30\x20\x6E\x65\x77\x20\x65\x2D\x6D\x61\x69\x6C\x27\x73\x00\x01\x01" ); |
|
104 msg = KMessage3().AllocLC (); |
|
105 break; |
|
106 |
|
107 case 3: |
|
108 /** Invalid Date |
|
109 */ |
|
110 _LIT8 ( KMessage4, "\x00\x05\x6A\x00\x45\xC6\x0D\x03\x78\x79\x7A\x00\x85\x03\x65\x6D\x61\x69\x6C\x2F\x31\x32\x33\x2F\x61\x62\x63\x2E\x77\x6D\x6C\x00\x0A\xC3\x07\x20\x08\x02\x30\x15\x23\x15\x10\xC3\x04\x20\x08\x06\x30\x01\x03\x59\x6F\x75\x20\x68\x61\x76\x65\x20\x31\x30\x20\x6E\x65\x77\x20\x65\x2D\x6D\x61\x69\x6C\x27\x73\x00\x01\x01" ); |
|
111 msg = KMessage4().AllocLC (); |
|
112 break; |
|
113 |
|
114 case 4: |
|
115 /** Invalid Time |
|
116 */ |
|
117 _LIT8 ( KMessage5, "\x00\x05\x6A\x00\x45\xC6\x0D\x03\x78\x79\x7A\x00\x85\x03\x65\x6D\x61\x69\x6C\x2F\x31\x32\x33\x2F\x61\x62\x63\x2E\x77\x6D\x6C\x00\x0A\xC3\x07\x20\x06\x02\x28\x15\x60\x15\x10\xC3\x04\x20\x08\x06\x30\x01\x03\x59\x6F\x75\x20\x68\x61\x76\x65\x20\x31\x30\x20\x6E\x65\x77\x20\x65\x2D\x6D\x61\x69\x6C\x27\x73\x00\x01\x01" ); |
|
118 msg = KMessage5().AllocLC (); |
|
119 break; |
|
120 |
|
121 } |
|
122 |
|
123 // copy data to iBodyBuf |
|
124 iBodyBuf.Delete(0,KBufferSize); |
|
125 iBodyBuf = msg->Des(); |
|
126 |
|
127 CleanupStack::PopAndDestroy(1); // msg |
|
128 } |
|
129 |
|
130 /** confirm the message has been stored in the message store. |
|
131 Writes confirmation of number of found messages to log file |
|
132 if present. |
|
133 @param void |
|
134 @return TBool |
|
135 ETrue = message(s) found |
|
136 EFalse = no message(s) found |
|
137 */ |
|
138 TBool CWapPushSICMessageTest::ConfirmMessagesSavedL() |
|
139 { |
|
140 TestMessageL ( KSICHref(), KSICText() ); |
|
141 TestMessageL ( KSICHref2(), KSICText() ); |
|
142 return TestMessageL ( KSICHref3(), KSICText2() ); |
|
143 } |
|
144 |
|
145 TBool CWapPushSICMessageTest::TestMessageL ( const TDesC& aUri, const TDesC8& aText ) |
|
146 { |
|
147 CSISLPushMsgUtils* wapPushUtils = CSISLPushMsgUtils::NewL(); |
|
148 CleanupStack::PushL(wapPushUtils); |
|
149 TMsvId slMsgEntryId; |
|
150 |
|
151 HBufC* tempHref = aUri.AllocLC(); |
|
152 |
|
153 slMsgEntryId = wapPushUtils->FindUrlL(*tempHref, KUidWapPushMsgSI); |
|
154 if (slMsgEntryId) |
|
155 { |
|
156 TBuf<KPushLogBuffer> buf; |
|
157 _LIT(KLogSLId,"SIC messages stored:\t%d"); |
|
158 buf.Format(KLogSLId,slMsgEntryId); |
|
159 WPLPrintf(buf); |
|
160 |
|
161 CSIPushMsgEntry* siLoad = CSIPushMsgEntry::NewL(); |
|
162 CleanupStack::PushL(siLoad); |
|
163 siLoad->RetrieveL(wapPushUtils->Session(), slMsgEntryId); |
|
164 const TDesC& text = siLoad->Text(); |
|
165 HBufC* des16 = EscapeUtils::ConvertToUnicodeFromUtf8L ( aText ); |
|
166 CleanupStack::PushL ( des16 ); |
|
167 if ( des16->CompareF ( text ) ) |
|
168 { |
|
169 User::Leave ( KErrCorrupt ); |
|
170 } |
|
171 |
|
172 // Check for Created time & expiration time. ( Only for the KSICHref3 ) |
|
173 if ( KSICHref3().CompareF ( siLoad->Url() ) == 0 ) |
|
174 { |
|
175 const TTime& createdTime = siLoad->Created(); |
|
176 TTime checkCreatedTime; |
|
177 checkCreatedTime.Set ( KCreatedTime() ); |
|
178 if ( createdTime != checkCreatedTime ) |
|
179 { |
|
180 User::Leave ( KErrCorrupt ); |
|
181 } |
|
182 |
|
183 // Check for expiration time |
|
184 const TTime& expiresTime = siLoad->Expires (); |
|
185 TTime checkExpiresTime; |
|
186 checkExpiresTime.Set ( KExpiresTime() ); |
|
187 if ( expiresTime != checkExpiresTime ) |
|
188 { |
|
189 User::Leave ( KErrCorrupt ); |
|
190 } |
|
191 } |
|
192 |
|
193 CleanupStack::PopAndDestroy(2); // des16, siLoad |
|
194 } |
|
195 CleanupStack::PopAndDestroy(2); // wapPushUtils, tempHref |
|
196 return slMsgEntryId; |
|
197 } |