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 descriptor.async; | 5 library descriptor.async; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io' as io; | |
9 | 8 |
10 import '../../descriptor.dart'; | 9 import '../../descriptor.dart'; |
11 import '../../scheduled_test.dart'; | 10 import '../../scheduled_test.dart'; |
12 import '../utils.dart'; | |
13 | 11 |
14 /// A descriptor that wraps a [Future<Descriptor>] and forwards all asynchronous | 12 /// A descriptor that wraps a [Future<Descriptor>] and forwards all asynchronous |
15 /// operations to the result of the future. It's designed for use when the full | 13 /// operations to the result of the future. It's designed for use when the full |
16 /// filesystem description isn't known when initializing the schedule. | 14 /// filesystem description isn't known when initializing the schedule. |
17 /// | 15 /// |
18 /// [AsyncDescriptor]s don't support [load], since their names aren't | 16 /// [AsyncDescriptor]s don't support [load], since their names aren't |
19 /// synchronously available. | 17 /// synchronously available. |
20 class AsyncDescriptor extends Descriptor { | 18 class AsyncDescriptor extends Descriptor { |
21 /// The [Future] that will complete to the [Descriptor] this descriptor is | 19 /// The [Future] that will complete to the [Descriptor] this descriptor is |
22 /// wrapping. | 20 /// wrapping. |
23 final Future<Descriptor> future; | 21 final Future<Descriptor> future; |
24 | 22 |
25 AsyncDescriptor(this.future) | 23 AsyncDescriptor(this.future) |
26 : super('<async descriptor>'); | 24 : super('<async descriptor>'); |
27 | 25 |
28 Future create([String parent]) => | 26 Future create([String parent]) => |
29 schedule(() => future.then((entry) => entry.create(parent))); | 27 schedule(() => future.then((entry) => entry.create(parent))); |
30 | 28 |
31 Future validate([String parent]) => schedule(() => validateNow(parent)); | 29 Future validate([String parent]) => schedule(() => validateNow(parent)); |
32 | 30 |
33 Future validateNow([String parent]) => | 31 Future validateNow([String parent]) => |
34 future.then((entry) => entry.validateNow(parent)); | 32 future.then((entry) => entry.validateNow(parent)); |
35 | 33 |
36 String describe() => "async descriptor"; | 34 String describe() => "async descriptor"; |
37 } | 35 } |
OLD | NEW |