Chromium Code Reviews| 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 { |
|
Cutch
2016/11/23 19:31:19
how can this test fail outside of checked mode?
| |
| 335 var client = new HttpClient(context: context); | |
| 336 try { | |
| 337 // First, check if the lookup works. | |
| 338 var address = await InternetAddress.lookup('www.google.com'); | |
| 339 print(address); | |
| 340 var request = await client.getUrl(Uri.parse('http://www.google.com/')); | |
| 341 request.followRedirects = false; | |
| 342 var response = await request.close(); | |
| 343 assert('pass' == outcome); | |
|
Cutch
2016/11/23 19:31:19
this should be an expect so that non-checked mode
| |
| 344 try { await response.drain(); } catch (e) { | |
| 345 print('drain failed: $e'); | |
| 346 } | |
| 347 } catch (e) { | |
| 348 // Lookup failed or connection failed. Don't report a failure. | |
| 349 print("SocketException: $e"); | |
| 350 } finally { | |
| 351 client.close(); | |
| 352 } | |
| 353 } | |
| 354 | |
| 355 Future testGoogleHttps(SecurityContext context, String outcome) async { | |
| 356 // If this isn't reasonable, the certificate will be rejected. | |
| 357 print(new DateTime.now()); | |
| 358 | |
| 335 var client = new HttpClient(context: context); | 359 var client = new HttpClient(context: context); |
| 336 // We need to use an external server that is backed by a | 360 // We need to use an external server that is backed by a |
| 337 // built-in root certificate authority. | 361 // built-in root certificate authority. |
| 338 try { | 362 try { |
| 339 // First, check if the lookup works. | 363 // First, check if the lookup works. |
| 340 var address = await InternetAddress.lookup('www.google.com'); | 364 var address = await InternetAddress.lookup('www.google.com'); |
| 341 print(address); | 365 print(address); |
| 342 var request = await client.getUrl(Uri.parse('http://www.google.com/')); | 366 var request = await client.getUrl(Uri.parse('https://www.google.com/')); |
| 343 request.followRedirects = false; | 367 request.followRedirects = false; |
| 344 var response = await request.close(); | 368 var response = await request.close(); |
| 345 assert('pass' == outcome); | 369 assert('pass' == outcome); |
| 346 try { await response.drain(); } catch (e) { | 370 try { await response.drain(); } catch (e) { |
| 347 print('drain failed: $e'); | 371 print('drain failed: $e'); |
| 348 } | 372 } |
| 349 } catch (e) { | 373 } catch (e) { |
| 350 // Lookup failed or connection failed. Don't report a failure. | 374 // Lookup failed or connection failed. Don't report a failure. |
| 351 print("SocketException: $e"); | 375 print("SocketException: $e"); |
| 352 } finally { | 376 } finally { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 371 | 395 |
| 372 print("testSimpleReadWriteClose"); | 396 print("testSimpleReadWriteClose"); |
| 373 await testSimpleReadWriteClose(); | 397 await testSimpleReadWriteClose(); |
| 374 print("testSimpleReadWriteClose done"); | 398 print("testSimpleReadWriteClose done"); |
| 375 | 399 |
| 376 // TODO(US-81): Enable. | 400 // TODO(US-81): Enable. |
| 377 // print("testSimpleReadWriteShutdown"); | 401 // print("testSimpleReadWriteShutdown"); |
| 378 // await testSimpleReadWriteShutdown(dropReads: false); | 402 // await testSimpleReadWriteShutdown(dropReads: false); |
| 379 // print("testSimpleReadWriteShutdown done"); | 403 // print("testSimpleReadWriteShutdown done"); |
| 380 | 404 |
| 381 print("testGoogleUrl"); | 405 print("testGoogleHttp"); |
| 382 await testGoogleUrl(null, 'pass'); | 406 await testGoogleHttp(null, 'pass'); |
| 383 print("testGoogleUrl done"); | 407 print("testGoogleHttp done"); |
| 408 | |
| 409 // TODO(US-96) | |
| 410 // print("testGoogleHttps"); | |
| 411 // await testGoogleHttps(null, 'pass'); | |
| 412 // print("testGoogleHttps done"); | |
| 384 | 413 |
| 385 print("Goodbyte, Fuchsia!"); | 414 print("Goodbyte, Fuchsia!"); |
| 386 } | 415 } |
| OLD | NEW |