| OLD | NEW |
| 1 library googleapis.common_internal_test; | 1 library googleapis.common_internal_test; |
| 2 import 'dart:async'; | 2 import 'dart:async'; |
| 3 import 'dart:convert'; | 3 import 'dart:convert'; |
| 4 | 4 |
| 5 import 'package:crypto/crypto.dart' as crypto; | 5 import 'package:crypto/crypto.dart' as crypto; |
| 6 import 'package:googleapis/common/common.dart'; | 6 import 'package:googleapis/common/common.dart'; |
| 7 import 'package:googleapis/src/common_internal.dart'; | 7 import 'package:googleapis/src/common_internal.dart'; |
| 8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 |
| 10 class HttpServerMock extends http.BaseClient { | 11 class HttpServerMock extends http.BaseClient { |
| 11 Function _callback; | 12 Function _callback; |
| 12 bool _expectJson; | 13 bool _expectJson; |
| 13 | 14 |
| 14 void register(Function callback, bool expectJson) { | 15 void register(Function callback, bool expectJson) { |
| 15 _callback = callback; | 16 _callback = callback; |
| 16 _expectJson = expectJson; | 17 _expectJson = expectJson; |
| 17 } | 18 } |
| 18 | 19 |
| 19 Future<http.StreamedResponse> send(http.BaseRequest request) { | 20 Future<http.StreamedResponse> send(http.BaseRequest request) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 var httpMock, rootUrl, basePath; | 301 var httpMock, rootUrl, basePath; |
| 301 ApiRequester requester; | 302 ApiRequester requester; |
| 302 | 303 |
| 303 var responseHeaders = { | 304 var responseHeaders = { |
| 304 'content-type' : 'application/json; charset=utf-8', | 305 'content-type' : 'application/json; charset=utf-8', |
| 305 }; | 306 }; |
| 306 | 307 |
| 307 setUp(() { | 308 setUp(() { |
| 308 httpMock = new HttpServerMock(); | 309 httpMock = new HttpServerMock(); |
| 309 rootUrl = 'http://example.com/'; | 310 rootUrl = 'http://example.com/'; |
| 310 basePath = '/base/'; | 311 basePath = 'base/'; |
| 311 requester = new ApiRequester(httpMock, rootUrl, basePath); | 312 requester = new ApiRequester(httpMock, rootUrl, basePath); |
| 312 }); | 313 }); |
| 313 | 314 |
| 314 | 315 |
| 315 // Tests for Request, Response | 316 // Tests for Request, Response |
| 316 | 317 |
| 317 group('metadata-request-response', () { | 318 group('metadata-request-response', () { |
| 318 test('empty-request-empty-response', () { | 319 test('empty-request-empty-response', () { |
| 319 httpMock.register(expectAsync((http.BaseRequest request, json) { | 320 httpMock.register(expectAsync((http.BaseRequest request, json) { |
| 320 expect(request.method, equals('GET')); | 321 expect(request.method, equals('GET')); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 test('length-big-block-parts', () { | 725 test('length-big-block-parts', () { |
| 725 runTest(1, 1024 * 1024, | 726 runTest(1, 1024 * 1024, |
| 726 [1, | 727 [1, |
| 727 256*1024-1, | 728 256*1024-1, |
| 728 256*1024, | 729 256*1024, |
| 729 256*1024+1, | 730 256*1024+1, |
| 730 1024*1024-1, | 731 1024*1024-1, |
| 731 1024*1024], false); | 732 1024*1024], false); |
| 732 }); | 733 }); |
| 733 | 734 |
| 735 test('length-big-block-parts-non-divisible', () { |
| 736 runTest(1, 1024 * 1024 + 1, |
| 737 [1, |
| 738 256*1024-1, |
| 739 256*1024, |
| 740 256*1024+1, |
| 741 1024*1024-1, |
| 742 1024*1024, |
| 743 1024*1024+1], false); |
| 744 }); |
| 745 |
| 734 test('stream-small-block', () { | 746 test('stream-small-block', () { |
| 735 runTest(1, 10, [10], true); | 747 runTest(1, 10, [10], true); |
| 736 }); | 748 }); |
| 737 | 749 |
| 738 test('stream-small-block-parts', () { | 750 test('stream-small-block-parts', () { |
| 739 runTest(1, 20, [1, 2, 3, 4, 5, 6, 7, 19, 20], true); | 751 runTest(1, 20, [1, 2, 3, 4, 5, 6, 7, 19, 20], true); |
| 740 }); | 752 }); |
| 741 | 753 |
| 742 test('stream-big-block', () { | 754 test('stream-big-block', () { |
| 743 runTest(1, 1024 * 1024, [1024*1024], true); | 755 runTest(1, 1024 * 1024, [1024*1024], true); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 return stringResponse(200, responseHeaders, ''); | 914 return stringResponse(200, responseHeaders, ''); |
| 903 }), true); | 915 }), true); |
| 904 requester.request('s/foo/a1/a2/bar/s1/e', 'GET') | 916 requester.request('s/foo/a1/a2/bar/s1/e', 'GET') |
| 905 .then(expectAsync((response) { | 917 .then(expectAsync((response) { |
| 906 expect(response, isNull); | 918 expect(response, isNull); |
| 907 })); | 919 })); |
| 908 }); | 920 }); |
| 909 }); | 921 }); |
| 910 }); | 922 }); |
| 911 } | 923 } |
| OLD | NEW |