|
1 // Copyright (c) 2004-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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // SmtpCountAttachments |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // MsgId <input>: Value of the message Id. |
|
20 // ExpectedCount <input>: (Optional) Additional check to check the expected number of attachments. |
|
21 // Count <output>: The number of attachments. |
|
22 // [Action Description] |
|
23 // Counts the number attachments associated with the specified message entry. |
|
24 // [APIs Used] |
|
25 // CMsvSession::GetEntryL |
|
26 // CImEmailMessage::AttachmentManagerL |
|
27 // MMsvAttachmentManager::AttachmentCount |
|
28 // __ACTION_INFO_END__ |
|
29 // |
|
30 // |
|
31 |
|
32 |
|
33 #include "CMtfTestActionSmtpCountAttachments.h" |
|
34 #include "CMtfTestCase.h" |
|
35 #include "CMtfTestActionParameters.h" |
|
36 #include "MtfTestActionUtilsUser.h" |
|
37 |
|
38 #include <miutset.h> |
|
39 #include <mmsvattachmentmanager.h> |
|
40 #include <miutmsg.h> |
|
41 |
|
42 CMtfTestAction* CMtfTestActionSmtpCountAttachments::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
43 { |
|
44 CMtfTestActionSmtpCountAttachments* self = new(ELeave) CMtfTestActionSmtpCountAttachments(aTestCase); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aActionParameters); |
|
47 CleanupStack::Pop(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 CMtfTestActionSmtpCountAttachments::CMtfTestActionSmtpCountAttachments(CMtfTestCase& aTestCase) |
|
53 : CMtfSynchronousTestAction(aTestCase) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 CMtfTestActionSmtpCountAttachments::~CMtfTestActionSmtpCountAttachments() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 void CMtfTestActionSmtpCountAttachments::ExecuteActionL() |
|
64 { |
|
65 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSmtpCountAttachments); |
|
66 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
67 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
68 TInt expectedCount = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), KErrNotFound); |
|
69 |
|
70 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
71 CleanupStack::PushL(entry); |
|
72 |
|
73 CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry); |
|
74 CleanupStack::PushL(emailMsg); |
|
75 |
|
76 MMsvAttachmentManager& manager = emailMsg->AttachmentManager(); |
|
77 |
|
78 TInt attachmentCount = manager.AttachmentCount(); |
|
79 |
|
80 CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry |
|
81 |
|
82 if( expectedCount >= 0 ) |
|
83 { |
|
84 // Expected count check is enabled |
|
85 if( expectedCount!=attachmentCount ) |
|
86 { |
|
87 // Not the expected number of attachments |
|
88 User::Leave(KErrGeneral); |
|
89 } |
|
90 } |
|
91 |
|
92 StoreParameterL<TInt>(TestCase(),attachmentCount,ActionParameters().Parameter(3)); |
|
93 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSmtpCountAttachments); |
|
94 TestCase().ActionCompletedL(*this); |
|
95 } |