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

Side by Side Diff: test/http_throttle_test.dart

Issue 1234313004: Upgrade to the new test runner. (Closed) Base URL: git@github.com:dart-lang/http_throttle@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:http/http.dart' as http; 7 import 'package:http/http.dart' as http;
8 import 'package:http/testing.dart'; 8 import 'package:http/testing.dart';
9 import 'package:http_throttle/http_throttle.dart'; 9 import 'package:http_throttle/http_throttle.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:test/test.dart';
11 11
12 void main() { 12 void main() {
13 test("makes requests until the limit is hit", () { 13 test("makes requests until the limit is hit", () {
14 var pendingResponses = []; 14 var pendingResponses = [];
15 var client = new ThrottleClient(10, new MockClient((request) { 15 var client = new ThrottleClient(10, new MockClient((request) {
16 var completer = new Completer(); 16 var completer = new Completer();
17 pendingResponses.add(completer); 17 pendingResponses.add(completer);
18 return completer.future.then((response) { 18 return completer.future.then((response) {
19 pendingResponses.remove(completer); 19 pendingResponses.remove(completer);
20 return response; 20 return response;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 /// times. By default, this should pump the event queue enough times to allow 60 /// times. By default, this should pump the event queue enough times to allow
61 /// any code to run, as long as it's not waiting on some external event. 61 /// any code to run, as long as it's not waiting on some external event.
62 Future pumpEventQueue([int times = 20]) { 62 Future pumpEventQueue([int times = 20]) {
63 if (times == 0) return new Future.value(); 63 if (times == 0) return new Future.value();
64 // We use a delayed future to allow microtask events to finish. The 64 // We use a delayed future to allow microtask events to finish. The
65 // Future.value or Future() constructors use scheduleMicrotask themselves and 65 // Future.value or Future() constructors use scheduleMicrotask themselves and
66 // would therefore not wait for microtask callbacks that are scheduled after 66 // would therefore not wait for microtask callbacks that are scheduled after
67 // invoking this method. 67 // invoking this method.
68 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); 68 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1));
69 } 69 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698