OLD | NEW |
| (Empty) |
1 library googleapis.webfonts.v1.test; | |
2 | |
3 import "dart:core" as core; | |
4 import "dart:collection" as collection; | |
5 import "dart:async" as async; | |
6 import "dart:convert" as convert; | |
7 | |
8 import 'package:http/http.dart' as http; | |
9 import 'package:http/testing.dart' as http_testing; | |
10 import 'package:unittest/unittest.dart' as unittest; | |
11 import 'package:googleapis/common/common.dart' as common; | |
12 import 'package:googleapis/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | |
15 import 'package:googleapis/webfonts/v1.dart' as api; | |
16 | |
17 | |
18 | |
19 buildUnnamed761() { | |
20 var o = new core.Map<core.String, core.String>(); | |
21 o["x"] = "foo"; | |
22 o["y"] = "foo"; | |
23 return o; | |
24 } | |
25 | |
26 checkUnnamed761(core.Map<core.String, core.String> o) { | |
27 unittest.expect(o, unittest.hasLength(2)); | |
28 unittest.expect(o["x"], unittest.equals('foo')); | |
29 unittest.expect(o["y"], unittest.equals('foo')); | |
30 } | |
31 | |
32 buildUnnamed762() { | |
33 var o = new core.List<core.String>(); | |
34 o.add("foo"); | |
35 o.add("foo"); | |
36 return o; | |
37 } | |
38 | |
39 checkUnnamed762(core.List<core.String> o) { | |
40 unittest.expect(o, unittest.hasLength(2)); | |
41 unittest.expect(o[0], unittest.equals('foo')); | |
42 unittest.expect(o[1], unittest.equals('foo')); | |
43 } | |
44 | |
45 buildUnnamed763() { | |
46 var o = new core.List<core.String>(); | |
47 o.add("foo"); | |
48 o.add("foo"); | |
49 return o; | |
50 } | |
51 | |
52 checkUnnamed763(core.List<core.String> o) { | |
53 unittest.expect(o, unittest.hasLength(2)); | |
54 unittest.expect(o[0], unittest.equals('foo')); | |
55 unittest.expect(o[1], unittest.equals('foo')); | |
56 } | |
57 | |
58 core.int buildCounterWebfont = 0; | |
59 buildWebfont() { | |
60 var o = new api.Webfont(); | |
61 buildCounterWebfont++; | |
62 if (buildCounterWebfont < 3) { | |
63 o.category = "foo"; | |
64 o.family = "foo"; | |
65 o.files = buildUnnamed761(); | |
66 o.kind = "foo"; | |
67 o.lastModified = core.DateTime.parse("2002-02-27T14:01:02Z"); | |
68 o.subsets = buildUnnamed762(); | |
69 o.variants = buildUnnamed763(); | |
70 o.version = "foo"; | |
71 } | |
72 buildCounterWebfont--; | |
73 return o; | |
74 } | |
75 | |
76 checkWebfont(api.Webfont o) { | |
77 buildCounterWebfont++; | |
78 if (buildCounterWebfont < 3) { | |
79 unittest.expect(o.category, unittest.equals('foo')); | |
80 unittest.expect(o.family, unittest.equals('foo')); | |
81 checkUnnamed761(o.files); | |
82 unittest.expect(o.kind, unittest.equals('foo')); | |
83 unittest.expect(o.lastModified, unittest.equals(core.DateTime.parse("2002-02
-27T00:00:00"))); | |
84 checkUnnamed762(o.subsets); | |
85 checkUnnamed763(o.variants); | |
86 unittest.expect(o.version, unittest.equals('foo')); | |
87 } | |
88 buildCounterWebfont--; | |
89 } | |
90 | |
91 buildUnnamed764() { | |
92 var o = new core.List<api.Webfont>(); | |
93 o.add(buildWebfont()); | |
94 o.add(buildWebfont()); | |
95 return o; | |
96 } | |
97 | |
98 checkUnnamed764(core.List<api.Webfont> o) { | |
99 unittest.expect(o, unittest.hasLength(2)); | |
100 checkWebfont(o[0]); | |
101 checkWebfont(o[1]); | |
102 } | |
103 | |
104 core.int buildCounterWebfontList = 0; | |
105 buildWebfontList() { | |
106 var o = new api.WebfontList(); | |
107 buildCounterWebfontList++; | |
108 if (buildCounterWebfontList < 3) { | |
109 o.items = buildUnnamed764(); | |
110 o.kind = "foo"; | |
111 } | |
112 buildCounterWebfontList--; | |
113 return o; | |
114 } | |
115 | |
116 checkWebfontList(api.WebfontList o) { | |
117 buildCounterWebfontList++; | |
118 if (buildCounterWebfontList < 3) { | |
119 checkUnnamed764(o.items); | |
120 unittest.expect(o.kind, unittest.equals('foo')); | |
121 } | |
122 buildCounterWebfontList--; | |
123 } | |
124 | |
125 | |
126 main() { | |
127 unittest.group("obj-schema-Webfont", () { | |
128 unittest.test("to-json--from-json", () { | |
129 var o = buildWebfont(); | |
130 var od = new api.Webfont.fromJson(o.toJson()); | |
131 checkWebfont(od); | |
132 }); | |
133 }); | |
134 | |
135 | |
136 unittest.group("obj-schema-WebfontList", () { | |
137 unittest.test("to-json--from-json", () { | |
138 var o = buildWebfontList(); | |
139 var od = new api.WebfontList.fromJson(o.toJson()); | |
140 checkWebfontList(od); | |
141 }); | |
142 }); | |
143 | |
144 | |
145 unittest.group("resource-WebfontsResourceApi", () { | |
146 unittest.test("method--list", () { | |
147 | |
148 var mock = new common_test.HttpServerMock(); | |
149 api.WebfontsResourceApi res = new api.WebfontsApi(mock).webfonts; | |
150 var arg_sort = "foo"; | |
151 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
152 var path = (req.url).path; | |
153 var pathOffset = 0; | |
154 var index; | |
155 var subPart; | |
156 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/webfonts/v1/")); | |
157 pathOffset += 13; | |
158 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ
als("webfonts")); | |
159 pathOffset += 8; | |
160 | |
161 var query = (req.url).query; | |
162 var queryOffset = 0; | |
163 var queryMap = {}; | |
164 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
165 parseBool(n) { | |
166 if (n == "true") return true; | |
167 if (n == "false") return false; | |
168 if (n == null) return null; | |
169 throw new core.ArgumentError("Invalid boolean: $n"); | |
170 } | |
171 if (query.length > 0) { | |
172 for (var part in query.split("&")) { | |
173 var keyvalue = part.split("="); | |
174 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
175 } | |
176 } | |
177 unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort)); | |
178 | |
179 | |
180 var h = { | |
181 "content-type" : "application/json; charset=utf-8", | |
182 }; | |
183 var resp = convert.JSON.encode(buildWebfontList()); | |
184 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
185 }), true); | |
186 res.list(sort: arg_sort).then(unittest.expectAsync(((api.WebfontList respo
nse) { | |
187 checkWebfontList(response); | |
188 }))); | |
189 }); | |
190 | |
191 }); | |
192 | |
193 | |
194 } | |
195 | |
OLD | NEW |