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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/mocks/repositories/target.dart
diff --git a/runtime/observatory/lib/src/mocks/repositories/target.dart b/runtime/observatory/lib/src/mocks/repositories/target.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8321f8612e7333a2ca177378c2bea58ae94190f0
--- /dev/null
+++ b/runtime/observatory/lib/src/mocks/repositories/target.dart
@@ -0,0 +1,72 @@
+// Copyright (c) 2016, 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
+
+part of mocks;
+
+class TargetChangeEventMock implements M.TargetChangeEvent {
+ final TargetRepositoryMock repository;
+ const TargetChangeEventMock({this.repository});
+}
+
+typedef void TargetRepositoryMockStringCallback(String notification);
+typedef void TargetRepositoryMockTargetCallback(M.Target notification);
+
+class TargetRepositoryMock implements M.TargetRepository {
+ final StreamController<M.TargetChangeEvent> _onChange =
+ new StreamController<M.TargetChangeEvent>.broadcast();
+ Stream<M.TargetChangeEvent> get onChange => _onChange.stream;
+
+ bool get hasListeners => _onChange.hasListener;
+
+ final M.Target _current;
+ final Iterable<M.Target> _list;
+ final TargetRepositoryMockStringCallback _add;
+ final TargetRepositoryMockTargetCallback _setCurrent;
+ final TargetRepositoryMockTargetCallback _delete;
+
+ bool currentInvoked = false;
+ bool addInvoked = false;
+ bool listInvoked = false;
+ bool setCurrentInvoked = false;
+ bool deleteInvoked = false;
+
+ M.Target get current {
+ currentInvoked = true;
+ return _current;
+ }
+
+ void add(String val) {
+ addInvoked = true;
+ if (_add != null) _add(val);
+ }
+
+ Iterable<M.Target> list() {
+ listInvoked = true;
+ return _list;
+ }
+
+ void setCurrent(M.Target target) {
+ setCurrentInvoked = true;
+ if (_setCurrent != null) _setCurrent(target);
+ }
+
+ void delete(M.Target target) {
+ deleteInvoked = true;
+ if (_delete != null) _delete(target);
+ }
+
+ void triggerChangeEvent() {
+ _onChange.add(new TargetChangeEventMock(repository: this));
+ }
+
+ TargetRepositoryMock({M.Target current, Iterable<M.Target> list : const [],
+ TargetRepositoryMockStringCallback add,
+ TargetRepositoryMockTargetCallback setCurrent,
+ TargetRepositoryMockTargetCallback delete})
+ : _current = current,
+ _list = list,
+ _add = add,
+ _setCurrent = setCurrent,
+ _delete = delete;
+}

Powered by Google App Engine
This is Rietveld 408576698