Chromium Code Reviews| Index: lib/unittest/mock.dart |
| =================================================================== |
| --- lib/unittest/mock.dart (revision 10584) |
| +++ lib/unittest/mock.dart (working copy) |
| @@ -493,7 +493,8 @@ |
| * a bool. If [logFilter] is null, it will match any [LogEntry]. |
| * If no entry is found, then [failureReturnValue] is returned. |
| * After each check the position is updated by [skip], so using |
| - * [skip] of -1 allows backward searches. |
| + * [skip] of -1 allows backward searches, using a [skip] of 2 can |
| + * be used to check pairs of adjacent entries, and so on. |
| */ |
| int findLogEntry(logFilter, [int start = 0, int failureReturnValue = -1, |
| skip = 1]) { |
| @@ -1435,4 +1436,24 @@ |
| arg9 = _noArg]) => |
| getLogs(callsTo(method, arg0, arg1, arg2, arg3, arg4, |
| arg5, arg6, arg7, arg8, arg9)); |
| + |
| + /** Clear the behaviors for the Mock. */ |
| + void resetBehavior() => _behaviors.clear(); |
|
Siggi Cherem (dart-lang)
2012/08/13 17:09:12
do you expect people will want to call these separ
gram
2012/08/13 17:26:58
Yes. For example, I may want to set up the behavio
|
| + |
| + /** Clear the logs for the Mock. */ |
| + void clearLogs() { |
| + if (log != null) { |
| + if (name == null) { // This log is not shared. |
| + log.logs.clear(); |
| + } else { // This log may be shared. |
| + log.logs = log.logs.filter((e) => e.mockName != name); |
| + } |
| + } |
| + } |
| + |
| + /** Clear both logs and behavior. */ |
| + void reset() { |
| + resetBehavior(); |
| + clearLogs(); |
| + } |
| } |