blob: 9a5a14b6f00b2c9da82033ee9383f177ecf89201 [file] [log] [blame]
Kevin Mooreaf84e102021-02-25 10:29:32 -08001// ignore_for_file: avoid_returning_null
Kevin Moore6d21e902021-01-15 06:41:08 -08002// ignore_for_file: camel_case_types
Kevin Mooreaf84e102021-02-25 10:29:32 -08003// ignore_for_file: cascade_invocations
Kevin Moore6d21e902021-01-15 06:41:08 -08004// ignore_for_file: comment_references
Kevin Moore1ad61ef2021-01-22 17:52:58 -08005// ignore_for_file: file_names
Kevin Moore6d21e902021-01-15 06:41:08 -08006// ignore_for_file: library_names
7// ignore_for_file: lines_longer_than_80_chars
8// ignore_for_file: non_constant_identifier_names
Kevin Moore1ad61ef2021-01-22 17:52:58 -08009// ignore_for_file: prefer_expression_function_bodies
Kevin Mooreaf84e102021-02-25 10:29:32 -080010// ignore_for_file: prefer_final_locals
Kevin Moore6d21e902021-01-15 06:41:08 -080011// ignore_for_file: prefer_interpolation_to_compose_strings
Kevin Mooreaf84e102021-02-25 10:29:32 -080012// ignore_for_file: prefer_single_quotes
Kevin Moore6d21e902021-01-15 06:41:08 -080013// ignore_for_file: unnecessary_brace_in_string_interps
14// ignore_for_file: unnecessary_cast
Kevin Moore1ad61ef2021-01-22 17:52:58 -080015// ignore_for_file: unnecessary_lambdas
Kevin Moore6d21e902021-01-15 06:41:08 -080016// ignore_for_file: unnecessary_parenthesis
17// ignore_for_file: unnecessary_string_interpolations
Kevin Moore6d21e902021-01-15 06:41:08 -080018// ignore_for_file: unused_local_variable
19
Kevin Moore2282df32021-01-27 19:15:24 -080020import 'dart:async' as async;
21import 'dart:convert' as convert;
22import 'dart:core' as core;
Martin Kustermann12cdd522018-08-27 10:46:50 +020023
Kevin Moore07f01b72021-04-25 17:33:47 -070024import 'package:googleapis/texttospeech/v1.dart' as api;
Martin Kustermann12cdd522018-08-27 10:46:50 +020025import 'package:http/http.dart' as http;
26import 'package:test/test.dart' as unittest;
Martin Kustermann12cdd522018-08-27 10:46:50 +020027
Kevin Moore2282df32021-01-27 19:15:24 -080028import '../test_shared.dart';
Martin Kustermann12cdd522018-08-27 10:46:50 +020029
Kevin Moore9f833c52021-06-22 15:37:16 -070030core.List<core.String> buildUnnamed5820() {
Kevin Moore6d21e902021-01-15 06:41:08 -080031 var o = <core.String>[];
Kevin Moored0251702021-01-15 06:41:08 -080032 o.add('foo');
33 o.add('foo');
Jonas Finnemann Jensendda12e42019-02-09 12:37:20 +010034 return o;
35}
36
Kevin Moore9f833c52021-06-22 15:37:16 -070037void checkUnnamed5820(core.List<core.String> o) {
Jonas Finnemann Jensendda12e42019-02-09 12:37:20 +010038 unittest.expect(o, unittest.hasLength(2));
Kevin Moore58e22332021-02-25 10:11:41 -080039 unittest.expect(
40 o[0],
41 unittest.equals('foo'),
42 );
43 unittest.expect(
44 o[1],
45 unittest.equals('foo'),
46 );
Jonas Finnemann Jensendda12e42019-02-09 12:37:20 +010047}
48
Martin Kustermann12cdd522018-08-27 10:46:50 +020049core.int buildCounterAudioConfig = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -080050api.AudioConfig buildAudioConfig() {
51 var o = api.AudioConfig();
Martin Kustermann12cdd522018-08-27 10:46:50 +020052 buildCounterAudioConfig++;
53 if (buildCounterAudioConfig < 3) {
Kevin Moored0251702021-01-15 06:41:08 -080054 o.audioEncoding = 'foo';
Kevin Moore9f833c52021-06-22 15:37:16 -070055 o.effectsProfileId = buildUnnamed5820();
Martin Kustermann12cdd522018-08-27 10:46:50 +020056 o.pitch = 42.0;
57 o.sampleRateHertz = 42;
58 o.speakingRate = 42.0;
59 o.volumeGainDb = 42.0;
60 }
61 buildCounterAudioConfig--;
62 return o;
63}
64
Kevin Moore6d21e902021-01-15 06:41:08 -080065void checkAudioConfig(api.AudioConfig o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +020066 buildCounterAudioConfig++;
67 if (buildCounterAudioConfig < 3) {
Kevin Moore58e22332021-02-25 10:11:41 -080068 unittest.expect(
69 o.audioEncoding!,
70 unittest.equals('foo'),
71 );
Kevin Moore9f833c52021-06-22 15:37:16 -070072 checkUnnamed5820(o.effectsProfileId!);
Kevin Moore58e22332021-02-25 10:11:41 -080073 unittest.expect(
74 o.pitch!,
75 unittest.equals(42.0),
76 );
77 unittest.expect(
78 o.sampleRateHertz!,
79 unittest.equals(42),
80 );
81 unittest.expect(
82 o.speakingRate!,
83 unittest.equals(42.0),
84 );
85 unittest.expect(
86 o.volumeGainDb!,
87 unittest.equals(42.0),
88 );
Martin Kustermann12cdd522018-08-27 10:46:50 +020089 }
90 buildCounterAudioConfig--;
91}
92
Kevin Moore9f833c52021-06-22 15:37:16 -070093core.List<api.Voice> buildUnnamed5821() {
Kevin Moore6d21e902021-01-15 06:41:08 -080094 var o = <api.Voice>[];
Martin Kustermann12cdd522018-08-27 10:46:50 +020095 o.add(buildVoice());
96 o.add(buildVoice());
97 return o;
98}
99
Kevin Moore9f833c52021-06-22 15:37:16 -0700100void checkUnnamed5821(core.List<api.Voice> o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200101 unittest.expect(o, unittest.hasLength(2));
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800102 checkVoice(o[0] as api.Voice);
103 checkVoice(o[1] as api.Voice);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200104}
105
106core.int buildCounterListVoicesResponse = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800107api.ListVoicesResponse buildListVoicesResponse() {
108 var o = api.ListVoicesResponse();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200109 buildCounterListVoicesResponse++;
110 if (buildCounterListVoicesResponse < 3) {
Kevin Moore9f833c52021-06-22 15:37:16 -0700111 o.voices = buildUnnamed5821();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200112 }
113 buildCounterListVoicesResponse--;
114 return o;
115}
116
Kevin Moore6d21e902021-01-15 06:41:08 -0800117void checkListVoicesResponse(api.ListVoicesResponse o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200118 buildCounterListVoicesResponse++;
119 if (buildCounterListVoicesResponse < 3) {
Kevin Moore9f833c52021-06-22 15:37:16 -0700120 checkUnnamed5821(o.voices!);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200121 }
122 buildCounterListVoicesResponse--;
123}
124
125core.int buildCounterSynthesisInput = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800126api.SynthesisInput buildSynthesisInput() {
127 var o = api.SynthesisInput();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200128 buildCounterSynthesisInput++;
129 if (buildCounterSynthesisInput < 3) {
Kevin Moored0251702021-01-15 06:41:08 -0800130 o.ssml = 'foo';
131 o.text = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200132 }
133 buildCounterSynthesisInput--;
134 return o;
135}
136
Kevin Moore6d21e902021-01-15 06:41:08 -0800137void checkSynthesisInput(api.SynthesisInput o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200138 buildCounterSynthesisInput++;
139 if (buildCounterSynthesisInput < 3) {
Kevin Moore58e22332021-02-25 10:11:41 -0800140 unittest.expect(
141 o.ssml!,
142 unittest.equals('foo'),
143 );
144 unittest.expect(
145 o.text!,
146 unittest.equals('foo'),
147 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200148 }
149 buildCounterSynthesisInput--;
150}
151
152core.int buildCounterSynthesizeSpeechRequest = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800153api.SynthesizeSpeechRequest buildSynthesizeSpeechRequest() {
154 var o = api.SynthesizeSpeechRequest();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200155 buildCounterSynthesizeSpeechRequest++;
156 if (buildCounterSynthesizeSpeechRequest < 3) {
157 o.audioConfig = buildAudioConfig();
158 o.input = buildSynthesisInput();
159 o.voice = buildVoiceSelectionParams();
160 }
161 buildCounterSynthesizeSpeechRequest--;
162 return o;
163}
164
Kevin Moore6d21e902021-01-15 06:41:08 -0800165void checkSynthesizeSpeechRequest(api.SynthesizeSpeechRequest o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200166 buildCounterSynthesizeSpeechRequest++;
167 if (buildCounterSynthesizeSpeechRequest < 3) {
Kevin Moore58e22332021-02-25 10:11:41 -0800168 checkAudioConfig(o.audioConfig! as api.AudioConfig);
169 checkSynthesisInput(o.input! as api.SynthesisInput);
170 checkVoiceSelectionParams(o.voice! as api.VoiceSelectionParams);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200171 }
172 buildCounterSynthesizeSpeechRequest--;
173}
174
175core.int buildCounterSynthesizeSpeechResponse = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800176api.SynthesizeSpeechResponse buildSynthesizeSpeechResponse() {
177 var o = api.SynthesizeSpeechResponse();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200178 buildCounterSynthesizeSpeechResponse++;
179 if (buildCounterSynthesizeSpeechResponse < 3) {
Kevin Moored0251702021-01-15 06:41:08 -0800180 o.audioContent = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200181 }
182 buildCounterSynthesizeSpeechResponse--;
183 return o;
184}
185
Kevin Moore6d21e902021-01-15 06:41:08 -0800186void checkSynthesizeSpeechResponse(api.SynthesizeSpeechResponse o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200187 buildCounterSynthesizeSpeechResponse++;
188 if (buildCounterSynthesizeSpeechResponse < 3) {
Kevin Moore58e22332021-02-25 10:11:41 -0800189 unittest.expect(
190 o.audioContent!,
191 unittest.equals('foo'),
192 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200193 }
194 buildCounterSynthesizeSpeechResponse--;
195}
196
Kevin Moore9f833c52021-06-22 15:37:16 -0700197core.List<core.String> buildUnnamed5822() {
Kevin Moore6d21e902021-01-15 06:41:08 -0800198 var o = <core.String>[];
Kevin Moored0251702021-01-15 06:41:08 -0800199 o.add('foo');
200 o.add('foo');
Martin Kustermann12cdd522018-08-27 10:46:50 +0200201 return o;
202}
203
Kevin Moore9f833c52021-06-22 15:37:16 -0700204void checkUnnamed5822(core.List<core.String> o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200205 unittest.expect(o, unittest.hasLength(2));
Kevin Moore58e22332021-02-25 10:11:41 -0800206 unittest.expect(
207 o[0],
208 unittest.equals('foo'),
209 );
210 unittest.expect(
211 o[1],
212 unittest.equals('foo'),
213 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200214}
215
216core.int buildCounterVoice = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800217api.Voice buildVoice() {
218 var o = api.Voice();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200219 buildCounterVoice++;
220 if (buildCounterVoice < 3) {
Kevin Moore9f833c52021-06-22 15:37:16 -0700221 o.languageCodes = buildUnnamed5822();
Kevin Moored0251702021-01-15 06:41:08 -0800222 o.name = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200223 o.naturalSampleRateHertz = 42;
Kevin Moored0251702021-01-15 06:41:08 -0800224 o.ssmlGender = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200225 }
226 buildCounterVoice--;
227 return o;
228}
229
Kevin Moore6d21e902021-01-15 06:41:08 -0800230void checkVoice(api.Voice o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200231 buildCounterVoice++;
232 if (buildCounterVoice < 3) {
Kevin Moore9f833c52021-06-22 15:37:16 -0700233 checkUnnamed5822(o.languageCodes!);
Kevin Moore58e22332021-02-25 10:11:41 -0800234 unittest.expect(
235 o.name!,
236 unittest.equals('foo'),
237 );
238 unittest.expect(
239 o.naturalSampleRateHertz!,
240 unittest.equals(42),
241 );
242 unittest.expect(
243 o.ssmlGender!,
244 unittest.equals('foo'),
245 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200246 }
247 buildCounterVoice--;
248}
249
250core.int buildCounterVoiceSelectionParams = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800251api.VoiceSelectionParams buildVoiceSelectionParams() {
252 var o = api.VoiceSelectionParams();
Martin Kustermann12cdd522018-08-27 10:46:50 +0200253 buildCounterVoiceSelectionParams++;
254 if (buildCounterVoiceSelectionParams < 3) {
Kevin Moored0251702021-01-15 06:41:08 -0800255 o.languageCode = 'foo';
256 o.name = 'foo';
257 o.ssmlGender = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200258 }
259 buildCounterVoiceSelectionParams--;
260 return o;
261}
262
Kevin Moore6d21e902021-01-15 06:41:08 -0800263void checkVoiceSelectionParams(api.VoiceSelectionParams o) {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200264 buildCounterVoiceSelectionParams++;
265 if (buildCounterVoiceSelectionParams < 3) {
Kevin Moore58e22332021-02-25 10:11:41 -0800266 unittest.expect(
267 o.languageCode!,
268 unittest.equals('foo'),
269 );
270 unittest.expect(
271 o.name!,
272 unittest.equals('foo'),
273 );
274 unittest.expect(
275 o.ssmlGender!,
276 unittest.equals('foo'),
277 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200278 }
279 buildCounterVoiceSelectionParams--;
280}
281
Kevin Moore6d21e902021-01-15 06:41:08 -0800282void main() {
Kevin Moored0251702021-01-15 06:41:08 -0800283 unittest.group('obj-schema-AudioConfig', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800284 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200285 var o = buildAudioConfig();
Kevin Mooreae408692021-02-25 12:00:44 -0800286 var oJson = convert.jsonDecode(convert.jsonEncode(o));
287 var od = api.AudioConfig.fromJson(
288 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800289 checkAudioConfig(od as api.AudioConfig);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200290 });
291 });
292
Kevin Moored0251702021-01-15 06:41:08 -0800293 unittest.group('obj-schema-ListVoicesResponse', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800294 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200295 var o = buildListVoicesResponse();
Kevin Mooreae408692021-02-25 12:00:44 -0800296 var oJson = convert.jsonDecode(convert.jsonEncode(o));
297 var od = api.ListVoicesResponse.fromJson(
298 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800299 checkListVoicesResponse(od as api.ListVoicesResponse);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200300 });
301 });
302
Kevin Moored0251702021-01-15 06:41:08 -0800303 unittest.group('obj-schema-SynthesisInput', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800304 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200305 var o = buildSynthesisInput();
Kevin Mooreae408692021-02-25 12:00:44 -0800306 var oJson = convert.jsonDecode(convert.jsonEncode(o));
307 var od = api.SynthesisInput.fromJson(
308 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800309 checkSynthesisInput(od as api.SynthesisInput);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200310 });
311 });
312
Kevin Moored0251702021-01-15 06:41:08 -0800313 unittest.group('obj-schema-SynthesizeSpeechRequest', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800314 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200315 var o = buildSynthesizeSpeechRequest();
Kevin Mooreae408692021-02-25 12:00:44 -0800316 var oJson = convert.jsonDecode(convert.jsonEncode(o));
317 var od = api.SynthesizeSpeechRequest.fromJson(
318 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800319 checkSynthesizeSpeechRequest(od as api.SynthesizeSpeechRequest);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200320 });
321 });
322
Kevin Moored0251702021-01-15 06:41:08 -0800323 unittest.group('obj-schema-SynthesizeSpeechResponse', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800324 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200325 var o = buildSynthesizeSpeechResponse();
Kevin Mooreae408692021-02-25 12:00:44 -0800326 var oJson = convert.jsonDecode(convert.jsonEncode(o));
327 var od = api.SynthesizeSpeechResponse.fromJson(
328 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800329 checkSynthesizeSpeechResponse(od as api.SynthesizeSpeechResponse);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200330 });
331 });
332
Kevin Moored0251702021-01-15 06:41:08 -0800333 unittest.group('obj-schema-Voice', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800334 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200335 var o = buildVoice();
Kevin Mooreae408692021-02-25 12:00:44 -0800336 var oJson = convert.jsonDecode(convert.jsonEncode(o));
337 var od = api.Voice.fromJson(oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800338 checkVoice(od as api.Voice);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200339 });
340 });
341
Kevin Moored0251702021-01-15 06:41:08 -0800342 unittest.group('obj-schema-VoiceSelectionParams', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800343 unittest.test('to-json--from-json', () async {
Martin Kustermann12cdd522018-08-27 10:46:50 +0200344 var o = buildVoiceSelectionParams();
Kevin Mooreae408692021-02-25 12:00:44 -0800345 var oJson = convert.jsonDecode(convert.jsonEncode(o));
346 var od = api.VoiceSelectionParams.fromJson(
347 oJson as core.Map<core.String, core.dynamic>);
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800348 checkVoiceSelectionParams(od as api.VoiceSelectionParams);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200349 });
350 });
351
Kevin Moore88512712021-01-28 14:43:28 -0800352 unittest.group('resource-TextResource', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800353 unittest.test('method--synthesize', () async {
Kevin Moore6d21e902021-01-15 06:41:08 -0800354 var mock = HttpServerMock();
Kevin Mooref1c03382021-01-22 19:48:10 -0800355 var res = api.TexttospeechApi(mock).text;
Martin Kustermann12cdd522018-08-27 10:46:50 +0200356 var arg_request = buildSynthesizeSpeechRequest();
Kevin Moored0251702021-01-15 06:41:08 -0800357 var arg_$fields = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200358 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
Kevin Moorec4dbd8e2021-01-26 14:40:35 -0800359 var obj = api.SynthesizeSpeechRequest.fromJson(
360 json as core.Map<core.String, core.dynamic>);
361 checkSynthesizeSpeechRequest(obj as api.SynthesizeSpeechRequest);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200362
363 var path = (req.url).path;
364 var pathOffset = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800365 core.int index;
366 core.String subPart;
Martin Kustermann12cdd522018-08-27 10:46:50 +0200367 unittest.expect(
Kevin Moore58e22332021-02-25 10:11:41 -0800368 path.substring(pathOffset, pathOffset + 1),
369 unittest.equals("/"),
370 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200371 pathOffset += 1;
Kevin Moore58e22332021-02-25 10:11:41 -0800372 unittest.expect(
373 path.substring(pathOffset, pathOffset + 18),
374 unittest.equals("v1/text:synthesize"),
375 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200376 pathOffset += 18;
377
378 var query = (req.url).query;
379 var queryOffset = 0;
380 var queryMap = <core.String, core.List<core.String>>{};
Kevin Moore91f7e3e2021-01-26 07:51:20 -0800381 void addQueryParam(core.String n, core.String v) =>
382 queryMap.putIfAbsent(n, () => []).add(v);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200383
Kevin Moore6d21e902021-01-15 06:41:08 -0800384 if (query.isNotEmpty) {
Kevin Moored0251702021-01-15 06:41:08 -0800385 for (var part in query.split('&')) {
386 var keyValue = part.split('=');
Kevin Moore6d21e902021-01-15 06:41:08 -0800387 addQueryParam(
388 core.Uri.decodeQueryComponent(keyValue[0]),
389 core.Uri.decodeQueryComponent(keyValue[1]),
390 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200391 }
392 }
Kevin Moore58e22332021-02-25 10:11:41 -0800393 unittest.expect(
394 queryMap["fields"]!.first,
395 unittest.equals(arg_$fields),
396 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200397
398 var h = {
Kevin Moored0251702021-01-15 06:41:08 -0800399 'content-type': 'application/json; charset=utf-8',
Martin Kustermann12cdd522018-08-27 10:46:50 +0200400 };
401 var resp = convert.json.encode(buildSynthesizeSpeechResponse());
Kevin Moore6d21e902021-01-15 06:41:08 -0800402 return async.Future.value(stringResponse(200, h, resp));
Martin Kustermann12cdd522018-08-27 10:46:50 +0200403 }), true);
Kevin Moore341348b2021-02-25 11:55:18 -0800404 final response = await res.synthesize(arg_request, $fields: arg_$fields);
405 checkSynthesizeSpeechResponse(response as api.SynthesizeSpeechResponse);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200406 });
407 });
408
Kevin Moore88512712021-01-28 14:43:28 -0800409 unittest.group('resource-VoicesResource', () {
Kevin Moore341348b2021-02-25 11:55:18 -0800410 unittest.test('method--list', () async {
Kevin Moore6d21e902021-01-15 06:41:08 -0800411 var mock = HttpServerMock();
Kevin Mooref1c03382021-01-22 19:48:10 -0800412 var res = api.TexttospeechApi(mock).voices;
Kevin Moored0251702021-01-15 06:41:08 -0800413 var arg_languageCode = 'foo';
414 var arg_$fields = 'foo';
Martin Kustermann12cdd522018-08-27 10:46:50 +0200415 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
416 var path = (req.url).path;
417 var pathOffset = 0;
Kevin Moore6d21e902021-01-15 06:41:08 -0800418 core.int index;
419 core.String subPart;
Martin Kustermann12cdd522018-08-27 10:46:50 +0200420 unittest.expect(
Kevin Moore58e22332021-02-25 10:11:41 -0800421 path.substring(pathOffset, pathOffset + 1),
422 unittest.equals("/"),
423 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200424 pathOffset += 1;
Kevin Moore58e22332021-02-25 10:11:41 -0800425 unittest.expect(
426 path.substring(pathOffset, pathOffset + 9),
427 unittest.equals("v1/voices"),
428 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200429 pathOffset += 9;
430
431 var query = (req.url).query;
432 var queryOffset = 0;
433 var queryMap = <core.String, core.List<core.String>>{};
Kevin Moore91f7e3e2021-01-26 07:51:20 -0800434 void addQueryParam(core.String n, core.String v) =>
435 queryMap.putIfAbsent(n, () => []).add(v);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200436
Kevin Moore6d21e902021-01-15 06:41:08 -0800437 if (query.isNotEmpty) {
Kevin Moored0251702021-01-15 06:41:08 -0800438 for (var part in query.split('&')) {
439 var keyValue = part.split('=');
Kevin Moore6d21e902021-01-15 06:41:08 -0800440 addQueryParam(
441 core.Uri.decodeQueryComponent(keyValue[0]),
442 core.Uri.decodeQueryComponent(keyValue[1]),
443 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200444 }
445 }
446 unittest.expect(
Kevin Moore58e22332021-02-25 10:11:41 -0800447 queryMap["languageCode"]!.first,
448 unittest.equals(arg_languageCode),
449 );
450 unittest.expect(
451 queryMap["fields"]!.first,
452 unittest.equals(arg_$fields),
453 );
Martin Kustermann12cdd522018-08-27 10:46:50 +0200454
455 var h = {
Kevin Moored0251702021-01-15 06:41:08 -0800456 'content-type': 'application/json; charset=utf-8',
Martin Kustermann12cdd522018-08-27 10:46:50 +0200457 };
458 var resp = convert.json.encode(buildListVoicesResponse());
Kevin Moore6d21e902021-01-15 06:41:08 -0800459 return async.Future.value(stringResponse(200, h, resp));
Martin Kustermann12cdd522018-08-27 10:46:50 +0200460 }), true);
Kevin Moore341348b2021-02-25 11:55:18 -0800461 final response =
462 await res.list(languageCode: arg_languageCode, $fields: arg_$fields);
463 checkListVoicesResponse(response as api.ListVoicesResponse);
Martin Kustermann12cdd522018-08-27 10:46:50 +0200464 });
465 });
466}