| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 polymer.test.transfom.common; | 5 library polymer.test.transfom.common; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 String idToString(AssetId id) => '${id.package}|${id.path}'; | 13 String idToString(AssetId id) => '${id.package}|${id.path}'; |
| 14 AssetId idFromString(String s) { | 14 AssetId idFromString(String s) { |
| 15 int index = s.indexOf('|'); | 15 int index = s.indexOf('|'); |
| 16 return new AssetId(s.substring(0, index), s.substring(index + 1)); | 16 return new AssetId(s.substring(0, index), s.substring(index + 1)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * A helper package provider that has files stored in memory, also wraps | 20 * A helper package provider that has files stored in memory, also wraps |
| 21 * [Barback] to simply our tests. | 21 * [Barback] to simply our tests. |
| 22 */ | 22 */ |
| 23 class TestHelper implements PackageProvider { | 23 class TestHelper implements PackageProvider { |
| 24 /** | 24 /** |
| 25 * Maps from an asset string identifier of the form 'package|path' to the | 25 * Maps from an asset string identifier of the form 'package|path' to the |
| 26 * file contents. | 26 * file contents. |
| 27 */ | 27 */ |
| 28 final Map<String, String> files; | 28 final Map<String, String> files; |
| 29 final Iterable<String> packages; | 29 final Iterable<String> packages; |
| 30 | 30 |
| 31 Barback barback; | 31 Barback barback; |
| 32 var errorSubscription; | 32 var errorSubscription; |
| 33 var resultSubscription; | 33 var resultSubscription; |
| 34 | 34 |
| 35 Future<Asset> getAsset(AssetId id) => | 35 Future<Asset> getAsset(AssetId id) => |
| 36 new Future.value(new Asset.fromString(id, files[idToString(id)])); | 36 new Future.value(new Asset.fromString(id, files[idToString(id)])); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 testPhases(String testName, List<List<Transformer>> phases, | 90 testPhases(String testName, List<List<Transformer>> phases, |
| 91 Map<String, String> inputFiles, Map<String, String> expectedFiles) { | 91 Map<String, String> inputFiles, Map<String, String> expectedFiles) { |
| 92 test(testName, () { | 92 test(testName, () { |
| 93 var helper = new TestHelper(phases, inputFiles)..run(); | 93 var helper = new TestHelper(phases, inputFiles)..run(); |
| 94 return helper.checkAll(expectedFiles).then((_) => helper.tearDown()); | 94 return helper.checkAll(expectedFiles).then((_) => helper.tearDown()); |
| 95 }); | 95 }); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // TODO(jmesserly): this is .debug to workaround issue 13046. |
| 98 const SHADOW_DOM_TAG = | 99 const SHADOW_DOM_TAG = |
| 99 '<script src="packages/shadow_dom/shadow_dom.min.js"></script>\n'; | 100 '<script src="packages/shadow_dom/shadow_dom.debug.js"></script>\n'; |
| 100 | 101 |
| 101 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n'; | 102 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n'; |
| 103 |
| 104 const PKG_JS_INTEROP_TAG = |
| 105 '<script src="packages/js/dart_interop.js"></script>\n'; |
| OLD | NEW |