| 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.transformer.mock; | 5 library barback.test.transformer.mock; |
| 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:barback/src/utils.dart'; | 10 import 'package:barback/src/utils.dart'; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 /// Like [Transform.primaryInput], but respects [pauseGetPrimary]. | 160 /// Like [Transform.primaryInput], but respects [pauseGetPrimary]. |
| 161 /// | 161 /// |
| 162 /// This is intended for use by subclasses of [MockTransformer]. | 162 /// This is intended for use by subclasses of [MockTransformer]. |
| 163 Future<Asset> getPrimary(Transform transform) { | 163 Future<Asset> getPrimary(Transform transform) { |
| 164 return newFuture(() { | 164 return newFuture(() { |
| 165 if (_primaryInput != null) return _primaryInput.future; | 165 if (_primaryInput != null) return _primaryInput.future; |
| 166 }).then((_) => transform.primaryInput); | 166 }).then((_) => transform.primaryInput); |
| 167 } | 167 } |
| 168 | 168 |
| 169 Future<bool> isPrimary(Asset asset) { | 169 Future<bool> isPrimary(AssetId id) { |
| 170 return newFuture(() => doIsPrimary(asset)).then((result) { | 170 return newFuture(() => doIsPrimary(id)).then((result) { |
| 171 return newFuture(() { | 171 return newFuture(() { |
| 172 if (_isPrimary.containsKey(asset.id)) { | 172 if (_isPrimary.containsKey(id)) { |
| 173 return _isPrimary[asset.id].future; | 173 return _isPrimary[id].future; |
| 174 } | 174 } |
| 175 }).then((_) => result); | 175 }).then((_) => result); |
| 176 }); | 176 }); |
| 177 } | 177 } |
| 178 | 178 |
| 179 Future apply(Transform transform) { | 179 Future apply(Transform transform) { |
| 180 _numRuns++; | 180 _numRuns++; |
| 181 if (_runningTransforms == 0) _started.complete(); | 181 if (_runningTransforms == 0) _started.complete(); |
| 182 _runningTransforms++; | 182 _runningTransforms++; |
| 183 if (consumePrimary) transform.consumePrimary(); | 183 if (consumePrimary) transform.consumePrimary(); |
| 184 return newFuture(() => doApply(transform)).then((_) { | 184 return newFuture(() => doApply(transform)).then((_) { |
| 185 if (_apply != null) return _apply.future; | 185 if (_apply != null) return _apply.future; |
| 186 }).whenComplete(() { | 186 }).whenComplete(() { |
| 187 _runningTransforms--; | 187 _runningTransforms--; |
| 188 if (_runningTransforms == 0) _started = new Completer(); | 188 if (_runningTransforms == 0) _started = new Completer(); |
| 189 }); | 189 }); |
| 190 } | 190 } |
| 191 | 191 |
| 192 /// The wrapped version of [isPrimary] for subclasses to override. | 192 /// The wrapped version of [isPrimary] for subclasses to override. |
| 193 Future<bool> doIsPrimary(Asset asset); | 193 Future<bool> doIsPrimary(AssetId id); |
| 194 | 194 |
| 195 /// The wrapped version of [doApply] for subclasses to override. | 195 /// The wrapped version of [doApply] for subclasses to override. |
| 196 Future doApply(Transform transform); | 196 Future doApply(Transform transform); |
| 197 } | 197 } |
| OLD | NEW |