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