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

Side by Side Diff: test/event_test.dart

Issue 2612233003: Always serialize 64-bit integers as strings in JSON. (Closed)
Patch Set: Add test for JSON-coding of int64s Created 3 years, 11 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
« no previous file with comments | « lib/src/protobuf/json.dart ('k') | test/json_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Tests event delivery using PbEventMixin. 5 /// Tests event delivery using PbEventMixin.
6 library event_test; 6 library event_test;
7 7
8 import 'dart:typed_data' show Uint8List; 8 import 'dart:typed_data' show Uint8List;
9 9
10 import 'package:protobuf/protobuf.dart' 10 import 'package:protobuf/protobuf.dart'
11 show GeneratedMessage, Extension, ExtensionRegistry, PbFieldType; 11 show GeneratedMessage, Extension, ExtensionRegistry, PbFieldType;
12 import 'package:protobuf/src/protobuf/mixins/event_mixin.dart' 12 import 'package:protobuf/src/protobuf/mixins/event_mixin.dart'
13 show PbEventMixin, PbFieldChange; 13 show PbEventMixin, PbFieldChange;
14 import 'package:test/test.dart' show test, expect; 14 import 'package:test/test.dart' show test, expect;
15 15
16 import 'mock_util.dart' show MockMessage, mockInfo; 16 import 'mock_util.dart' show MockMessage, mockInfo;
17 17
18 class Rec extends MockMessage with PbEventMixin { 18 class Rec extends MockMessage with PbEventMixin {
19 get info_ => _info; 19 get info_ => _info;
20 static final _info = mockInfo("Rec", () => new Rec()); 20 static final _info = mockInfo("Rec", () => new Rec());
21 } 21 }
22 22
23 Extension comment = new Extension("Rec", "comment", 5, PbFieldType.OS); 23 Extension comment = new Extension("Rec", "comment", 6, PbFieldType.OS);
24 24
25 main() { 25 main() {
26 test('Events are sent when setting and clearing a non-repeated field', () { 26 test('Events are sent when setting and clearing a non-repeated field', () {
27 var log = makeLog(); 27 var log = makeLog();
28 var r = new Rec(); 28 var r = new Rec();
29 r.changes.listen((List<PbFieldChange> changes) { 29 r.changes.listen((List<PbFieldChange> changes) {
30 log.add(changes); 30 log.add(changes);
31 }); 31 });
32 32
33 r.val = 123; 33 r.val = 123;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 clear(String expected) { 217 clear(String expected) {
218 r.clear(); 218 r.clear();
219 r.deliverChanges(); 219 r.deliverChanges();
220 checkLogOnce(log, [tag, expected, ""]); 220 checkLogOnce(log, [tag, expected, ""]);
221 } 221 }
222 222
223 setComment("hello"); 223 setComment("hello");
224 clear("hello"); 224 clear("hello");
225 225
226 setComment("hello"); 226 setComment("hello");
227 r.setField(5, "hi"); 227 r.setField(6, "hi");
228 r.deliverChanges(); 228 r.deliverChanges();
229 checkLogOnce(log, [tag, "hello", "hi"]); 229 checkLogOnce(log, [tag, "hello", "hi"]);
230 clear("hi"); 230 clear("hi");
231 231
232 setComment("hello"); 232 setComment("hello");
233 r.clearExtension(comment); 233 r.clearExtension(comment);
234 r.deliverChanges(); 234 r.deliverChanges();
235 checkLogOnce(log, [tag, "hello", ""]); 235 checkLogOnce(log, [tag, "hello", ""]);
236 236
237 setComment("hello"); 237 setComment("hello");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 List toTuple(PbFieldChange fc) { 292 List toTuple(PbFieldChange fc) {
293 fixValue(v) { 293 fixValue(v) {
294 if (v is GeneratedMessage) { 294 if (v is GeneratedMessage) {
295 return "<msg>"; 295 return "<msg>";
296 } 296 }
297 return v; 297 return v;
298 } 298 }
299 return [fc.tag, fixValue(fc.oldValue), fixValue(fc.newValue)]; 299 return [fc.tag, fixValue(fc.oldValue), fixValue(fc.newValue)];
300 } 300 }
OLDNEW
« no previous file with comments | « lib/src/protobuf/json.dart ('k') | test/json_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698