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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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:typed_data'; | 77 import 'dart:typed_data'; |
78 | 78 |
| 79 import 'package:fixnum/fixnum.dart'; |
79 import 'package:protobuf/protobuf.dart'; | 80 import 'package:protobuf/protobuf.dart'; |
80 | 81 |
81 class PhoneNumber extends GeneratedMessage { | 82 class PhoneNumber extends GeneratedMessage { |
82 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 83 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
83 ..a(1, 'number', GeneratedMessage.QS) | 84 ..a(1, 'number', GeneratedMessage.QS) |
84 ..a(2, 'type', GeneratedMessage.O3) | 85 ..a(2, 'type', GeneratedMessage.O3) |
85 ..a(3, 'name', GeneratedMessage.OS, () => '\$') | 86 ..a(3, 'name', GeneratedMessage.OS, () => '\$') |
86 ; | 87 ; |
87 | 88 |
88 PhoneNumber() : super(); | 89 PhoneNumber() : super(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 test('testMessageGeneratorTopLevelEmun', () { | 124 test('testMessageGeneratorTopLevelEmun', () { |
124 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 125 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
125 String expected = r''' | 126 String expected = r''' |
126 /// | 127 /// |
127 // Generated code. Do not modify. | 128 // Generated code. Do not modify. |
128 /// | 129 /// |
129 library test; | 130 library test; |
130 | 131 |
131 import 'dart:typed_data'; | 132 import 'dart:typed_data'; |
132 | 133 |
| 134 import 'package:fixnum/fixnum.dart'; |
133 import 'package:protobuf/protobuf.dart'; | 135 import 'package:protobuf/protobuf.dart'; |
134 | 136 |
135 class PhoneType extends ProtobufEnum { | 137 class PhoneType extends ProtobufEnum { |
136 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); | 138 static const PhoneType MOBILE = const PhoneType._(0, 'MOBILE'); |
137 static const PhoneType HOME = const PhoneType._(1, 'HOME'); | 139 static const PhoneType HOME = const PhoneType._(1, 'HOME'); |
138 static const PhoneType WORK = const PhoneType._(2, 'WORK'); | 140 static const PhoneType WORK = const PhoneType._(2, 'WORK'); |
139 | 141 |
140 static const PhoneType BUSINESS = WORK; | 142 static const PhoneType BUSINESS = WORK; |
141 | 143 |
142 static const List<PhoneType> values = const <PhoneType> [ | 144 static const List<PhoneType> values = const <PhoneType> [ |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 test('testMessageGeneratorPackage', () { | 198 test('testMessageGeneratorPackage', () { |
197 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 199 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
198 String expected = r''' | 200 String expected = r''' |
199 /// | 201 /// |
200 // Generated code. Do not modify. | 202 // Generated code. Do not modify. |
201 /// | 203 /// |
202 library pb_library; | 204 library pb_library; |
203 | 205 |
204 import 'dart:typed_data'; | 206 import 'dart:typed_data'; |
205 | 207 |
| 208 import 'package:fixnum/fixnum.dart'; |
206 import 'package:protobuf/protobuf.dart'; | 209 import 'package:protobuf/protobuf.dart'; |
207 | 210 |
208 class PhoneNumber extends GeneratedMessage { | 211 class PhoneNumber extends GeneratedMessage { |
209 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 212 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
210 ..a(1, 'number', GeneratedMessage.QS) | 213 ..a(1, 'number', GeneratedMessage.QS) |
211 ..a(2, 'type', GeneratedMessage.O3) | 214 ..a(2, 'type', GeneratedMessage.O3) |
212 ..a(3, 'name', GeneratedMessage.OS, () => '\$') | 215 ..a(3, 'name', GeneratedMessage.OS, () => '\$') |
213 ; | 216 ; |
214 | 217 |
215 PhoneNumber() : super(); | 218 PhoneNumber() : super(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 test('testMessageGeneratorFieldNameOption', () { | 254 test('testMessageGeneratorFieldNameOption', () { |
252 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. | 255 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. |
253 String expected = r''' | 256 String expected = r''' |
254 /// | 257 /// |
255 // Generated code. Do not modify. | 258 // Generated code. Do not modify. |
256 /// | 259 /// |
257 library test; | 260 library test; |
258 | 261 |
259 import 'dart:typed_data'; | 262 import 'dart:typed_data'; |
260 | 263 |
| 264 import 'package:fixnum/fixnum.dart'; |
261 import 'package:protobuf/protobuf.dart'; | 265 import 'package:protobuf/protobuf.dart'; |
262 | 266 |
263 class PhoneNumber extends GeneratedMessage { | 267 class PhoneNumber extends GeneratedMessage { |
264 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') | 268 static final BuilderInfo _i = new BuilderInfo('PhoneNumber') |
265 ..a(1, 'no', GeneratedMessage.QS) | 269 ..a(1, 'no', GeneratedMessage.QS) |
266 ..a(2, 'the_type', GeneratedMessage.O3) | 270 ..a(2, 'the_type', GeneratedMessage.O3) |
267 ..a(3, 'name_', GeneratedMessage.OS, () => '\$') | 271 ..a(3, 'name_', GeneratedMessage.OS, () => '\$') |
268 ; | 272 ; |
269 | 273 |
270 PhoneNumber() : super(); | 274 PhoneNumber() : super(); |
(...skipping 29 matching lines...) Expand all Loading... |
300 var options = | 304 var options = |
301 new GenerationOptions( | 305 new GenerationOptions( |
302 request, new CodeGeneratorResponse()); | 306 request, new CodeGeneratorResponse()); |
303 FileGenerator fg = | 307 FileGenerator fg = |
304 new FileGenerator( | 308 new FileGenerator( |
305 fd, null, new GenerationContext(options)); | 309 fd, null, new GenerationContext(options)); |
306 fg.generate(writer); | 310 fg.generate(writer); |
307 expect(buffer.toString(), expected); | 311 expect(buffer.toString(), expected); |
308 }); | 312 }); |
309 } | 313 } |
OLD | NEW |