| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library trydart.incremental_compilation_update_test; | 5 library trydart.incremental_compilation_update_test; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 | 8 |
| 9 import 'dart:async' show | 9 import 'dart:async' show |
| 10 Future; | 10 Future; |
| 11 | 11 |
| 12 import 'package:async_helper/async_helper.dart' show | 12 import 'package:async_helper/async_helper.dart' show |
| 13 asyncTest; | 13 asyncTest; |
| 14 | 14 |
| 15 import 'sandbox.dart' show | 15 import 'sandbox.dart' show |
| 16 appendIFrame, | 16 appendIFrame, |
| 17 listener; | 17 listener; |
| 18 | 18 |
| 19 import 'web_compiler_test_case.dart' show | 19 import 'web_compiler_test_case.dart' show |
| 20 WebCompilerTestCase, | 20 WebCompilerTestCase, |
| 21 WebInputProvider; | 21 WebInputProvider; |
| 22 | 22 |
| 23 import 'program_result.dart'; | 23 import 'program_result.dart'; |
| 24 | 24 |
| 25 const int TIMEOUT = 100; |
| 26 |
| 25 const List<List<ProgramResult>> tests = const <List<ProgramResult>>[ | 27 const List<List<ProgramResult>> tests = const <List<ProgramResult>>[ |
| 26 // Basic hello-world test. | 28 // Basic hello-world test. |
| 27 const <ProgramResult>[ | 29 const <ProgramResult>[ |
| 28 const ProgramResult( | 30 const ProgramResult( |
| 29 "main() { print('Hello, World!'); }", | 31 "main() { print('Hello, World!'); }", |
| 30 const <String> ['Hello, World!']), | 32 const <String> ['Hello, World!']), |
| 31 const ProgramResult( | 33 const ProgramResult( |
| 32 "main() { print('Hello, Brave New World!'); }", | 34 "main() { print('Hello, Brave New World!'); }", |
| 33 const <String> ['Hello, Brave New World!']), | 35 const <String> ['Hello, Brave New World!']), |
| 34 ], | 36 ], |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 int version = 2; | 198 int version = 2; |
| 197 return Future.forEach(programs.skip(1), (ProgramResult program) { | 199 return Future.forEach(programs.skip(1), (ProgramResult program) { |
| 198 | 200 |
| 199 status.append(new PreElement()..appendText(program.code)); | 201 status.append(new PreElement()..appendText(program.code)); |
| 200 | 202 |
| 201 WebInputProvider inputProvider = | 203 WebInputProvider inputProvider = |
| 202 test.incrementalCompiler.inputProvider; | 204 test.incrementalCompiler.inputProvider; |
| 203 Uri uri = test.scriptUri.resolve('?v${version++}'); | 205 Uri uri = test.scriptUri.resolve('?v${version++}'); |
| 204 inputProvider.cachedSources[uri] = new Future.value(program.code); | 206 inputProvider.cachedSources[uri] = new Future.value(program.code); |
| 205 Future future = test.incrementalCompiler.compileUpdates( | 207 Future future = test.incrementalCompiler.compileUpdates( |
| 206 {test.scriptUri: uri}, logVerbose: print, logTime: print); | 208 {test.scriptUri: uri}, logVerbose: logger, logTime: logger); |
| 207 return future.then((String update) { | 209 return future.then((String update) { |
| 208 print({'update': update}); | 210 print({'update': update}); |
| 209 iframe.contentWindow.postMessage(['apply-update', update], '*'); | 211 iframe.contentWindow.postMessage(['apply-update', update], '*'); |
| 210 | 212 |
| 211 return listener.expect( | 213 return listener.expect( |
| 212 program.messagesWith('iframe-dart-updated-main-done')); | 214 program.messagesWith('iframe-dart-updated-main-done')); |
| 213 }); | 215 }); |
| 214 }); | 216 }); |
| 215 }); | 217 }); |
| 216 }); | 218 }); |
| 217 }).then((_) { | 219 }).then((_) { |
| 218 status.style.color = 'limegreen'; | 220 status.style.color = 'limegreen'; |
| 219 | 221 |
| 220 // Remove the iframe to work around a bug in test.dart. | 222 // Remove the iframe to work around a bug in test.dart. |
| 221 iframe.remove(); | 223 iframe.remove(); |
| 222 }); | 224 }); |
| 223 } | 225 } |
| 226 |
| 227 void logger(x) { |
| 228 print(x); |
| 229 bool isCheckedMode = false; |
| 230 assert(isCheckedMode = true); |
| 231 int timeout = isCheckedMode ? TIMEOUT * 2 : TIMEOUT; |
| 232 if (listener.elapsed > timeout) { |
| 233 throw 'Test timed out.'; |
| 234 } |
| 235 } |
| OLD | NEW |