|
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 // CreateTestMimeHeaders |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // MsgId <input>: Value of the message Id. |
|
20 // AttachmentId <input>: Attachment to add the mime headers to. |
|
21 // [Action Description] |
|
22 // Creates a set of test mime headers and stores |
|
23 // [APIs Used] |
|
24 // CMsvSession::GetEntryL |
|
25 // CMsvStore::ReadStoreL |
|
26 // CMsvStore::AttachmentManagerL |
|
27 // MMsvAttachmentManager::AttachmentCount |
|
28 // TODO |
|
29 // __ACTION_INFO_END__ |
|
30 // |
|
31 // |
|
32 |
|
33 |
|
34 #include "CMtfTestActionCreateTestMimeHeaders.h" |
|
35 #include "CMtfTestCase.h" |
|
36 #include "CMtfTestActionParameters.h" |
|
37 #include "MtfTestActionUtilsUser.h" |
|
38 #include "CMtfAsyncWaiter.h" |
|
39 |
|
40 #include <miutset.h> |
|
41 #include <mmsvattachmentmanager.h> |
|
42 #include <cmsvmimeheaders.h> |
|
43 |
|
44 _LIT8(KTxtContentDescription, "TestContentDescription"); |
|
45 _LIT8(KTxtContentBase, "TestContentBase"); |
|
46 _LIT(KTxtContentLocation, "TestContentLocation"); |
|
47 _LIT8(KTxtContentId, "TestContentId"); |
|
48 _LIT8(KTxtContentType, "Text"); |
|
49 _LIT8(KTxtContentSubType, "Plain"); |
|
50 _LIT8(KTxtContentDisposition, "TestContentDisposition"); |
|
51 _LIT8(KTxtParam1, "Param1"); |
|
52 _LIT8(KTxtParam2, "Param2"); |
|
53 _LIT8(KTxtParam3, "Param3"); |
|
54 _LIT8(KTxtParam4, "Param4"); |
|
55 _LIT8(KTxtParam5, "Param5"); |
|
56 _LIT8(KTxtParam6, "Param6"); |
|
57 _LIT8(KTxtParam7, "Param7"); |
|
58 _LIT8(KTxtParam8, "Param8"); |
|
59 _LIT8(KTxtParam9, "Param9"); |
|
60 |
|
61 CMtfTestAction* CMtfTestActionCreateTestMimeHeaders::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
62 { |
|
63 CMtfTestActionCreateTestMimeHeaders* self = new(ELeave) CMtfTestActionCreateTestMimeHeaders(aTestCase); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(aActionParameters); |
|
66 CleanupStack::Pop(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 CMtfTestActionCreateTestMimeHeaders::CMtfTestActionCreateTestMimeHeaders(CMtfTestCase& aTestCase) |
|
72 : CMtfSynchronousTestAction(aTestCase) |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 CMtfTestActionCreateTestMimeHeaders::~CMtfTestActionCreateTestMimeHeaders() |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 void CMtfTestActionCreateTestMimeHeaders::ExecuteActionL() |
|
83 { |
|
84 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateTestMimeHeaders); |
|
85 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
86 TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1)); |
|
87 TMsvAttachmentId attachmentId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2)); |
|
88 |
|
89 CMsvEntry* entry = paramSession->GetEntryL(messageEntry); |
|
90 CleanupStack::PushL(entry); |
|
91 |
|
92 CMsvStore* store = entry->EditStoreL(); |
|
93 CleanupStack::PushL(store); |
|
94 |
|
95 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
96 |
|
97 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
98 CleanupStack::PushL(mimeHeaders); |
|
99 |
|
100 mimeHeaders->SetContentDescriptionL(KTxtContentDescription()); |
|
101 mimeHeaders->SetContentBaseL(KTxtContentBase()); |
|
102 mimeHeaders->SetContentLocationL(KTxtContentLocation()); |
|
103 mimeHeaders->SetContentIdL(KTxtContentId()); |
|
104 mimeHeaders->SetContentTypeL(KTxtContentType()); |
|
105 mimeHeaders->SetContentSubTypeL(KTxtContentSubType()); |
|
106 mimeHeaders->SetContentDispositionL(KTxtContentDisposition()); |
|
107 mimeHeaders->ContentTypeParams().AppendL(KTxtParam1()); |
|
108 mimeHeaders->ContentTypeParams().AppendL(KTxtParam2()); |
|
109 mimeHeaders->ContentTypeParams().AppendL(KTxtParam3()); |
|
110 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam4()); |
|
111 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam5()); |
|
112 mimeHeaders->ContentDispositionParams().AppendL(KTxtParam6()); |
|
113 mimeHeaders->XTypeParams().AppendL(KTxtParam7()); |
|
114 mimeHeaders->XTypeParams().AppendL(KTxtParam8()); |
|
115 mimeHeaders->XTypeParams().AppendL(KTxtParam9()); |
|
116 |
|
117 CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL(); |
|
118 CleanupStack::PushL(waiter); |
|
119 CMsvAttachment* attachment = manager.GetAttachmentInfoL(attachmentId); |
|
120 CleanupStack::PushL(attachment); |
|
121 mimeHeaders->StoreL(*attachment); |
|
122 manager.ModifyAttachmentInfoL(attachment, waiter->iStatus); |
|
123 CleanupStack::Pop(attachment); |
|
124 waiter->StartAndWait(); |
|
125 User::LeaveIfError(waiter->Result()); |
|
126 store->CommitL(); |
|
127 CleanupStack::PopAndDestroy(3, store); // waiter, mimeHeaders, store |
|
128 |
|
129 CompareMimeHeadersL(*entry, attachmentId); |
|
130 |
|
131 |
|
132 CleanupStack::PopAndDestroy(entry); |
|
133 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateTestMimeHeaders); |
|
134 TestCase().ActionCompletedL(*this); |
|
135 |
|
136 |
|
137 |
|
138 } |
|
139 |
|
140 void CMtfTestActionCreateTestMimeHeaders::CompareMimeHeadersL(CMsvEntry& aEntry, TMsvAttachmentId aAttachId) |
|
141 { |
|
142 CMsvStore* store = aEntry.ReadStoreL(); |
|
143 CleanupStack::PushL(store); |
|
144 |
|
145 CMsvAttachment* attachment = store->AttachmentManagerL().GetAttachmentInfoL(aAttachId); |
|
146 CleanupStack::PushL(attachment); |
|
147 |
|
148 CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL(); |
|
149 CleanupStack::PushL(mimeHeaders); |
|
150 |
|
151 mimeHeaders->RestoreL(*attachment); |
|
152 if( mimeHeaders->ContentDescription().Compare(KTxtContentDescription()) != 0 ) |
|
153 User::Leave(KErrNotFound); |
|
154 if( mimeHeaders->ContentBase().Compare(KTxtContentBase()) != 0 ) |
|
155 User::Leave(KErrNotFound); |
|
156 if( mimeHeaders->ContentLocation().Compare(KTxtContentLocation()) != 0 ) |
|
157 User::Leave(KErrNotFound); |
|
158 if( mimeHeaders->ContentId().Compare(KTxtContentId()) != 0 ) |
|
159 User::Leave(KErrNotFound); |
|
160 if( mimeHeaders->ContentType().Compare(KTxtContentType()) != 0 ) |
|
161 User::Leave(KErrNotFound); |
|
162 if( mimeHeaders->ContentSubType().Compare(KTxtContentSubType()) != 0 ) |
|
163 User::Leave(KErrNotFound); |
|
164 if( mimeHeaders->ContentDisposition().Compare(KTxtContentDisposition()) != 0 ) |
|
165 User::Leave(KErrNotFound); |
|
166 |
|
167 CDesC8Array& desArray1 = mimeHeaders->ContentTypeParams(); |
|
168 if( desArray1.Count() == 3 ) |
|
169 { |
|
170 if( desArray1[0].Compare(KTxtParam1()) != 0 ) |
|
171 User::Leave(KErrNotFound); |
|
172 if( desArray1[1].Compare(KTxtParam2()) != 0 ) |
|
173 User::Leave(KErrNotFound); |
|
174 if( desArray1[2].Compare(KTxtParam3()) != 0 ) |
|
175 User::Leave(KErrNotFound); |
|
176 } |
|
177 else |
|
178 User::Leave(KErrNotFound); |
|
179 |
|
180 CDesC8Array& desArray2 = mimeHeaders->ContentDispositionParams(); |
|
181 if( desArray2.Count() == 3 ) |
|
182 { |
|
183 if( desArray2[0].Compare(KTxtParam4()) != 0 ) |
|
184 User::Leave(KErrNotFound); |
|
185 if( desArray2[1].Compare(KTxtParam5()) != 0 ) |
|
186 User::Leave(KErrNotFound); |
|
187 if( desArray2[2].Compare(KTxtParam6()) != 0 ) |
|
188 User::Leave(KErrNotFound); |
|
189 } |
|
190 else |
|
191 User::Leave(KErrNotFound); |
|
192 |
|
193 CDesC8Array& desArray3 = mimeHeaders->XTypeParams(); |
|
194 if( desArray3.Count() == 3 ) |
|
195 { |
|
196 if( desArray3[0].Compare(KTxtParam7()) != 0 ) |
|
197 User::Leave(KErrNotFound); |
|
198 if( desArray3[1].Compare(KTxtParam8()) != 0 ) |
|
199 User::Leave(KErrNotFound); |
|
200 if( desArray3[2].Compare(KTxtParam9()) != 0 ) |
|
201 User::Leave(KErrNotFound); |
|
202 } |
|
203 else |
|
204 User::Leave(KErrNotFound); |
|
205 |
|
206 CleanupStack::PopAndDestroy(3, store); // mimeHeaders, attachment, store |
|
207 } |