|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32math.h> |
|
23 #include "DownloadMgrClientApiTest.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // None |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 // None |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 |
|
34 // MACROS |
|
35 // None |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 // None |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 // None |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 // None |
|
48 |
|
49 // ==================== LOCAL FUNCTIONS ======================================= |
|
50 |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 /* |
|
55 ------------------------------------------------------------------------------- |
|
56 |
|
57 Class: CDownloadMgrClientApiTest |
|
58 |
|
59 Method: DownloadStartTest |
|
60 |
|
61 Description: Test the RHttpDownload Start method. |
|
62 |
|
63 Parameters: TTestResult& aErrorDescription: out: |
|
64 Test result and on error case a short description of error |
|
65 |
|
66 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
67 |
|
68 Errors/Exceptions: None |
|
69 |
|
70 Status: Approved |
|
71 |
|
72 ------------------------------------------------------------------------------- |
|
73 */ |
|
74 TInt CDownloadMgrClientApiTest::DownloadStartTest( TTestResult& aResult ) |
|
75 { |
|
76 /* Simple server connect */ |
|
77 _LIT( KDefinition ,"State"); |
|
78 _LIT( KData ,"Test the RHttpDownload Start method"); |
|
79 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
80 |
|
81 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
82 CleanupStack::PushL( scheduler ); |
|
83 CActiveScheduler::Install( scheduler ); |
|
84 |
|
85 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
86 |
|
87 TBool isNewDl = ETrue; |
|
88 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
89 |
|
90 // Added To avoid user Input while Automation in is Progress |
|
91 // 7 - SONERA GPRS Access Point |
|
92 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
93 |
|
94 TInt result = download.Start(); |
|
95 |
|
96 _LIT( KData2 ,"Finished"); |
|
97 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
98 |
|
99 if( result == KErrNone ) |
|
100 { |
|
101 _LIT( KDescription , "Test case passed" ); |
|
102 aResult.SetResult( KErrNone, KDescription ); |
|
103 } |
|
104 else |
|
105 { |
|
106 _LIT( KDescription , "Test case failed" ); |
|
107 aResult.SetResult( KErrGeneral, KDescription ); |
|
108 } |
|
109 |
|
110 iDownloadManager.DeleteAll(); |
|
111 CleanupStack::PopAndDestroy(); // scheduler |
|
112 |
|
113 // Case was executed |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 /* |
|
118 ------------------------------------------------------------------------------- |
|
119 |
|
120 Class: CDownloadMgrClientApiTest |
|
121 |
|
122 Method: DownloadPauseTest |
|
123 |
|
124 Description: Test the RHttpDownload Pause method. |
|
125 |
|
126 Parameters: TTestResult& aErrorDescription: out: |
|
127 Test result and on error case a short description of error |
|
128 |
|
129 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
130 |
|
131 Errors/Exceptions: None |
|
132 |
|
133 Status: Approved |
|
134 |
|
135 ------------------------------------------------------------------------------- |
|
136 */ |
|
137 TInt CDownloadMgrClientApiTest::DownloadPauseTest( TTestResult& aResult ) |
|
138 { |
|
139 /* Simple server connect */ |
|
140 _LIT( KDefinition ,"State"); |
|
141 _LIT( KData ,"Test the RHttpDownload Pause method"); |
|
142 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
143 |
|
144 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
145 CleanupStack::PushL( scheduler ); |
|
146 CActiveScheduler::Install( scheduler ); |
|
147 |
|
148 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
149 |
|
150 TBool isNewDl = ETrue; |
|
151 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
152 |
|
153 // Added To avoid user Input while Automation in is Progress |
|
154 // 7 - SONERA GPRS Access Point |
|
155 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
156 |
|
157 download.Start(); |
|
158 |
|
159 TInt result = download.Pause(); |
|
160 |
|
161 _LIT( KData2 ,"Finished"); |
|
162 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
163 |
|
164 if( result == KErrNone ) |
|
165 { |
|
166 _LIT( KDescription , "Test case passed" ); |
|
167 aResult.SetResult( KErrNone, KDescription ); |
|
168 } |
|
169 else |
|
170 { |
|
171 _LIT( KDescription , "Test case failed" ); |
|
172 aResult.SetResult( KErrGeneral, KDescription ); |
|
173 } |
|
174 |
|
175 iDownloadManager.DeleteAll(); |
|
176 CleanupStack::PopAndDestroy(); // scheduler |
|
177 |
|
178 // Case was executed |
|
179 return KErrNone; |
|
180 } |
|
181 |
|
182 /* |
|
183 ------------------------------------------------------------------------------- |
|
184 |
|
185 Class: CDownloadMgrClientApiTest |
|
186 |
|
187 Method: DownloadResetTest |
|
188 |
|
189 Description: Test the RHttpDownload Reset method. |
|
190 |
|
191 Parameters: TTestResult& aErrorDescription: out: |
|
192 Test result and on error case a short description of error |
|
193 |
|
194 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
195 |
|
196 Errors/Exceptions: None |
|
197 |
|
198 Status: Approved |
|
199 |
|
200 ------------------------------------------------------------------------------- |
|
201 */ |
|
202 TInt CDownloadMgrClientApiTest::DownloadResetTest( TTestResult& aResult ) |
|
203 { |
|
204 /* Simple server connect */ |
|
205 _LIT( KDefinition ,"State"); |
|
206 _LIT( KData ,"Test the RHttpDownload Reset method"); |
|
207 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
208 |
|
209 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
210 CleanupStack::PushL( scheduler ); |
|
211 CActiveScheduler::Install( scheduler ); |
|
212 |
|
213 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
214 |
|
215 TBool isNewDl = ETrue; |
|
216 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
217 |
|
218 // Added To avoid user Input while Automation in is Progress |
|
219 // 7 - SONERA GPRS Access Point |
|
220 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
221 |
|
222 download.Start(); |
|
223 |
|
224 TInt result = download.Reset(); |
|
225 |
|
226 _LIT( KData2 ,"Finished"); |
|
227 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
228 |
|
229 if( result == KErrNone ) |
|
230 { |
|
231 _LIT( KDescription , "Test case passed" ); |
|
232 aResult.SetResult( KErrNone, KDescription ); |
|
233 } |
|
234 else |
|
235 { |
|
236 _LIT( KDescription , "Test case failed" ); |
|
237 aResult.SetResult( KErrGeneral, KDescription ); |
|
238 } |
|
239 |
|
240 iDownloadManager.DeleteAll(); |
|
241 CleanupStack::PopAndDestroy(); // scheduler |
|
242 |
|
243 // Case was executed |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 /* |
|
248 ------------------------------------------------------------------------------- |
|
249 |
|
250 Class: CDownloadMgrClientApiTest |
|
251 |
|
252 Method: DownloadDeleteTest |
|
253 |
|
254 Description: Test the RHttpDownload Delete method. |
|
255 |
|
256 Parameters: TTestResult& aErrorDescription: out: |
|
257 Test result and on error case a short description of error |
|
258 |
|
259 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
260 |
|
261 Errors/Exceptions: None |
|
262 |
|
263 Status: Approved |
|
264 |
|
265 ------------------------------------------------------------------------------- |
|
266 */ |
|
267 TInt CDownloadMgrClientApiTest::DownloadDeleteTest( TTestResult& aResult ) |
|
268 { |
|
269 /* Simple server connect */ |
|
270 _LIT( KDefinition ,"State"); |
|
271 _LIT( KData ,"Test the RHttpDownload Delete method"); |
|
272 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
273 |
|
274 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
275 CleanupStack::PushL( scheduler ); |
|
276 CActiveScheduler::Install( scheduler ); |
|
277 |
|
278 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
279 |
|
280 TBool isNewDl = ETrue; |
|
281 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
282 |
|
283 // Added To avoid user Input while Automation in is Progress |
|
284 // 7 - SONERA GPRS Access Point |
|
285 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
286 |
|
287 download.Start(); |
|
288 |
|
289 TInt result = download.Delete(); |
|
290 |
|
291 _LIT( KData2 ,"Finished"); |
|
292 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
293 |
|
294 if( result == KErrNone ) |
|
295 { |
|
296 _LIT( KDescription , "Test case passed" ); |
|
297 aResult.SetResult( KErrNone, KDescription ); |
|
298 } |
|
299 else |
|
300 { |
|
301 _LIT( KDescription , "Test case failed" ); |
|
302 aResult.SetResult( KErrGeneral, KDescription ); |
|
303 } |
|
304 |
|
305 iDownloadManager.DeleteAll(); |
|
306 CleanupStack::PopAndDestroy(); // scheduler |
|
307 |
|
308 // Case was executed |
|
309 return KErrNone; |
|
310 } |
|
311 |
|
312 /* |
|
313 ------------------------------------------------------------------------------- |
|
314 |
|
315 Class: CDownloadMgrClientApiTest |
|
316 |
|
317 Method: DownloadMoveTest |
|
318 |
|
319 Description: Test the RHttpDownload Move method. |
|
320 |
|
321 Parameters: TTestResult& aErrorDescription: out: |
|
322 Test result and on error case a short description of error |
|
323 |
|
324 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
325 |
|
326 Errors/Exceptions: None |
|
327 |
|
328 Status: Approved |
|
329 |
|
330 ------------------------------------------------------------------------------- |
|
331 */ |
|
332 TInt CDownloadMgrClientApiTest::DownloadMoveTest( TTestResult& aResult ) |
|
333 { |
|
334 /* Simple server connect */ |
|
335 _LIT( KDefinition ,"State"); |
|
336 _LIT( KData ,"Test the RHttpDownload Move method"); |
|
337 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
338 |
|
339 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
340 CleanupStack::PushL( scheduler ); |
|
341 CActiveScheduler::Install( scheduler ); |
|
342 |
|
343 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
344 |
|
345 TBool isNewDl = ETrue; |
|
346 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
347 |
|
348 // Added To avoid user Input while Automation in is Progress |
|
349 // 7 - SONERA GPRS Access Point |
|
350 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
351 |
|
352 download.Start(); |
|
353 |
|
354 TInt result = download.Move(); |
|
355 |
|
356 _LIT( KData2 ,"Finished"); |
|
357 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
358 |
|
359 if( result == KErrNotReady ) |
|
360 { |
|
361 _LIT( KDescription , "Test case passed" ); |
|
362 aResult.SetResult( KErrNone, KDescription ); |
|
363 } |
|
364 else |
|
365 { |
|
366 _LIT( KDescription , "Test case failed" ); |
|
367 aResult.SetResult( KErrGeneral, KDescription ); |
|
368 } |
|
369 |
|
370 iDownloadManager.DeleteAll(); |
|
371 CleanupStack::PopAndDestroy(); // scheduler |
|
372 |
|
373 // Case was executed |
|
374 return KErrNone; |
|
375 } |
|
376 |
|
377 /* |
|
378 ------------------------------------------------------------------------------- |
|
379 |
|
380 Class: CDownloadMgrClientApiTest |
|
381 |
|
382 Method: DownloadGetIntAttributeTest |
|
383 |
|
384 Description: Test the RHttpDownload GetIntAttribute method. |
|
385 |
|
386 Parameters: TTestResult& aErrorDescription: out: |
|
387 Test result and on error case a short description of error |
|
388 |
|
389 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
390 |
|
391 Errors/Exceptions: None |
|
392 |
|
393 Status: Approved |
|
394 |
|
395 ------------------------------------------------------------------------------- |
|
396 */ |
|
397 TInt CDownloadMgrClientApiTest::DownloadGetIntAttributeTest( TTestResult& aResult ) |
|
398 { |
|
399 /* Simple server connect */ |
|
400 _LIT( KDefinition ,"State"); |
|
401 _LIT( KData ,"Test the RHttpDownload GetIntAttribute method"); |
|
402 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
403 |
|
404 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
405 CleanupStack::PushL( scheduler ); |
|
406 CActiveScheduler::Install( scheduler ); |
|
407 |
|
408 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
409 |
|
410 TBool isNewDl = ETrue; |
|
411 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
412 |
|
413 TInt32 value; |
|
414 TInt result = download.GetIntAttribute( EDlAttrId, value ); |
|
415 |
|
416 _LIT( KData2 ,"Finished"); |
|
417 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
418 |
|
419 if( result == KErrNone ) |
|
420 { |
|
421 _LIT( KDescription , "Test case passed" ); |
|
422 aResult.SetResult( KErrNone, KDescription ); |
|
423 } |
|
424 else |
|
425 { |
|
426 _LIT( KDescription , "Test case failed" ); |
|
427 aResult.SetResult( KErrGeneral, KDescription ); |
|
428 } |
|
429 |
|
430 iDownloadManager.DeleteAll(); |
|
431 CleanupStack::PopAndDestroy(); // scheduler |
|
432 |
|
433 // Case was executed |
|
434 return KErrNone; |
|
435 } |
|
436 |
|
437 /* |
|
438 ------------------------------------------------------------------------------- |
|
439 |
|
440 Class: CDownloadMgrClientApiTest |
|
441 |
|
442 Method: DownloadGetBoolAttributeTest |
|
443 |
|
444 Description: Test the RHttpDownload GetBoolAttribute method. |
|
445 |
|
446 Parameters: TTestResult& aErrorDescription: out: |
|
447 Test result and on error case a short description of error |
|
448 |
|
449 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
450 |
|
451 Errors/Exceptions: None |
|
452 |
|
453 Status: Approved |
|
454 |
|
455 ------------------------------------------------------------------------------- |
|
456 */ |
|
457 TInt CDownloadMgrClientApiTest::DownloadGetBoolAttributeTest( TTestResult& aResult ) |
|
458 { |
|
459 /* Simple server connect */ |
|
460 _LIT( KDefinition ,"State"); |
|
461 _LIT( KData ,"Test the RHttpDownload GetBoolAttribute method"); |
|
462 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
463 |
|
464 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
465 CleanupStack::PushL( scheduler ); |
|
466 CActiveScheduler::Install( scheduler ); |
|
467 |
|
468 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
469 |
|
470 TBool isNewDl = ETrue; |
|
471 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
472 |
|
473 TBool value; |
|
474 TInt result = download.GetBoolAttribute( EDlAttrDestRemovable, value ); |
|
475 |
|
476 _LIT( KData2 ,"Finished"); |
|
477 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
478 |
|
479 if( result == KErrNone ) |
|
480 { |
|
481 _LIT( KDescription , "Test case passed" ); |
|
482 aResult.SetResult( KErrNone, KDescription ); |
|
483 } |
|
484 else |
|
485 { |
|
486 _LIT( KDescription , "Test case failed" ); |
|
487 aResult.SetResult( KErrGeneral, KDescription ); |
|
488 } |
|
489 |
|
490 iDownloadManager.DeleteAll(); |
|
491 CleanupStack::PopAndDestroy(); // scheduler |
|
492 |
|
493 // Case was executed |
|
494 return KErrNone; |
|
495 } |
|
496 |
|
497 /* |
|
498 ------------------------------------------------------------------------------- |
|
499 |
|
500 Class: CDownloadMgrClientApiTest |
|
501 |
|
502 Method: DownloadGetStringAttribute16Test |
|
503 |
|
504 Description: Test the RHttpDownload GetStringAttribute method using TDes16 argument. |
|
505 |
|
506 Parameters: TTestResult& aErrorDescription: out: |
|
507 Test result and on error case a short description of error |
|
508 |
|
509 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
510 |
|
511 Errors/Exceptions: None |
|
512 |
|
513 Status: Approved |
|
514 |
|
515 ------------------------------------------------------------------------------- |
|
516 */ |
|
517 TInt CDownloadMgrClientApiTest::DownloadGetStringAttribute16Test( TTestResult& aResult ) |
|
518 { |
|
519 /* Simple server connect */ |
|
520 _LIT( KDefinition ,"State"); |
|
521 _LIT( KData ,"Test the RHttpDownload GetStringAttribute method using TDes16 argument"); |
|
522 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
523 |
|
524 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
525 CleanupStack::PushL( scheduler ); |
|
526 CActiveScheduler::Install( scheduler ); |
|
527 |
|
528 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
529 |
|
530 TBool isNewDl = ETrue; |
|
531 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
532 |
|
533 HBufC16* stringAttr = HBufC16::NewLC( KMaxUrlLength ); |
|
534 TPtr16 stringAttrPtr = stringAttr->Des(); |
|
535 TInt result = download.GetStringAttribute( EDlAttrCurrentUrl, stringAttrPtr ); |
|
536 |
|
537 _LIT( KData2 ,"Finished"); |
|
538 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
539 |
|
540 if( result == KErrNone ) |
|
541 { |
|
542 _LIT( KDescription , "Test case passed" ); |
|
543 aResult.SetResult( KErrNone, KDescription ); |
|
544 } |
|
545 else |
|
546 { |
|
547 _LIT( KDescription , "Test case failed" ); |
|
548 aResult.SetResult( KErrGeneral, KDescription ); |
|
549 } |
|
550 |
|
551 iDownloadManager.DeleteAll(); |
|
552 CleanupStack::PopAndDestroy( 2 ); // scheduler, stringAttr |
|
553 |
|
554 // Case was executed |
|
555 return KErrNone; |
|
556 } |
|
557 |
|
558 /* |
|
559 ------------------------------------------------------------------------------- |
|
560 |
|
561 Class: CDownloadMgrClientApiTest |
|
562 |
|
563 Method: DownloadGetStringAttribute8Test |
|
564 |
|
565 Description: Test the RHttpDownload GetStringAttribute method using TDes8 argument. |
|
566 |
|
567 Parameters: TTestResult& aErrorDescription: out: |
|
568 Test result and on error case a short description of error |
|
569 |
|
570 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
571 |
|
572 Errors/Exceptions: None |
|
573 |
|
574 Status: Approved |
|
575 |
|
576 ------------------------------------------------------------------------------- |
|
577 */ |
|
578 TInt CDownloadMgrClientApiTest::DownloadGetStringAttribute8Test( TTestResult& aResult ) |
|
579 { |
|
580 /* Simple server connect */ |
|
581 _LIT( KDefinition ,"State"); |
|
582 _LIT( KData ,"Test the RHttpDownload GetStringAttribute method using TDes8 argument"); |
|
583 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
584 |
|
585 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
586 CleanupStack::PushL( scheduler ); |
|
587 CActiveScheduler::Install( scheduler ); |
|
588 |
|
589 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
590 |
|
591 TBool isNewDl = ETrue; |
|
592 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
593 |
|
594 HBufC8* stringAttr = HBufC8::NewLC( KMaxUrlLength ); |
|
595 TPtr8 stringAttrPtr = stringAttr->Des(); |
|
596 TInt result = download.GetStringAttribute( EDlAttrCurrentUrl, stringAttrPtr ); |
|
597 |
|
598 _LIT( KData2 ,"Finished"); |
|
599 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
600 |
|
601 if( result == KErrNone ) |
|
602 { |
|
603 _LIT( KDescription , "Test case passed" ); |
|
604 aResult.SetResult( KErrNone, KDescription ); |
|
605 } |
|
606 else |
|
607 { |
|
608 _LIT( KDescription , "Test case failed" ); |
|
609 aResult.SetResult( KErrGeneral, KDescription ); |
|
610 } |
|
611 |
|
612 iDownloadManager.DeleteAll(); |
|
613 CleanupStack::PopAndDestroy( 2 ); // scheduler, stringAttr |
|
614 |
|
615 // Case was executed |
|
616 return KErrNone; |
|
617 } |
|
618 |
|
619 /* |
|
620 ------------------------------------------------------------------------------- |
|
621 |
|
622 Class: CDownloadMgrClientApiTest |
|
623 |
|
624 Method: DownloadGetFileHandleAttributeTest |
|
625 |
|
626 Description: Test the RHttpDownload GetFileHandleAttribute method. |
|
627 |
|
628 Parameters: TTestResult& aErrorDescription: out: |
|
629 Test result and on error case a short description of error |
|
630 |
|
631 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
632 |
|
633 Errors/Exceptions: None |
|
634 |
|
635 Status: Approved |
|
636 |
|
637 ------------------------------------------------------------------------------- |
|
638 */ |
|
639 TInt CDownloadMgrClientApiTest::DownloadGetFileHandleAttributeTest( TTestResult& aResult ) |
|
640 { |
|
641 /* Simple server connect */ |
|
642 _LIT( KDefinition ,"State"); |
|
643 _LIT( KData ,"Test the RHttpDownload GetFileHandleAttribute method"); |
|
644 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
645 |
|
646 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
647 CleanupStack::PushL( scheduler ); |
|
648 CActiveScheduler::Install( scheduler ); |
|
649 |
|
650 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
651 |
|
652 TBool isNewDl = ETrue; |
|
653 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
654 |
|
655 // Added To avoid user Input while Automation in is Progress |
|
656 // 7 - SONERA GPRS Access Point |
|
657 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
658 |
|
659 download.Start(); |
|
660 |
|
661 RFile file; |
|
662 TInt result = download.GetFileHandleAttribute( file ); |
|
663 |
|
664 _LIT( KData2 ,"Finished"); |
|
665 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
666 |
|
667 if( result == KErrArgument ) |
|
668 { |
|
669 _LIT( KDescription , "Test case passed" ); |
|
670 aResult.SetResult( KErrNone, KDescription ); |
|
671 } |
|
672 else |
|
673 { |
|
674 _LIT( KDescription , "Test case failed" ); |
|
675 aResult.SetResult( KErrGeneral, KDescription ); |
|
676 } |
|
677 |
|
678 iDownloadManager.DeleteAll(); |
|
679 CleanupStack::PopAndDestroy(); // scheduler |
|
680 |
|
681 // Case was executed |
|
682 return KErrNone; |
|
683 } |
|
684 |
|
685 /* |
|
686 ------------------------------------------------------------------------------- |
|
687 |
|
688 Class: CDownloadMgrClientApiTest |
|
689 |
|
690 Method: DownloadSetIntAttributeTest |
|
691 |
|
692 Description: Test the RHttpDownload SetIntAttribute method. |
|
693 |
|
694 Parameters: TTestResult& aErrorDescription: out: |
|
695 Test result and on error case a short description of error |
|
696 |
|
697 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
698 |
|
699 Errors/Exceptions: None |
|
700 |
|
701 Status: Approved |
|
702 |
|
703 ------------------------------------------------------------------------------- |
|
704 */ |
|
705 TInt CDownloadMgrClientApiTest::DownloadSetIntAttributeTest( TTestResult& aResult ) |
|
706 { |
|
707 /* Simple server connect */ |
|
708 _LIT( KDefinition ,"State"); |
|
709 _LIT( KData ,"Test the RHttpDownload SetIntAttribute method"); |
|
710 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
711 |
|
712 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
713 CleanupStack::PushL( scheduler ); |
|
714 CActiveScheduler::Install( scheduler ); |
|
715 |
|
716 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
717 |
|
718 TBool isNewDl = ETrue; |
|
719 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
720 |
|
721 TInt result = download.SetIntAttribute( EDlAttrFotaPckgId, KDefaultFotaPckgId ); |
|
722 |
|
723 _LIT( KData2 ,"Finished"); |
|
724 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
725 |
|
726 if( result == KErrNone ) |
|
727 { |
|
728 _LIT( KDescription , "Test case passed" ); |
|
729 aResult.SetResult( KErrNone, KDescription ); |
|
730 } |
|
731 else |
|
732 { |
|
733 _LIT( KDescription , "Test case failed" ); |
|
734 aResult.SetResult( KErrGeneral, KDescription ); |
|
735 } |
|
736 |
|
737 iDownloadManager.DeleteAll(); |
|
738 CleanupStack::PopAndDestroy(); // scheduler |
|
739 |
|
740 // Case was executed |
|
741 return KErrNone; |
|
742 } |
|
743 |
|
744 /* |
|
745 ------------------------------------------------------------------------------- |
|
746 |
|
747 Class: CDownloadMgrClientApiTest |
|
748 |
|
749 Method: DownloadSetBoolAttributeTest |
|
750 |
|
751 Description: Test the RHttpDownload SetBoolAttribute method. |
|
752 |
|
753 Parameters: TTestResult& aErrorDescription: out: |
|
754 Test result and on error case a short description of error |
|
755 |
|
756 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
757 |
|
758 Errors/Exceptions: None |
|
759 |
|
760 Status: Approved |
|
761 |
|
762 ------------------------------------------------------------------------------- |
|
763 */ |
|
764 TInt CDownloadMgrClientApiTest::DownloadSetBoolAttributeTest( TTestResult& aResult ) |
|
765 { |
|
766 /* Simple server connect */ |
|
767 _LIT( KDefinition ,"State"); |
|
768 _LIT( KData ,"Test the RHttpDownload SetBoolAttribute method"); |
|
769 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
770 |
|
771 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
772 CleanupStack::PushL( scheduler ); |
|
773 CActiveScheduler::Install( scheduler ); |
|
774 |
|
775 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
776 |
|
777 TBool isNewDl = ETrue; |
|
778 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
779 |
|
780 TInt result = download.SetBoolAttribute( EDlAttrProgressive, EFalse ); |
|
781 |
|
782 _LIT( KData2 ,"Finished"); |
|
783 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
784 |
|
785 if( result == KErrNone ) |
|
786 { |
|
787 _LIT( KDescription , "Test case passed" ); |
|
788 aResult.SetResult( KErrNone, KDescription ); |
|
789 } |
|
790 else |
|
791 { |
|
792 _LIT( KDescription , "Test case failed" ); |
|
793 aResult.SetResult( KErrGeneral, KDescription ); |
|
794 } |
|
795 |
|
796 iDownloadManager.DeleteAll(); |
|
797 CleanupStack::PopAndDestroy(); // scheduler |
|
798 |
|
799 // Case was executed |
|
800 return KErrNone; |
|
801 } |
|
802 |
|
803 /* |
|
804 ------------------------------------------------------------------------------- |
|
805 |
|
806 Class: CDownloadMgrClientApiTest |
|
807 |
|
808 Method: DownloadSetStringAttribute16Test |
|
809 |
|
810 Description: Test the RHttpDownload SetStringAttribute method using TDes16 argument. |
|
811 |
|
812 Parameters: TTestResult& aErrorDescription: out: |
|
813 Test result and on error case a short description of error |
|
814 |
|
815 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
816 |
|
817 Errors/Exceptions: None |
|
818 |
|
819 Status: Approved |
|
820 |
|
821 ------------------------------------------------------------------------------- |
|
822 */ |
|
823 TInt CDownloadMgrClientApiTest::DownloadSetStringAttribute16Test( TTestResult& aResult ) |
|
824 { |
|
825 /* Simple server connect */ |
|
826 _LIT( KDefinition ,"State"); |
|
827 _LIT( KData ,"Test the RHttpDownload SetStringAttribute method using TDes16 argument"); |
|
828 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
829 |
|
830 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
831 CleanupStack::PushL( scheduler ); |
|
832 CActiveScheduler::Install( scheduler ); |
|
833 |
|
834 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
835 |
|
836 TBool isNewDl = ETrue; |
|
837 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
838 |
|
839 _LIT( KDestFileName, "c:\\fakefile\\"); |
|
840 TInt result = download.SetStringAttribute( EDlAttrDestFilename, KDestFileName() ); |
|
841 |
|
842 _LIT( KData2 ,"Finished"); |
|
843 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
844 |
|
845 if( result == KErrArgument ) |
|
846 { |
|
847 _LIT( KDescription , "Test case passed" ); |
|
848 aResult.SetResult( KErrNone, KDescription ); |
|
849 } |
|
850 else |
|
851 { |
|
852 _LIT( KDescription , "Test case failed" ); |
|
853 aResult.SetResult( KErrGeneral, KDescription ); |
|
854 } |
|
855 |
|
856 iDownloadManager.DeleteAll(); |
|
857 CleanupStack::PopAndDestroy(); // scheduler |
|
858 |
|
859 // Case was executed |
|
860 return KErrNone; |
|
861 } |
|
862 |
|
863 /* |
|
864 ------------------------------------------------------------------------------- |
|
865 |
|
866 Class: CDownloadMgrClientApiTest |
|
867 |
|
868 Method: DownloadSetStringAttribute8Test |
|
869 |
|
870 Description: Test the RHttpDownload SetStringAttribute method using TDes8 argument. |
|
871 |
|
872 Parameters: TTestResult& aErrorDescription: out: |
|
873 Test result and on error case a short description of error |
|
874 |
|
875 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
876 |
|
877 Errors/Exceptions: None |
|
878 |
|
879 Status: Approved |
|
880 |
|
881 ------------------------------------------------------------------------------- |
|
882 */ |
|
883 TInt CDownloadMgrClientApiTest::DownloadSetStringAttribute8Test( TTestResult& aResult ) |
|
884 { |
|
885 /* Simple server connect */ |
|
886 _LIT( KDefinition ,"State"); |
|
887 _LIT( KData ,"Test the RHttpDownload SetStringAttribute method using TDes8 argument"); |
|
888 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
889 |
|
890 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
891 CleanupStack::PushL( scheduler ); |
|
892 CActiveScheduler::Install( scheduler ); |
|
893 |
|
894 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
895 |
|
896 TBool isNewDl = ETrue; |
|
897 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
898 |
|
899 _LIT8( KUserName, "username"); |
|
900 TInt result = download.SetStringAttribute( EDlAttrUsername, KUserName ); |
|
901 |
|
902 _LIT( KData2 ,"Finished"); |
|
903 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
904 |
|
905 if( result == KErrNone ) |
|
906 { |
|
907 _LIT( KDescription , "Test case passed" ); |
|
908 aResult.SetResult( KErrNone, KDescription ); |
|
909 } |
|
910 else |
|
911 { |
|
912 _LIT( KDescription , "Test case failed" ); |
|
913 aResult.SetResult( KErrGeneral, KDescription ); |
|
914 } |
|
915 |
|
916 iDownloadManager.DeleteAll(); |
|
917 CleanupStack::PopAndDestroy(); // scheduler |
|
918 |
|
919 // Case was executed |
|
920 return KErrNone; |
|
921 } |
|
922 |
|
923 /* |
|
924 ------------------------------------------------------------------------------- |
|
925 |
|
926 Class: CDownloadMgrClientApiTest |
|
927 |
|
928 Method: DownloadSetFileHandleAttributeTest |
|
929 |
|
930 Description: Test the RHttpDownload SetFileHandleAttribute method. |
|
931 |
|
932 Parameters: TTestResult& aErrorDescription: out: |
|
933 Test result and on error case a short description of error |
|
934 |
|
935 Return Values: TInt: Always KErrNone to indicate that test was valid |
|
936 |
|
937 Errors/Exceptions: None |
|
938 |
|
939 Status: Approved |
|
940 |
|
941 ------------------------------------------------------------------------------- |
|
942 */ |
|
943 TInt CDownloadMgrClientApiTest::DownloadSetFileHandleAttributeTest( TTestResult& aResult ) |
|
944 { |
|
945 /* Simple server connect */ |
|
946 _LIT( KDefinition ,"State"); |
|
947 _LIT( KData ,"Test the RHttpDownload SetFileHandleAttribute method"); |
|
948 TestModuleIf().Printf( 0, KDefinition, KData ); |
|
949 |
|
950 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
951 CleanupStack::PushL( scheduler ); |
|
952 CActiveScheduler::Install( scheduler ); |
|
953 |
|
954 TBuf8<128> url = _L8("http://waplabdc.nokia-boston.com/browser/users/s60_devtests/nightly_ss_on.xml"); |
|
955 |
|
956 TBool isNewDl = ETrue; |
|
957 RHttpDownload& download = iDownloadManager.CreateDownloadL( url, isNewDl ); |
|
958 |
|
959 // Added To avoid user Input while Automation in is Progress |
|
960 // 7 - SONERA GPRS Access Point |
|
961 TInt dlresult = iDownloadManager.SetIntAttribute( EDlMgrIap, 7 ); |
|
962 |
|
963 download.Start(); |
|
964 |
|
965 RFile file; |
|
966 TInt result = download.SetFileHandleAttribute( file ); |
|
967 |
|
968 _LIT( KData2 ,"Finished"); |
|
969 TestModuleIf().Printf( 0, KDefinition, KData2 ); |
|
970 |
|
971 if( result == KErrBadHandle ) |
|
972 { |
|
973 _LIT( KDescription , "Test case passed" ); |
|
974 aResult.SetResult( KErrNone, KDescription ); |
|
975 } |
|
976 else |
|
977 { |
|
978 _LIT( KDescription , "Test case failed" ); |
|
979 aResult.SetResult( KErrGeneral, KDescription ); |
|
980 } |
|
981 |
|
982 iDownloadManager.DeleteAll(); |
|
983 CleanupStack::PopAndDestroy(); // scheduler |
|
984 |
|
985 // Case was executed |
|
986 return KErrNone; |
|
987 } |
|
988 |
|
989 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
990 |
|
991 // End of File |