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

Unified Diff: runtime/observatory/tests/observatory_ui/isolate_reconnect/element_test.dart

Issue 2202973002: Converted Observatory isolate-reconnect element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixed typo 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/tests/observatory_ui/isolate_reconnect/element_test.dart
diff --git a/runtime/observatory/tests/observatory_ui/isolate_reconnect/element_test.dart b/runtime/observatory/tests/observatory_ui/isolate_reconnect/element_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b56e57e9746cb06cf46c57cbe57982d946d9ec57
--- /dev/null
+++ b/runtime/observatory/tests/observatory_ui/isolate_reconnect/element_test.dart
@@ -0,0 +1,79 @@
+// 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/src/elements/isolate_reconnect.dart';
+import 'package:observatory/src/elements/nav/notify.dart';
+import '../mocks.dart';
+
+main(){
+ IsolateReconnectElement.tag.ensureRegistration();
+
+ final nTag = NavNotifyElement.tag.name;
+
+ EventRepositoryMock events;
+ NotificationRepositoryMock notifications;
+ Uri uri;
+ const vm = const VMMock(isolates: const [
+ const IsolateMock(id: 'i-1-id'), const IsolateMock(id: 'i-2-id')
+ ]);
+ const missing = 'missing-id';
+ setUp(() {
+ events = new EventRepositoryMock();
+ notifications = new NotificationRepositoryMock();
+ uri = new Uri(path: 'path');
+ });
+ test('instantiation', () {
+ final e = new IsolateReconnectElement(vm, events, notifications, missing,
+ uri);
+ expect(e, isNotNull, reason: 'element correctly created');
+ expect(e.vm, equals(vm));
+ expect(e.missing, equals(missing));
+ expect(e.uri, equals(uri));
+ });
+ test('elements created after attachment', () async {
+ final e = new IsolateReconnectElement(vm, events, notifications, missing,
+ uri);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(e.children.length, isNonZero, reason: 'has elements');
+ expect(e.querySelector(nTag), isNotNull, reason: 'has notifications');
+ expect(e.querySelectorAll('.isolate-link').length,
+ equals(vm.isolates.length), reason: 'has links');
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ group('updates', () {
+ test('are correctly listen', () async {
+ final e = new IsolateReconnectElement(vm, events, notifications, missing,
+ uri);
+ expect(events.onVMUpdateHasListener, isFalse);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(events.onVMUpdateHasListener, isTrue);
+ e.remove();
+ await e.onRendered.first;
+ expect(events.onVMUpdateHasListener, isFalse);
+ });
+ test('have effects', () async {
+ final e = new IsolateReconnectElement(vm, events, notifications, missing,
+ uri);
+ const vm2 = const VMMock(isolates: const [
+ const IsolateMock(id: 'i-1-id'), const IsolateMock(id: 'i-2-id'),
+ const IsolateMock(id: 'i-3-id')
+ ]);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(e.querySelectorAll('.isolate-link').length,
+ equals(vm.isolates.length));
+ events.add(new VMUpdateEventMock(vm: vm2));
+ await e.onRendered.first;
+ expect(e.querySelectorAll('.isolate-link').length,
+ equals(vm2.isolates.length));
+ e.remove();
+ await e.onRendered.first;
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698