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

Side by Side Diff: runtime/observatory/tests/observatory_ui/inbound_references/element_test.dart

Issue 2873013004: Omnibus Observatory UI fixes: (Closed)
Patch Set: Created 3 years, 7 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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:html'; 5 import 'dart:html';
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:observatory/src/elements/curly_block.dart'; 7 import 'package:observatory/src/elements/curly_block.dart';
8 import 'package:observatory/src/elements/inbound_references.dart'; 8 import 'package:observatory/src/elements/inbound_references.dart';
9 import 'package:observatory/src/elements/instance_ref.dart'; 9 import 'package:observatory/src/elements/instance_ref.dart';
10 import '../mocks.dart'; 10 import '../mocks.dart';
11 11
12 main() { 12 main() {
13 InboundReferencesElement.tag.ensureRegistration(); 13 InboundReferencesElement.tag.ensureRegistration();
14 14
15 final cTag = CurlyBlockElement.tag.name; 15 final cTag = CurlyBlockElement.tag.name;
16 final iTag = InstanceRefElement.tag.name; 16 final iTag = InstanceRefElement.tag.name;
17 final rTag = InboundReferencesElement.tag.name; 17 final rTag = InboundReferencesElement.tag.name;
18 18
19 const isolate = const IsolateRefMock(); 19 const isolate = const IsolateRefMock();
20 const object = const InstanceRefMock(); 20 const object = const InstanceRefMock();
21 final inbounds = new InboundReferencesRepositoryMock(); 21 final inbounds = new InboundReferencesRepositoryMock();
22 final instances = new InstanceRepositoryMock(); 22 final objects = new ObjectRepositoryMock();
23 test('instantiation', () { 23 test('instantiation', () {
24 final e = 24 final e = new InboundReferencesElement(isolate, object, inbounds, objects);
25 new InboundReferencesElement(isolate, object, inbounds, instances);
26 expect(e, isNotNull, reason: 'element correctly created'); 25 expect(e, isNotNull, reason: 'element correctly created');
27 expect(e.isolate, equals(isolate)); 26 expect(e.isolate, equals(isolate));
28 expect(e.object, equals(object)); 27 expect(e.object, equals(object));
29 }); 28 });
30 test('elements created after attachment', () async { 29 test('elements created after attachment', () async {
31 const source = const InstanceRefMock(id: 'source-id', name: 'source_name'); 30 const source = const InstanceRefMock(id: 'source-id', name: 'source_name');
32 const references = const InboundReferencesMock( 31 const references = const InboundReferencesMock(
33 elements: const [const InboundReferenceMock(source: source)]); 32 elements: const [const InboundReferenceMock(source: source)]);
34 bool invoked = false; 33 bool invoked = false;
35 final inbounds = new InboundReferencesRepositoryMock( 34 final inbounds = new InboundReferencesRepositoryMock(
36 getter: expectAsync((i, id) async { 35 getter: expectAsync((i, id) async {
37 expect(i, equals(isolate)); 36 expect(i, equals(isolate));
38 expect(id, equals(object.id)); 37 expect(id, equals(object.id));
39 invoked = true; 38 invoked = true;
40 return references; 39 return references;
41 }, count: 1)); 40 }, count: 1));
42 final instances = new InstanceRepositoryMock(); 41 final objects = new ObjectRepositoryMock();
43 final e = 42 final e = new InboundReferencesElement(isolate, object, inbounds, objects);
44 new InboundReferencesElement(isolate, object, inbounds, instances);
45 document.body.append(e); 43 document.body.append(e);
46 await e.onRendered.first; 44 await e.onRendered.first;
47 expect(invoked, isFalse); 45 expect(invoked, isFalse);
48 expect(e.children.length, isNonZero, reason: 'has elements'); 46 expect(e.children.length, isNonZero, reason: 'has elements');
49 expect(e.querySelectorAll(iTag).length, isZero); 47 expect(e.querySelectorAll(iTag).length, isZero);
50 (e.querySelector(cTag) as CurlyBlockElement).toggle(); 48 (e.querySelector(cTag) as CurlyBlockElement).toggle();
51 await e.onRendered.first; 49 await e.onRendered.first;
52 expect(invoked, isTrue); 50 expect(invoked, isTrue);
53 expect(e.querySelectorAll(iTag).length, equals(1)); 51 expect(e.querySelectorAll(iTag).length, equals(1));
54 expect(e.querySelectorAll(rTag).length, equals(1)); 52 expect(e.querySelectorAll(rTag).length, equals(1));
55 e.remove(); 53 e.remove();
56 await e.onRendered.first; 54 await e.onRendered.first;
57 expect(e.children.length, isZero, reason: 'is empty'); 55 expect(e.children.length, isZero, reason: 'is empty');
58 }); 56 });
59 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698