| OLD | NEW |
| 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, predicate, same; | 14 import 'package:test/test.dart' show test, expect, predicate, same; |
| 15 | 15 |
| 16 import 'mock_util.dart' show MockMessage; | 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 className => "Rec"; | 19 get info_ => _info; |
| 20 Rec create() => 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", 5, 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); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |