|
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 // CreateEmailOverSmsMessage ????? |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. ???? |
|
19 // ParentId <input>: Value of the parent id. |
|
20 // ServiceId <input>: Value of the the service id. |
|
21 // (ConfigIndexHeader) <input>: Value of config index for SMS header settings. Default is 0. |
|
22 // MessageId <output>: Value of the created message id. |
|
23 // [Action Description] |
|
24 // Creates a message on the specified parent. |
|
25 // [APIs Used] |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 // |
|
31 #include "CMtfTestActionCompareEntryWithFile.h" |
|
32 #include "CMtfTestCase.h" |
|
33 #include "CMtfTestActionParameters.h" |
|
34 #include "CMtfTestActionUtilsConfigFileParser.h" |
|
35 #include <msvapi.h> |
|
36 #include <msvuids.h> |
|
37 #include <txtrich.h> |
|
38 #include <smuthdr.h> |
|
39 #include <csmsemailfields.h> |
|
40 |
|
41 |
|
42 _LIT(KBodyText, "BodyText"); |
|
43 |
|
44 CMtfTestAction* CMtfTestActionCompareEntryWithFile::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
45 { |
|
46 CMtfTestActionCompareEntryWithFile* self = new (ELeave) CMtfTestActionCompareEntryWithFile(aTestCase); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aActionParameters); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 CMtfTestActionCompareEntryWithFile::CMtfTestActionCompareEntryWithFile(CMtfTestCase& aTestCase) |
|
55 : CMtfSynchronousTestAction(aTestCase) |
|
56 { |
|
57 } |
|
58 |
|
59 void CMtfTestActionCompareEntryWithFile::ExecuteActionL() |
|
60 { |
|
61 TestCase().Logger().Write(_L("CMtfTestActionCompareEntryWithFile::ExecuteActionL IN")); |
|
62 TInt paramCount = ActionParameters().Count(); |
|
63 if( paramCount != 3) |
|
64 { |
|
65 User::Leave(KErrArgument); |
|
66 } |
|
67 |
|
68 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
69 TMsvId paramEntryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
70 HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(2));; |
|
71 |
|
72 CMsvEntry* entry = CMsvEntry::NewL(*paramSession, paramEntryId,TMsvSelectionOrdering()); |
|
73 CleanupStack::PushL(entry); |
|
74 |
|
75 if ( EqualL( (*entry) , (*paramFilePath)) ) |
|
76 { // Test passed |
|
77 TestCase().Logger().Write(_L("CMtfTestActionCompareEntryWithFile::Comparison passes")); |
|
78 TestCase().SetTestStepResult(EPass); |
|
79 } |
|
80 else |
|
81 { // Test failed not the same data. |
|
82 TestCase().Logger().Write(_L("CMtfTestActionCompareEntryWithFile::Comparison fails")); |
|
83 TestCase().SetTestStepResult(EFail); |
|
84 } |
|
85 |
|
86 CleanupStack::PopAndDestroy(entry); |
|
87 |
|
88 TestCase().Logger().Write(_L("CMtfTestActionCompareEntryWithFile::ExecuteActionL OUT")); |
|
89 TestCase().ActionCompletedL(*this); |
|
90 } |
|
91 |
|
92 |
|
93 // Compares only those fields that you request to be compared. |
|
94 |
|
95 TBool CMtfTestActionCompareEntryWithFile::EqualL(CMsvEntry& aEntry, const TPtrC& smsMessageFileName) |
|
96 { |
|
97 TBool ret=ETrue; |
|
98 |
|
99 CMtfTestActionUtilsConfigFileParser* configParser = CMtfTestActionUtilsConfigFileParser::NewL(smsMessageFileName); |
|
100 CleanupStack::PushL(configParser); |
|
101 |
|
102 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); |
|
103 CleanupStack::PushL(paraFormatLayer); |
|
104 |
|
105 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); |
|
106 CleanupStack::PushL(charFormatLayer); |
|
107 |
|
108 _LIT( KEmailToAddress, "EmailToAddress" ); |
|
109 TPtrC emailToAddressText; |
|
110 if(configParser->GetFieldAsString(KEmailToAddress, emailToAddressText) != KErrNotFound) |
|
111 { // Then do the compare. |
|
112 const TPtrC& tmp = aEntry.Entry().iDetails; |
|
113 if ( tmp.Compare(emailToAddressText)!=0 ) |
|
114 { // Not equal fail. |
|
115 TestCase().Logger().WriteFormat(_L("CMtfTestActionCompareEntryWithFile:: EmailToAddress: (%S) (%S)"), &tmp, &emailToAddressText); |
|
116 ret = EFalse; |
|
117 } |
|
118 } |
|
119 |
|
120 _LIT( KSubject, "Subject" ); |
|
121 TPtrC subjectText; |
|
122 if(configParser->GetFieldAsString(KSubject, subjectText) != KErrNotFound) |
|
123 { |
|
124 const TPtrC& tmp = aEntry.Entry().iDescription; |
|
125 if ( tmp.Compare(subjectText)!=0 ) |
|
126 { // Not equal fail. |
|
127 TestCase().Logger().WriteFormat(_L("CMtfTestActionCompareEntryWithFile:: Subject: (%S) (%S)"), &tmp, &subjectText); |
|
128 ret = EFalse; |
|
129 } |
|
130 } |
|
131 |
|
132 TPtrC bodyText; |
|
133 if(configParser->GetFieldAsString(KBodyText, bodyText) != KErrNotFound) |
|
134 { |
|
135 CMsvStore* store = aEntry.ReadStoreL(); |
|
136 CleanupStack::PushL(store); |
|
137 |
|
138 if ( !(store->HasBodyTextL()) ) |
|
139 { // We have been asked to compare something which does not exist. |
|
140 TestCase().Logger().WriteFormat(_L("CMtfTestActionCompareEntryWithFile:: No Message exists at all")); |
|
141 ret = EFalse; |
|
142 } |
|
143 else |
|
144 { |
|
145 CRichText* richText = CRichText::NewL(paraFormatLayer,charFormatLayer); |
|
146 CleanupStack::PushL(richText); |
|
147 store->RestoreBodyTextL(*richText); |
|
148 |
|
149 const TInt length = richText->DocumentLength(); |
|
150 TPtrC textMessage = richText->Read(0, length); |
|
151 |
|
152 if ( textMessage.Compare(bodyText)!=0 ) |
|
153 { // Not equal fail. |
|
154 TestCase().Logger().WriteFormat(_L("CMtfTestActionCompareEntryWithFile:: BodyText: (%S) (%S)"), &bodyText, &textMessage); |
|
155 ret = EFalse; |
|
156 } |
|
157 |
|
158 CleanupStack::PopAndDestroy(richText); |
|
159 |
|
160 } |
|
161 CleanupStack::PopAndDestroy(store); |
|
162 } |
|
163 |
|
164 //??? SC etc |
|
165 |
|
166 CleanupStack::PopAndDestroy(3, configParser); |
|
167 |
|
168 return ret; |
|
169 } |
|
170 |