| 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 barback.test.utils; | 5 library barback.test.utils; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert' show Encoding; | 9 import 'dart:convert' show Encoding; |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // Make sure that packages that have transformers but no assets are considered | 81 // Make sure that packages that have transformers but no assets are considered |
| 82 // by MockProvider to exist. | 82 // by MockProvider to exist. |
| 83 for (var package in transformers.keys) { | 83 for (var package in transformers.keys) { |
| 84 assetMap.putIfAbsent(package, () => new AssetSet()); | 84 assetMap.putIfAbsent(package, () => new AssetSet()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 _provider = new MockProvider(assetMap); | 87 _provider = new MockProvider(assetMap); |
| 88 _barback = new Barback(_provider); | 88 _barback = new Barback(_provider); |
| 89 _nextBuildResult = 0; | 89 _nextBuildResult = 0; |
| 90 | 90 |
| 91 transformers.forEach(_barback.updateTransformers); | 91 transformers.forEach(_barback.updateOperators); |
| 92 | 92 |
| 93 // There should be one successful build after adding all the transformers but | 93 // There should be one successful build after adding all the transformers but |
| 94 // before adding any sources. | 94 // before adding any sources. |
| 95 if (!transformers.isEmpty) buildShouldSucceed(); | 95 if (!transformers.isEmpty) buildShouldSucceed(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 /// Updates [assets] in the current [PackageProvider]. | 98 /// Updates [assets] in the current [PackageProvider]. |
| 99 /// | 99 /// |
| 100 /// Each item in the list may either be an [AssetId] or a string that can be | 100 /// Each item in the list may either be an [AssetId] or a string that can be |
| 101 /// parsed as one. | 101 /// parsed as one. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 | 125 |
| 126 /// Removes [assets] from the current [PackageProvider]. | 126 /// Removes [assets] from the current [PackageProvider]. |
| 127 /// | 127 /// |
| 128 /// Each item in the list may either be an [AssetId] or a string that can be | 128 /// Each item in the list may either be an [AssetId] or a string that can be |
| 129 /// parsed as one. Unlike [removeSources], this is not automatically scheduled | 129 /// parsed as one. Unlike [removeSources], this is not automatically scheduled |
| 130 /// and will be run synchronously when called. | 130 /// and will be run synchronously when called. |
| 131 void removeSourcesSync(Iterable assets) => | 131 void removeSourcesSync(Iterable assets) => |
| 132 _barback.removeSources(_parseAssets(assets)); | 132 _barback.removeSources(_parseAssets(assets)); |
| 133 | 133 |
| 134 /// Sets the transformers for [package] to [transformers]. | 134 /// Sets the operators for [package] to [operators]. |
| 135 void updateTransformers(String package, | 135 void updateOperators(String package, |
| 136 Iterable<Iterable<Transformer>> transformers) { | 136 Iterable<Iterable<Operator>> operators) { |
| 137 schedule(() => _barback.updateTransformers(package, transformers), | 137 schedule(() => _barback.updateOperators(package, operators), |
| 138 "updating transformers for $package"); | 138 "updating operators for $package"); |
| 139 } | 139 } |
| 140 | 140 |
| 141 /// Parse a list of strings or [AssetId]s into a list of [AssetId]s. | 141 /// Parse a list of strings or [AssetId]s into a list of [AssetId]s. |
| 142 List<AssetId> _parseAssets(Iterable assets) { | 142 List<AssetId> _parseAssets(Iterable assets) { |
| 143 return assets.map((asset) { | 143 return assets.map((asset) { |
| 144 if (asset is String) return new AssetId.parse(asset); | 144 if (asset is String) return new AssetId.parse(asset); |
| 145 return asset; | 145 return asset; |
| 146 }).toList(); | 146 }).toList(); |
| 147 } | 147 } |
| 148 | 148 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 519 |
| 520 _MockAsset(this.id, this.contents); | 520 _MockAsset(this.id, this.contents); |
| 521 | 521 |
| 522 Future<String> readAsString({Encoding encoding}) => | 522 Future<String> readAsString({Encoding encoding}) => |
| 523 new Future.value(contents); | 523 new Future.value(contents); |
| 524 | 524 |
| 525 Stream<List<int>> read() => throw new UnimplementedError(); | 525 Stream<List<int>> read() => throw new UnimplementedError(); |
| 526 | 526 |
| 527 String toString() => "MockAsset $id $contents"; | 527 String toString() => "MockAsset $id $contents"; |
| 528 } | 528 } |
| OLD | NEW |