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

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

Issue 2265513003: Converted Observatory object-common element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Addressed comments 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/object_common/element_test.dart
diff --git a/runtime/observatory/tests/observatory_ui/object_common/element_test.dart b/runtime/observatory/tests/observatory_ui/object_common/element_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bb83bc5cc3382b76e950f0920c071b7f6839b35a
--- /dev/null
+++ b/runtime/observatory/tests/observatory_ui/object_common/element_test.dart
@@ -0,0 +1,111 @@
+// 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/class_ref.dart';
+import 'package:observatory/src/elements/inbound_references.dart';
+import 'package:observatory/src/elements/object_common.dart';
+import 'package:observatory/src/elements/retaining_path.dart';
+import '../mocks.dart';
+
+main() {
+ ObjectCommonElement.tag.ensureRegistration();
+
+ final cTag = ClassRefElement.tag.name;
+ final iTag = InboundReferencesElement.tag.name;
+ final rTag = RetainingPathElement.tag.name;
+
+ const isolate = const IsolateRefMock();
+ const object = const InstanceMock();
+ final reachableSizes = new ReachableSizeRepositoryMock();
+ final retainedSizes = new RetainedSizeRepositoryMock();
+ final inbounds = new InboundReferencesRepositoryMock();
+ final paths = new RetainingPathRepositoryMock();
+ final instances = new InstanceRepositoryMock();
+ test('instantiation', () {
+ final e = new ObjectCommonElement(isolate, object, retainedSizes,
+ reachableSizes, inbounds, paths,
+ instances);
+ expect(e, isNotNull, reason: 'element correctly created');
+ expect(e.isolate, equals(isolate));
+ expect(e.object, equals(object));
+ });
+ group('elements', () {
+ test('created after attachment', () async {
+ final e = new ObjectCommonElement(isolate, object, retainedSizes,
+ reachableSizes, inbounds, paths,
+ instances);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(e.children.length, isNonZero, reason: 'has elements');
+ expect(e.querySelectorAll(cTag).length, equals(1));
+ expect(e.querySelectorAll(iTag).length, equals(1));
+ expect(e.querySelectorAll(rTag).length, equals(1));
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ test('created after attachment', () async {
+ const value = const GuardedMock<InstanceMock>.fromValue(
+ const InstanceMock(valueAsString: '10')
+ );
+ bool invoked = false;
+ final reachableSizes = new ReachableSizeRepositoryMock(
+ getter: expectAsync((i, id) async {
+ expect(i, equals(isolate));
+ expect(id, equals(object.id));
+ invoked = true;
+ return value;
+ }, count: 1)
+ );
+ final e = new ObjectCommonElement(isolate, object, retainedSizes,
+ reachableSizes, inbounds, paths,
+ instances);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(invoked, isFalse);
+ expect(e.children.length, isNonZero, reason: 'has elements');
+ expect(e.querySelectorAll(cTag).length, equals(1));
+ expect(e.querySelectorAll(iTag).length, equals(1));
+ expect(e.querySelectorAll(rTag).length, equals(1));
+ e.querySelector('.reachable_size').click();
+ await e.onRendered.first;
+ expect(invoked, isTrue);
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ test('created after attachment', () async {
+ const value = const GuardedMock<InstanceMock>.fromValue(
+ const InstanceMock(valueAsString: '10')
+ );
+ bool invoked = false;
+ final retainedSizes = new RetainedSizeRepositoryMock(
+ getter: expectAsync((i, id) async {
+ expect(i, equals(isolate));
+ expect(id, equals(object.id));
+ invoked = true;
+ return value;
+ }, count: 1)
+ );
+ final e = new ObjectCommonElement(isolate, object, retainedSizes,
+ reachableSizes, inbounds, paths,
+ instances);
+ document.body.append(e);
+ await e.onRendered.first;
+ expect(invoked, isFalse);
+ expect(e.children.length, isNonZero, reason: 'has elements');
+ expect(e.querySelectorAll(cTag).length, equals(1));
+ expect(e.querySelectorAll(iTag).length, equals(1));
+ expect(e.querySelectorAll(rTag).length, equals(1));
+ e.querySelector('.retained_size').click();
+ await e.onRendered.first;
+ expect(invoked, isTrue);
+ e.remove();
+ await e.onRendered.first;
+ expect(e.children.length, isZero, reason: 'is empty');
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698