|
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 // SendAsAddMultipleRecipient |
|
17 // [Action Parameters] |
|
18 // RSendAsMessage sendAsMessage <input> : Reference of the RSendAsMessage object |
|
19 // TDesC recipientAddress<input> : Recipient address |
|
20 // TDesC alias <input> : Alias of recipient addresses. Default value implies no Alias information is provided |
|
21 // TDesC recipientAddress1<input> : Second Recipient address |
|
22 // TSendAsRecipientType recipientType <input> : Type of recipient (ESendAsRecipientTo or ESendAsRecipientCc or ESendAsRecipientBcc) |
|
23 // TMsvId paramServiceId <input> : Value of the SMTP service id. Recipient address determined using this ID for SMTP message. |
|
24 // [Action Description] |
|
25 // SendAsAddMultipleRecipient Test Action is intended to add a new recipient to the |
|
26 // created message. |
|
27 // [APIs Used] |
|
28 // 1. RSendAsMessage::AddRecipient(const TDesC& aAddress, TSendAsRecipientType aRecipientType) |
|
29 // 2. RSendAsMessage::AddRecipient(const TDesC& aAddress, const TDesC& aAlias, |
|
30 // TSendAsRecipientType aRecipientType); |
|
31 // __ACTION_INFO_END__ |
|
32 // |
|
33 // |
|
34 |
|
35 /** |
|
36 @file |
|
37 @internalTechnology |
|
38 */ |
|
39 |
|
40 // User include |
|
41 #include "CMtfTestActionSendAsAddMultipleRecipient.h" |
|
42 #include "CMtfTestCase.h" |
|
43 #include "CMtfTestActionParameters.h" |
|
44 #include "TestFrameworkActionsUtils.h" |
|
45 #include "CMtfTestActionUtilsMessage.h" |
|
46 #include "CMtfTestActionUtilsConfigFileMachineName.h" |
|
47 |
|
48 #include <btmsgtypeuid.h> |
|
49 #include <cemailaccounts.h> |
|
50 /** |
|
51 NewL() |
|
52 Constructs a CMtfTestActionSendAsAddMultipleRecipient object. |
|
53 Uses two phase construction and leaves nothing on the CleanupStack. |
|
54 @internalTechnology |
|
55 @param aTestCase Test Case to which this Test Action belongs |
|
56 @param aActionParameters Action parameters, must not be NULL |
|
57 @return Created object of type CMtfTestActionSendAsAddMultipleRecipient |
|
58 @pre None |
|
59 @post CMtfTestActionSendAsAddMultipleRecipient object is created |
|
60 */ |
|
61 CMtfTestAction* CMtfTestActionSendAsAddMultipleRecipient:: |
|
62 NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
63 { |
|
64 CMtfTestActionSendAsAddMultipleRecipient* self = |
|
65 new (ELeave) CMtfTestActionSendAsAddMultipleRecipient(aTestCase); |
|
66 |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(aActionParameters); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 /** |
|
75 CMtfTestActionSendAsAddMultipleRecipient constructor |
|
76 Calls the base class' constructor |
|
77 @internalTechnology |
|
78 @param aTestCase Test Case to which this Test Action belongs |
|
79 @pre None |
|
80 @post None |
|
81 */ |
|
82 CMtfTestActionSendAsAddMultipleRecipient::CMtfTestActionSendAsAddMultipleRecipient(CMtfTestCase& aTestCase) |
|
83 : CMtfSynchronousTestAction(aTestCase) |
|
84 { |
|
85 } |
|
86 |
|
87 /** |
|
88 Function : ~CMtfTestActionSendAsCloseAndDeleteMessage |
|
89 Description : Destructor |
|
90 @internalTechnology |
|
91 @param : |
|
92 @return : |
|
93 @pre |
|
94 @post |
|
95 */ |
|
96 CMtfTestActionSendAsAddMultipleRecipient::~CMtfTestActionSendAsAddMultipleRecipient() |
|
97 { |
|
98 } |
|
99 |
|
100 |
|
101 /** |
|
102 ExecuteActionL |
|
103 Obtain the input parameters |
|
104 1. sendAsMessage |
|
105 2. recipientAddress |
|
106 3. alias (Default value implies empty string) |
|
107 4. recipientAddress1 |
|
108 5. recipientType |
|
109 IF alias for recipient address is provided as input |
|
110 Call RSendAsMessage::AddRecipient (const TDesC& aAddress, const TDesC& aAlias, |
|
111 TSendAsRecipientType aRecipientType) passing recipientAddress, alias and |
|
112 recipientType as input parameters |
|
113 ELSE |
|
114 Call RSendAsMessage::AddRecipient (const TDesC& aAddress, TSendAsRecipientType aRecipientType) passing recipientAddress and recipientType as input parameters |
|
115 |
|
116 @internalTechnology |
|
117 @pre None |
|
118 @post None |
|
119 @leave System wide errors |
|
120 */ |
|
121 void CMtfTestActionSendAsAddMultipleRecipient::ExecuteActionL() |
|
122 { |
|
123 if((TestCase().TestStepResult()) == EPass) |
|
124 { |
|
125 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsAddMultipleRecipient); |
|
126 |
|
127 // Get test action input parameters |
|
128 RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(), |
|
129 ActionParameters().Parameter(0)); |
|
130 |
|
131 HBufC* recipientAddress = ObtainParameterReferenceL<HBufC>(TestCase(), |
|
132 ActionParameters().Parameter(1), NULL); |
|
133 |
|
134 |
|
135 HBufC* alias = ObtainParameterReferenceL<HBufC>(TestCase(), |
|
136 ActionParameters().Parameter(2), NULL); |
|
137 |
|
138 |
|
139 RSendAsMessage::TSendAsRecipientType recipientType |
|
140 = ObtainValueParameterL<RSendAsMessage::TSendAsRecipientType>(TestCase(), |
|
141 ActionParameters().Parameter(3)); |
|
142 |
|
143 TUid msgTypeId = ObtainValueParameterL<TUid>(TestCase(), |
|
144 ActionParameters().Parameter(4)); |
|
145 |
|
146 TInt expectedErr = ObtainValueParameterL<TInt>(TestCase(), |
|
147 ActionParameters().Parameter(5)); |
|
148 //Get the second recipient address |
|
149 HBufC* recipientAddress1 = ObtainParameterReferenceL<HBufC>(TestCase(), |
|
150 ActionParameters().Parameter(6), NULL); |
|
151 |
|
152 TInt err = KErrNone; |
|
153 TBuf16<3> btAddress; |
|
154 |
|
155 |
|
156 if(recipientAddress == NULL) |
|
157 { |
|
158 if( msgTypeId.operator == (KUidMsgTypeSMTP)) |
|
159 { |
|
160 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(7), 0); |
|
161 CImSmtpSettings* settings = new(ELeave) CImSmtpSettings(); |
|
162 CleanupStack::PushL(settings); |
|
163 |
|
164 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
165 TSmtpAccount smtpAccount; |
|
166 accounts->GetSmtpAccountL(paramServiceId, smtpAccount); |
|
167 accounts->LoadSmtpSettingsL(smtpAccount, *settings); |
|
168 CleanupStack::PopAndDestroy(accounts); |
|
169 |
|
170 recipientAddress=settings->EmailAddress().AllocL(); |
|
171 CleanupStack::PopAndDestroy(settings); |
|
172 } |
|
173 else |
|
174 { |
|
175 TestCase().ERR_PRINTF1(_L("Recipient address is not provided")); |
|
176 TestCase().SetTestStepResult(EFail); |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 if( msgTypeId.operator == (KUidMsgTypeBt)) |
|
182 { |
|
183 CMtfTestActionUtilsMessage::FormatBtRecipientAddress(*recipientAddress, btAddress); |
|
184 } |
|
185 } |
|
186 if((TestCase().TestStepResult()) == EPass) |
|
187 { |
|
188 if(alias == NULL ) |
|
189 { |
|
190 if( msgTypeId.operator == (KUidMsgTypeBt)) |
|
191 { |
|
192 TRAP(err,sendAsMessage.AddRecipientL(btAddress, recipientType)); |
|
193 } |
|
194 else |
|
195 { |
|
196 TRAP(err,sendAsMessage.AddRecipientL(*recipientAddress, recipientType)); |
|
197 TRAP(err, sendAsMessage.AddRecipientL(*recipientAddress1, recipientType)); |
|
198 } |
|
199 if(err == expectedErr) |
|
200 { |
|
201 TestCase().INFO_PRINTF1(_L("Recipient address added successfully")); |
|
202 } |
|
203 else |
|
204 { |
|
205 TestCase().ERR_PRINTF2(_L("Add Recipient address failed with error %d"), err); |
|
206 } |
|
207 } |
|
208 else |
|
209 { |
|
210 if( msgTypeId.operator == (KUidMsgTypeBt)) |
|
211 { |
|
212 TRAP(err,sendAsMessage.AddRecipientL(btAddress, alias->Des(), recipientType)); |
|
213 } |
|
214 else |
|
215 { |
|
216 TRAP(err, sendAsMessage.AddRecipientL(recipientAddress->Des(), alias->Des(), recipientType)); |
|
217 } |
|
218 |
|
219 if (err == expectedErr) |
|
220 { |
|
221 if(err == KErrNone) |
|
222 { |
|
223 TestCase().INFO_PRINTF1(_L("Recipient address with alias added successfully")); |
|
224 } |
|
225 else |
|
226 { |
|
227 TestCase().INFO_PRINTF1(_L("Recipient address with alias failed with expected error")); |
|
228 } |
|
229 } |
|
230 else |
|
231 { |
|
232 TestCase().ERR_PRINTF2(_L("Add Recipient address with alias failed with error %d"), err); |
|
233 } |
|
234 } |
|
235 |
|
236 } |
|
237 |
|
238 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsAddMultipleRecipient); |
|
239 } |
|
240 TestCase().ActionCompletedL(*this); |
|
241 } |
|
242 |