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

Unified Diff: runtime/observatory/tests/observatory_ui/vm_connect/element_test.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/tests/observatory_ui/vm_connect/element_test.dart
diff --git a/runtime/observatory/tests/observatory_ui/vm_connect/element_test.dart b/runtime/observatory/tests/observatory_ui/vm_connect/element_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..15a853ca76cd904823d178af8f556e56de5cde10
--- /dev/null
+++ b/runtime/observatory/tests/observatory_ui/vm_connect/element_test.dart
@@ -0,0 +1,119 @@
+// 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.
+import 'dart:html';
+import 'package:unittest/unittest.dart';
+import 'package:observatory/mocks.dart';
+import 'package:observatory/models.dart' as M;
+import 'package:observatory/src/elements/nav/notify.dart';
+import 'package:observatory/src/elements/vm_connect_target.dart';
+import 'package:observatory/src/elements/vm_connect.dart';
+
+main() {
+ VMConnectElement.tag.ensureRegistration();
+
+ final String nTag = NavNotifyElement.tag.name;
+ final String tTag = VMConnectTargetElement.tag.name;
+
+ group('instantiation', () {
+ test('default', () {
+ final VMConnectElement e = new VMConnectElement(
+ new TargetRepositoryMock(),
+ new CrashDumpRepositoryMock(),
+ new NotificationRepositoryMock());
+ expect(e, isNotNull, reason: 'element correctly created');
+ });
+ });
+ test('is correctly listening', () async {
+ final targets = new TargetRepositoryMock();
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock());
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(targets.hasListeners, isTrue, reason: 'is listening');
+ e.remove();
+ await e.onRendered.first;
+ expect(targets.hasListeners, isFalse, reason: 'is no more listening');
+ });
+ group('elements', () {
+ test('created after attachment', () async {
+ final targets = new TargetRepositoryMock(list: const [
+ const TargetMock(name: 't-1'), const TargetMock(name: 't-2'),
+ ]);
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock());
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(targets.listInvoked, isTrue, reason: 'should invoke list()');
+ expect(targets.currentInvoked, isTrue, reason: 'should invoke current');
+ expect(e.children.length, isNonZero, reason: 'has elements');
+ expect(e.querySelectorAll(nTag).length, equals(1));
+ expect(e.querySelectorAll(tTag).length, equals(2));
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ test('react to update event', () async {
+ final list = <M.Target>[const TargetMock(name: 't-1')];
+ final targets = new TargetRepositoryMock(list: list);
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock());
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(e.querySelectorAll(tTag).length, equals(1));
+ list.add(const TargetMock(name: 't-2'));
+ targets.triggerChangeEvent();
+ await e.onRendered.first;
+ expect(e.querySelectorAll(tTag).length, equals(2));
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ });
+ group('invokes', () {
+ test('add on click', () async {
+ final address = 'ws://host:1234';
+ final list = <M.Target>[const TargetMock(name: 't-1')];
+ final targets = new TargetRepositoryMock(list: list,
+ add: expectAsync((String val) {
+ expect(val, equals(address));
+ }, count: 1, reason: 'should be invoked'));
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock(),
+ address: address);
+ document.body.append(e);
+ await e.onRendered.first;
+ (e.querySelector('button.vm_connect') as ButtonElement).click();
+ e.remove();
+ await e.onRendered.first;
+ });
+ test('connect', () async {
+ final list = <M.Target>[const TargetMock(name: 't-1')];
+ final targets = new TargetRepositoryMock(list: list,
+ setCurrent: expectAsync((M.Target t) {
+ expect(t, equals(list[0]));
+ }, count: 1, reason: 'should be invoked'));
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock());
+ document.body.append(e);
+ await e.onRendered.first;
+ (e.querySelector(tTag) as VMConnectTargetElement).connect();
+ e.remove();
+ await e.onRendered.first;
+ });
+ test('delete', () async {
+ final list = <M.Target>[const TargetMock(name: 't-1')];
+ final targets = new TargetRepositoryMock(list: list,
+ delete: expectAsync((M.Target t) {
+ expect(t, equals(list[0]));
+ }, count: 1, reason: 'should be invoked'));
+ final VMConnectElement e = new VMConnectElement(targets,
+ new CrashDumpRepositoryMock(), new NotificationRepositoryMock());
+ document.body.append(e);
+ await e.onRendered.first;
+ (e.querySelector(tTag) as VMConnectTargetElement).delete();
+ e.remove();
+ await e.onRendered.first;
+ });
+ });
+}
« no previous file with comments | « runtime/observatory/observatory_sources.gypi ('k') | runtime/observatory/tests/observatory_ui/vm_connect/element_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698