|
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 // VerifyBodyText |
|
17 // [Action Parameters] |
|
18 // CMsvStore paramMsgStore <input> : Reference to Message Store object |
|
19 // TMtfConfigurationType paramConfigurationType <input> : Configuration type required for identifying the corresponding list of configuration files |
|
20 // TInt paramIndex <input> : Index of the file name present in the list of configuration files ( file added to the list using SetDefaultConfiguration Test Action) |
|
21 // ErrorCode <output> (Optional) Returned error code, if not requested then code will |
|
22 // leave if not KErrNone |
|
23 // [Action Description] |
|
24 // VerifyBodyText Test Action is intended to read the body text contents of |
|
25 // a message and compare it with the contents of a file |
|
26 // [APIs Used] |
|
27 // CMsvStore::HasBodyTextL () |
|
28 // CRichText::Extract () |
|
29 // __ACTION_INFO_END__ |
|
30 // |
|
31 // |
|
32 |
|
33 /** |
|
34 @file |
|
35 @internalTechnology |
|
36 */ |
|
37 |
|
38 //system include |
|
39 #include <msvapi.h> |
|
40 #include <txtrich.h> |
|
41 |
|
42 // User include |
|
43 #include "CMtfTestActionVerifyBodyText.h" |
|
44 #include "CMtfTestCase.h" |
|
45 #include "CMtfTestActionParameters.h" |
|
46 #include "CMtfTestActionUtilsMessage.h" |
|
47 #include "sendas2.h" |
|
48 |
|
49 /** |
|
50 NewL() |
|
51 Constructs a CMtfTestActionVerifyBodyText object. |
|
52 Uses two phase construction and leaves nothing on the CleanupStack. |
|
53 @internalTechnology |
|
54 @param aTestCase Test Case to which this Test Action belongs |
|
55 @param aActionParameters Action parameters, must not be NULL |
|
56 @return Created object of type CMtfTestActionVerifyBodyText |
|
57 @pre None |
|
58 @post CMtfTestActionVerifyBodyText object is created |
|
59 */ |
|
60 CMtfTestAction* CMtfTestActionVerifyBodyText:: |
|
61 NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
62 { |
|
63 CMtfTestActionVerifyBodyText* self = |
|
64 new (ELeave) CMtfTestActionVerifyBodyText(aTestCase); |
|
65 |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(aActionParameters); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 CMtfTestActionVerifyBodyText constructor |
|
75 Calls the base class' constructor |
|
76 @internalTechnology |
|
77 @param aTestCase Test Case to which this Test Action belongs |
|
78 @pre None |
|
79 @post None |
|
80 */ |
|
81 CMtfTestActionVerifyBodyText::CMtfTestActionVerifyBodyText(CMtfTestCase& aTestCase) |
|
82 : CMtfSynchronousTestAction(aTestCase) |
|
83 { |
|
84 } |
|
85 |
|
86 /** |
|
87 Function : ~CMtfTestActionVerifyBodyText |
|
88 Description : Destructor |
|
89 @internalTechnology |
|
90 @param : |
|
91 @return : |
|
92 @pre |
|
93 @post |
|
94 */ |
|
95 CMtfTestActionVerifyBodyText::~CMtfTestActionVerifyBodyText() |
|
96 { |
|
97 } |
|
98 |
|
99 /** |
|
100 ExecuteActionL |
|
101 Obtain the input parameters |
|
102 1. CMsvStore |
|
103 2. paramConfigurationType |
|
104 3. paramIndex |
|
105 Check if the store contains any streams using CMsvStore::IsNullL () function. If store is empty, leave with appropriate error |
|
106 Call CMtfTestCase::GetConfigurationFileL(configurationType, Index) passing the configuration type and the index to the file name |
|
107 Call User::LeaveIfError( CMtfTestActionUtilsMessage::VerifyBodyTextContentsL()), passing CMsvStore and the file name to the VerifyBodyTextContentsL() function. |
|
108 |
|
109 |
|
110 @internalTechnology |
|
111 @pre None |
|
112 @post None |
|
113 @leave System wide errors |
|
114 */ |
|
115 void CMtfTestActionVerifyBodyText::ExecuteActionL() |
|
116 { |
|
117 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionVerifyBodyText); |
|
118 if( ActionParameters().Count() < 4 ) |
|
119 { |
|
120 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Insufficient Action Parameters") , &KTestActionVerifyBodyText); |
|
121 } |
|
122 else |
|
123 { |
|
124 TRAPD(err, RunTestL()); |
|
125 |
|
126 TInt paramExpectedResult = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3)); |
|
127 |
|
128 if(err != paramExpectedResult) |
|
129 { |
|
130 TestCase().ERR_PRINTF3(_L("%S :: FAIL :: Verify Body Text Failed with error = %d") , &KTestActionVerifyBodyText, err); |
|
131 } |
|
132 else |
|
133 { |
|
134 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionVerifyBodyText); |
|
135 } |
|
136 } |
|
137 |
|
138 TestCase().ActionCompletedL(*this); |
|
139 } |
|
140 |
|
141 |
|
142 void CMtfTestActionVerifyBodyText::RunTestL() |
|
143 { |
|
144 |
|
145 CMsvEntry* paramEntry = ObtainParameterReferenceL<CMsvEntry>(TestCase(), |
|
146 ActionParameters().Parameter(0)); |
|
147 |
|
148 CMtfConfigurationType::TMtfConfigurationType paramConfigurationType = ObtainValueParameterL<CMtfConfigurationType::TMtfConfigurationType>(TestCase(), |
|
149 ActionParameters().Parameter(1)); |
|
150 |
|
151 TInt paramIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); |
|
152 |
|
153 |
|
154 TPtrC fileName = TestCase().GetConfigurationFileL(paramConfigurationType,paramIndex); |
|
155 |
|
156 // Call the utils function to verify the body text contents |
|
157 User::LeaveIfError(CMtfTestActionUtilsMessage:: VerifyBodyTextContentsL(*paramEntry,fileName.AllocLC())); |
|
158 |
|
159 CleanupStack::PopAndDestroy(); |
|
160 |
|
161 } |
|
162 |