24
|
1 |
// Copyright (c) 2001-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 |
// This contains PsdAgt TestCase Test 11.1 - 11.7
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
// EPOC includes
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <in_sock.h>
|
|
21 |
|
|
22 |
// Test system includes
|
|
23 |
#include "networking/log.h"
|
|
24 |
#include "networking/teststep.h"
|
|
25 |
#include "TestStepPsdAgt.h"
|
|
26 |
#include "TestSuitePsdAgt.h"
|
|
27 |
|
|
28 |
// COMMDB Database Undo
|
|
29 |
#include "DbUndo.h"
|
|
30 |
|
|
31 |
// RPacketContext
|
|
32 |
#include <etelpckt.h>
|
|
33 |
|
|
34 |
// EPsdStartingConfiguration
|
|
35 |
#include <psdprog.h>
|
|
36 |
|
|
37 |
// EConnectionOpen
|
|
38 |
#include <connectprog.h>
|
|
39 |
|
|
40 |
//#include <psdpanic.h>
|
|
41 |
|
|
42 |
// Class definitions
|
|
43 |
#include "PsdAgtTestOpen.h"
|
|
44 |
|
|
45 |
|
|
46 |
// Test case 11.1
|
|
47 |
enum TVerdict CPsdAgtTest11_1::doPsdAgtTestStepL( void )
|
|
48 |
{
|
|
49 |
TRealAgtNotify agtNotify;
|
|
50 |
agtNotify.SetTestCase(1101);
|
|
51 |
|
|
52 |
ConnectAndWaitForTwentySecondsL();
|
|
53 |
|
|
54 |
// Should have been incremented when DummyETEL simulated the Status changed
|
|
55 |
TESTL(iStage == 2);
|
|
56 |
|
|
57 |
return iTestStepResult;
|
|
58 |
}
|
|
59 |
|
|
60 |
void CPsdAgtTest11_1::AgentProgress(TInt aStage, TInt aError)
|
|
61 |
{
|
|
62 |
// Only interested in the 1st notification after we started waiting for
|
|
63 |
// RPacketContext::NotifyStatusChange() to signal to PsdOpen
|
|
64 |
// Subsequent notifications could be during disconnect etc.
|
|
65 |
if(iStage == 1)
|
|
66 |
{
|
|
67 |
iStage++;
|
|
68 |
if(aStage == KConnectionOpen && aError == KErrNone)
|
|
69 |
return;
|
|
70 |
else TESTE(EFalse,aError); //We didn't get the notification we were after
|
|
71 |
}
|
|
72 |
}
|
|
73 |
|
|
74 |
// Test case 11.2
|
|
75 |
enum TVerdict CPsdAgtTest11_2::doPsdAgtTestStepL( void )
|
|
76 |
{
|
|
77 |
TRealAgtNotify agtNotify;
|
|
78 |
|
|
79 |
agtNotify.SetTestCase(1102);
|
|
80 |
|
|
81 |
ConnectAndWaitForTwentySecondsL();
|
|
82 |
|
|
83 |
// Should have been incremented when DummyETEL simulated the Status changed
|
|
84 |
TESTL(iStage == 2);
|
|
85 |
|
|
86 |
return iTestStepResult;
|
|
87 |
}
|
|
88 |
|
|
89 |
void CPsdAgtTest11_2::AgentProgress(TInt aStage, TInt aError)
|
|
90 |
{
|
|
91 |
// Only interested in the 1st notification after we started waiting for
|
|
92 |
// RPacketContext::NotifyStatusChange() to signal to PsdOpen
|
|
93 |
// Subsequent notifications could be during disconnect etc.
|
|
94 |
if(iStage == 1)
|
|
95 |
{
|
|
96 |
iStage++;
|
|
97 |
if(aStage == EPsdSuspended && aError == KErrNone)
|
|
98 |
return;
|
|
99 |
else TESTE(EFalse, aError); // We didn't get the notification we were after
|
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
// Test case 11.3
|
|
104 |
enum TVerdict CPsdAgtTest11_3::doPsdAgtTestStepL( void )
|
|
105 |
{
|
|
106 |
TRealAgtNotify agtNotify;
|
|
107 |
agtNotify.SetTestCase(1103);
|
|
108 |
|
|
109 |
ConnectAndWaitForTwentySecondsL();
|
|
110 |
|
|
111 |
// Should have been incremented when DummyETEL simulated the Status changed
|
|
112 |
TESTL(iStage == 2);
|
|
113 |
|
|
114 |
return iTestStepResult;
|
|
115 |
}
|
|
116 |
|
|
117 |
void CPsdAgtTest11_3::AgentProgress(TInt aStage, TInt aError)
|
|
118 |
{
|
|
119 |
// Only interested in the 1st notification after we started waiting for
|
|
120 |
// RPacketContext::NotifyStatusChange() to signal to PsdOpen
|
|
121 |
// Subsequent notifications could be during disconnect etc.
|
|
122 |
if(iStage == 1)
|
|
123 |
{
|
|
124 |
iStage++;
|
|
125 |
if(aStage == EPsdStartingDeactivation && aError == KErrNone)
|
|
126 |
return;
|
|
127 |
else TESTE(EFalse, aError); // We didn't get the notification we were after
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
// Test case 11.4
|
|
132 |
enum TVerdict CPsdAgtTest11_4::doPsdAgtTestStepL( void )
|
|
133 |
{
|
|
134 |
// This test is really only here for code coverage purposes
|
|
135 |
// It's difficult to actually test for any particular result
|
|
136 |
// aside from a successful connection / disconnection
|
|
137 |
|
|
138 |
TRealAgtNotify agtNotify;
|
|
139 |
agtNotify.SetTestCase(1104);
|
|
140 |
|
|
141 |
ConnectAndWaitForTwentySecondsL();
|
|
142 |
|
|
143 |
return iTestStepResult;
|
|
144 |
}
|
|
145 |
|
|
146 |
// Test case 11.5
|
|
147 |
enum TVerdict CPsdAgtTest11_5::doPsdAgtTestStepL( void )
|
|
148 |
{
|
|
149 |
TRealAgtNotify agtNotify;
|
|
150 |
|
|
151 |
agtNotify.SetTestCase(1105);
|
|
152 |
|
|
153 |
ConnectAndWaitForTwentySecondsL();
|
|
154 |
|
|
155 |
// Should have been incremented when DummyETEL simulated the Status changed
|
|
156 |
TESTL(iStage == 2);
|
|
157 |
|
|
158 |
return iTestStepResult;
|
|
159 |
}
|
|
160 |
|
|
161 |
void CPsdAgtTest11_5::AgentProgress(TInt aStage, TInt aError)
|
|
162 |
{
|
|
163 |
// Only interested in the 1st notification after we started waiting for
|
|
164 |
// RPacketContext::NotifyStatusChange() to signal to PsdOpen
|
|
165 |
// Subsequent notifications could be during disconnect etc.
|
|
166 |
if(iStage == 1)
|
|
167 |
{
|
|
168 |
iStage++;
|
|
169 |
if(aStage == EPsdFinishedDeactivation && aError == KErrNone)
|
|
170 |
return;
|
|
171 |
else TESTE(EFalse,aError); // We didn't get the notification we were after
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
|
175 |
// Test case 11.6
|
|
176 |
enum TVerdict CPsdAgtTest11_6::doPsdAgtTestStepL( void )
|
|
177 |
{
|
|
178 |
// This test is really only here for code coverage purposes
|
|
179 |
// It's difficult to actually test for any particular result
|
|
180 |
// aside from a successful connection / disconnection
|
|
181 |
TRealAgtNotify agtNotify;
|
|
182 |
agtNotify.SetTestCase(1106);
|
|
183 |
|
|
184 |
ConnectAndWaitForTwentySecondsL();
|
|
185 |
|
|
186 |
return iTestStepResult;
|
|
187 |
}
|
|
188 |
|
|
189 |
// Test case 11.7
|
|
190 |
enum TVerdict CPsdAgtTest11_7::doPsdAgtTestStepL( void )
|
|
191 |
{
|
|
192 |
TRealAgtNotify agtNotify;
|
|
193 |
agtNotify.SetTestCase(1107);
|
|
194 |
|
|
195 |
ConnectAndWaitForTwentySecondsL();
|
|
196 |
|
|
197 |
return iTestStepResult;
|
|
198 |
}
|
|
199 |
|
|
200 |
// Test case 11.8
|
|
201 |
// This is a test for the issue PDEF087346 in the TRP TSY's agent, which has a similar state machine.
|
|
202 |
// Connect, and on encountering an open connection immediately complete a high-priority AO to artificially
|
|
203 |
// set the progress. If the progress is then later reported by the agent to a lower value, then we have
|
|
204 |
// an out-of-order AO evaluation "bug" in the agent.
|
|
205 |
|
|
206 |
enum TVerdict CPsdAgtTest11_8::doPsdAgtTestStepL( void )
|
|
207 |
{
|
|
208 |
TRealAgtNotify agtNotify;
|
|
209 |
agtNotify.SetTestCase(1108);
|
|
210 |
|
|
211 |
TInt err;
|
|
212 |
TInt stage;
|
|
213 |
CNifAgentRefN1 *agent;
|
|
214 |
|
|
215 |
// Construct a new Dummy Nifman Instance
|
|
216 |
Log(_L("Loading DUMMYNIF.DLL"));
|
|
217 |
agent = CNifAgentRefN1::NewL(this,EFalse);
|
|
218 |
CleanupStack::PushL(agent);
|
|
219 |
|
|
220 |
// Attempt connection
|
|
221 |
Log(_L("Connecting..."));
|
|
222 |
agent->Connect();
|
|
223 |
|
|
224 |
// Check result codes
|
|
225 |
agent->GetCompletionCode(err);
|
|
226 |
TESTEL(err==KErrNone,err);
|
|
227 |
|
|
228 |
// Check ConnectComplete was reported at the correct stage in the state machine
|
|
229 |
agent->GetProgressStage(stage);
|
|
230 |
TESTEL(stage==KConnectionOpen,stage);
|
|
231 |
|
|
232 |
Log(_L("Connect Successful"));
|
|
233 |
|
|
234 |
// Kick off a high priority AO and wait...
|
|
235 |
Log(_L("Completing callback AO"));
|
|
236 |
|
|
237 |
CAsyncCallBack* async;
|
|
238 |
TCallBack cb(CPsdAgtTest11_8::Callback, static_cast<TAny*>(this));
|
|
239 |
async = new(ELeave)CAsyncCallBack(cb, EPriorityHigh); // must be high priority so that this AO runs before any AOs of the agent after it
|
|
240 |
// has declared the connection open. This is to simulate other components completing
|
|
241 |
// an AO which was created earlier than any completed AOs the agent may have pending.
|
|
242 |
CleanupStack::PushL(async);
|
|
243 |
async->CallBack();
|
|
244 |
|
|
245 |
Log(_L("Waiting..."));
|
|
246 |
DelayL(2000000);
|
|
247 |
|
|
248 |
// Preserve the progress value at this point
|
|
249 |
// If the agent had an AO scheduled to set the progress after it had reported
|
|
250 |
// successful connection, then this will NOT be the value set by the callback.
|
|
251 |
Log(_L("Preserving reported progress value..."));
|
|
252 |
TInt openProgressValue = iProgress;
|
|
253 |
|
|
254 |
|
|
255 |
// Disconnect
|
|
256 |
Log(_L("Disconnecting"));
|
|
257 |
agent->Disconnect();
|
|
258 |
|
|
259 |
// Check for an error code
|
|
260 |
agent->GetCompletionCode(err);
|
|
261 |
TESTEL(err==KErrNone,err);
|
|
262 |
Log(_L("Disconnect Successful"));
|
|
263 |
|
|
264 |
// Finished with Dummy Nifman and callback so delete them
|
|
265 |
CleanupStack::PopAndDestroy(async);
|
|
266 |
CleanupStack::PopAndDestroy(agent);
|
|
267 |
Log(_L("DUMMYNIF.DLL Unloaded"));
|
|
268 |
|
|
269 |
// Check that the progress value was the value last set by the async call.
|
|
270 |
Log(_L("Testing preserved progress value was KLinkLayerOpen..."));
|
|
271 |
TESTEL(openProgressValue == KLinkLayerOpen, openProgressValue);
|
|
272 |
|
|
273 |
return iTestStepResult;
|
|
274 |
}
|
|
275 |
|
|
276 |
void CPsdAgtTest11_8::AgentProgress(TInt aStage, TInt /*aError*/)
|
|
277 |
{
|
|
278 |
iProgress = aStage;
|
|
279 |
}
|
|
280 |
|
|
281 |
TInt CPsdAgtTest11_8::Callback(TAny* aParam)
|
|
282 |
{
|
|
283 |
CPsdAgtTest11_8* obj = static_cast<CPsdAgtTest11_8*>(aParam);
|
|
284 |
obj->AgentProgress(KLinkLayerOpen, KErrNone); // as per defect, set progress to KLinkLayerOpen
|
|
285 |
|
|
286 |
return KErrNone;
|
|
287 |
}
|
|
288 |
//
|