|
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 // ReadMessage |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // Entry <input>: Reference to the entry. |
|
20 // [Action Description] |
|
21 // Reads the contents of a message and prints it in the log. |
|
22 // [APIs Used] |
|
23 // CMsvEntry::Entry |
|
24 // CMtfTestActionUtilsEmailMessage::GetBodyTextL |
|
25 // CRichText::Read |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 |
|
31 #include "CMtfTestActionReadMessage.h" |
|
32 #include "CMtfTestCase.h" |
|
33 #include "CMtfTestActionParameters.h" |
|
34 #include "CMtfTestActionUtilsEmailMessage.h" |
|
35 |
|
36 #include <miutset.h> |
|
37 |
|
38 |
|
39 |
|
40 CMtfTestAction* CMtfTestActionReadMessage::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
41 { |
|
42 CMtfTestActionReadMessage* self = new(ELeave) CMtfTestActionReadMessage(aTestCase); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(aActionParameters); |
|
45 CleanupStack::Pop(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 CMtfTestActionReadMessage::CMtfTestActionReadMessage(CMtfTestCase& aTestCase) |
|
51 : CMtfSynchronousTestAction(aTestCase) |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 CMtfTestActionReadMessage::~CMtfTestActionReadMessage() |
|
57 { |
|
58 } |
|
59 |
|
60 void CMtfTestActionReadMessage::ExecuteActionL() |
|
61 { |
|
62 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionAddReadMessage); |
|
63 |
|
64 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
65 CMsvEntry* messageEntry = ObtainParameterReferenceL<CMsvEntry>(TestCase(),ActionParameters().Parameter(1)); |
|
66 |
|
67 // print message subject in log |
|
68 TestCase().INFO_PRINTF1(_L("Message subject:")); |
|
69 TPtrC subject = messageEntry->Entry().iDescription; |
|
70 TestCase().INFO_PRINTF1(subject); |
|
71 |
|
72 // get and read message body |
|
73 CMtfTestActionUtilsEmailMessage* messageInfo = CMtfTestActionUtilsEmailMessage::NewL(*messageEntry, TestCase()); |
|
74 CleanupStack::PushL(messageInfo); |
|
75 |
|
76 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
77 CleanupStack::PushL(paraFormatLayer); |
|
78 |
|
79 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
80 CleanupStack::PushL(charFormatLayer); |
|
81 |
|
82 CRichText* plainBodyText = CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256); |
|
83 CleanupStack::PushL(plainBodyText); |
|
84 |
|
85 messageInfo->GetBodyTextL(*plainBodyText, *paraFormatLayer, *charFormatLayer); |
|
86 |
|
87 TPtrC bodyText = plainBodyText->Read(0); |
|
88 |
|
89 // print message body in log |
|
90 TestCase().INFO_PRINTF1(_L("Message body:")); |
|
91 TestCase().INFO_PRINTF1(bodyText); |
|
92 |
|
93 CleanupStack::PopAndDestroy(4); |
|
94 |
|
95 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionAddReadMessage); |
|
96 TestCase().ActionCompletedL(*this); |
|
97 } |
|
98 |
|
99 |
|
100 |