|
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 // VerifySubject |
|
17 // [Action Parameters] |
|
18 // CMsvEntry msgEntry <input> : Reference to the message entry object |
|
19 // HBufC subject <input> : String containing the Subject |
|
20 // [Action Description] |
|
21 // Compares the subject field of the message with the string provided as input to the Test Action. |
|
22 // If the subject field of the message does not match with the specified string, the Test Action fails. |
|
23 // [APIs Used] |
|
24 // CImHeader::RestoreL () |
|
25 // CImHeader::Subject () |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 /** |
|
31 @file |
|
32 @internalTechnology |
|
33 */ |
|
34 |
|
35 |
|
36 // User include |
|
37 #include "CMtfTestActionVerifySubject.h" |
|
38 #include "CMtfTestCase.h" |
|
39 #include "CMtfTestActionUtilsMessage.h" |
|
40 #include "CMtfTestActionParameters.h" |
|
41 |
|
42 #include <smut.h> //KUidMsgTypeSms |
|
43 #include <irmsgtypeuid.h> |
|
44 #include <btmsgtypeuid.h> |
|
45 |
|
46 /** |
|
47 NewL() |
|
48 Constructs a CMtfTestActionVerifySubject object. |
|
49 Uses two phase construction and leaves nothing on the CleanupStack. |
|
50 @internalTechnology |
|
51 @param aTestCase Test Case to which this Test Action belongs |
|
52 @param aActionParameters Action parameters, must not be NULL |
|
53 @return Created object of type CMtfTestActionVerifySubject |
|
54 @pre None |
|
55 @post CMtfTestActionVerifySubject object is created |
|
56 */ |
|
57 CMtfTestAction* CMtfTestActionVerifySubject:: |
|
58 NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
59 { |
|
60 CMtfTestActionVerifySubject* self = |
|
61 new (ELeave) CMtfTestActionVerifySubject(aTestCase); |
|
62 |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aActionParameters); |
|
65 CleanupStack::Pop(self); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 CMtfTestActionVerifySubject constructor |
|
72 Calls the base class' constructor |
|
73 @internalTechnology |
|
74 @param aTestCase Test Case to which this Test Action belongs |
|
75 @pre None |
|
76 @post None |
|
77 */ |
|
78 CMtfTestActionVerifySubject::CMtfTestActionVerifySubject(CMtfTestCase& aTestCase) |
|
79 : CMtfSynchronousTestAction(aTestCase) |
|
80 { |
|
81 } |
|
82 |
|
83 /** |
|
84 Function : ~CMtfTestActionVerifySubject |
|
85 Description : Destructor |
|
86 @internalTechnology |
|
87 @param : |
|
88 @return : |
|
89 @pre |
|
90 @post |
|
91 */ |
|
92 CMtfTestActionVerifySubject::~CMtfTestActionVerifySubject() |
|
93 { |
|
94 } |
|
95 |
|
96 |
|
97 |
|
98 /** |
|
99 ExecuteActionL |
|
100 Verifies the subject field contents set for a message by comparing it with the expected value. |
|
101 The subject field is varified for SMTP, IR and BT messages, where as for SMS message, returns |
|
102 KErrNotSupported. |
|
103 |
|
104 @internalTechnology |
|
105 @pre None |
|
106 @post None |
|
107 @leave System wide errors |
|
108 */ |
|
109 void CMtfTestActionVerifySubject::ExecuteActionL() |
|
110 { |
|
111 if((TestCase().TestStepResult()) == EPass) |
|
112 { |
|
113 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionVerifySubject); |
|
114 |
|
115 // Get test action input parameters |
|
116 CMsvEntry* paramMsgEntry = ObtainParameterReferenceL<CMsvEntry>(TestCase(), |
|
117 ActionParameters().Parameter(0)); |
|
118 |
|
119 HBufC* paramSubject = ObtainParameterReferenceL<HBufC>(TestCase(), |
|
120 ActionParameters().Parameter(1)); |
|
121 |
|
122 if((paramMsgEntry == NULL) || (paramSubject == NULL)) |
|
123 { |
|
124 TestCase().ERR_PRINTF1(_L("Test Action input not valid")); |
|
125 TestCase().SetTestStepResult(EFail); |
|
126 } |
|
127 |
|
128 if((TestCase().TestStepResult()) == EPass) |
|
129 { |
|
130 // Call function to verify the subject field |
|
131 TInt err = VerifySubjectL(*paramMsgEntry, paramSubject); |
|
132 |
|
133 if (err == KErrNone) |
|
134 { |
|
135 TestCase().INFO_PRINTF1(_L("Comparison of Subject field was successful.")); |
|
136 } |
|
137 else |
|
138 { |
|
139 TestCase().ERR_PRINTF2(_L("Test VerifySubject failed with error %d"), err); |
|
140 TestCase().SetTestStepResult(EFail); |
|
141 } |
|
142 |
|
143 } |
|
144 } |
|
145 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionVerifySubject); |
|
146 TestCase().ActionCompletedL(*this); |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 /** |
|
152 Compares the Subject filed of the message with the expected value |
|
153 */ |
|
154 TInt CMtfTestActionVerifySubject::VerifySubjectL(CMsvEntry& aMsvEntry,HBufC* aSubject) |
|
155 { |
|
156 TInt returnValue = KErrNone; |
|
157 |
|
158 // Get Message type id |
|
159 TUid msgMtmType = aMsvEntry.Entry().iMtm; |
|
160 |
|
161 |
|
162 if( (msgMtmType.operator == (KUidMsgTypeSMTP)) || |
|
163 (msgMtmType.operator == (KUidMsgTypePOP3)) || |
|
164 (msgMtmType.operator == (KUidMsgTypeIMAP4) )) |
|
165 { |
|
166 // Email message |
|
167 returnValue = CMtfTestActionUtilsMessage::VerifyEmailSubjectL (aMsvEntry, aSubject); |
|
168 } |
|
169 else if( (msgMtmType.operator == (KUidMsgTypeBt)) || |
|
170 (msgMtmType.operator == (KUidMsgTypeIrUID)) |
|
171 ) |
|
172 { |
|
173 // OBEX message |
|
174 returnValue = CMtfTestActionUtilsMessage::VerifyObexSubjectL (aMsvEntry, aSubject); |
|
175 } |
|
176 else if(msgMtmType.operator == (KUidMsgTypeSMS)) |
|
177 { |
|
178 // SMS message, subject field is not supported |
|
179 returnValue = KErrNotSupported; |
|
180 } |
|
181 else |
|
182 { |
|
183 // Message type supported, can be extended later |
|
184 returnValue = KErrNotSupported; |
|
185 } |
|
186 |
|
187 return returnValue; |
|
188 } |