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

Side by Side Diff: runtime/observatory/lib/src/mocks/repositories/target.dart

Issue 2180803002: Converted Observatory vm-connect element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Renamed DumpRepository to CrashDumpRepository Created 4 years, 4 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
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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
4
5 part of mocks;
6
7 class TargetChangeEventMock implements M.TargetChangeEvent {
8 final TargetRepositoryMock repository;
9 const TargetChangeEventMock({this.repository});
10 }
11
12 typedef void TargetRepositoryMockStringCallback(String notification);
13 typedef void TargetRepositoryMockTargetCallback(M.Target notification);
14
15 class TargetRepositoryMock implements M.TargetRepository {
16 final StreamController<M.TargetChangeEvent> _onChange =
17 new StreamController<M.TargetChangeEvent>.broadcast();
18 Stream<M.TargetChangeEvent> get onChange => _onChange.stream;
19
20 bool get hasListeners => _onChange.hasListener;
21
22 final M.Target _current;
23 final Iterable<M.Target> _list;
24 final TargetRepositoryMockStringCallback _add;
25 final TargetRepositoryMockTargetCallback _setCurrent;
26 final TargetRepositoryMockTargetCallback _delete;
27
28 bool currentInvoked = false;
29 bool addInvoked = false;
30 bool listInvoked = false;
31 bool setCurrentInvoked = false;
32 bool deleteInvoked = false;
33
34 M.Target get current {
35 currentInvoked = true;
36 return _current;
37 }
38
39 void add(String val) {
40 addInvoked = true;
41 if (_add != null) _add(val);
42 }
43
44 Iterable<M.Target> list() {
45 listInvoked = true;
46 return _list;
47 }
48
49 void setCurrent(M.Target target) {
50 setCurrentInvoked = true;
51 if (_setCurrent != null) _setCurrent(target);
52 }
53
54 void delete(M.Target target) {
55 deleteInvoked = true;
56 if (_delete != null) _delete(target);
57 }
58
59 void triggerChangeEvent() {
60 _onChange.add(new TargetChangeEventMock(repository: this));
61 }
62
63 TargetRepositoryMock({M.Target current, Iterable<M.Target> list : const [],
64 TargetRepositoryMockStringCallback add,
65 TargetRepositoryMockTargetCallback setCurrent,
66 TargetRepositoryMockTargetCallback delete})
67 : _current = current,
68 _list = list,
69 _add = add,
70 _setCurrent = setCurrent,
71 _delete = delete;
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698