|
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 "CMtfTestActionSendEMsvCopyEntries.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 CMtfTestActionSendEMsvCopyEntries object |
|
41 @pre none |
|
42 @post none |
|
43 */ |
|
44 CMtfTestAction* CMtfTestActionSendEMsvCopyEntries::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
45 { |
|
46 CMtfTestActionSendEMsvCopyEntries* self = new (ELeave) CMtfTestActionSendEMsvCopyEntries(aTestCase); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aActionParameters); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 /** |
|
54 Function : CMtfTestActionSendEMsvCopyEntries |
|
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 CMtfTestActionSendEMsvCopyEntries::CMtfTestActionSendEMsvCopyEntries(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
63 { |
|
64 } |
|
65 |
|
66 /** |
|
67 Function : ~CMtfTestActionSendEMsvCopyEntries |
|
68 Description : Destructor |
|
69 @internalTechnology |
|
70 @param : |
|
71 @return : |
|
72 @pre |
|
73 @post |
|
74 */ |
|
75 CMtfTestActionSendEMsvCopyEntries::~CMtfTestActionSendEMsvCopyEntries() |
|
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 CMtfTestActionSendEMsvCopyEntries::ExecuteActionL() |
|
93 { |
|
94 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvCopyEntries); |
|
95 TMsvId multiMsg1 = 0; // need these for testing special case of copying to Outbox |
|
96 // must have several entries with different caps requirements |
|
97 |
|
98 TMsvId messageIdFrom = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0) ); |
|
99 TMsvId parentIdTo = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(1) ); |
|
100 TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2)); |
|
101 |
|
102 if (ActionParameters().Count() > 3) |
|
103 { |
|
104 multiMsg1 = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(3) ); |
|
105 } |
|
106 |
|
107 RProxyServerSession RPSS; |
|
108 TInt error = RPSS.Connect(); |
|
109 // Will auto start the server if not started. |
|
110 |
|
111 if (error!=KErrNone) |
|
112 { |
|
113 TestCase().ERR_PRINTF2(_L("%S :: Unable to start proxy server. !") , &KTestActionSendEMsvCopyEntries ); |
|
114 TestCase().SetTestStepResult(EFail); |
|
115 } |
|
116 else |
|
117 { |
|
118 TInt32 serverCaps; |
|
119 RPSS.GetServerCapabilities(serverCaps); |
|
120 TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps); |
|
121 |
|
122 error = 0; |
|
123 CleanupClosePushL(RPSS); |
|
124 |
|
125 HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength); |
|
126 TPtr8 ptr=buffer->Des(); |
|
127 |
|
128 CMsvEntrySelection* entrySelection = new (ELeave) (CMsvEntrySelection); |
|
129 CleanupDeletePushL(entrySelection); |
|
130 |
|
131 entrySelection->SetReserveL(1); |
|
132 entrySelection->AppendL(messageIdFrom); |
|
133 |
|
134 // add more entries for testing special outbox case |
|
135 if (multiMsg1 != 0) |
|
136 { |
|
137 entrySelection->AppendL(multiMsg1); |
|
138 } |
|
139 |
|
140 TMsvPackedOperation packedOperation(buffer); |
|
141 error = packedOperation.Pack(*entrySelection, parentIdTo); |
|
142 if (error) |
|
143 { |
|
144 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to pack the message") , &KTestActionSendEMsvCopyEntries ); |
|
145 TestCase().SetTestStepResult(EFail); |
|
146 User::LeaveIfError(error); |
|
147 } |
|
148 |
|
149 |
|
150 TMsvOp operationId=1; |
|
151 |
|
152 error= RPSS.SendReceive(EMsvOperationData, TIpcArgs(operationId,buffer)); |
|
153 if (error) |
|
154 { |
|
155 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to send the created message") , &KTestActionSendEMsvCopyEntries ); |
|
156 TestCase().SetTestStepResult(EFail); |
|
157 User::LeaveIfError(error); |
|
158 } |
|
159 |
|
160 error=RPSS.SendReceive(EMsvCopyEntries , TIpcArgs(operationId)); |
|
161 |
|
162 IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KTestActionSendEMsvCopyEntries, error , pass ); |
|
163 if ( (pass == 0) && (error!=KErrNone ) ) |
|
164 { // We expected it to fail and it did so do nothing else basically ignore the error. |
|
165 // Appears to be no need to do EMsvOperationCompletion. |
|
166 } |
|
167 else |
|
168 { |
|
169 |
|
170 TMsvLocalOperationProgress progress; |
|
171 TPckg<TMsvLocalOperationProgress> progressPack(progress); |
|
172 TInt ret=RPSS.SendReceive(EMsvOperationCompletion , TIpcArgs(operationId, &progressPack)); |
|
173 // We need to indicate that we have finished and clean up otherwise we will get |
|
174 // a panic. |
|
175 |
|
176 if (ret>0) |
|
177 { // We are happy some sort of length returned. |
|
178 } |
|
179 else if (ret<0) |
|
180 { |
|
181 TestCase().ERR_PRINTF2(_L("%S :: FAIL :: Unable to finish sending the modified message") , &KTestActionSendEMsvCopyEntries ); |
|
182 TestCase().SetTestStepResult(EFail); |
|
183 User::LeaveIfError(error); |
|
184 } |
|
185 // else KErrNone |
|
186 |
|
187 |
|
188 } |
|
189 |
|
190 CleanupStack::Check(entrySelection); |
|
191 CleanupStack::PopAndDestroy(); |
|
192 |
|
193 CleanupStack::Check(buffer); |
|
194 CleanupStack::PopAndDestroy(); |
|
195 |
|
196 CleanupStack::Check(&RPSS); |
|
197 CleanupStack::PopAndDestroy(); |
|
198 } |
|
199 |
|
200 |
|
201 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvCopyEntries); |
|
202 TestCase().ActionCompletedL(*this); |
|
203 |
|
204 } |
|
205 |