| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // or details. All rights reserved. Use of this source code is governed by a | 2 // or 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 /** | 5 /** |
| 6 * Test date formatting and parsing using locale data read via an http request | 6 * Test date formatting and parsing using locale data read via an http request |
| 7 * to a server. | 7 * to a server. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 // TODO(alanknight): It would be nice if there were a more general facility | 10 // TODO(alanknight): It would be nice if there were a more general facility |
| 11 // than this and it could be replaced, possibly the things Graham is working on. | 11 // than this and it could be replaced, possibly the things Graham is working on. |
| 12 // The following magical comments will cause the test code run via test.py | 12 // The following magical comments will cause the test code run via test.py |
| 13 // to add an extra command starting up a web server that will serve the | 13 // to add an extra command starting up a web server that will serve the |
| 14 // files we are looking for. "dart" will be replaced by the current dart | 14 // files we are looking for. "dart" will be replaced by the current dart |
| 15 // VM, and in arguments, $dartDir will be replaced by the current Dart | 15 // VM, and in arguments, $dartDir will be replaced by the current Dart |
| 16 // root directory. | 16 // root directory. |
| 17 // ExtraCommand=dart | 17 // ExtraCommand=dart |
| 18 // ExtraCommandArgs=pkg/intl/test/start_web_server.dart | 18 // ExtraCommandArgs=$dartDir/pkg/intl/test/start_web_server.dart |
| 19 #library('date_time_format_http_request_test'); | 19 #library('date_time_format_http_request_test'); |
| 20 | 20 |
| 21 #import('../lib/date_format.dart'); | 21 #import('../lib/date_format.dart'); |
| 22 #import('../lib/date_symbol_data_http_request.dart'); | 22 #import('../lib/date_symbol_data_http_request.dart'); |
| 23 #import('date_time_format_test_core.dart'); | 23 #import('date_time_format_test_core.dart'); |
| 24 #import('dart:html'); | 24 #import('dart:html'); |
| 25 | 25 |
| 26 var url = "http://localhost:8000/dates/"; | 26 var url = "http://localhost:8000/dates/"; |
| 27 | 27 |
| 28 main() { | 28 main() { |
| 29 // Initialize one locale just so we know what the list is. | 29 // Initialize one locale just so we know what the list is. |
| 30 initializeDateFormatting("en_US", url).then(runEverything); | 30 initializeDateFormatting("en_US", url).then(runEverything); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void runEverything(_) { | 33 void runEverything(_) { |
| 34 // Initialize all locales and wait for them to finish before running tests. | 34 // Initialize all locales and wait for them to finish before running tests. |
| 35 var futures = DateFormat.allLocalesWithSymbols().map( | 35 var futures = DateFormat.allLocalesWithSymbols().map( |
| 36 (locale) => initializeDateFormatting(locale, url)); | 36 (locale) => initializeDateFormatting(locale, url)); |
| 37 Futures.wait(futures).then((results) { | 37 Futures.wait(futures).then((results) { |
| 38 runDateTests(); | 38 runDateTests(); |
| 39 shutDown();}); | 39 shutDown();}); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void shutDown() { | 42 void shutDown() { |
| 43 // The tiny web server knows to use this request as a cue to terminate. | 43 // The tiny web server knows to use this request as a cue to terminate. |
| 44 var source = '$url/terminate'; | 44 var source = '$url/terminate'; |
| 45 var request = new HttpRequest.get(source, (_) {}); | 45 var request = new HttpRequest.get(source, (_) {}); |
| 46 } | 46 } |
| OLD | NEW |