|
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 <push/sislpushmsgutils.h> |
|
17 |
|
18 #include "pushtests.h" |
|
19 #include "dummywapstack.h" |
|
20 #include "wappushmsggen.h" |
|
21 |
|
22 //_LIT(KTextDoingStuff,"Doing some stuff"); |
|
23 //_LIT(KTextFinished,"All finished"); |
|
24 |
|
25 //Hard coded SL Text Msg elements |
|
26 //for 1st SL test Msg |
|
27 _LIT8(KSLHref, "http://www.xyz.com/ppaid/123/abc.wml"); |
|
28 _LIT8(KSLAction, "execute-high"); |
|
29 |
|
30 //for 2nd SL test Msg- |
|
31 _LIT8(KSLHref_1, "http://www.xyz.com/ppaid/100/aaa.wml"); |
|
32 |
|
33 /** set the test name for this test case |
|
34 @param void |
|
35 @return string |
|
36 returns test name |
|
37 */ |
|
38 const TDesC& CWapPushSLMessageTest::TestName() |
|
39 { |
|
40 _LIT(KTextSLMessageTest,"Service Loading"); |
|
41 return KTextSLMessageTest; |
|
42 } |
|
43 |
|
44 |
|
45 /** specify the number of test messages to use */ |
|
46 void CWapPushSLMessageTest::NumberTestCasesToRun() |
|
47 { |
|
48 iNumberOfTestCases = 3; |
|
49 } |
|
50 |
|
51 |
|
52 /** create test messages to use where aTestCase represents the |
|
53 message index for multiple messages. |
|
54 Tests: 0- Complete SL Push Msg |
|
55 1- SL Push Msg with attribute 'action' not specified. |
|
56 2- SL Push Msg with attribute 'href' not specified. |
|
57 |
|
58 @param aTestCase message index value for selecting a test message |
|
59 @return void |
|
60 */ |
|
61 void CWapPushSLMessageTest::PrepareTestMessageL(TInt aTestCase) |
|
62 { |
|
63 // create hardcoded SL test message (Julia's code) |
|
64 const TUint8 KMessageHeader[] = |
|
65 { |
|
66 //0xB0, //Content type "application/vnd.wap.slc" |
|
67 0xAF, //Content type "application/vnd.wap.sl" |
|
68 0x92, // Date |
|
69 0x04, // length of field |
|
70 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
71 0x90, |
|
72 0x6a, |
|
73 0xd0, |
|
74 0x94, // Expires |
|
75 0x04, // length of field |
|
76 0x39, // Monday 15 August 2000 10:41:37 GMT |
|
77 0x9a, |
|
78 0x6a, |
|
79 0xd0, |
|
80 0xAF, //X-Wap-Application-ID |
|
81 0x82 // Short int - 0x02 represent x-wap-application:push.ua |
|
82 }; |
|
83 |
|
84 // const TUint8 aChar[]={0x0a}; |
|
85 |
|
86 iHeadersBuf.Append(KMessageHeader, sizeof(KMessageHeader)); |
|
87 |
|
88 CWapPushMsgGen* msgGen = CWapPushMsgGen::NewL(); |
|
89 CleanupStack::PushL(msgGen); |
|
90 msgGen->StartNewMsgL(CWapPushMsgGen::EServiceLoad); |
|
91 |
|
92 switch (aTestCase) |
|
93 { |
|
94 case 0 : // |
|
95 msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSLHref); |
|
96 msgGen->AppendFieldL(CWapPushMsgGen::EAction, KSLAction); |
|
97 break; |
|
98 case 1 :// Attribute 'action' Not specified. |
|
99 // the value 'execute-low' should be used |
|
100 msgGen->AppendFieldL(CWapPushMsgGen::EHRef, KSLHref_1); |
|
101 break; |
|
102 case 2 :// Attribute 'href' Not specified. |
|
103 // the SL Content handler should leave with KErrCorrupt |
|
104 msgGen->AppendFieldL(CWapPushMsgGen::EAction, KSLAction); |
|
105 break; |
|
106 // case 3 :// only one character in Msg Body |
|
107 // iHeadersBuf.Append(aChar, sizeof(aChar)); |
|
108 // break; |
|
109 |
|
110 default: |
|
111 // do nothing |
|
112 break; |
|
113 } |
|
114 |
|
115 HBufC8* msg = msgGen->CreateMsgLC(); |
|
116 |
|
117 // copy data to iBodyBuf |
|
118 iBodyBuf.Delete(0,KBufferSize); |
|
119 iBodyBuf = msg->Des(); |
|
120 |
|
121 CleanupStack::PopAndDestroy(2); // msg, msgGen; |
|
122 } |
|
123 |
|
124 /** confirm the message has been stored in the message store. |
|
125 Writes confirmation of number of found messages to log file |
|
126 if present. |
|
127 @param void |
|
128 @return TBool |
|
129 ETrue = message(s) found |
|
130 EFalse = no message(s) found |
|
131 */ |
|
132 TBool CWapPushSLMessageTest::ConfirmMessagesSavedL() |
|
133 { |
|
134 CSISLPushMsgUtils* wapPushUtils = CSISLPushMsgUtils::NewL(); |
|
135 CleanupStack::PushL(wapPushUtils); |
|
136 TMsvId slMsgEntryId; |
|
137 // convert KSLHref from 8 to 16 bit for FindUrlL |
|
138 HBufC* tempHref = HBufC::NewLC(KSLHref().Length()); |
|
139 tempHref->Des().Copy(KSLHref()); |
|
140 |
|
141 slMsgEntryId = wapPushUtils->FindUrlL(*tempHref, KUidWapPushMsgSL); |
|
142 if (slMsgEntryId) |
|
143 { |
|
144 TBuf<KPushLogBuffer> buf; |
|
145 _LIT(KLogSLId,"SL messages stored:\t%d"); |
|
146 buf.Format(KLogSLId,slMsgEntryId); |
|
147 WPLPrintf(buf); |
|
148 } |
|
149 CleanupStack::PopAndDestroy(2); // wapPushUtils, tempHref |
|
150 return slMsgEntryId; |
|
151 } |