|
1 // Copyright (c) 1999-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 "poptestparsers.h" |
|
17 #include "poptests.h" |
|
18 |
|
19 _LIT(KCommandPop3ClientTest, "pop3_client_test"); |
|
20 _LIT(KCommandPop3Service, "pop3_service"); |
|
21 _LIT(KCommandPop3UseService, "use_service"); // 0 parameters, uses the currently selected service |
|
22 |
|
23 // POP3 settings strings |
|
24 _LIT(KCommandPop3SetServer, "set_server"); |
|
25 _LIT(KCommandPop3SetUserName, "set_user"); |
|
26 _LIT(KCommandPop3SetPassword, "set_pass"); |
|
27 _LIT(KCommandPop3SetName, "set_name"); |
|
28 _LIT(KCommandPop3SetTLS, "set_tls"); // 1 parameter, sets the secure connection for POP service. value should be 1 or 0 |
|
29 _LIT(KCommandPop3SetWrappedTLS, "set_wrapped_tls"); // 1 parameter, sets the secure connection for POP service. value should be 1 or 0 |
|
30 _LIT(KCommandPop3SetPort, "set_port"); // 1 parameter, sets the port no for POP service. |
|
31 |
|
32 // POP3 Operations |
|
33 _LIT(KCommandPop3Connect, "connect"); |
|
34 _LIT(KCommandPop3ConnectAndMonitor, "connect_and_monitor"); // 0 parameters, connects to the Pop3 service and monitors connection |
|
35 _LIT(KCommandPop3Disconnect, "disconnect"); |
|
36 |
|
37 _LIT(KCommandPop3CheckStatus, "check_pop3_error"); |
|
38 |
|
39 _LIT(KCommandPop3SetSyncLimits, "set_sync_limits"); // 2 parameters, resets the sync limits for currently selected pop service |
|
40 |
|
41 |
|
42 // |
|
43 // |
|
44 // CNewPop3TestCommandParser |
|
45 // |
|
46 |
|
47 // A command parser |
|
48 // Parses the command which generates a new Pop3 test harness |
|
49 // This command would usually be found in an email test section |
|
50 |
|
51 CNewPop3TestCommandParser* CNewPop3TestCommandParser::NewL(CTestScript& aScript, CEmailClientTest& aEmailClientTest) |
|
52 { |
|
53 CNewPop3TestCommandParser* self = new (ELeave) CNewPop3TestCommandParser(aScript, aEmailClientTest); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 }; |
|
59 |
|
60 void CNewPop3TestCommandParser::ProcessL() |
|
61 { |
|
62 // Create an smtp test, give it the test utilities |
|
63 CPop3ClientTest* pop3Test = CPop3ClientTest::NewL(iEmailClientTest.EmailTestUtils(), iEmailClientTest.TestConsole()); |
|
64 CleanupStack::PushL(pop3Test); |
|
65 |
|
66 // Attach the email test to the main test |
|
67 iEmailClientTest.AddStateL(pop3Test, iDebugInfo); |
|
68 CleanupStack::Pop(pop3Test); // emailTest is now owned by the iMainTest |
|
69 |
|
70 // Check that there is one argument, the email test section name |
|
71 CheckNumberOfArgumentsL(1); |
|
72 |
|
73 // Create an email section parser |
|
74 CPop3ClientSectionParser* sectionParser = CPop3ClientSectionParser::NewL(*pop3Test, iScript, (*iArgumentList)[0]); |
|
75 CleanupStack::PushL(sectionParser); |
|
76 sectionParser->ParseL(); |
|
77 CleanupStack::PopAndDestroy(sectionParser); |
|
78 } |
|
79 |
|
80 void CNewPop3TestCommandParser::ConstructL() |
|
81 { |
|
82 CBaseCommandParser::ConstructL(); |
|
83 AddCommandL(KCommandPop3ClientTest); |
|
84 } |
|
85 |
|
86 CNewPop3TestCommandParser::CNewPop3TestCommandParser(CTestScript& aScript, CEmailClientTest& aEmailClientTest) : iEmailClientTest(aEmailClientTest), iScript(aScript) |
|
87 { |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 // |
|
94 // |
|
95 // CPop3ClientSectionParser |
|
96 // |
|
97 |
|
98 // A section parser |
|
99 // Parses an POP3 test section |
|
100 |
|
101 CPop3ClientSectionParser* CPop3ClientSectionParser::NewL(CPop3ClientTest& aPop3ClientTest, CTestScript& aScript, const TDesC& aNewSectionName) |
|
102 { |
|
103 CPop3ClientSectionParser* self = new (ELeave) CPop3ClientSectionParser(aPop3ClientTest, aScript); |
|
104 CleanupStack::PushL(self); |
|
105 self->ConstructL(aNewSectionName); |
|
106 CleanupStack::Pop(self); |
|
107 return self; |
|
108 } |
|
109 |
|
110 void CPop3ClientSectionParser::ConstructL(const TDesC& aNewSectionName) |
|
111 { |
|
112 CEmailClientSectionParser::ConstructL(aNewSectionName); |
|
113 AddCommandParserL(CPop3ServiceCommandParser::NewL(iScript, iPop3Test)); |
|
114 AddCommandParserL(CPop3OperationParser::NewL(iPop3Test)); |
|
115 AddCommandParserL(CPop3CheckStatusParser::NewL(iPop3Test)); |
|
116 } |
|
117 |
|
118 CPop3ClientSectionParser::CPop3ClientSectionParser(CPop3ClientTest& aPop3Test, CTestScript& aScript) : CEmailClientSectionParser(aPop3Test, aScript), iPop3Test(aPop3Test) |
|
119 { |
|
120 } |
|
121 |
|
122 |
|
123 |
|
124 // |
|
125 // |
|
126 // CPop3ServiceCommandParser |
|
127 // |
|
128 |
|
129 void CPop3ServiceCommandParser::ProcessL() |
|
130 { |
|
131 CheckNumberOfArgumentsL(1); |
|
132 // Create the settings object which we will give to the settings section parser |
|
133 CPop3ServiceSectionParser* serviceParser = CPop3ServiceSectionParser::NewL(iScript, iPop3ClientTest, (*iArgumentList)[0]); |
|
134 CleanupStack::PushL(serviceParser); |
|
135 |
|
136 serviceParser->ParseL(); |
|
137 CleanupStack::PopAndDestroy(serviceParser); |
|
138 } |
|
139 |
|
140 CPop3ServiceCommandParser* CPop3ServiceCommandParser::NewL(CTestScript& aScript, CPop3ClientTest& aPop3ClientTest) |
|
141 { |
|
142 CPop3ServiceCommandParser* self = new (ELeave) CPop3ServiceCommandParser(aScript, aPop3ClientTest); |
|
143 CleanupStack::PushL(self); |
|
144 self->ConstructL(); |
|
145 CleanupStack::Pop(self); |
|
146 return self; |
|
147 } |
|
148 |
|
149 void CPop3ServiceCommandParser::ConstructL() |
|
150 { |
|
151 CBaseCommandParser::ConstructL(); |
|
152 AddCommandL(KCommandPop3Service); |
|
153 } |
|
154 |
|
155 CPop3ServiceCommandParser::CPop3ServiceCommandParser(CTestScript& aScript, CPop3ClientTest& aPop3ClientTest) : iPop3ClientTest(aPop3ClientTest), iScript(aScript) |
|
156 { |
|
157 } |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 // |
|
163 // |
|
164 // CPop3ServiceSectionParser |
|
165 // |
|
166 |
|
167 // A section parser |
|
168 // Parses a POP3 section to create a POP3 service |
|
169 |
|
170 CPop3ServiceSectionParser* CPop3ServiceSectionParser::NewL(CTestScript& aScript, CEmailClientTest& aTestHarness, const TDesC& aSectionName) |
|
171 { |
|
172 CPop3ServiceSectionParser* self = new (ELeave) CPop3ServiceSectionParser(aScript, aTestHarness); |
|
173 CleanupStack::PushL(self); |
|
174 self->ConstructL(aSectionName); |
|
175 CleanupStack::Pop(self); |
|
176 return self; |
|
177 } |
|
178 |
|
179 void CPop3ServiceSectionParser::ConstructL(const TDesC& aSectionName) |
|
180 { |
|
181 CBaseSectionParser::ConstructL(aSectionName); |
|
182 |
|
183 // Add the state to generate the pop3 service |
|
184 CCreatePop3Service* testState = CCreatePop3Service::NewL(iTestHarness); |
|
185 TTestDebugInfo debugInfo(iScript, iSection->SectionPosition(), 0); |
|
186 iTestHarness.AddStateL(testState, debugInfo); |
|
187 |
|
188 // The parsers will fill in the entry and service details before the state that creates the entry is run. |
|
189 AddCommandParserL(CPop3ServiceCommands::NewL(*testState)); |
|
190 |
|
191 CEmailServiceSectionParser::ConstructL(aSectionName, *testState); |
|
192 } |
|
193 |
|
194 CPop3ServiceSectionParser::CPop3ServiceSectionParser(CTestScript& aScript, CEmailClientTest& aTestHarness) : CEmailServiceSectionParser(aScript, aTestHarness) |
|
195 { |
|
196 } |
|
197 |
|
198 CPop3ServiceSectionParser::~CPop3ServiceSectionParser() |
|
199 { |
|
200 } |
|
201 |
|
202 |
|
203 |
|
204 // |
|
205 // |
|
206 // CPop3ServiceCommands |
|
207 // |
|
208 |
|
209 // A command parser |
|
210 // Parses the commands that generate the POP3 service |
|
211 |
|
212 CPop3ServiceCommands* CPop3ServiceCommands::NewL(CCreatePop3Service& aTestState) |
|
213 { |
|
214 CPop3ServiceCommands* self = new (ELeave) CPop3ServiceCommands(aTestState); |
|
215 CleanupStack::PushL(self); |
|
216 self->ConstructL(); |
|
217 CleanupStack::Pop(self); |
|
218 return self; |
|
219 } |
|
220 |
|
221 void CPop3ServiceCommands::ProcessL() |
|
222 { |
|
223 if ((*iCurrentCommand) == KCommandPop3SetServer) |
|
224 { |
|
225 CheckNumberOfArgumentsL(1); |
|
226 iTestState.Settings().SetServerAddressL((*iArgumentList)[0]); |
|
227 } |
|
228 else if ((*iCurrentCommand) == KCommandPop3SetUserName) |
|
229 { |
|
230 CheckNumberOfArgumentsL(1); |
|
231 TBuf8<128> loginName; |
|
232 loginName.Copy((*iArgumentList)[0]); |
|
233 iTestState.Settings().SetLoginNameL(loginName); |
|
234 } |
|
235 else if ((*iCurrentCommand) == KCommandPop3SetPassword) |
|
236 { |
|
237 CheckNumberOfArgumentsL(1); |
|
238 TBuf8<128> password; |
|
239 password.Copy((*iArgumentList)[0]); |
|
240 iTestState.Settings().SetPasswordL(password); |
|
241 } |
|
242 else if ((*iCurrentCommand) == KCommandPop3SetName) |
|
243 { |
|
244 iTestState.SetDetailsStringL((*iArgumentList)[0]); |
|
245 } |
|
246 else if ((*iCurrentCommand) == KCommandPop3SetTLS) |
|
247 { |
|
248 CheckNumberOfArgumentsL(1); |
|
249 TLex lex((*iArgumentList)[0]); |
|
250 TInt setTls=0; |
|
251 User::LeaveIfError(lex.Val(setTls)); |
|
252 iTestState.Settings().SetSecureSockets(setTls); |
|
253 } |
|
254 else if ((*iCurrentCommand) == KCommandPop3SetPort) |
|
255 { |
|
256 |
|
257 CheckNumberOfArgumentsL(1); |
|
258 TLex lex((*iArgumentList)[0]); |
|
259 TInt setPort=0; |
|
260 User::LeaveIfError(lex.Val(setPort)); |
|
261 iTestState.Settings().SetPort(setPort); |
|
262 |
|
263 } |
|
264 else if ((*iCurrentCommand) == KCommandPop3SetWrappedTLS) |
|
265 { |
|
266 CheckNumberOfArgumentsL(1); |
|
267 TLex lex((*iArgumentList)[0]); |
|
268 TInt setWrappedTls=0; |
|
269 User::LeaveIfError(lex.Val(setWrappedTls)); |
|
270 iTestState.Settings().SetSSLWrapper(setWrappedTls); |
|
271 } |
|
272 |
|
273 } |
|
274 |
|
275 CPop3ServiceCommands::CPop3ServiceCommands(CCreatePop3Service& aTestState) : iTestState(aTestState) |
|
276 { |
|
277 } |
|
278 |
|
279 void CPop3ServiceCommands::ConstructL() |
|
280 { |
|
281 CBaseCommandParser::ConstructL(); |
|
282 AddCommandL(KCommandPop3SetServer); |
|
283 AddCommandL(KCommandPop3SetUserName); |
|
284 AddCommandL(KCommandPop3SetPassword); |
|
285 AddCommandL(KCommandPop3SetName); |
|
286 AddCommandL(KCommandPop3SetTLS); |
|
287 AddCommandL(KCommandPop3SetPort); |
|
288 AddCommandL(KCommandPop3SetWrappedTLS); |
|
289 } |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 // |
|
298 // |
|
299 // CPop3OperationParser |
|
300 // |
|
301 |
|
302 CPop3OperationParser* CPop3OperationParser::NewL(CPop3ClientTest& aPop3ClientTest) |
|
303 { |
|
304 CPop3OperationParser* self = new (ELeave) CPop3OperationParser(aPop3ClientTest); |
|
305 CleanupStack::PushL(self); |
|
306 self->ConstructL(); |
|
307 CleanupStack::Pop(self); |
|
308 return self; |
|
309 } |
|
310 |
|
311 void CPop3OperationParser::ProcessL() |
|
312 { |
|
313 if ((*iCurrentCommand) == KCommandPop3Connect) |
|
314 { |
|
315 CheckNumberOfArgumentsL(0); |
|
316 iPop3ClientTest.AddStateL(new (ELeave) CPop3Connect(iPop3ClientTest), iDebugInfo); |
|
317 } |
|
318 else if ((*iCurrentCommand) == KCommandPop3ConnectAndMonitor) |
|
319 { |
|
320 CheckNumberOfArgumentsL(0); |
|
321 |
|
322 iPop3ClientTest.AddStateL(new (ELeave) CPop3ConnectAndMonitor(iPop3ClientTest, EFalse), iDebugInfo); |
|
323 } |
|
324 else if ((*iCurrentCommand) == KCommandPop3Disconnect) |
|
325 { |
|
326 CheckNumberOfArgumentsL(0); |
|
327 iPop3ClientTest.AddStateL(new (ELeave) CPop3Disconnect(iPop3ClientTest), iDebugInfo); |
|
328 } |
|
329 else if ((*iCurrentCommand) == KCommandPop3UseService) |
|
330 { |
|
331 CheckNumberOfArgumentsL(0); |
|
332 iPop3ClientTest.AddStateL(new (ELeave) CPop3UseService(iPop3ClientTest), iDebugInfo); |
|
333 } |
|
334 else if ((*iCurrentCommand) == KCommandPop3SetSyncLimits) |
|
335 { |
|
336 CheckNumberOfArgumentsL(1); |
|
337 |
|
338 TInt inboxSyncLimit; |
|
339 TLex inboxLex((*iArgumentList)[0]); |
|
340 User::LeaveIfError(inboxLex.Val(inboxSyncLimit)); |
|
341 |
|
342 iPop3ClientTest.AddStateL(new (ELeave) CPop3SetSyncLimits(inboxSyncLimit,iPop3ClientTest), iDebugInfo); |
|
343 } |
|
344 else |
|
345 { |
|
346 User::Leave(KErrNotFound); |
|
347 } |
|
348 } |
|
349 |
|
350 void CPop3OperationParser::ConstructL() |
|
351 { |
|
352 CBaseCommandParser::ConstructL(); |
|
353 AddCommandL(KCommandPop3Connect); |
|
354 AddCommandL(KCommandPop3ConnectAndMonitor); |
|
355 AddCommandL(KCommandPop3Disconnect); |
|
356 AddCommandL(KCommandPop3UseService); |
|
357 AddCommandL(KCommandPop3SetSyncLimits); |
|
358 } |
|
359 |
|
360 CPop3OperationParser::CPop3OperationParser(CPop3ClientTest& aPop3ClientTest) : iPop3ClientTest(aPop3ClientTest) |
|
361 { |
|
362 } |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 // |
|
368 // |
|
369 // CPop3CheckStatusParser |
|
370 // |
|
371 |
|
372 |
|
373 CPop3CheckStatusParser* CPop3CheckStatusParser::NewL(CPop3ClientTest& aPop3TestHarness) |
|
374 { |
|
375 CPop3CheckStatusParser* self = new (ELeave) CPop3CheckStatusParser(aPop3TestHarness); |
|
376 CleanupStack::PushL(self); |
|
377 self->ConstructL(); |
|
378 CleanupStack::Pop(self); |
|
379 return self; |
|
380 } |
|
381 |
|
382 void CPop3CheckStatusParser::ProcessL() |
|
383 { |
|
384 TLex lex((*iArgumentList)[0]); |
|
385 TInt expectedStatus; |
|
386 User::LeaveIfError(lex.Val(expectedStatus)); |
|
387 iTestHarness.AddStateL(new (ELeave) CCheckPop3Operation(expectedStatus, iTestHarness), iDebugInfo); |
|
388 } |
|
389 |
|
390 CPop3CheckStatusParser::CPop3CheckStatusParser(CPop3ClientTest& aPop3TestHarness) : iTestHarness(aPop3TestHarness) |
|
391 { |
|
392 } |
|
393 |
|
394 void CPop3CheckStatusParser::ConstructL() |
|
395 { |
|
396 CBaseCommandParser::ConstructL(); |
|
397 AddCommandL(KCommandPop3CheckStatus); |
|
398 } |
|
399 |