|
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 // |
|
15 |
|
16 #include "CMtfTestActionSendEMsvCreateEntry.h" |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <msvipc.h> |
|
22 #include "MCLIENT.H" |
|
23 #include "MSERVER.H" |
|
24 |
|
25 |
|
26 #include "CMtfTestCase.h" |
|
27 #include "CMtfTestActionParameters.h" |
|
28 |
|
29 #include "IPCCommandForCapsPermissions.h" |
|
30 #include "SendProxyClient.h" |
|
31 #include "SendProxyserver.h" |
|
32 |
|
33 |
|
34 /** |
|
35 Function : NewL |
|
36 Description : |
|
37 @internalTechnology |
|
38 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
39 @param : aActionParams - CMtfTestActionParameters |
|
40 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSendEMsvCreateEntry object |
|
41 @pre none |
|
42 @post none |
|
43 */ |
|
44 CMtfTestAction* CMtfTestActionSendEMsvCreateEntry::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
45 { |
|
46 CMtfTestActionSendEMsvCreateEntry* self = new (ELeave) CMtfTestActionSendEMsvCreateEntry(aTestCase); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aActionParameters); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 /** |
|
54 Function : CMtfTestActionSendEMsvCreateEntry |
|
55 Description : Constructor |
|
56 @internalTechnology |
|
57 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
58 @return : N/A |
|
59 @pre none |
|
60 @post none |
|
61 */ |
|
62 CMtfTestActionSendEMsvCreateEntry::CMtfTestActionSendEMsvCreateEntry(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
63 { |
|
64 } |
|
65 |
|
66 /** |
|
67 Function : ~CMtfTestActionSendEMsvCreateEntry |
|
68 Description : Destructor |
|
69 @internalTechnology |
|
70 @param : |
|
71 @return : |
|
72 @pre |
|
73 @post |
|
74 */ |
|
75 CMtfTestActionSendEMsvCreateEntry::~CMtfTestActionSendEMsvCreateEntry() |
|
76 { |
|
77 } |
|
78 |
|
79 /** |
|
80 Function : ExecuteActionL |
|
81 Description : Entry point for the this test action in the test framework |
|
82 @internalTechnology |
|
83 @param : none |
|
84 @return : void |
|
85 @pre none |
|
86 @post none |
|
87 */ |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 void CMtfTestActionSendEMsvCreateEntry::ExecuteActionL() |
|
93 { |
|
94 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvCreateEntry); |
|
95 // input params |
|
96 TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(0), 0); |
|
97 TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1), 0); |
|
98 TInt createEntryType = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); |
|
99 TInt useProxyServerSecurityId = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(3) , 1); |
|
100 TInt canReadBack = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(4) ); |
|
101 TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(5) ); |
|
102 |
|
103 |
|
104 TSecureId ownerId = 0; |
|
105 // Assume set caps had set this correctly. |
|
106 RProxyServerSession RPSS; |
|
107 TInt error = RPSS.Connect(); |
|
108 // Will auto start the server if not started. |
|
109 |
|
110 // Allow us to change the owning process of the message. |
|
111 if (useProxyServerSecurityId) |
|
112 { // Use the security Id of the proxy server. |
|
113 RPSS.GetServerSecureId( ownerId ); |
|
114 } |
|
115 else |
|
116 { // Use the security id of the test server. |
|
117 ownerId = RProcess().SecureId(); |
|
118 } |
|
119 |
|
120 |
|
121 if (error!=KErrNone) |
|
122 { |
|
123 TestCase().ERR_PRINTF2(_L("%S :: Unable to start proxy server. !"), &KTestActionSendEMsvCreateEntry); |
|
124 TestCase().SetTestStepResult(EFail); |
|
125 } |
|
126 else |
|
127 { |
|
128 TInt32 serverCaps; |
|
129 RPSS.GetServerCapabilities(serverCaps); |
|
130 TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps); |
|
131 |
|
132 error = 0; |
|
133 CleanupClosePushL(RPSS); |
|
134 |
|
135 |
|
136 HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength); |
|
137 TPtr8 ptr=buffer->Des(); |
|
138 |
|
139 |
|
140 TMsvEntryForward entry; |
|
141 if ( createEntryType == ECreateMessage ) |
|
142 { |
|
143 FillInSimpleMessageEntry( 0, paramParentId, paramServiceId, entry); |
|
144 // aMessageId=0 will be filled in when we attempt to create the message. |
|
145 } |
|
146 else if (createEntryType == ECreateRemote) |
|
147 { |
|
148 FillInRemoteMessageEntry(0, paramParentId, paramServiceId, entry); |
|
149 } |
|
150 else if (createEntryType == ECreateService) |
|
151 { |
|
152 FillInServiceEntry(0, entry); |
|
153 } |
|
154 else if ( createEntryType == ECreateMessageSMS ) |
|
155 { |
|
156 FillInSimpleMessageEntry( 0, paramParentId, paramServiceId, entry); |
|
157 // aMessageId=0 will be filled in when we attempt to create the message. |
|
158 entry.iMtm = KUidMsgTypeSMS; |
|
159 } |
|
160 else if (createEntryType == ECreateServiceSMS) |
|
161 { |
|
162 FillInServiceEntry(0, entry); |
|
163 entry.iMtm = KUidMsgTypeSMS; |
|
164 } |
|
165 else if (createEntryType == ECreateRemoteSMS) |
|
166 { |
|
167 FillInRemoteMessageEntry(0, paramParentId, paramServiceId, entry); |
|
168 entry.iMtm = KUidMsgTypeSMS; |
|
169 } |
|
170 else |
|
171 { |
|
172 User::Leave(KErrGeneral); |
|
173 } |
|
174 |
|
175 TMsvPackedEntry packedEntry(buffer); |
|
176 error = packedEntry.PackEntry(entry); |
|
177 if (error) |
|
178 { |
|
179 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvCreateEntry ); |
|
180 TestCase().SetTestStepResult(EFail); |
|
181 User::LeaveIfError(error); |
|
182 } |
|
183 |
|
184 |
|
185 TMsvOp operationId=1; |
|
186 error= RPSS.SendReceive(EMsvOperationData, TIpcArgs(operationId,buffer)); |
|
187 if (error) |
|
188 { |
|
189 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the created message") , &KTestActionSendEMsvCreateEntry ); |
|
190 TestCase().SetTestStepResult(EFail); |
|
191 User::LeaveIfError(error); |
|
192 } |
|
193 |
|
194 error=RPSS.SendReceive(EMsvCreateEntry , TIpcArgs(operationId, ownerId)); |
|
195 IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass ); |
|
196 |
|
197 |
|
198 if ( (pass == 0) && (error!=KErrNone ) ) |
|
199 { // We expected it to fail and it did so do nothing else basically ignore the error. |
|
200 // Appears to be no need to do EMsvOperationCompletion. |
|
201 } |
|
202 else |
|
203 { |
|
204 |
|
205 TMsvLocalOperationProgress progress; |
|
206 TPckg<TMsvLocalOperationProgress> progressPack(progress); |
|
207 TInt ret=RPSS.SendReceive(EMsvOperationCompletion , TIpcArgs(operationId, &progressPack)); |
|
208 // We need to indicate that we have finished and clean up otherwise we will get |
|
209 // a panic. |
|
210 |
|
211 if (ret>0) |
|
212 { // We are happy some sort of length returned. |
|
213 } |
|
214 else if (ret<0) |
|
215 { |
|
216 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to finish sending the modified message") , &KTestActionSendEMsvCreateEntry ); |
|
217 TestCase().SetTestStepResult(EFail); |
|
218 User::LeaveIfError(error); |
|
219 } |
|
220 // else KErrNone |
|
221 |
|
222 if ( pass && canReadBack ) |
|
223 { // Lets just check that we get the same results out as an extra check. |
|
224 // If it passes we know we must have suffient rights. |
|
225 CheckWentInStoreL( TestCase(), KTestActionSendEMsvCreateEntry, RPSS, progress.iId, entry, operationId); |
|
226 } |
|
227 } |
|
228 |
|
229 CleanupStack::Check(buffer); |
|
230 CleanupStack::PopAndDestroy(); |
|
231 |
|
232 CleanupStack::Check(&RPSS); |
|
233 CleanupStack::PopAndDestroy(); |
|
234 } |
|
235 |
|
236 |
|
237 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvCreateEntry); |
|
238 TestCase().ActionCompletedL(*this); |
|
239 } |