OLD | NEW |
---|---|
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 | 7 |
8 testAddressParse() async { | 8 testAddressParse() async { |
9 print(new InternetAddress("1.0.2.3").rawAddress); | 9 print(new InternetAddress("1.0.2.3").rawAddress); |
10 print(new InternetAddress("1.0.2.3").type); | 10 print(new InternetAddress("1.0.2.3").type); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 }, | 324 }, |
325 onDone: () { | 325 onDone: () { |
326 assert(closedEventReceived); | 326 assert(closedEventReceived); |
327 completer.complete(null); | 327 completer.complete(null); |
328 }); | 328 }); |
329 | 329 |
330 return completer.future; | 330 return completer.future; |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 Future testGoogleUrl(SecurityContext context, String outcome) async { | 334 Future testGoogleHttp(SecurityContext context, String outcome) async { |
335 var client = new HttpClient(context: context); | 335 var client = new HttpClient(context: context); |
336 // We need to use an external server that is backed by a | 336 // We need to use an external server that is backed by a |
337 // built-in root certificate authority. | 337 // built-in root certificate authority. |
siva
2016/11/23 18:36:04
This comment here is probably not needed as you ar
rmacnak
2016/11/23 18:43:02
Done.
| |
338 try { | 338 try { |
339 // First, check if the lookup works. | 339 // First, check if the lookup works. |
340 var address = await InternetAddress.lookup('www.google.com'); | 340 var address = await InternetAddress.lookup('www.google.com'); |
341 print(address); | 341 print(address); |
342 var request = await client.getUrl(Uri.parse('http://www.google.com/')); | 342 var request = await client.getUrl(Uri.parse('http://www.google.com/')); |
343 request.followRedirects = false; | 343 request.followRedirects = false; |
344 var response = await request.close(); | 344 var response = await request.close(); |
345 assert('pass' == outcome); | 345 assert('pass' == outcome); |
346 try { await response.drain(); } catch (e) { | 346 try { await response.drain(); } catch (e) { |
347 print('drain failed: $e'); | 347 print('drain failed: $e'); |
348 } | 348 } |
349 } catch (e) { | 349 } catch (e) { |
350 // Lookup failed or connection failed. Don't report a failure. | 350 // Lookup failed or connection failed. Don't report a failure. |
351 print("SocketException: $e"); | 351 print("SocketException: $e"); |
352 } finally { | 352 } finally { |
353 client.close(); | 353 client.close(); |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 Future testGoogleHttps(SecurityContext context, String outcome) async { | |
358 var client = new HttpClient(context: context); | |
359 // We need to use an external server that is backed by a | |
360 // built-in root certificate authority. | |
361 try { | |
362 // First, check if the lookup works. | |
363 var address = await InternetAddress.lookup('www.google.com'); | |
364 print(address); | |
365 var request = await client.getUrl(Uri.parse('https://www.google.com/')); | |
366 request.followRedirects = false; | |
367 var response = await request.close(); | |
368 assert('pass' == outcome); | |
369 try { await response.drain(); } catch (e) { | |
370 print('drain failed: $e'); | |
371 } | |
372 } catch (e) { | |
373 // Lookup failed or connection failed. Don't report a failure. | |
374 print("SocketException: $e"); | |
375 } finally { | |
376 client.close(); | |
377 } | |
378 } | |
379 | |
357 main() async { | 380 main() async { |
358 print("Hello, Fuchsia!"); | 381 print("Hello, Fuchsia!"); |
359 | 382 |
360 print("testAddressParse"); | 383 print("testAddressParse"); |
361 await testAddressParse(); | 384 await testAddressParse(); |
362 print("testAddressParse done"); | 385 print("testAddressParse done"); |
363 | 386 |
364 print("testSimpleBind"); | 387 print("testSimpleBind"); |
365 await testSimpleBind(); | 388 await testSimpleBind(); |
366 print("testSimpleBind done"); | 389 print("testSimpleBind done"); |
367 | 390 |
368 print("testSimpleConnect"); | 391 print("testSimpleConnect"); |
369 await testSimpleConnect(); | 392 await testSimpleConnect(); |
370 print("testSimpleConnect done"); | 393 print("testSimpleConnect done"); |
371 | 394 |
372 print("testSimpleReadWriteClose"); | 395 print("testSimpleReadWriteClose"); |
373 await testSimpleReadWriteClose(); | 396 await testSimpleReadWriteClose(); |
374 print("testSimpleReadWriteClose done"); | 397 print("testSimpleReadWriteClose done"); |
375 | 398 |
376 // TODO(US-81): Enable. | 399 // TODO(US-81): Enable. |
377 // print("testSimpleReadWriteShutdown"); | 400 // print("testSimpleReadWriteShutdown"); |
378 // await testSimpleReadWriteShutdown(dropReads: false); | 401 // await testSimpleReadWriteShutdown(dropReads: false); |
379 // print("testSimpleReadWriteShutdown done"); | 402 // print("testSimpleReadWriteShutdown done"); |
380 | 403 |
381 print("testGoogleUrl"); | 404 print("testGoogleHttp"); |
382 await testGoogleUrl(null, 'pass'); | 405 await testGoogleHttp(null, 'pass'); |
383 print("testGoogleUrl done"); | 406 print("testGoogleHttp done"); |
407 | |
408 print("testGoogleHttps"); | |
409 await testGoogleHttps(null, 'pass'); | |
410 print("testGoogleHttps done"); | |
siva
2016/11/23 18:36:04
Should we comment out this under US-96?
rmacnak
2016/11/23 18:43:02
Done.
| |
384 | 411 |
385 print("Goodbyte, Fuchsia!"); | 412 print("Goodbyte, Fuchsia!"); |
413 print(new DateTime.now()); | |
siva
2016/11/23 18:36:04
Is this line added for debugging?
rmacnak
2016/11/23 18:43:02
Moved under testGoogleHttps with an explanation th
| |
386 } | 414 } |
OLD | NEW |