Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: pkg/barback/test/transformer/mock.dart

Issue 23543005: Make Transform a little more pleasant to use: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 /// Like [Transform.getInput], but respects [pauseGetInput]. 123 /// Like [Transform.getInput], but respects [pauseGetInput].
124 /// 124 ///
125 /// This is intended for use by subclasses of [MockTransformer]. 125 /// This is intended for use by subclasses of [MockTransformer].
126 Future<Asset> getInput(Transform transform, AssetId id) { 126 Future<Asset> getInput(Transform transform, AssetId id) {
127 return newFuture(() { 127 return newFuture(() {
128 if (_getInput.containsKey(id)) return _getInput[id].future; 128 if (_getInput.containsKey(id)) return _getInput[id].future;
129 }).then((_) => transform.getInput(id)); 129 }).then((_) => transform.getInput(id));
130 } 130 }
131 131
132 /// Like [Transform.primaryInput], but respects [pauseGetInput].
133 ///
134 /// This is intended for use by subclasses of [MockTransformer].
135 Future<Asset> getPrimary(Transform transform) =>
nweiz 2013/08/28 19:29:43 We should keep this around so [pauseGetInput] stil
Bob Nystrom 2013/08/28 20:51:27 Done, but modified to actually call primaryInput i
136 getInput(transform, transform.primaryId);
137
138 Future<bool> isPrimary(Asset asset) { 132 Future<bool> isPrimary(Asset asset) {
139 return newFuture(() => doIsPrimary(asset)).then((result) { 133 return newFuture(() => doIsPrimary(asset)).then((result) {
140 return newFuture(() { 134 return newFuture(() {
141 if (_isPrimary.containsKey(asset.id)) { 135 if (_isPrimary.containsKey(asset.id)) {
142 return _isPrimary[asset.id].future; 136 return _isPrimary[asset.id].future;
143 } 137 }
144 }).then((_) => result); 138 }).then((_) => result);
145 }); 139 });
146 } 140 }
147 141
148 Future apply(Transform transform) { 142 Future apply(Transform transform) {
149 _numRuns++; 143 _numRuns++;
150 if (_runningTransforms == 0) _started.complete(); 144 if (_runningTransforms == 0) _started.complete();
151 _runningTransforms++; 145 _runningTransforms++;
152 return newFuture(() => doApply(transform)).then((_) { 146 return newFuture(() => doApply(transform)).then((_) {
153 if (_apply != null) return _apply.future; 147 if (_apply != null) return _apply.future;
154 }).whenComplete(() { 148 }).whenComplete(() {
155 _runningTransforms--; 149 _runningTransforms--;
156 if (_runningTransforms == 0) _started = new Completer(); 150 if (_runningTransforms == 0) _started = new Completer();
157 }); 151 });
158 } 152 }
159 153
160 /// The wrapped version of [isPrimary] for subclasses to override. 154 /// The wrapped version of [isPrimary] for subclasses to override.
161 Future<bool> doIsPrimary(Asset asset); 155 Future<bool> doIsPrimary(Asset asset);
162 156
163 /// The wrapped version of [doApply] for subclasses to override. 157 /// The wrapped version of [doApply] for subclasses to override.
164 Future doApply(Transform transform); 158 Future doApply(Transform transform);
165 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698