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

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

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Updated observatory_sources 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 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 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:async';
6 import 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
7 import 'package:observatory/models.dart';
8 import 'package:observatory/mocks.dart';
9 import 'package:observatory/src/elements/isolate_ref.dart'; 6 import 'package:observatory/src/elements/isolate_ref.dart';
7 import '../mocks.dart';
10 8
11 main(){ 9 main(){
12 IsolateRefElement.tag.ensureRegistration(); 10 IsolateRefElement.tag.ensureRegistration();
13 11
14 StreamController<IsolateUpdateEvent> updatesController; 12 final ref = new IsolateRefMock(id: 'id', name: 'old-name');
15 final IsolateRefMock ref = new IsolateRefMock(id: 'id', name: 'old-name'); 13 final events = new EventRepositoryMock();
16 final IsolateMock obj = new IsolateMock(id: 'id', name: 'new-name'); 14 final obj = new IsolateMock(id: 'id', name: 'new-name');
17 setUp(() {
18 updatesController = new StreamController<IsolateUpdateEvent>();
19 });
20 group('instantiation', () { 15 group('instantiation', () {
21 test('IsolateRef', () { 16 test('IsolateRef', () {
22 final IsolateRefElement e = new IsolateRefElement(ref, 17 final e = new IsolateRefElement(ref, events);
23 updatesController.stream);
24 expect(e, isNotNull, reason: 'element correctly created'); 18 expect(e, isNotNull, reason: 'element correctly created');
25 expect(e.isolate, equals(ref)); 19 expect(e.isolate, equals(ref));
26 }); 20 });
27 test('Isolate', () { 21 test('Isolate', () {
28 final IsolateRefElement e = new IsolateRefElement(obj, 22 final e = new IsolateRefElement(obj, events);
29 updatesController.stream);
30 expect(e, isNotNull, reason: 'element correctly created'); 23 expect(e, isNotNull, reason: 'element correctly created');
31 expect(e.isolate, equals(obj)); 24 expect(e.isolate, equals(obj));
32 }); 25 });
33 }); 26 });
34 test('elements created after attachment', () async { 27 test('elements created after attachment', () async {
35 final IsolateRefElement e = new IsolateRefElement(ref, 28 final e = new IsolateRefElement(ref, events);
36 updatesController.stream);
37 document.body.append(e); 29 document.body.append(e);
38 await e.onRendered.first; 30 await e.onRendered.first;
39 expect(e.children.length, isNonZero, reason: 'has elements'); 31 expect(e.children.length, isNonZero, reason: 'has elements');
40 e.remove(); 32 e.remove();
41 await e.onRendered.first; 33 await e.onRendered.first;
42 expect(e.children.length, isZero, reason: 'is empty'); 34 expect(e.children.length, isZero, reason: 'is empty');
43 }); 35 });
44 group('updates', () { 36 group('updates', () {
45 test('are correctly listen', () async { 37 test('are correctly listen', () async {
46 final IsolateRefElement e = new IsolateRefElement(ref, 38 final e = new IsolateRefElement(ref, events);
47 updatesController.stream); 39 expect(events.onIsolateUpdateHasListener, isFalse);
48 expect(updatesController.hasListener, isFalse);
49 document.body.append(e); 40 document.body.append(e);
50 await e.onRendered.first; 41 await e.onRendered.first;
51 expect(updatesController.hasListener, isTrue); 42 expect(events.onIsolateUpdateHasListener, isTrue);
52 e.remove(); 43 e.remove();
53 await e.onRendered.first; 44 await e.onRendered.first;
54 expect(updatesController.hasListener, isFalse); 45 expect(events.onIsolateUpdateHasListener, isFalse);
55 }); 46 });
56 test('have effects', () async { 47 test('have effects', () async {
57 final IsolateRefElement e = new IsolateRefElement(ref, 48 final e = new IsolateRefElement(ref, events);
58 updatesController.stream);
59 document.body.append(e); 49 document.body.append(e);
60 await e.onRendered.first; 50 await e.onRendered.first;
61 expect(e.innerHtml.contains(ref.id), isTrue); 51 expect(e.innerHtml.contains(ref.id), isTrue);
62 updatesController.add(new IsolateUpdateEventMock(isolate: obj)); 52 events.add(new IsolateUpdateEventMock(isolate: obj));
63 await e.onRendered.first; 53 await e.onRendered.first;
64 expect(e.innerHtml.contains(ref.name), isFalse); 54 expect(e.innerHtml.contains(ref.name), isFalse);
65 expect(e.innerHtml.contains(obj.name), isTrue); 55 expect(e.innerHtml.contains(obj.name), isTrue);
66 e.remove(); 56 e.remove();
67 }); 57 });
68 }); 58 });
69 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698