31
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 2007 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: Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// [INCLUDE FILES] - do not remove
|
|
22 |
#include <e32svr.h>
|
|
23 |
#include <StifParser.h>
|
|
24 |
#include <Stiftestinterface.h>
|
|
25 |
#include <msvapi.h>
|
|
26 |
#include <msvids.h>
|
|
27 |
#include "MmsCodecClientApiTest.h"
|
|
28 |
#include "mmscodecclient.h"
|
|
29 |
#include "mmsconst.h"
|
|
30 |
#include "e32const.h"
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
// EXTERNAL DATA STRUCTURES
|
|
37 |
|
|
38 |
|
|
39 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
40 |
|
|
41 |
|
|
42 |
// CONSTANTS
|
|
43 |
|
|
44 |
#ifdef __WINSCW__
|
|
45 |
_LIT( KBinaryMessage, "\\mmsmessagebinaries\\m.mms");
|
|
46 |
_LIT( KBinaryMessage2, "\\mmsmessagebinaries\\multipartrelated.mms");
|
|
47 |
#else
|
|
48 |
_LIT( KBinaryMessage, "%C:\\testing\\data\\mmsmessagebinaries\\m.mms");
|
|
49 |
_LIT( KBinaryMessage2, "%C:\\testing\\data\\mmsmessagebinaries\\multipartrelated.mms");
|
|
50 |
#endif
|
|
51 |
const TInt KMmsCodecClientChunkSize = 1024;
|
|
52 |
// MACROS
|
|
53 |
|
|
54 |
|
|
55 |
// LOCAL CONSTANTS AND MACROS
|
|
56 |
|
|
57 |
|
|
58 |
// MODULE DATA STRUCTURES
|
|
59 |
|
|
60 |
|
|
61 |
// LOCAL FUNCTION PROTOTYPES
|
|
62 |
|
|
63 |
|
|
64 |
// FORWARD DECLARATIONS
|
|
65 |
|
|
66 |
|
|
67 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CMmsCodecClientApiTest::Delete
|
|
75 |
// Delete here all resources allocated and opened from test methods.
|
|
76 |
// Called from destructor.
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
void CMmsCodecClientApiTest::Delete()
|
|
80 |
{
|
|
81 |
//CleanAllL();
|
|
82 |
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// CMmsCodecClientApiTest::RunMethodL
|
|
87 |
// Run specified method. Contains also table of test mothods and their names.
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
TInt CMmsCodecClientApiTest::RunMethodL(
|
|
91 |
CStifItemParser& aItem )
|
|
92 |
{
|
|
93 |
|
|
94 |
static TStifFunctionInfo const KFunctions[] =
|
|
95 |
{
|
|
96 |
// Copy this line for every implemented function.
|
|
97 |
// First string is the function name used in TestScripter script file.
|
|
98 |
// Second is the actual implementation member function.
|
|
99 |
ENTRY( "Example", CMmsCodecClientApiTest::ExampleL ),
|
|
100 |
ENTRY( "CreateNewMessageEntryL", CMmsCodecClientApiTest::CreateNewMessageEntryL ),
|
|
101 |
ENTRY( "AddMMTestL", CMmsCodecClientApiTest::AddMMTestL ),
|
|
102 |
ENTRY( "RelaceMMTestL", CMmsCodecClientApiTest::RelaceMMTestL ),
|
|
103 |
ENTRY( "RetreiveMMTestL", CMmsCodecClientApiTest::RetreiveMMTestL ),
|
|
104 |
ENTRY( "SendMMTestL", CMmsCodecClientApiTest::SendMMTestL ),
|
|
105 |
ENTRY( "MoveMMTestL", CMmsCodecClientApiTest::MoveMMTestL ),
|
|
106 |
ENTRY( "SetFlagsTest", CMmsCodecClientApiTest::SetFlagsTestL ),
|
|
107 |
ENTRY( "InitializeChunkedRetrievingTestL", CMmsCodecClientApiTest::InitializeChunkedRetrievingTestL ),
|
|
108 |
ENTRY( "DiskSpaceBelowCriticalLevelTestL", CMmsCodecClientApiTest::DiskSpaceBelowCriticalLevelTestL ),
|
|
109 |
ENTRY( "InitializeChunkedAddingTestL", CMmsCodecClientApiTest::InitializeChunkedAddingTestL ),
|
|
110 |
ENTRY( "InitializeChunkedReplacingTestL", CMmsCodecClientApiTest::InitializeChunkedReplacingTestL ),
|
|
111 |
ENTRY( "DeleteMM", CMmsCodecClientApiTest::DeleteMMTestL ),
|
|
112 |
ENTRY( "CleanMessageStore", CMmsCodecClientApiTest::CleanAllL ),
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
//ADD NEW ENTRY HERE
|
|
117 |
// [test cases entries] - Do not remove
|
|
118 |
|
|
119 |
};
|
|
120 |
|
|
121 |
const TInt count = sizeof( KFunctions ) /
|
|
122 |
sizeof( TStifFunctionInfo );
|
|
123 |
|
|
124 |
return RunInternalL( KFunctions, count, aItem );
|
|
125 |
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
// CMmsCodecClientApiTest::ExampleL
|
|
130 |
// Example test method function.
|
|
131 |
// (other items were commented in a header).
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
TInt CMmsCodecClientApiTest::ExampleL( CStifItemParser& aItem )
|
|
135 |
{
|
|
136 |
|
|
137 |
// Print to UI
|
|
138 |
_LIT( KMmsCodecClientApiTest, "MmsCodecClientApiTest" );
|
|
139 |
_LIT( KExample, "In Example" );
|
|
140 |
TestModuleIf().Printf( 0, KMmsCodecClientApiTest, KExample );
|
|
141 |
// Print to log file
|
|
142 |
iLog->Log( KExample );
|
|
143 |
|
|
144 |
TInt i = 0;
|
|
145 |
TPtrC string;
|
|
146 |
_LIT( KParam, "Param[%i]: %S" );
|
|
147 |
while ( aItem.GetNextString ( string ) == KErrNone )
|
|
148 |
{
|
|
149 |
TestModuleIf().Printf( i, KMmsCodecClientApiTest,
|
|
150 |
KParam, i, &string );
|
|
151 |
i++;
|
|
152 |
}
|
|
153 |
|
|
154 |
return KErrNone;
|
|
155 |
|
|
156 |
}
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CMmsCodecClientApiTest::CreateNewMessageEntryL
|
|
159 |
// Calls the method CreateNewMessageEntryL in CMmsCodecClient class.
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
TInt CMmsCodecClientApiTest::CreateNewMessageEntryL()
|
|
163 |
{
|
|
164 |
TInt errorCount =2;
|
|
165 |
iLog->Log(_L(" In CreateNewMessageEntryL Test"));
|
|
166 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
167 |
TMsvId folder = KMsvDraftEntryId;
|
|
168 |
TInt error1 = iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
169 |
if(error1 == KErrNone)
|
|
170 |
{
|
|
171 |
iLog->Log(_L("Created New entry in Drafts Folder successfully"));
|
|
172 |
errorCount--;
|
|
173 |
}
|
|
174 |
//Try creating the same message entry again.. It should return KErrArgument and delete the entry
|
|
175 |
error1 = iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
176 |
if(error1 == KErrArgument)
|
|
177 |
{
|
|
178 |
iLog->Log(_L("Creating same entry in Drafts Folder again returned KErrArg "));
|
|
179 |
errorCount--;
|
|
180 |
}
|
|
181 |
CleanAllL();
|
|
182 |
return errorCount;
|
|
183 |
}
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
// CMmsCodecClientApiTest::AddMMTestL
|
|
186 |
// Calls the method AddMML in CMmsCodecClient class.
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
TInt CMmsCodecClientApiTest::AddMMTestL()
|
|
190 |
{
|
|
191 |
TInt errorCount = 3;
|
|
192 |
TInt error1;
|
|
193 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
194 |
TMsvId folder = KMsvDraftEntryId;
|
|
195 |
TUint32 flags = 0;
|
|
196 |
TBool unread = EFalse;
|
|
197 |
//We are trying to call the AddMML function before calling CreateNewMessageEntryL() function.
|
|
198 |
//The size of the encode buffer is also zero
|
|
199 |
//It should return with KErrArgument
|
|
200 |
TRAPD(error2, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
201 |
if(error2 != KErrNone)
|
|
202 |
{
|
|
203 |
iLog->Log(_L("AddMMTestL returned error for the call made to AddMML before calling CreateNewMessageEntry()"));
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
iWait->Start();
|
|
208 |
if(iWait->iStatus.Int() == KErrArgument)
|
|
209 |
{
|
|
210 |
iLog->Log(_L("AddMML Returned with KErrArgument for not calling CreateNewMessageEntryL()"));
|
|
211 |
errorCount--;
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
//We are trying to call the AddMML function after calling CreateNewMessageEntryL() function.
|
|
216 |
//The size of the encode buffer is zero
|
|
217 |
//It should return KErrArgument
|
|
218 |
error1 = iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
219 |
iEncodeBuffer = CBufFlat::NewL(1);
|
|
220 |
iEncodeBuffer->ResizeL(0);
|
|
221 |
if(error1!=KErrNone)
|
|
222 |
{
|
|
223 |
return error1;
|
|
224 |
}
|
|
225 |
TRAPD(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
226 |
|
|
227 |
if(error != KErrNone)
|
|
228 |
{
|
|
229 |
iLog->Log(_L("AddMMTestL failed with error %d"),error);
|
|
230 |
}
|
|
231 |
else
|
|
232 |
{
|
|
233 |
iWait->Start();
|
|
234 |
if(iWait->iStatus.Int() == KErrArgument)
|
|
235 |
{
|
|
236 |
iLog->Log(_L("AddMMTestL returned KErrArgument,when the passed buffer size is zero"));
|
|
237 |
errorCount--;
|
|
238 |
}
|
|
239 |
}
|
|
240 |
//We are trying to call the AddMML function after calling CreateNewMessageEntryL() function.
|
|
241 |
//The size of the encode buffer is not zero
|
|
242 |
//It should return with KErrNone or KErrNotSupported if decoding fails...
|
|
243 |
|
|
244 |
error1 = iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
245 |
if(error1!=KErrNone)
|
|
246 |
{
|
|
247 |
CleanAllL();
|
|
248 |
return error1;
|
|
249 |
}
|
|
250 |
iFilePath = KBinaryMessage;
|
|
251 |
#ifndef __WINSCW__
|
|
252 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
253 |
#endif
|
|
254 |
iLog->Log(iFilePath);
|
|
255 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
256 |
// iEncodeBuffer->ResizeL(10);
|
|
257 |
|
|
258 |
TRAPD(error3, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
259 |
if(error3 != KErrNone)
|
|
260 |
{
|
|
261 |
iLog->Log(_L("AddMMTestL returned error %d "),error3);
|
|
262 |
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
iWait->Start();
|
|
267 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
268 |
{
|
|
269 |
iLog->Log(_L("AddMMTestL with valid parameters returned %d"),iWait->iStatus.Int());
|
|
270 |
errorCount--;
|
|
271 |
}
|
|
272 |
}
|
|
273 |
CleanAllL();
|
|
274 |
return errorCount;
|
|
275 |
}
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
// CMmsCodecClientApiTest::RelaceMMTestL
|
|
278 |
// Calls the method RelaceMML in CMmsCodecClient class.
|
|
279 |
// -----------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
TInt CMmsCodecClientApiTest::RelaceMMTestL()
|
|
282 |
{
|
|
283 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
284 |
TMsvId folder = KMsvDraftEntryId;
|
|
285 |
TMsvId outbox = KMsvGlobalOutBoxIndexEntryIdValue;
|
|
286 |
TUint32 flags = 0;
|
|
287 |
TBool unread = EFalse;
|
|
288 |
TInt error;
|
|
289 |
TInt returnValue;
|
|
290 |
TInt errorCount = 4;
|
|
291 |
iFilePath = KBinaryMessage;
|
|
292 |
#ifndef __WINSCW__
|
|
293 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
294 |
#endif
|
|
295 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
296 |
error = iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
297 |
if(error!=KErrNone)
|
|
298 |
{
|
|
299 |
return error;
|
|
300 |
}
|
|
301 |
//iEncodeBuffer->ResizeL(10);
|
|
302 |
TRAPD(error1, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
303 |
|
|
304 |
if(error1 != KErrNone)
|
|
305 |
{
|
|
306 |
iLog->Log(_L("AddMMTestL returned error %d "),error1);
|
|
307 |
returnValue = error1;
|
|
308 |
}
|
|
309 |
else
|
|
310 |
{
|
|
311 |
iWait->Start();
|
|
312 |
returnValue = iWait->iStatus.Int();
|
|
313 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
314 |
|
|
315 |
}
|
|
316 |
if(!returnValue)
|
|
317 |
{
|
|
318 |
iLog->Log(_L("Calling ReplaceMML with valid parameters"));
|
|
319 |
TRAPD(error3,iCodecClient->ReplaceMML(messageId, *iEncodeBuffer, flags, unread, iWait->iStatus));
|
|
320 |
|
|
321 |
if(error3 != KErrNone)
|
|
322 |
{
|
|
323 |
iLog->Log(_L("Call to ReplaceMML failed with %d"),error3);
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
iWait->Start();
|
|
328 |
iLog->Log(_L("ReplaceMML returned with state %d"),iWait->iStatus.Int());
|
|
329 |
errorCount--;
|
|
330 |
}
|
|
331 |
}
|
|
332 |
|
|
333 |
//Try to call the ReplaceMML function when the state is EEntryCreated...
|
|
334 |
//Should return with KErrArgument and changes the state to EIdle
|
|
335 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
336 |
// iEncodeBuffer->ResizeL(10);
|
|
337 |
iLog->Log(_L("Calling ReplaceMML with Invalid state"));
|
|
338 |
TRAPD(err,iCodecClient->ReplaceMML(messageId, *iEncodeBuffer, flags, unread, iWait->iStatus));
|
|
339 |
|
|
340 |
if(err != KErrNone)
|
|
341 |
{
|
|
342 |
iLog->Log(_L("Call to ReplaceMML passed even when the state is EEntryCreated"));
|
|
343 |
}
|
|
344 |
else
|
|
345 |
{
|
|
346 |
iWait->Start();
|
|
347 |
iLog->Log(_L("ReplaceMML returned with state %d"),iWait->iStatus.Int());
|
|
348 |
errorCount--;
|
|
349 |
}
|
|
350 |
// Call the ReplaceMML method with an empty buffer
|
|
351 |
iEncodeBuffer->ResizeL(0);
|
|
352 |
iLog->Log(_L("Calling ReplaceMML with empty buffer"));
|
|
353 |
TRAPD(error2,iCodecClient->ReplaceMML(messageId, *iEncodeBuffer, flags, unread, iWait->iStatus));
|
|
354 |
|
|
355 |
if(error2 != KErrNone)
|
|
356 |
{
|
|
357 |
iLog->Log(_L("Call to ReplaceMML passed even when the buffer size is zero"));
|
|
358 |
}
|
|
359 |
else
|
|
360 |
{
|
|
361 |
iWait->Start();
|
|
362 |
iLog->Log(_L("ReplaceMML returned with state %d"),iWait->iStatus.Int());
|
|
363 |
errorCount--;
|
|
364 |
}
|
|
365 |
//Call ReplaceMML to replace a message in OutBox, it should return with error.
|
|
366 |
|
|
367 |
iLog->Log(_L("Calling ReplaceMML to replace a message in outbox"));
|
|
368 |
iCodecClient->CreateNewMessageEntryL(outbox, messageId);
|
|
369 |
// iEncodeBuffer->ResizeL(10);
|
|
370 |
TRAPD(error3, iCodecClient->AddMML(*iEncodeBuffer, outbox, flags, unread, messageId, iWait->iStatus ) );
|
|
371 |
|
|
372 |
if(error3 != KErrNone)
|
|
373 |
{
|
|
374 |
iLog->Log(_L("AddMMTestL returned error %d "),error1);
|
|
375 |
|
|
376 |
}
|
|
377 |
else
|
|
378 |
{
|
|
379 |
iWait->Start();
|
|
380 |
returnValue = iWait->iStatus.Int();
|
|
381 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
382 |
|
|
383 |
}
|
|
384 |
TRAPD(err4,iCodecClient->ReplaceMML(messageId, *iEncodeBuffer, flags, unread, iWait->iStatus));
|
|
385 |
|
|
386 |
if(err4 != KErrNone)
|
|
387 |
{
|
|
388 |
iLog->Log(_L("Call to ReplaceMML passed even when the state is EEntryCreated"));
|
|
389 |
}
|
|
390 |
else
|
|
391 |
{
|
|
392 |
iWait->Start();
|
|
393 |
iLog->Log(_L("ReplaceMML returned with state %d"),iWait->iStatus.Int());
|
|
394 |
errorCount--;
|
|
395 |
}
|
|
396 |
CleanAllL();
|
|
397 |
return errorCount;
|
|
398 |
}
|
|
399 |
// -----------------------------------------------------------------------------
|
|
400 |
// CMmsCodecClientApiTest::RetreiveMMTestL
|
|
401 |
// Calls the method RetreiveMML in CMmsCodecClient class.
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
//
|
|
404 |
TInt CMmsCodecClientApiTest::RetreiveMMTestL()
|
|
405 |
{
|
|
406 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
407 |
TMsvId folder = KMsvDraftEntryId;
|
|
408 |
TUint32 flags = 0;
|
|
409 |
TBool unread = EFalse;
|
|
410 |
TInt returnValue;
|
|
411 |
TInt errorCount = 2;
|
|
412 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
413 |
iFilePath = KBinaryMessage2;
|
|
414 |
#ifndef __WINSCW__
|
|
415 |
iFilePath.Format(KBinaryMessage2,69);/*69 Repesents E*/
|
|
416 |
#endif
|
|
417 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
418 |
iLog->Log(_L("Calling RetrieveMML with invalid state"));
|
|
419 |
TRAPD( error1, iCodecClient->RetrieveMML( messageId, *iEncodeBuffer, folder, flags, unread, iWait->iStatus ) );
|
|
420 |
|
|
421 |
if ( error1 != KErrNone )
|
|
422 |
{
|
|
423 |
iLog->Log( _L("Retrieve Message entry failed, left with error: %d"), error1 );
|
|
424 |
|
|
425 |
}
|
|
426 |
else
|
|
427 |
{
|
|
428 |
iWait->Start();
|
|
429 |
iLog->Log( _L("Retrieve Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
430 |
errorCount--;
|
|
431 |
}
|
|
432 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
433 |
TRAPD(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
434 |
|
|
435 |
if(error != KErrNone)
|
|
436 |
{
|
|
437 |
iLog->Log(_L("AddMMTestL returned error %d "),error1);
|
|
438 |
returnValue = error1;
|
|
439 |
}
|
|
440 |
else
|
|
441 |
{
|
|
442 |
iWait->Start();
|
|
443 |
returnValue = iWait->iStatus.Int();
|
|
444 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
445 |
}
|
|
446 |
if(!returnValue)
|
|
447 |
{
|
|
448 |
iLog->Log(_L("Calling RetrieveMML with valid parameters"));
|
|
449 |
TRAP( error, iCodecClient->RetrieveMML( messageId, *iEncodeBuffer, folder, flags, unread, iWait->iStatus ) );
|
|
450 |
if ( error != KErrNone )
|
|
451 |
{
|
|
452 |
iLog->Log( _L("Retrieve Message entry failed, left with error: %d"), error );
|
|
453 |
}
|
|
454 |
else
|
|
455 |
{
|
|
456 |
iWait->Start();
|
|
457 |
iLog->Log( _L("Retrieve Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
458 |
errorCount--;
|
|
459 |
}
|
|
460 |
}
|
|
461 |
CleanAllL();
|
|
462 |
return errorCount;
|
|
463 |
}
|
|
464 |
// -----------------------------------------------------------------------------
|
|
465 |
// CMmsCodecClientApiTest::SendMMTestL
|
|
466 |
// Calls the method SendMML in CMmsCodecClient class.
|
|
467 |
// -----------------------------------------------------------------------------
|
|
468 |
//
|
|
469 |
|
|
470 |
TInt CMmsCodecClientApiTest::SendMMTestL()
|
|
471 |
{
|
|
472 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
473 |
TMsvId folder = KMsvDraftEntryId;
|
|
474 |
TUint32 flags = 0;
|
|
475 |
TBool unread = EFalse;
|
|
476 |
TInt errorCount = 2;
|
|
477 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
478 |
iFilePath = KBinaryMessage;
|
|
479 |
#ifndef __WINSCW__
|
|
480 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
481 |
#endif
|
|
482 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
483 |
iLog->Log(_L("Calling SendMML with invalid state"));
|
|
484 |
TRAPD( error1, iCodecClient->SendMML( messageId,iWait->iStatus ) );
|
|
485 |
|
|
486 |
if ( error1 != KErrNone )
|
|
487 |
{
|
|
488 |
iLog->Log( _L("Sending Message entry failed, left with error: %d"), error1 );
|
|
489 |
|
|
490 |
}
|
|
491 |
else
|
|
492 |
{
|
|
493 |
iWait->Start();
|
|
494 |
iLog->Log( _L("Sending Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
495 |
errorCount--;
|
|
496 |
}
|
|
497 |
|
|
498 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
499 |
TRAPD(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
500 |
|
|
501 |
if(error != KErrNone)
|
|
502 |
{
|
|
503 |
iLog->Log(_L("AddMMTestL returned error %d "),error1);
|
|
504 |
|
|
505 |
}
|
|
506 |
else
|
|
507 |
{
|
|
508 |
iWait->Start();
|
|
509 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
510 |
|
|
511 |
}
|
|
512 |
iLog->Log(_L("Calling SendMML with valid parameters"));
|
|
513 |
TRAPD( error2, iCodecClient->SendMML( messageId,iWait->iStatus ) );
|
|
514 |
|
|
515 |
if ( error2 != KErrNone )
|
|
516 |
{
|
|
517 |
iLog->Log( _L("Sending Message entry failed, left with error: %d"), error1 );
|
|
518 |
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
iWait->Start();
|
|
523 |
iLog->Log( _L("Sending Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
524 |
errorCount--;
|
|
525 |
}
|
|
526 |
CleanAllL();
|
|
527 |
return errorCount;
|
|
528 |
}
|
|
529 |
// -----------------------------------------------------------------------------
|
|
530 |
// CMmsCodecClientApiTest::MoveMMTestL
|
|
531 |
// Calls the method MoveMML in CMmsCodecClient class.
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
|
|
535 |
TInt CMmsCodecClientApiTest::MoveMMTestL()
|
|
536 |
{
|
|
537 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
538 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
539 |
TMsvId sentFolder = KMsvSentEntryId;
|
|
540 |
TUint32 flags = 0;
|
|
541 |
TBool unread = EFalse;
|
|
542 |
TInt errorCount = 5;
|
|
543 |
TInt error;
|
|
544 |
CMsvEntry* cEntry = iSession->GetEntryL( KMsvRootIndexEntryId );
|
|
545 |
CleanupStack::PushL( cEntry );
|
|
546 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
547 |
iFilePath = KBinaryMessage2;
|
|
548 |
#ifndef __WINSCW__
|
|
549 |
iFilePath.Format(KBinaryMessage2,69);/*69 Repesents E*/
|
|
550 |
#endif
|
|
551 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
552 |
iLog->Log(_L("Calling MoveMML with invalid state"));
|
|
553 |
TRAPD( error1, iCodecClient->MoveMML( messageId,KMsvDraftEntryId,iWait->iStatus ) );
|
|
554 |
|
|
555 |
if ( error1 != KErrNone )
|
|
556 |
{
|
|
557 |
iLog->Log( _L("Moving Message entry failed, left with error: %d"), error1 );
|
|
558 |
|
|
559 |
}
|
|
560 |
else
|
|
561 |
{
|
|
562 |
iWait->Start();
|
|
563 |
iLog->Log( _L("Moving Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
564 |
errorCount--;
|
|
565 |
}
|
|
566 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
567 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
568 |
|
|
569 |
if(error != KErrNone)
|
|
570 |
{
|
|
571 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
572 |
}
|
|
573 |
else
|
|
574 |
{
|
|
575 |
iWait->Start();
|
|
576 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
577 |
|
|
578 |
}
|
|
579 |
iLog->Log(_L("Moving message to Outbox"));
|
|
580 |
TRAPD( error2, iCodecClient->MoveMML( messageId,KMsvGlobalOutBoxIndexEntryId,iWait->iStatus ) );
|
|
581 |
|
|
582 |
if ( error2 != KErrNone )
|
|
583 |
{
|
|
584 |
iLog->Log( _L("Moving Message entry failed, left with error: %d"), error1 );
|
|
585 |
|
|
586 |
}
|
|
587 |
else
|
|
588 |
{
|
|
589 |
iWait->Start();
|
|
590 |
iLog->Log( _L("Moving Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
591 |
errorCount--;
|
|
592 |
}
|
|
593 |
iLog->Log(_L("Calling MoveMML with samefolder as parent"));
|
|
594 |
TRAPD( error4, iCodecClient->MoveMML( messageId,KMsvGlobalInBoxIndexEntryId,iWait->iStatus ) );
|
|
595 |
|
|
596 |
if ( error4 != KErrNone )
|
|
597 |
{
|
|
598 |
iLog->Log( _L("Moving Message entry failed, left with error: %d"), error1 );
|
|
599 |
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
iWait->Start();
|
|
604 |
iLog->Log( _L("Moving Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
605 |
errorCount--;
|
|
606 |
}
|
|
607 |
|
|
608 |
iLog->Log(_L("Moving Message to Sent folder"));
|
|
609 |
TRAPD( error5, iCodecClient->MoveMML( messageId,KMsvSentEntryId,iWait->iStatus ) );
|
|
610 |
|
|
611 |
if ( error5 != KErrNone )
|
|
612 |
{
|
|
613 |
iLog->Log( _L("Moving Message entry failed, left with error: %d"), error5 );
|
|
614 |
|
|
615 |
}
|
|
616 |
else
|
|
617 |
{
|
|
618 |
iWait->Start();
|
|
619 |
iLog->Log( _L("Moving Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
620 |
errorCount--;
|
|
621 |
}
|
|
622 |
iCodecClient->CreateNewMessageEntryL(sentFolder, messageId);
|
|
623 |
|
|
624 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, sentFolder, flags, unread, messageId, iWait->iStatus ) );
|
|
625 |
|
|
626 |
if(error != KErrNone)
|
|
627 |
{
|
|
628 |
iLog->Log(_L("AddMMTestL returned error %d "),error1);
|
|
629 |
|
|
630 |
}
|
|
631 |
else
|
|
632 |
{
|
|
633 |
iWait->Start();
|
|
634 |
iLog->Log(_L("AddMMTestL returned %d"),iWait->iStatus.Int());
|
|
635 |
|
|
636 |
}
|
|
637 |
iLog->Log(_L("Moving message to Inbox"));
|
|
638 |
TRAPD( error3, iCodecClient->MoveMML( messageId,KMsvGlobalInBoxIndexEntryId,iWait->iStatus ) );
|
|
639 |
|
|
640 |
if ( error3 != KErrNone )
|
|
641 |
{
|
|
642 |
iLog->Log( _L("Moving Message entry failed, left with error: %d"), error1 );
|
|
643 |
}
|
|
644 |
else
|
|
645 |
{
|
|
646 |
iWait->Start();
|
|
647 |
iLog->Log( _L("Moving Message entry completed with status: %d"), iWait->iStatus.Int() );
|
|
648 |
errorCount--;
|
|
649 |
}
|
|
650 |
CleanupStack::PopAndDestroy(cEntry);
|
|
651 |
CleanAllL();
|
|
652 |
return errorCount;
|
|
653 |
}
|
|
654 |
// -----------------------------------------------------------------------------
|
|
655 |
// CMmsCodecClientApiTest::SetFlagsTest
|
|
656 |
// Calls the method SetFlags() in CMmsCodecClient class.
|
|
657 |
// -----------------------------------------------------------------------------
|
|
658 |
//
|
|
659 |
|
|
660 |
TInt CMmsCodecClientApiTest::SetFlagsTestL()
|
|
661 |
{
|
|
662 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
663 |
TMsvId nullMessageId = KMsvNullIndexEntryId;
|
|
664 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
665 |
TMsvId outbox = KMsvGlobalOutBoxIndexEntryId;
|
|
666 |
TUint32 flags = 0;
|
|
667 |
TBool unread = EFalse;
|
|
668 |
TInt error;
|
|
669 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
670 |
iFilePath = KBinaryMessage;
|
|
671 |
#ifndef __WINSCW__
|
|
672 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
673 |
#endif
|
|
674 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
675 |
iLog->Log(_L("Calling SetFlags() with invalid state"));
|
|
676 |
error = iCodecClient->SetFlags(messageId, flags, unread );
|
|
677 |
iLog->Log(_L("Set Flags returned %d"),error);
|
|
678 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
679 |
iLog->Log(_L("Calling SetFlags() with invalid state and Null MessageId"));
|
|
680 |
error = iCodecClient->SetFlags(nullMessageId, flags, unread );
|
|
681 |
iLog->Log(_L("Set Flags returned %d"),error);
|
|
682 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
683 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
684 |
|
|
685 |
if(error != KErrNone)
|
|
686 |
{
|
|
687 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
688 |
}
|
|
689 |
else
|
|
690 |
{
|
|
691 |
iWait->Start();
|
|
692 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
693 |
}
|
|
694 |
iLog->Log(_L("Calling SetFlags() valid params"));
|
|
695 |
error = iCodecClient->SetFlags(messageId, flags, unread );
|
|
696 |
iLog->Log(_L("Set Flags returned with %d"),error);
|
|
697 |
iCodecClient->CreateNewMessageEntryL(outbox, messageId);
|
|
698 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, outbox, flags, unread, messageId, iWait->iStatus ) );
|
|
699 |
|
|
700 |
if(error != KErrNone)
|
|
701 |
{
|
|
702 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
703 |
}
|
|
704 |
else
|
|
705 |
{
|
|
706 |
iWait->Start();
|
|
707 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
708 |
}
|
|
709 |
iLog->Log(_L("Calling SetFlags() for message in OutBox"));
|
|
710 |
error = iCodecClient->SetFlags(messageId, flags, unread );
|
|
711 |
iLog->Log(_L("Set Flags returned with %d"),error);
|
|
712 |
CleanAllL();
|
|
713 |
return KErrNone;
|
|
714 |
}
|
|
715 |
// -----------------------------------------------------------------------------
|
|
716 |
// CMmsCodecClientApiTest::InitializeChunkedRetrievingTestL
|
|
717 |
// Calls the method InitializeChunkedRetrievingL() in CMmsCodecClient class.
|
|
718 |
// -----------------------------------------------------------------------------
|
|
719 |
//
|
|
720 |
TInt CMmsCodecClientApiTest::InitializeChunkedRetrievingTestL()
|
|
721 |
{
|
|
722 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
723 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
724 |
TUint32 flags = 0;
|
|
725 |
TBool unread = EFalse;
|
|
726 |
TInt error;
|
|
727 |
TInt size = 1;
|
|
728 |
TBool lastChunk = EFalse;
|
|
729 |
TPtrC8 dataPart;
|
|
730 |
TInt pos = 0;
|
|
731 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
732 |
iCodecClient->NextDataPart( dataPart, lastChunk ); //Calling Next Data Part with invalid state
|
|
733 |
iFilePath = KBinaryMessage;
|
|
734 |
#ifndef __WINSCW__
|
|
735 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
736 |
#endif
|
|
737 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
738 |
iLog->Log(_L("Calling InitializeChunkedRetrievingL() with invalid state"));
|
|
739 |
TRAP( error, iCodecClient->InitializeChunkedRetrievingL( messageId, folder,flags, unread, size, iWait->iStatus ) );
|
|
740 |
|
|
741 |
if ( error == KErrNone )
|
|
742 |
{
|
|
743 |
if ( iWait->iStatus.Int() == KErrNone )
|
|
744 |
{
|
|
745 |
iLog->Log( _L("InitializeChunkedRetrievingL Failed, should have returned error"));
|
|
746 |
}
|
|
747 |
else
|
|
748 |
{
|
|
749 |
iLog->Log(_L("InitializeChunkedRetrievingL returned error %d"),error);
|
|
750 |
}
|
|
751 |
}
|
|
752 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
753 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
754 |
|
|
755 |
if(error != KErrNone)
|
|
756 |
{
|
|
757 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
758 |
}
|
|
759 |
else
|
|
760 |
{
|
|
761 |
iWait->Start();
|
|
762 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
763 |
}
|
|
764 |
|
|
765 |
TRAP( error, iCodecClient->InitializeChunkedRetrievingL( messageId, folder,flags, unread, size, iWait->iStatus ) );
|
|
766 |
|
|
767 |
if ( error == KErrNone )
|
|
768 |
{
|
|
769 |
iWait->Start();
|
|
770 |
if ( iWait->iStatus.Int() == KErrNone )
|
|
771 |
{
|
|
772 |
while ( !lastChunk && error == KErrNone )
|
|
773 |
{
|
|
774 |
error = iCodecClient->GetNextDataPart( dataPart, lastChunk ); //This is a correct context of GetNextDataPart
|
|
775 |
if ( error != KErrNone )
|
|
776 |
{
|
|
777 |
iLog->Log(_L("GetNextDataPart returned error %d"), error );
|
|
778 |
|
|
779 |
}
|
|
780 |
if ( dataPart.Length() > 0 && error == KErrNone )
|
|
781 |
{
|
|
782 |
if ( iEncodeBuffer->Size() < pos + dataPart.Length() )
|
|
783 |
{
|
|
784 |
iEncodeBuffer->ResizeL( pos + dataPart.Length() );
|
|
785 |
}
|
|
786 |
iEncodeBuffer->Write( pos, dataPart );
|
|
787 |
pos += dataPart.Length();
|
|
788 |
}
|
|
789 |
error = iCodecClient->ReleaseData();
|
|
790 |
if ( error != KErrNone )
|
|
791 |
{
|
|
792 |
iLog->Log(_L("ReleaseData returned error %d"), error );
|
|
793 |
}
|
|
794 |
}
|
|
795 |
iLog->Log( _L("InitializeChunkedRetrievingL Passed"));
|
|
796 |
}
|
|
797 |
else
|
|
798 |
{
|
|
799 |
iLog->Log(_L("InitializeChunkedRetrievingL returned with status %d"),iWait->iStatus.Int());
|
|
800 |
}
|
|
801 |
}
|
|
802 |
else
|
|
803 |
{
|
|
804 |
iLog->Log(_L("InitializeChunkedRetrievingL left with error %d"),error);
|
|
805 |
}
|
|
806 |
// The pass case is executed again to Cover the decision " if(iEncodeBuffer)" in CUT
|
|
807 |
messageId = KMsvNullIndexEntryId;
|
|
808 |
iFilePath = KBinaryMessage;
|
|
809 |
#ifndef __WINSCW__
|
|
810 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
811 |
#endif
|
|
812 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
813 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
814 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
815 |
if(error != KErrNone)
|
|
816 |
{
|
|
817 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
818 |
}
|
|
819 |
else
|
|
820 |
{
|
|
821 |
iWait->Start();
|
|
822 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
823 |
}
|
|
824 |
|
|
825 |
TRAP( error, iCodecClient->InitializeChunkedRetrievingL( messageId, folder,flags, unread, size, iWait->iStatus ) );
|
|
826 |
|
|
827 |
if ( error == KErrNone )
|
|
828 |
{
|
|
829 |
iWait->Start();
|
|
830 |
if ( iWait->iStatus.Int() == KErrNone )
|
|
831 |
{
|
|
832 |
while ( !lastChunk && error == KErrNone )
|
|
833 |
{
|
|
834 |
error = iCodecClient->GetNextDataPart( dataPart, lastChunk ); //This is a correct context of GetNextDataPart
|
|
835 |
if ( error != KErrNone )
|
|
836 |
{
|
|
837 |
iLog->Log(_L("GetNextDataPart returned error %d"), error );
|
|
838 |
|
|
839 |
}
|
|
840 |
if ( dataPart.Length() > 0 && error == KErrNone )
|
|
841 |
{
|
|
842 |
if ( iEncodeBuffer->Size() < pos + dataPart.Length() )
|
|
843 |
{
|
|
844 |
iEncodeBuffer->ResizeL( pos + dataPart.Length() );
|
|
845 |
}
|
|
846 |
iEncodeBuffer->Write( pos, dataPart );
|
|
847 |
pos += dataPart.Length();
|
|
848 |
}
|
|
849 |
error = iCodecClient->ReleaseData();
|
|
850 |
if ( error != KErrNone )
|
|
851 |
{
|
|
852 |
iLog->Log(_L("ReleaseData returned error %d"), error );
|
|
853 |
}
|
|
854 |
}
|
|
855 |
iLog->Log( _L("InitializeChunkedRetrievingL Passed"));
|
|
856 |
}
|
|
857 |
else
|
|
858 |
{
|
|
859 |
iLog->Log(_L("InitializeChunkedRetrievingL returned with status %d"),iWait->iStatus.Int());
|
|
860 |
}
|
|
861 |
}
|
|
862 |
else
|
|
863 |
{
|
|
864 |
iLog->Log(_L("InitializeChunkedRetrievingL left with error %d"),error);
|
|
865 |
}
|
|
866 |
CleanAllL();
|
|
867 |
return KErrNone;
|
|
868 |
}
|
|
869 |
// -----------------------------------------------------------------------------
|
|
870 |
// CMmsCodecClientApiTest::DiskSpaceBelowCriticalLevelTestL
|
|
871 |
// Calls the method DiskSpaceBelowCriticalLevelL() in CMmsCodecClient class.
|
|
872 |
// -----------------------------------------------------------------------------
|
|
873 |
//
|
|
874 |
|
|
875 |
TInt CMmsCodecClientApiTest::DiskSpaceBelowCriticalLevelTestL()
|
|
876 |
{
|
|
877 |
iCodecClient->DiskSpaceBelowCriticalLevelL(KMmsIndexEntryExtra);
|
|
878 |
return KErrNone;
|
|
879 |
}
|
|
880 |
// -----------------------------------------------------------------------------
|
|
881 |
// CMmsCodecClientApiTest::InitializeChunkedAddingTestL
|
|
882 |
// Calls the method InitializeChunkedAddingL() in CMmsCodecClient class.
|
|
883 |
// -----------------------------------------------------------------------------
|
|
884 |
//
|
|
885 |
TInt CMmsCodecClientApiTest::InitializeChunkedAddingTestL()
|
|
886 |
{
|
|
887 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
888 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
889 |
TUint32 flags = 0;
|
|
890 |
TBool unread = EFalse;
|
|
891 |
TInt error;
|
|
892 |
TBool lastChunk = EFalse;
|
|
893 |
TPtrC8 dataPart;
|
|
894 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
895 |
iFilePath = KBinaryMessage;
|
|
896 |
#ifndef __WINSCW__
|
|
897 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
898 |
#endif
|
|
899 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
900 |
iLog->Log(_L("Calling InitializeChunkedAddingL() with invalid state"));
|
|
901 |
TRAP( error, iCodecClient->InitializeChunkedAddingL( KMsvDraftEntryId, messageId, flags, unread ) );
|
|
902 |
if ( error == KErrNone )
|
|
903 |
{
|
|
904 |
iLog->Log( _L("InitializeChunkedAddingL Failed, should have returned error"));
|
|
905 |
}
|
|
906 |
else
|
|
907 |
{
|
|
908 |
iLog->Log(_L("InitializeChunkedAddingL returned error %d"),error);
|
|
909 |
}
|
|
910 |
|
|
911 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
912 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
913 |
if(error != KErrNone)
|
|
914 |
{
|
|
915 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
916 |
}
|
|
917 |
else
|
|
918 |
{
|
|
919 |
iWait->Start();
|
|
920 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
921 |
{
|
|
922 |
//returnValue = iWait->iStatus.Int();
|
|
923 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
924 |
}
|
|
925 |
}
|
|
926 |
TRAP( error, iCodecClient->InitializeChunkedAddingL( KMsvDraftEntryId, messageId, flags, unread ) );
|
|
927 |
error = FeedDataInChunks( iCodecClient );
|
|
928 |
if ( error == KErrNone )
|
|
929 |
{
|
|
930 |
iLog->Log( _L("InitializeChunkedAddingL passed"));
|
|
931 |
}
|
|
932 |
else
|
|
933 |
{
|
|
934 |
iLog->Log(_L("InitializeChunkedAddingL returned error %d"),error);
|
|
935 |
}
|
|
936 |
TInt error1 = iCodecClient->GetNextDataPart( dataPart, lastChunk ); //Calling GetNextDataPart out of context...
|
|
937 |
error1 = iCodecClient->ReleaseData(); //Calling Release Data Out of Context....
|
|
938 |
|
|
939 |
// The pass case is executed again to Cover the decision " if(iEncodeBuffer)" in CUT
|
|
940 |
messageId = KMsvNullIndexEntryId;
|
|
941 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
942 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
943 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
944 |
if(error != KErrNone)
|
|
945 |
{
|
|
946 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
947 |
}
|
|
948 |
else
|
|
949 |
{
|
|
950 |
iWait->Start();
|
|
951 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
952 |
{
|
|
953 |
//returnValue = iWait->iStatus.Int();
|
|
954 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
955 |
}
|
|
956 |
}
|
|
957 |
TRAP( error, iCodecClient->InitializeChunkedAddingL( KMsvDraftEntryId, messageId, flags, unread ) );
|
|
958 |
error = FeedDataInChunks( iCodecClient );
|
|
959 |
if ( error == KErrNone )
|
|
960 |
{
|
|
961 |
iLog->Log( _L("InitializeChunkedAddingL passed"));
|
|
962 |
}
|
|
963 |
else
|
|
964 |
{
|
|
965 |
iLog->Log(_L("InitializeChunkedAddingL returned error %d"),error);
|
|
966 |
}
|
|
967 |
CleanAllL();
|
|
968 |
return error;
|
|
969 |
}
|
|
970 |
// -----------------------------------------------------------------------------
|
|
971 |
// CMmsCodecClientApiTest::InitializeChunkedReplacingTestL
|
|
972 |
// Calls the method InitializeChunkedReplacingL() in CMmsCodecClient class.
|
|
973 |
// -----------------------------------------------------------------------------
|
|
974 |
//
|
|
975 |
TInt CMmsCodecClientApiTest::InitializeChunkedReplacingTestL()
|
|
976 |
{
|
|
977 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
978 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
979 |
TMsvId outBox = KMsvGlobalOutBoxIndexEntryId;
|
|
980 |
TUint32 flags = 0;
|
|
981 |
TBool unread = EFalse;
|
|
982 |
TInt error;
|
|
983 |
TPtrC8 dataPart;
|
|
984 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
985 |
iFilePath = KBinaryMessage;
|
|
986 |
#ifndef __WINSCW__
|
|
987 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
988 |
#endif
|
|
989 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
990 |
iLog->Log(_L("Calling InitializeChunkedReplacingL() with invalid state"));
|
|
991 |
TRAP( error, iCodecClient->InitializeChunkedReplacingL(messageId, flags, unread ) );
|
|
992 |
if ( error == KErrNone )
|
|
993 |
{
|
|
994 |
iLog->Log( _L("InitializeChunkedReplacingL Failed, should have returned error"));
|
|
995 |
}
|
|
996 |
else
|
|
997 |
{
|
|
998 |
iLog->Log(_L("InitializeChunkedReplacingL returned error %d"),error);
|
|
999 |
}
|
|
1000 |
iLog->Log(_L("Calling InitializeChunkedReplacingL() to replace message in Outbox"));
|
|
1001 |
iCodecClient->CreateNewMessageEntryL(outBox, messageId);
|
|
1002 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, outBox, flags, unread, messageId, iWait->iStatus ) );
|
|
1003 |
if(error != KErrNone)
|
|
1004 |
{
|
|
1005 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
1006 |
}
|
|
1007 |
else
|
|
1008 |
{
|
|
1009 |
iWait->Start();
|
|
1010 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
1011 |
{
|
|
1012 |
//returnValue = iWait->iStatus.Int();
|
|
1013 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
1014 |
}
|
|
1015 |
}
|
|
1016 |
TRAP( error, iCodecClient->InitializeChunkedReplacingL( messageId, flags, unread ) );
|
|
1017 |
if ( error == KErrNone )
|
|
1018 |
{
|
|
1019 |
iLog->Log( _L("InitializeChunkedReplacingL Failed, should have returned error"));
|
|
1020 |
}
|
|
1021 |
else
|
|
1022 |
{
|
|
1023 |
iLog->Log(_L("InitializeChunkedReplacingL returned error %d"),error);
|
|
1024 |
}
|
|
1025 |
iLog->Log(_L("Calling InitializeChunkedReplacingL() with valid parameters"));
|
|
1026 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
1027 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
1028 |
if(error != KErrNone)
|
|
1029 |
{
|
|
1030 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
1031 |
}
|
|
1032 |
else
|
|
1033 |
{
|
|
1034 |
iWait->Start();
|
|
1035 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
1036 |
{
|
|
1037 |
//returnValue = iWait->iStatus.Int();
|
|
1038 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
1039 |
}
|
|
1040 |
}
|
|
1041 |
TRAP( error, iCodecClient->InitializeChunkedReplacingL( messageId, flags, unread ) );
|
|
1042 |
error = FeedDataInChunks( iCodecClient );
|
|
1043 |
if ( error == KErrNone )
|
|
1044 |
{
|
|
1045 |
iLog->Log( _L("InitializeChunkedReplacingL Passed"));
|
|
1046 |
}
|
|
1047 |
else
|
|
1048 |
{
|
|
1049 |
iLog->Log(_L("InitializeChunkedReplacingL returned error %d"),error);
|
|
1050 |
}
|
|
1051 |
// The pass case is executed again to Cover the decision " if(iEncodeBuffer)" in CUT
|
|
1052 |
messageId = KMsvNullIndexEntryId;
|
|
1053 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
1054 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
1055 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
1056 |
if(error != KErrNone)
|
|
1057 |
{
|
|
1058 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
1059 |
}
|
|
1060 |
else
|
|
1061 |
{
|
|
1062 |
iWait->Start();
|
|
1063 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
1064 |
{
|
|
1065 |
//returnValue = iWait->iStatus.Int();
|
|
1066 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
1067 |
}
|
|
1068 |
}
|
|
1069 |
TRAP( error, iCodecClient->InitializeChunkedReplacingL( messageId, flags, unread ) );
|
|
1070 |
error = FeedDataInChunks( iCodecClient );
|
|
1071 |
if ( error == KErrNone )
|
|
1072 |
{
|
|
1073 |
iLog->Log( _L("InitializeChunkedReplacingL Passed"));
|
|
1074 |
}
|
|
1075 |
else
|
|
1076 |
{
|
|
1077 |
iLog->Log(_L("InitializeChunkedReplacingL returned error %d"),error);
|
|
1078 |
}
|
|
1079 |
CleanAllL();
|
|
1080 |
return error;
|
|
1081 |
}
|
|
1082 |
// -----------------------------------------------------------------------------
|
|
1083 |
// CMmsCodecClientApiTest::DeleteMMTestL
|
|
1084 |
// Calls the method DeleteMML() in CMmsCodecClient class.
|
|
1085 |
// -----------------------------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
TInt CMmsCodecClientApiTest::DeleteMMTestL()
|
|
1088 |
{
|
|
1089 |
TMsvId messageId = KMsvNullIndexEntryId;
|
|
1090 |
TMsvId folder = KMsvGlobalInBoxIndexEntryId;
|
|
1091 |
TUint32 flags = 0;
|
|
1092 |
TBool unread = EFalse;
|
|
1093 |
TInt error = KErrNone;
|
|
1094 |
TPtrC8 dataPart;
|
|
1095 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
1096 |
iFilePath = KBinaryMessage;
|
|
1097 |
#ifndef __WINSCW__
|
|
1098 |
iFilePath.Format(KBinaryMessage,69);/*69 Repesents E*/
|
|
1099 |
#endif
|
|
1100 |
FillBufferFromFileL( iFilePath,iFs,iEncodeBuffer);
|
|
1101 |
iLog->Log(_L("Calling DeleteMM with invalid state"));
|
|
1102 |
iCodecClient->DeleteMM(messageId);
|
|
1103 |
if ( error == KErrNone )
|
|
1104 |
{
|
|
1105 |
iLog->Log( _L("DeleteMM Failed, should have left with error"));
|
|
1106 |
}
|
|
1107 |
else
|
|
1108 |
{
|
|
1109 |
iLog->Log(_L("DeleteMM returned error %d"),error);
|
|
1110 |
}
|
|
1111 |
iLog->Log(_L("Calling DeleteMM with valid parameters"));
|
|
1112 |
iCodecClient->CreateNewMessageEntryL(folder, messageId);
|
|
1113 |
TRAP(error, iCodecClient->AddMML(*iEncodeBuffer, folder, flags, unread, messageId, iWait->iStatus ) );
|
|
1114 |
if(error != KErrNone)
|
|
1115 |
{
|
|
1116 |
iLog->Log(_L("AddMMTestL returned error %d "),error);
|
|
1117 |
}
|
|
1118 |
else
|
|
1119 |
{
|
|
1120 |
iWait->Start();
|
|
1121 |
if(iWait->iStatus.Int() == KErrNone || iWait->iStatus.Int() == KErrNotSupported)
|
|
1122 |
{
|
|
1123 |
//returnValue = iWait->iStatus.Int();
|
|
1124 |
iLog->Log(_L("AddMMTestL returned with %d"),iWait->iStatus.Int());
|
|
1125 |
}
|
|
1126 |
}
|
|
1127 |
error = iCodecClient->DeleteMM( messageId);
|
|
1128 |
if ( error == KErrNone )
|
|
1129 |
{
|
|
1130 |
iLog->Log( _L("DeleteMM Passed"));
|
|
1131 |
}
|
|
1132 |
else
|
|
1133 |
{
|
|
1134 |
iLog->Log(_L("DeleteMM returned error %d"),error);
|
|
1135 |
}
|
|
1136 |
CleanAllL();
|
|
1137 |
return error;
|
|
1138 |
}
|
|
1139 |
// -----------------------------------------------------------------------------
|
|
1140 |
// CMmsCodecClientApiTest::FeedDataInChunks
|
|
1141 |
// Method used to retrieve the data in chunks.
|
|
1142 |
// -----------------------------------------------------------------------------
|
|
1143 |
//
|
|
1144 |
TInt CMmsCodecClientApiTest::FeedDataInChunks( CMmsCodecClient* aCodecClient )
|
|
1145 |
{
|
|
1146 |
|
|
1147 |
TInt error = KErrNone;
|
|
1148 |
TInt chunkSize = KMmsCodecClientChunkSize;
|
|
1149 |
TInt size = iEncodeBuffer->Size();
|
|
1150 |
|
|
1151 |
// Number of full chunks
|
|
1152 |
TInt chunkNumber = size / chunkSize;
|
|
1153 |
TInt remainder = size % chunkSize;
|
|
1154 |
|
|
1155 |
TInt pos = 0;
|
|
1156 |
TPtrC8 messagePtr( iEncodeBuffer->Ptr( 0 ) );
|
|
1157 |
|
|
1158 |
TBool lastChunk = EFalse;
|
|
1159 |
TInt i = 0;
|
|
1160 |
for ( i = 0; i < chunkNumber && error == KErrNone; i++ )
|
|
1161 |
{
|
|
1162 |
pos = i * chunkSize;
|
|
1163 |
TPtrC8 ptr( iEncodeBuffer->Ptr( 0 ).Mid( pos, chunkSize ) );
|
|
1164 |
error = aCodecClient->NextDataPart( ptr, lastChunk );
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
// last chunk
|
|
1168 |
|
|
1169 |
if ( remainder > 0 && error == KErrNone )
|
|
1170 |
{
|
|
1171 |
TPtrC8 ptr2( iEncodeBuffer->Ptr( size - remainder ) );
|
|
1172 |
if ( ptr2.Length() > 0 )
|
|
1173 |
{
|
|
1174 |
error = aCodecClient->NextDataPart( ptr2, lastChunk );
|
|
1175 |
}
|
|
1176 |
}
|
|
1177 |
|
|
1178 |
lastChunk = ETrue;
|
|
1179 |
TPtrC8 ptr3;
|
|
1180 |
if ( error == KErrNone )
|
|
1181 |
{
|
|
1182 |
aCodecClient->NextDataPart( ptr3, lastChunk );
|
|
1183 |
}
|
|
1184 |
return error;
|
|
1185 |
}
|
|
1186 |
|
|
1187 |
void CMmsCodecClientApiTest::FillBufferFromFileL(const TDesC& aFilePath,RFs& aFs,CBufFlat* aEncodeBuffer)
|
|
1188 |
{
|
|
1189 |
TInt error = KErrNone;
|
|
1190 |
TEntry orgEntry;
|
|
1191 |
error = aFs.Entry( aFilePath, orgEntry );
|
|
1192 |
TInt size = orgEntry.iSize;
|
|
1193 |
RFile inFile;
|
|
1194 |
|
|
1195 |
if ( aEncodeBuffer == NULL )
|
|
1196 |
{
|
|
1197 |
aEncodeBuffer = CBufFlat::NewL( size );
|
|
1198 |
}
|
|
1199 |
else
|
|
1200 |
{
|
|
1201 |
aEncodeBuffer->ResizeL( 0 );
|
|
1202 |
aEncodeBuffer->ResizeL( size );
|
|
1203 |
}
|
|
1204 |
|
|
1205 |
error = inFile.Open( aFs, aFilePath, EFileShareReadersOnly );
|
|
1206 |
TPtr8 ptr = aEncodeBuffer->Ptr( 0 );
|
|
1207 |
if ( error == KErrNone )
|
|
1208 |
{
|
|
1209 |
error = inFile.Read( ptr, size );
|
|
1210 |
inFile.Close();
|
|
1211 |
}
|
|
1212 |
else
|
|
1213 |
{
|
|
1214 |
iLog->Log(_L("*** - can't read file"));
|
|
1215 |
}
|
|
1216 |
User::LeaveIfError( error );
|
|
1217 |
}
|
|
1218 |
void CMmsCodecClientApiTest::CleanAllL()
|
|
1219 |
{
|
|
1220 |
|
|
1221 |
iLog->Log(_L("In Clean All"));
|
|
1222 |
CleanBoxL(KMsvGlobalInBoxIndexEntryId,*iSession);
|
|
1223 |
CleanBoxL(KMsvGlobalOutBoxIndexEntryId,*iSession);
|
|
1224 |
CleanBoxL(KMsvSentEntryId,*iSession);
|
|
1225 |
CleanBoxL(KMsvDraftEntryId,*iSession);
|
|
1226 |
iLog->Log(_L("End of Clean All"));
|
|
1227 |
|
|
1228 |
}
|
|
1229 |
void CMmsCodecClientApiTest::CleanBoxL(TMsvId aBoxId, CMsvSession& aSession)
|
|
1230 |
{
|
|
1231 |
iLog->Log(_L("In CleanBoxL"));
|
|
1232 |
CMsvEntry* cEntry = NULL;
|
|
1233 |
// delete all messages from the specified box
|
|
1234 |
cEntry = aSession.GetEntryL(KMsvRootIndexEntryId);
|
|
1235 |
CleanupStack::PushL(cEntry);
|
|
1236 |
cEntry->SetEntryL(aBoxId);
|
|
1237 |
// show invisible entries
|
|
1238 |
cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
|
|
1239 |
CMsvEntrySelection* msvEntrySelection = cEntry->ChildrenWithMtmL(KUidMsgTypeMultimedia);
|
|
1240 |
CleanupStack::PushL(msvEntrySelection);
|
|
1241 |
|
|
1242 |
CMsvEntrySelection* selection = NULL;
|
|
1243 |
cEntry->SetSortTypeL( TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) );
|
|
1244 |
selection = cEntry->ChildrenWithMtmL(KUidMsgMMSNotification);
|
|
1245 |
CleanupStack::PushL( selection );
|
|
1246 |
if ( selection->Count() > 0 )
|
|
1247 |
{
|
|
1248 |
msvEntrySelection->AppendL( selection->Back( 0 ), selection->Count() );
|
|
1249 |
}
|
|
1250 |
CleanupStack::PopAndDestroy(); // selection
|
|
1251 |
|
|
1252 |
int i;
|
|
1253 |
for (i = 0; i < msvEntrySelection->Count(); ++i)
|
|
1254 |
{
|
|
1255 |
CMsvEntry* entry = aSession.GetEntryL( msvEntrySelection->At(i) );
|
|
1256 |
CleanupStack::PushL( entry );
|
|
1257 |
TMsvEntry tEntry = entry->Entry();
|
|
1258 |
tEntry.SetReadOnly(EFalse);
|
|
1259 |
entry->ChangeL(tEntry);
|
|
1260 |
cEntry->DeleteL( msvEntrySelection->At(i) );
|
|
1261 |
CleanupStack::PopAndDestroy( entry );
|
|
1262 |
}
|
|
1263 |
|
|
1264 |
CleanupStack::PopAndDestroy(msvEntrySelection);
|
|
1265 |
CleanupStack::PopAndDestroy(cEntry);
|
|
1266 |
iLog->Log(_L("End of CleanBoxL"));
|
|
1267 |
}
|
|
1268 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
1269 |
// None
|
|
1270 |
|
|
1271 |
// [End of File] - Do not remove
|