| OLD | NEW | 
|---|
| 1 library googleapis.webfonts.v1.test; | 1 library googleapis.webfonts.v1.test; | 
| 2 | 2 | 
| 3 import "dart:core" as core; | 3 import "dart:core" as core; | 
| 4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; | 
| 5 import "dart:async" as async; | 5 import "dart:async" as async; | 
| 6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; | 
| 7 | 7 | 
| 8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; | 
| 9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; | 
| 10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:test/test.dart' as unittest; | 
| 11 | 11 | 
| 12 import 'package:googleapis/webfonts/v1.dart' as api; | 12 import 'package:googleapis/webfonts/v1.dart' as api; | 
| 13 | 13 | 
| 14 class HttpServerMock extends http.BaseClient { | 14 class HttpServerMock extends http.BaseClient { | 
| 15   core.Function _callback; | 15   core.Function _callback; | 
| 16   core.bool _expectJson; | 16   core.bool _expectJson; | 
| 17 | 17 | 
| 18   void register(core.Function callback, core.bool expectJson) { | 18   void register(core.Function callback, core.bool expectJson) { | 
| 19     _callback = callback; | 19     _callback = callback; | 
| 20     _expectJson = expectJson; | 20     _expectJson = expectJson; | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 39       } else { | 39       } else { | 
| 40         return stream.toBytes().then((data) { | 40         return stream.toBytes().then((data) { | 
| 41           return _callback(request, data); | 41           return _callback(request, data); | 
| 42         }); | 42         }); | 
| 43       } | 43       } | 
| 44     } | 44     } | 
| 45   } | 45   } | 
| 46 } | 46 } | 
| 47 | 47 | 
| 48 http.StreamedResponse stringResponse( | 48 http.StreamedResponse stringResponse( | 
| 49     core.int status, core.Map headers, core.String body) { | 49     core.int status, core.Map<core.String, core.String> headers, core.String bod
     y) { | 
| 50   var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 50   var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); | 
| 51   return new http.StreamedResponse(stream, status, headers: headers); | 51   return new http.StreamedResponse(stream, status, headers: headers); | 
| 52 } | 52 } | 
| 53 | 53 | 
| 54 buildUnnamed1542() { | 54 buildUnnamed1549() { | 
| 55   var o = new core.Map<core.String, core.String>(); | 55   var o = new core.Map<core.String, core.String>(); | 
| 56   o["x"] = "foo"; | 56   o["x"] = "foo"; | 
| 57   o["y"] = "foo"; | 57   o["y"] = "foo"; | 
| 58   return o; | 58   return o; | 
| 59 } | 59 } | 
| 60 | 60 | 
| 61 checkUnnamed1542(core.Map<core.String, core.String> o) { | 61 checkUnnamed1549(core.Map<core.String, core.String> o) { | 
| 62   unittest.expect(o, unittest.hasLength(2)); | 62   unittest.expect(o, unittest.hasLength(2)); | 
| 63   unittest.expect(o["x"], unittest.equals('foo')); | 63   unittest.expect(o["x"], unittest.equals('foo')); | 
| 64   unittest.expect(o["y"], unittest.equals('foo')); | 64   unittest.expect(o["y"], unittest.equals('foo')); | 
| 65 } | 65 } | 
| 66 | 66 | 
| 67 buildUnnamed1543() { | 67 buildUnnamed1550() { | 
| 68   var o = new core.List<core.String>(); | 68   var o = new core.List<core.String>(); | 
| 69   o.add("foo"); | 69   o.add("foo"); | 
| 70   o.add("foo"); | 70   o.add("foo"); | 
| 71   return o; | 71   return o; | 
| 72 } | 72 } | 
| 73 | 73 | 
| 74 checkUnnamed1543(core.List<core.String> o) { | 74 checkUnnamed1550(core.List<core.String> o) { | 
| 75   unittest.expect(o, unittest.hasLength(2)); | 75   unittest.expect(o, unittest.hasLength(2)); | 
| 76   unittest.expect(o[0], unittest.equals('foo')); | 76   unittest.expect(o[0], unittest.equals('foo')); | 
| 77   unittest.expect(o[1], unittest.equals('foo')); | 77   unittest.expect(o[1], unittest.equals('foo')); | 
| 78 } | 78 } | 
| 79 | 79 | 
| 80 buildUnnamed1544() { | 80 buildUnnamed1551() { | 
| 81   var o = new core.List<core.String>(); | 81   var o = new core.List<core.String>(); | 
| 82   o.add("foo"); | 82   o.add("foo"); | 
| 83   o.add("foo"); | 83   o.add("foo"); | 
| 84   return o; | 84   return o; | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 checkUnnamed1544(core.List<core.String> o) { | 87 checkUnnamed1551(core.List<core.String> o) { | 
| 88   unittest.expect(o, unittest.hasLength(2)); | 88   unittest.expect(o, unittest.hasLength(2)); | 
| 89   unittest.expect(o[0], unittest.equals('foo')); | 89   unittest.expect(o[0], unittest.equals('foo')); | 
| 90   unittest.expect(o[1], unittest.equals('foo')); | 90   unittest.expect(o[1], unittest.equals('foo')); | 
| 91 } | 91 } | 
| 92 | 92 | 
| 93 core.int buildCounterWebfont = 0; | 93 core.int buildCounterWebfont = 0; | 
| 94 buildWebfont() { | 94 buildWebfont() { | 
| 95   var o = new api.Webfont(); | 95   var o = new api.Webfont(); | 
| 96   buildCounterWebfont++; | 96   buildCounterWebfont++; | 
| 97   if (buildCounterWebfont < 3) { | 97   if (buildCounterWebfont < 3) { | 
| 98     o.category = "foo"; | 98     o.category = "foo"; | 
| 99     o.family = "foo"; | 99     o.family = "foo"; | 
| 100     o.files = buildUnnamed1542(); | 100     o.files = buildUnnamed1549(); | 
| 101     o.kind = "foo"; | 101     o.kind = "foo"; | 
| 102     o.lastModified = core.DateTime.parse("2002-02-27T14:01:02Z"); | 102     o.lastModified = core.DateTime.parse("2002-02-27T14:01:02Z"); | 
| 103     o.subsets = buildUnnamed1543(); | 103     o.subsets = buildUnnamed1550(); | 
| 104     o.variants = buildUnnamed1544(); | 104     o.variants = buildUnnamed1551(); | 
| 105     o.version = "foo"; | 105     o.version = "foo"; | 
| 106   } | 106   } | 
| 107   buildCounterWebfont--; | 107   buildCounterWebfont--; | 
| 108   return o; | 108   return o; | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 checkWebfont(api.Webfont o) { | 111 checkWebfont(api.Webfont o) { | 
| 112   buildCounterWebfont++; | 112   buildCounterWebfont++; | 
| 113   if (buildCounterWebfont < 3) { | 113   if (buildCounterWebfont < 3) { | 
| 114     unittest.expect(o.category, unittest.equals('foo')); | 114     unittest.expect(o.category, unittest.equals('foo')); | 
| 115     unittest.expect(o.family, unittest.equals('foo')); | 115     unittest.expect(o.family, unittest.equals('foo')); | 
| 116     checkUnnamed1542(o.files); | 116     checkUnnamed1549(o.files); | 
| 117     unittest.expect(o.kind, unittest.equals('foo')); | 117     unittest.expect(o.kind, unittest.equals('foo')); | 
| 118     unittest.expect(o.lastModified, unittest.equals(core.DateTime.parse("2002-02
     -27T00:00:00"))); | 118     unittest.expect(o.lastModified, unittest.equals(core.DateTime.parse("2002-02
     -27T00:00:00"))); | 
| 119     checkUnnamed1543(o.subsets); | 119     checkUnnamed1550(o.subsets); | 
| 120     checkUnnamed1544(o.variants); | 120     checkUnnamed1551(o.variants); | 
| 121     unittest.expect(o.version, unittest.equals('foo')); | 121     unittest.expect(o.version, unittest.equals('foo')); | 
| 122   } | 122   } | 
| 123   buildCounterWebfont--; | 123   buildCounterWebfont--; | 
| 124 } | 124 } | 
| 125 | 125 | 
| 126 buildUnnamed1545() { | 126 buildUnnamed1552() { | 
| 127   var o = new core.List<api.Webfont>(); | 127   var o = new core.List<api.Webfont>(); | 
| 128   o.add(buildWebfont()); | 128   o.add(buildWebfont()); | 
| 129   o.add(buildWebfont()); | 129   o.add(buildWebfont()); | 
| 130   return o; | 130   return o; | 
| 131 } | 131 } | 
| 132 | 132 | 
| 133 checkUnnamed1545(core.List<api.Webfont> o) { | 133 checkUnnamed1552(core.List<api.Webfont> o) { | 
| 134   unittest.expect(o, unittest.hasLength(2)); | 134   unittest.expect(o, unittest.hasLength(2)); | 
| 135   checkWebfont(o[0]); | 135   checkWebfont(o[0]); | 
| 136   checkWebfont(o[1]); | 136   checkWebfont(o[1]); | 
| 137 } | 137 } | 
| 138 | 138 | 
| 139 core.int buildCounterWebfontList = 0; | 139 core.int buildCounterWebfontList = 0; | 
| 140 buildWebfontList() { | 140 buildWebfontList() { | 
| 141   var o = new api.WebfontList(); | 141   var o = new api.WebfontList(); | 
| 142   buildCounterWebfontList++; | 142   buildCounterWebfontList++; | 
| 143   if (buildCounterWebfontList < 3) { | 143   if (buildCounterWebfontList < 3) { | 
| 144     o.items = buildUnnamed1545(); | 144     o.items = buildUnnamed1552(); | 
| 145     o.kind = "foo"; | 145     o.kind = "foo"; | 
| 146   } | 146   } | 
| 147   buildCounterWebfontList--; | 147   buildCounterWebfontList--; | 
| 148   return o; | 148   return o; | 
| 149 } | 149 } | 
| 150 | 150 | 
| 151 checkWebfontList(api.WebfontList o) { | 151 checkWebfontList(api.WebfontList o) { | 
| 152   buildCounterWebfontList++; | 152   buildCounterWebfontList++; | 
| 153   if (buildCounterWebfontList < 3) { | 153   if (buildCounterWebfontList < 3) { | 
| 154     checkUnnamed1545(o.items); | 154     checkUnnamed1552(o.items); | 
| 155     unittest.expect(o.kind, unittest.equals('foo')); | 155     unittest.expect(o.kind, unittest.equals('foo')); | 
| 156   } | 156   } | 
| 157   buildCounterWebfontList--; | 157   buildCounterWebfontList--; | 
| 158 } | 158 } | 
| 159 | 159 | 
| 160 | 160 | 
| 161 main() { | 161 main() { | 
| 162   unittest.group("obj-schema-Webfont", () { | 162   unittest.group("obj-schema-Webfont", () { | 
| 163     unittest.test("to-json--from-json", () { | 163     unittest.test("to-json--from-json", () { | 
| 164       var o = buildWebfont(); | 164       var o = buildWebfont(); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 176     }); | 176     }); | 
| 177   }); | 177   }); | 
| 178 | 178 | 
| 179 | 179 | 
| 180   unittest.group("resource-WebfontsResourceApi", () { | 180   unittest.group("resource-WebfontsResourceApi", () { | 
| 181     unittest.test("method--list", () { | 181     unittest.test("method--list", () { | 
| 182 | 182 | 
| 183       var mock = new HttpServerMock(); | 183       var mock = new HttpServerMock(); | 
| 184       api.WebfontsResourceApi res = new api.WebfontsApi(mock).webfonts; | 184       api.WebfontsResourceApi res = new api.WebfontsApi(mock).webfonts; | 
| 185       var arg_sort = "foo"; | 185       var arg_sort = "foo"; | 
| 186       mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 186       mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 
| 187         var path = (req.url).path; | 187         var path = (req.url).path; | 
| 188         var pathOffset = 0; | 188         var pathOffset = 0; | 
| 189         var index; | 189         var index; | 
| 190         var subPart; | 190         var subPart; | 
| 191         unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
     als("/")); | 191         unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
     als("/")); | 
| 192         pathOffset += 1; | 192         pathOffset += 1; | 
| 193         unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
     uals("webfonts/v1/")); | 193         unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq
     uals("webfonts/v1/")); | 
| 194         pathOffset += 12; | 194         pathOffset += 12; | 
| 195         unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
     als("webfonts")); | 195         unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
     als("webfonts")); | 
| 196         pathOffset += 8; | 196         pathOffset += 8; | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 213         } | 213         } | 
| 214         unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort)); | 214         unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort)); | 
| 215 | 215 | 
| 216 | 216 | 
| 217         var h = { | 217         var h = { | 
| 218           "content-type" : "application/json; charset=utf-8", | 218           "content-type" : "application/json; charset=utf-8", | 
| 219         }; | 219         }; | 
| 220         var resp = convert.JSON.encode(buildWebfontList()); | 220         var resp = convert.JSON.encode(buildWebfontList()); | 
| 221         return new async.Future.value(stringResponse(200, h, resp)); | 221         return new async.Future.value(stringResponse(200, h, resp)); | 
| 222       }), true); | 222       }), true); | 
| 223       res.list(sort: arg_sort).then(unittest.expectAsync(((api.WebfontList respo
     nse) { | 223       res.list(sort: arg_sort).then(unittest.expectAsync1(((api.WebfontList resp
     onse) { | 
| 224         checkWebfontList(response); | 224         checkWebfontList(response); | 
| 225       }))); | 225       }))); | 
| 226     }); | 226     }); | 
| 227 | 227 | 
| 228   }); | 228   }); | 
| 229 | 229 | 
| 230 | 230 | 
| 231 } | 231 } | 
| 232 | 232 | 
| OLD | NEW | 
|---|