| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:fake_async/fake_async.dart'; | 7 import 'package:fake_async/fake_async.dart'; |
| 8 import 'package:pool/pool.dart'; | 8 import 'package:pool/pool.dart'; |
| 9 import 'package:stack_trace/stack_trace.dart'; | 9 import 'package:stack_trace/stack_trace.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 expect(pool.request(), throwsA(new isInstanceOf<TimeoutException>())); | 156 expect(pool.request(), throwsA(new isInstanceOf<TimeoutException>())); |
| 157 | 157 |
| 158 async.elapse(new Duration(seconds: 6)); | 158 async.elapse(new Duration(seconds: 6)); |
| 159 }); | 159 }); |
| 160 }); | 160 }); |
| 161 }); | 161 }); |
| 162 | 162 |
| 163 group("allowRelease()", () { | 163 group("allowRelease()", () { |
| 164 test("runs the callback once the resource limit is exceeded", () async { | 164 test("runs the callback once the resource limit is exceeded", () async { |
| 165 var pool = new Pool(50); | 165 var pool = new Pool(50); |
| 166 var requests = []; | |
| 167 for (var i = 0; i < 49; i++) { | 166 for (var i = 0; i < 49; i++) { |
| 168 expect(pool.request(), completes); | 167 expect(pool.request(), completes); |
| 169 } | 168 } |
| 170 | 169 |
| 171 var resource = await pool.request(); | 170 var resource = await pool.request(); |
| 172 var onReleaseCalled = false; | 171 var onReleaseCalled = false; |
| 173 resource.allowRelease(() => onReleaseCalled = true); | 172 resource.allowRelease(() => onReleaseCalled = true); |
| 174 await new Future.delayed(Duration.ZERO); | 173 await new Future.delayed(Duration.ZERO); |
| 175 expect(onReleaseCalled, isFalse); | 174 expect(onReleaseCalled, isFalse); |
| 176 | 175 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 /// | 286 /// |
| 288 /// This should only be called within a [FakeAsync.run] zone. | 287 /// This should only be called within a [FakeAsync.run] zone. |
| 289 Matcher get doesNotComplete => predicate((future) { | 288 Matcher get doesNotComplete => predicate((future) { |
| 290 expect(future, new isInstanceOf<Future>()); | 289 expect(future, new isInstanceOf<Future>()); |
| 291 | 290 |
| 292 var stack = new Trace.current(1); | 291 var stack = new Trace.current(1); |
| 293 future.then((_) => registerException( | 292 future.then((_) => registerException( |
| 294 new TestFailure("Expected future not to complete."), stack)); | 293 new TestFailure("Expected future not to complete."), stack)); |
| 295 return true; | 294 return true; |
| 296 }); | 295 }); |
| OLD | NEW |