|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include <StifParser.h> |
|
24 //#include <SAPI_TEST\testprg.h> |
|
25 #include <Stiftestinterface.h> |
|
26 #include <msvstd.h> |
|
27 #include <msvapi.h> |
|
28 #include <msvids.h> |
|
29 #include "tchangestatustest.h" |
|
30 #include "messageheader.h" |
|
31 #include "messagingservice.h" |
|
32 ////#include <senduiconsts.h> |
|
33 |
|
34 |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CTChangeStatusTest::Delete |
|
40 // Delete here all resources allocated and opened from test methods. |
|
41 // Called from destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CTChangeStatusTest::Delete() |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CTChangeStatusTest::RunMethodL |
|
51 // Run specified method. Contains also table of test mothods and their names. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TInt CTChangeStatusTest::RunMethodL( |
|
55 CStifItemParser& aItem ) |
|
56 { |
|
57 |
|
58 static TStifFunctionInfo const KFunctions[] = |
|
59 { |
|
60 // Copy this line for every implemented function. |
|
61 // First string is the function name used in TestScripter script file. |
|
62 // Second is the actual implementation member function. |
|
63 //TRY( "SendMessage", CTDeleteMessageTest::SendMessage ), |
|
64 |
|
65 ENTRY( "ChangeStatusSms", CTChangeStatusTest::ChangeStatusSms), |
|
66 ENTRY( "ChangeStatusMms", CTChangeStatusTest::ChangeStatusMms), |
|
67 ENTRY( "ChangeStatusInvalid", CTChangeStatusTest::ChangeStatusInvalid), |
|
68 |
|
69 }; |
|
70 |
|
71 const TInt count = sizeof( KFunctions ) / |
|
72 sizeof( TStifFunctionInfo ); |
|
73 |
|
74 return RunInternalL( KFunctions, count, aItem ); |
|
75 |
|
76 } |
|
77 |
|
78 |
|
79 TInt CTChangeStatusTest::ChangeStatusSms(CStifItemParser& /*aItem*/) |
|
80 { |
|
81 __UHEAP_MARK; |
|
82 |
|
83 TInt result = KErrNone; |
|
84 |
|
85 CMessagingService* test = (CMessagingService* ) CMessagingService::NewL() ; |
|
86 |
|
87 CleanupStack::PushL(test); |
|
88 |
|
89 CFilterParamInfo* filterParams = CFilterParamInfo::NewL(); |
|
90 |
|
91 filterParams->AddMtmL(_L("SMS")); |
|
92 |
|
93 CMsvEntrySelection* entrySelection = NULL; |
|
94 |
|
95 test->GetIdListL( filterParams, 0, NULL, entrySelection ); |
|
96 |
|
97 if ( entrySelection && ( entrySelection->Count() > 0 )) |
|
98 { |
|
99 TMsvId messageid; |
|
100 |
|
101 TBool value,newValue=EFalse; |
|
102 CMessageHeader* header = NULL; |
|
103 |
|
104 TInt index = 0; |
|
105 test->GetNextHeaderL( filterParams, entrySelection, index, NULL, header ); |
|
106 if ( header ) |
|
107 { |
|
108 header->GetMessageId( messageid ); |
|
109 header->GetUnreadFlag( value ); |
|
110 delete header; |
|
111 header = NULL; |
|
112 |
|
113 test->ChangeStatusL( messageid, EUnread, !value, NULL); |
|
114 |
|
115 entrySelection->Reset(); |
|
116 delete entrySelection; |
|
117 entrySelection = NULL; |
|
118 |
|
119 filterParams->SetMessageIdFilter( messageid ); |
|
120 |
|
121 test->GetIdListL( filterParams, 0, NULL, entrySelection ); |
|
122 if ( entrySelection && ( entrySelection->Count() > 0 )) |
|
123 { |
|
124 index = 0; |
|
125 test->GetNextHeaderL( filterParams, entrySelection, index, NULL, header ); |
|
126 if ( header ) |
|
127 { |
|
128 header->GetUnreadFlag(newValue); |
|
129 |
|
130 if(value == newValue) |
|
131 { |
|
132 result = KErrGeneral; |
|
133 } |
|
134 } |
|
135 } |
|
136 delete header; |
|
137 } |
|
138 } |
|
139 |
|
140 delete entrySelection; |
|
141 delete filterParams; |
|
142 |
|
143 CleanupStack::PopAndDestroy(test); |
|
144 |
|
145 __UHEAP_MARKEND; |
|
146 return result; |
|
147 |
|
148 } |
|
149 |
|
150 |
|
151 |
|
152 TInt CTChangeStatusTest::ChangeStatusMms(CStifItemParser& /*aItem*/) |
|
153 { |
|
154 __UHEAP_MARK; |
|
155 |
|
156 TInt result = KErrNone; |
|
157 |
|
158 CMessagingService* test = (CMessagingService* ) CMessagingService::NewL() ; |
|
159 |
|
160 CleanupStack::PushL(test); |
|
161 |
|
162 CFilterParamInfo* filterParams = CFilterParamInfo::NewL(); |
|
163 |
|
164 filterParams->AddMtmL(_L("MMS")); |
|
165 |
|
166 CMsvEntrySelection* entrySelection = NULL; |
|
167 |
|
168 test->GetIdListL( filterParams, 0, NULL, entrySelection ); |
|
169 |
|
170 if ( entrySelection && ( entrySelection->Count() > 0 )) |
|
171 { |
|
172 TMsvId messageid; |
|
173 |
|
174 TBool value,newValue=EFalse; |
|
175 CMessageHeader* header = NULL; |
|
176 |
|
177 TInt index = 0; |
|
178 test->GetNextHeaderL( filterParams, entrySelection, index, NULL, header ); |
|
179 if ( header ) |
|
180 { |
|
181 header->GetMessageId( messageid ); |
|
182 header->GetUnreadFlag( value ); |
|
183 delete header; |
|
184 header = NULL; |
|
185 |
|
186 test->ChangeStatusL( messageid, EUnread, !value, NULL); |
|
187 |
|
188 entrySelection->Reset(); |
|
189 delete entrySelection; |
|
190 entrySelection = NULL; |
|
191 |
|
192 filterParams->SetMessageIdFilter( messageid ); |
|
193 |
|
194 test->GetIdListL( filterParams, 0, NULL, entrySelection ); |
|
195 if ( entrySelection && ( entrySelection->Count() > 0 )) |
|
196 { |
|
197 index = 0; |
|
198 test->GetNextHeaderL( filterParams, entrySelection, index, NULL, header ); |
|
199 if ( header ) |
|
200 { |
|
201 header->GetUnreadFlag(newValue); |
|
202 |
|
203 if(value == newValue) |
|
204 { |
|
205 result = KErrGeneral; |
|
206 } |
|
207 } |
|
208 } |
|
209 delete header; |
|
210 } |
|
211 } |
|
212 |
|
213 delete entrySelection; |
|
214 delete filterParams; |
|
215 |
|
216 CleanupStack::PopAndDestroy(test); |
|
217 |
|
218 __UHEAP_MARKEND; |
|
219 return result; |
|
220 } |
|
221 |
|
222 |
|
223 |
|
224 TInt CTChangeStatusTest::ChangeStatusInvalid(CStifItemParser& /*aItem*/) |
|
225 { |
|
226 __UHEAP_MARK; |
|
227 CMessagingService* test = (CMessagingService* ) CMessagingService::NewL() ; |
|
228 CleanupStack::PushL(test); |
|
229 |
|
230 |
|
231 TRAPD( err, test->ChangeStatusL(-1,EUnread,TRUE,NULL) ); |
|
232 |
|
233 |
|
234 CleanupStack::PopAndDestroy(1) ; |
|
235 __UHEAP_MARKEND; |
|
236 |
|
237 if(err != KErrNone) |
|
238 { |
|
239 return KErrNone; |
|
240 } |
|
241 else |
|
242 { |
|
243 return err; |
|
244 } |
|
245 |
|
246 |
|
247 } |
|
248 |
|
249 |