|
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 // SetBodyText |
|
17 // [Action Parameters] |
|
18 // CMsvStore msgStore <input> : Message Store of the message |
|
19 // for which the body text is to be set |
|
20 // HBufC fileName <input> : Name of the file from which the body text |
|
21 // contents are read |
|
22 // [Action Description] |
|
23 // Sets the body text for a message |
|
24 // [APIs Used] |
|
25 // __ACTION_INFO_END__ |
|
26 // |
|
27 // |
|
28 |
|
29 /** |
|
30 @file |
|
31 @internalTechnology |
|
32 */ |
|
33 |
|
34 //system include |
|
35 #include <msvapi.h> |
|
36 #include <txtrich.h> |
|
37 |
|
38 #include <txtetext.h> |
|
39 // User include |
|
40 #include "CMtfTestActionSetBodyText.h" |
|
41 #include "CMtfTestCase.h" |
|
42 #include "CMtfTestActionParameters.h" |
|
43 |
|
44 |
|
45 |
|
46 /** |
|
47 NewL() |
|
48 Constructs a CMtfTestActionSetBodyText 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 CMtfTestActionSetBodyText |
|
54 @pre None |
|
55 @post CMtfTestActionSetBodyText object is created |
|
56 */ |
|
57 CMtfTestAction* CMtfTestActionSetBodyText:: |
|
58 NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
59 { |
|
60 CMtfTestActionSetBodyText* self = |
|
61 new (ELeave) CMtfTestActionSetBodyText(aTestCase); |
|
62 |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(aActionParameters); |
|
65 CleanupStack::Pop(self); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 CMtfTestActionSetBodyText 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 CMtfTestActionSetBodyText::CMtfTestActionSetBodyText(CMtfTestCase& aTestCase) |
|
79 : CMtfSynchronousTestAction(aTestCase) |
|
80 { |
|
81 } |
|
82 |
|
83 /** |
|
84 Function : ~CMtfTestActionSetBodyText |
|
85 Description : Destructor |
|
86 @internalTechnology |
|
87 @param : |
|
88 @return : |
|
89 @pre |
|
90 @post |
|
91 */ |
|
92 CMtfTestActionSetBodyText::~CMtfTestActionSetBodyText() |
|
93 { |
|
94 } |
|
95 |
|
96 /** |
|
97 ExecuteActionL |
|
98 Sets the Body text for the specified message |
|
99 @internalTechnology |
|
100 @pre None |
|
101 @post None |
|
102 @leave System wide errors |
|
103 */ |
|
104 void CMtfTestActionSetBodyText::ExecuteActionL() |
|
105 { |
|
106 if((TestCase().TestStepResult()) == EPass) |
|
107 { |
|
108 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetBodyText); |
|
109 |
|
110 // Get test action parameters |
|
111 CMsvStore* paramStore = ObtainParameterReferenceL<CMsvStore>(TestCase(), |
|
112 ActionParameters().Parameter(0)); |
|
113 |
|
114 // File from which the body contents is read |
|
115 HBufC* paramFileName = ObtainParameterReferenceL<HBufC>(TestCase(), |
|
116 ActionParameters().Parameter(1)); |
|
117 |
|
118 // Create a rich text object |
|
119 CPlainText::TTextOrganisation ttOrg = {CPlainText::EOrganiseByLine}; |
|
120 |
|
121 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
122 CleanupStack::PushL(paraFormatLayer); |
|
123 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
124 CleanupStack::PushL(charFormatLayer); |
|
125 CRichText* bodyCRichText = CRichText::NewL(paraFormatLayer, charFormatLayer); |
|
126 CleanupStack::PushL(bodyCRichText); |
|
127 |
|
128 // Copy the contents of the file into Rich text object |
|
129 bodyCRichText->ImportTextFileL(0,paramFileName->Des(),ttOrg); |
|
130 |
|
131 // Set the body text for the message |
|
132 TRAPD(err, paramStore->StoreBodyTextL(*bodyCRichText)); |
|
133 if(err == KErrNone) |
|
134 { |
|
135 TestCase().INFO_PRINTF2(_L("Setting Body Text was successful, Error code = %d"), err); |
|
136 } |
|
137 else |
|
138 { |
|
139 TestCase().ERR_PRINTF2(_L("Setting Body Text falied with error = %d"), err); |
|
140 TestCase().SetTestStepResult(EFail); |
|
141 } |
|
142 |
|
143 CleanupStack::PopAndDestroy(3); // paraFormatLayer, charFormatLayer, bodyCRichText |
|
144 |
|
145 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetBodyText); |
|
146 } |
|
147 TestCase().ActionCompletedL(*this); |
|
148 } |
|
149 |
|
150 |