Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: test/message_generator_test.dart

Issue 2086253002: Allow application of external mixins to generated dart protos. (Closed) Base URL: https://github.com/dart-lang/dart-protoc-plugin.git@master
Patch Set: Add support for mixins in protos. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 message_generator_test; 6 library message_generator_test;
7 7
8 import 'package:protoc_plugin/indenting_writer.dart'; 8 import 'package:protoc_plugin/indenting_writer.dart';
9 import 'package:protoc_plugin/protoc.dart'; 9 import 'package:protoc_plugin/protoc.dart';
10 import 'package:test/test.dart';
11
10 import 'package:protoc_plugin/src/descriptor.pb.dart'; 12 import 'package:protoc_plugin/src/descriptor.pb.dart';
11 import 'package:protoc_plugin/src/plugin.pb.dart'; 13 import 'package:protoc_plugin/src/plugin.pb.dart';
12 import 'package:test/test.dart';
13 14
14 void main() { 15 void main() {
15 test('testMessageGenerator', () { 16 test('testMessageGenerator', () {
16 // NOTE: Below > 80 cols because it is matching generated code > 80 cols. 17 // NOTE: Below > 80 cols because it is matching generated code > 80 cols.
17 String expectedEnums = r''' 18 String expectedEnums = r'''
18 class PhoneNumber_PhoneType extends ProtobufEnum { 19 class PhoneNumber_PhoneType extends ProtobufEnum {
19 static const PhoneNumber_PhoneType MOBILE = const PhoneNumber_PhoneType._(0, ' MOBILE'); 20 static const PhoneNumber_PhoneType MOBILE = const PhoneNumber_PhoneType._(0, ' MOBILE');
20 static const PhoneNumber_PhoneType HOME = const PhoneNumber_PhoneType._(1, 'HO ME'); 21 static const PhoneNumber_PhoneType HOME = const PhoneNumber_PhoneType._(1, 'HO ME');
21 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO RK'); 22 static const PhoneNumber_PhoneType WORK = const PhoneNumber_PhoneType._(2, 'WO RK');
22 23
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ..number = 3 121 ..number = 3
121 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL 122 ..label = FieldDescriptorProto_Label.LABEL_OPTIONAL
122 ..type = FieldDescriptorProto_Type.TYPE_STRING 123 ..type = FieldDescriptorProto_Type.TYPE_STRING
123 ..defaultValue = r'$' 124 ..defaultValue = r'$'
124 ]) 125 ])
125 ..enumType.add(ed); 126 ..enumType.add(ed);
126 var options = parseGenerationOptions( 127 var options = parseGenerationOptions(
127 new CodeGeneratorRequest(), new CodeGeneratorResponse()); 128 new CodeGeneratorRequest(), new CodeGeneratorResponse());
128 129
129 FileGenerator fg = new FileGenerator(fd); 130 FileGenerator fg = new FileGenerator(fd);
130 MessageGenerator mg = new MessageGenerator(md, fg, null); 131 MessageGenerator mg = new MessageGenerator(md, fg, {}, '');
131 132
132 var ctx = new GenerationContext(options); 133 var ctx = new GenerationContext(options);
133 mg.register(ctx); 134 mg.register(ctx);
134 mg.resolve(ctx); 135 mg.resolve(ctx);
135 136
136 var writer = new IndentingWriter(); 137 var writer = new IndentingWriter();
137 mg.generate(writer); 138 mg.generate(writer);
138 expect(writer.toString(), expected); 139 expect(writer.toString(), expected);
139 140
140 writer = new IndentingWriter(); 141 writer = new IndentingWriter();
141 mg.generateEnums(writer); 142 mg.generateEnums(writer);
142 expect(writer.toString(), expectedEnums); 143 expect(writer.toString(), expectedEnums);
143 }); 144 });
144 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698