|
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 "CMtfTestActionSendEMsvGetChildren.h" |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <msvipc.h> |
|
22 #include "MCLIENT.H" |
|
23 #include "MSERVER.H" |
|
24 #include "MSVSTD.H" |
|
25 #include "MCLENTRY.H" |
|
26 |
|
27 #include "CMtfTestCase.h" |
|
28 #include "CMtfTestActionParameters.h" |
|
29 |
|
30 #include "IPCCommandForCapsPermissions.h" |
|
31 #include "SendProxyClient.h" |
|
32 #include "SendProxyserver.h" |
|
33 |
|
34 |
|
35 /** |
|
36 Function : NewL |
|
37 Description : |
|
38 @internalTechnology |
|
39 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
40 @param : aActionParams - CMtfTestActionParameters |
|
41 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSendEMsvGetChildren object |
|
42 @pre none |
|
43 @post none |
|
44 */ |
|
45 CMtfTestAction* CMtfTestActionSendEMsvGetChildren::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
46 { |
|
47 CMtfTestActionSendEMsvGetChildren* self = new (ELeave) CMtfTestActionSendEMsvGetChildren(aTestCase); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aActionParameters); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 /** |
|
55 Function : CMtfTestActionSendEMsvGetChildren |
|
56 Description : Constructor |
|
57 @internalTechnology |
|
58 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
59 @return : N/A |
|
60 @pre none |
|
61 @post none |
|
62 */ |
|
63 CMtfTestActionSendEMsvGetChildren::CMtfTestActionSendEMsvGetChildren(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
64 { |
|
65 } |
|
66 |
|
67 /** |
|
68 Function : ~CMtfTestActionSendEMsvGetChildren |
|
69 Description : Destructor |
|
70 @internalTechnology |
|
71 @param : |
|
72 @return : |
|
73 @pre |
|
74 @post |
|
75 */ |
|
76 CMtfTestActionSendEMsvGetChildren::~CMtfTestActionSendEMsvGetChildren() |
|
77 { |
|
78 } |
|
79 |
|
80 /** |
|
81 Function : ExecuteActionL |
|
82 Description : Entry point for the this test action in the test framework |
|
83 @internalTechnology |
|
84 @param : none |
|
85 @return : void |
|
86 @pre none |
|
87 @post none |
|
88 */ |
|
89 void CMtfTestActionSendEMsvGetChildren::ExecuteActionL() |
|
90 { |
|
91 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendEMsvGetChildren); |
|
92 TMsvId parentId = ObtainValueParameterL<TMsvId>( TestCase(), ActionParameters().Parameter(0)); |
|
93 TInt numberOfEntries = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1)); |
|
94 TInt pass = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2) ); |
|
95 |
|
96 RProxyServerSession RPSS; |
|
97 |
|
98 // Will auto start the server if not started. |
|
99 TInt error = RPSS.Connect(); |
|
100 CleanupClosePushL(RPSS); |
|
101 |
|
102 if (error!=KErrNone) |
|
103 { |
|
104 TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvGetChildren :: Unable to start proxy server. !")); |
|
105 TestCase().SetTestStepResult(EFail); |
|
106 } |
|
107 else |
|
108 { |
|
109 TInt32 serverCaps; |
|
110 RPSS.GetServerCapabilities(serverCaps); |
|
111 TestCase().INFO_PRINTF2(_L("Proxy Server has capabilities: %x"), serverCaps); |
|
112 |
|
113 |
|
114 HBufC8* buffer = HBufC8::NewLC(KMsvSessionBufferLength); |
|
115 if (buffer==NULL) |
|
116 { |
|
117 TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvGetChildren :: Unable to allocate mem. !")); |
|
118 TestCase().SetTestStepResult(EFail); |
|
119 } |
|
120 |
|
121 TInt entriesReturned = 0; |
|
122 error = 0; |
|
123 TPtr8 ptr=buffer->Des(); |
|
124 |
|
125 TPckgBuf<TMsvChildrenDetails> details; |
|
126 details().iParentId = parentId; |
|
127 |
|
128 TMsvSelectionOrdering ordering; |
|
129 TPckgC<TMsvSelectionOrdering> pckgOrdering(ordering); |
|
130 |
|
131 error=RPSS.SendReceive(EMsvGetChildren , TIpcArgs( &details ,&pckgOrdering, &ptr)); |
|
132 if (error == KErrOverflow) |
|
133 { |
|
134 // KErrOverflow is ok only means there are more entries than fits in the buffer |
|
135 TestCase().INFO_PRINTF2(_L("Test Action %S: Got KErrOverflow, more entries are available. Getting remaining entries."), &KTestActionSendEMsvGetChildren); |
|
136 |
|
137 // Add number of entries retreived by EMsvGetChildren to total count |
|
138 entriesReturned += details().iNumberChildrenInArray; |
|
139 |
|
140 // Get the rest of the entries |
|
141 while (error == KErrOverflow) |
|
142 { |
|
143 error=RPSS.SendReceive(EMsvGetRemainingChildren , TIpcArgs( &details ,NULL, &ptr)); |
|
144 if (error != KErrNone && error != KErrOverflow) |
|
145 { |
|
146 // got an error! |
|
147 TestCase().ERR_PRINTF2(_L("CMtfTestActionSendEMsvGetChildren :: EMsvGetRemainingChildren failed with error [%d] !"), error); |
|
148 break; |
|
149 } |
|
150 if (details().iNumberChildrenInArray == 0) |
|
151 { |
|
152 // The buffer isn't big enough for the current entry |
|
153 // we must resize the buffer or we're in an infinite loop |
|
154 buffer->Des().SetLength(0); |
|
155 buffer->ReAlloc(buffer->Des().MaxSize() + KMsvSessionBufferLength); |
|
156 continue; |
|
157 } |
|
158 |
|
159 // Add number of entries to total count |
|
160 entriesReturned += details().iNumberChildrenInArray; |
|
161 } |
|
162 } |
|
163 else if (error == KErrNone) |
|
164 { |
|
165 entriesReturned = details().iNumberChildrenInArray; |
|
166 } |
|
167 |
|
168 /* ** Data validity check. Since EMsvGetChildren does not return an error even when it gets ** |
|
169 ** KErrPermissionDenied, the only way to check if it failed is to count the entries. If ** |
|
170 ** the call failed there should be 0 entries. Unfortunately there seems to be no way to ** |
|
171 ** verify what error code we got so we can't guarantee that it failed because of caps! ** |
|
172 */ |
|
173 // Check number of returned entires. Should match parameter value from script. |
|
174 if (entriesReturned != numberOfEntries) |
|
175 { |
|
176 TestCase().ERR_PRINTF1(_L("CMtfTestActionSendEMsvGetChildren :: Number of children returned does not match !")); |
|
177 TestCase().SetTestStepResult(EFail); |
|
178 } |
|
179 else |
|
180 { |
|
181 IPCCommandReportPassOrFailForCapsPermissions( TestCase(), KMsvServerName, error , pass ); |
|
182 } |
|
183 |
|
184 CleanupStack::PopAndDestroy(buffer); |
|
185 } |
|
186 |
|
187 CleanupStack::Check(&RPSS); |
|
188 CleanupStack::PopAndDestroy(); // RPSS |
|
189 |
|
190 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendEMsvGetChildren); |
|
191 TestCase().ActionCompletedL(*this); |
|
192 |
|
193 } |