OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 library file_generator_test; | 6 library file_generator_test; |
7 | 7 |
8 import 'package:protoc_plugin/src/descriptor.pb.dart'; | 8 import 'package:protoc_plugin/src/descriptor.pb.dart'; |
9 import 'package:protoc_plugin/src/plugin.pb.dart'; | 9 import 'package:protoc_plugin/src/plugin.pb.dart'; |
10 import 'package:protoc_plugin/protoc.dart'; | 10 import 'package:protoc_plugin/protoc.dart'; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 void main() { | 68 void main() { |
69 test('testMessageGenerator', () { | 69 test('testMessageGenerator', () { |
70 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 70 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
71 String expected = r''' | 71 String expected = r''' |
72 /// | 72 /// |
73 // Generated code. Do not modify. | 73 // Generated code. Do not modify. |
74 /// | 74 /// |
75 library test; | 75 library test; |
76 | 76 |
| 77 import 'dart:async'; |
| 78 |
77 import 'package:fixnum/fixnum.dart'; | 79 import 'package:fixnum/fixnum.dart'; |
78 import 'package:protobuf/protobuf.dart'; | 80 import 'package:protobuf/protobuf.dart'; |
79 | 81 |
80 class PhoneNumber extends GeneratedMessage { | 82 class PhoneNumber extends GeneratedMessage { |
81 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 83 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
82 ..a(1, 'number', GeneratedMessage.QS) | 84 ..a(1, 'number', GeneratedMessage.QS) |
83 ..a(2, 'type', GeneratedMessage.O3) | 85 ..a(2, 'type', GeneratedMessage.O3) |
84 ..a(3, 'name', GeneratedMessage.OS, '\$') | 86 ..a(3, 'name', GeneratedMessage.OS, '\$') |
85 ; | 87 ; |
86 | 88 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 }); | 123 }); |
122 | 124 |
123 test('testMessageGeneratorTopLevelEmun', () { | 125 test('testMessageGeneratorTopLevelEmun', () { |
124 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 126 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
125 String expected = r''' | 127 String expected = r''' |
126 /// | 128 /// |
127 // Generated code. Do not modify. | 129 // Generated code. Do not modify. |
128 /// | 130 /// |
129 library test; | 131 library test; |
130 | 132 |
| 133 import 'dart:async'; |
| 134 |
131 import 'package:fixnum/fixnum.dart'; | 135 import 'package:fixnum/fixnum.dart'; |
132 import 'package:protobuf/protobuf.dart'; | 136 import 'package:protobuf/protobuf.dart'; |
133 | 137 |
134 class PhoneType extends ProtobufEnum { | 138 class PhoneType extends ProtobufEnum { |
135 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); | 139 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); |
136 static const PhoneType HOME = const PhoneType._(1, 'HOME'); | 140 static const PhoneType HOME = const PhoneType._(1, 'HOME'); |
137 static const PhoneType WORK = const PhoneType._(2, 'WORK'); | 141 static const PhoneType WORK = const PhoneType._(2, 'WORK'); |
138 | 142 |
139 static const PhoneType BUSINESS = WORK; | 143 static const PhoneType BUSINESS = WORK; |
140 | 144 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 }); | 198 }); |
195 | 199 |
196 test('testMessageGeneratorPackage', () { | 200 test('testMessageGeneratorPackage', () { |
197 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 201 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
198 String expected = r''' | 202 String expected = r''' |
199 /// | 203 /// |
200 // Generated code. Do not modify. | 204 // Generated code. Do not modify. |
201 /// | 205 /// |
202 library pb_library; | 206 library pb_library; |
203 | 207 |
| 208 import 'dart:async'; |
| 209 |
204 import 'package:fixnum/fixnum.dart'; | 210 import 'package:fixnum/fixnum.dart'; |
205 import 'package:protobuf/protobuf.dart'; | 211 import 'package:protobuf/protobuf.dart'; |
206 | 212 |
207 class PhoneNumber extends GeneratedMessage { | 213 class PhoneNumber extends GeneratedMessage { |
208 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 214 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
209 ..a(1, 'number', GeneratedMessage.QS) | 215 ..a(1, 'number', GeneratedMessage.QS) |
210 ..a(2, 'type', GeneratedMessage.O3) | 216 ..a(2, 'type', GeneratedMessage.O3) |
211 ..a(3, 'name', GeneratedMessage.OS, '\$') | 217 ..a(3, 'name', GeneratedMessage.OS, '\$') |
212 ; | 218 ; |
213 | 219 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 }); | 255 }); |
250 | 256 |
251 test('testMessageGeneratorFieldNameOption', () { | 257 test('testMessageGeneratorFieldNameOption', () { |
252 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 258 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
253 String expected = r''' | 259 String expected = r''' |
254 /// | 260 /// |
255 // Generated code. Do not modify. | 261 // Generated code. Do not modify. |
256 /// | 262 /// |
257 library test; | 263 library test; |
258 | 264 |
| 265 import 'dart:async'; |
| 266 |
259 import 'package:fixnum/fixnum.dart'; | 267 import 'package:fixnum/fixnum.dart'; |
260 import 'package:protobuf/protobuf.dart'; | 268 import 'package:protobuf/protobuf.dart'; |
261 | 269 |
262 class PhoneNumber extends GeneratedMessage { | 270 class PhoneNumber extends GeneratedMessage { |
263 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 271 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
264 ..a(1, 'no', GeneratedMessage.QS) | 272 ..a(1, 'no', GeneratedMessage.QS) |
265 ..a(2, 'the_type', GeneratedMessage.O3) | 273 ..a(2, 'the_type', GeneratedMessage.O3) |
266 ..a(3, 'name_', GeneratedMessage.OS, '\$') | 274 ..a(3, 'name_', GeneratedMessage.OS, '\$') |
267 ; | 275 ; |
268 | 276 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 }); | 315 }); |
308 | 316 |
309 test('testMessageGeneratorFieldNameOption', () { | 317 test('testMessageGeneratorFieldNameOption', () { |
310 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 318 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
311 String expected = r''' | 319 String expected = r''' |
312 /// | 320 /// |
313 // Generated code. Do not modify. | 321 // Generated code. Do not modify. |
314 /// | 322 /// |
315 library test; | 323 library test; |
316 | 324 |
| 325 import 'dart:async'; |
| 326 |
317 import 'package:fixnum/fixnum.dart'; | 327 import 'package:fixnum/fixnum.dart'; |
318 import 'package:protobuf/protobuf.dart'; | 328 import 'package:protobuf/protobuf.dart'; |
319 import 'package1.pb.dart' as p1; | 329 import 'package1.pb.dart' as p1; |
320 import 'package2.pb.dart' as p2; | 330 import 'package2.pb.dart' as p2; |
321 | 331 |
322 class M extends GeneratedMessage { | 332 class M extends GeneratedMessage { |
323 static final BuilderInfo _i = new BuilderInfo('M') | 333 static final BuilderInfo _i = new BuilderInfo('M') |
324 ..a(1, 'm', GeneratedMessage.OM, M.create, M.create) | 334 ..a(1, 'm', GeneratedMessage.OM, M.create, M.create) |
325 ..a(2, 'm1', GeneratedMessage.OM, p1.M.create, p1.M.create) | 335 ..a(2, 'm1', GeneratedMessage.OM, p1.M.create, p1.M.create) |
326 ..a(3, 'm2', GeneratedMessage.OM, p2.M.create, p2.M.create) | 336 ..a(3, 'm2', GeneratedMessage.OM, p2.M.create, p2.M.create) |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 var options = parseGenerationOptions(request, response); | 462 var options = parseGenerationOptions(request, response); |
453 var context = new GenerationContext(options, | 463 var context = new GenerationContext(options, |
454 new DefaultOutputConfiguration()); | 464 new DefaultOutputConfiguration()); |
455 new FileGenerator(fd1, null, context); | 465 new FileGenerator(fd1, null, context); |
456 new FileGenerator(fd2, null, context); | 466 new FileGenerator(fd2, null, context); |
457 FileGenerator fg = new FileGenerator(fd, null, context); | 467 FileGenerator fg = new FileGenerator(fd, null, context); |
458 fg.generate(writer); | 468 fg.generate(writer); |
459 expect(buffer.toString(), expected); | 469 expect(buffer.toString(), expected); |
460 }); | 470 }); |
461 } | 471 } |
OLD | NEW |