forked from google/protobuf.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- move mock message to mock_util.dart and clean up - use it in json_test and remove copied code - bugfix: info_ should be a getter in a mixin. BUG= [email protected] Review URL: https://chromiumcodereview.appspot.com//1247683002.
- Loading branch information
Brian Slesinsky
committed
Jul 22, 2015
1 parent
0a75ca6
commit 66a2a31
Showing
4 changed files
with
55 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright(c) 2015, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
library mock_util; | ||
|
||
import 'package:protobuf/protobuf.dart' | ||
show GeneratedMessage, PbMapMixin, BuilderInfo; | ||
|
||
/// A minimal protobuf implementation for testing. | ||
abstract class MockMessage extends GeneratedMessage { | ||
|
||
BuilderInfo _infoCache; | ||
|
||
// subclasses must provide these | ||
String get className; | ||
MockMessage create(); | ||
|
||
get val => getField(1); | ||
set val(x) => setField(1, x); | ||
get str => getField(2); | ||
set str(x) => setField(2, x); | ||
get child => getField(3); | ||
set child(x) => setField(3, x); | ||
|
||
@override | ||
BuilderInfo get info_ { | ||
if (_infoCache != null) return _infoCache; | ||
_infoCache = new BuilderInfo(className) | ||
..a(1, "val", GeneratedMessage.O3) | ||
..a(2, "str", GeneratedMessage.OS) | ||
..a(3, "child", GeneratedMessage.OM, create); | ||
return _infoCache; | ||
} | ||
} |