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

Side by Side Diff: runtime/observatory/tests/observatory_ui/nav/isolate-menu/element_test.dart

Issue 2173373002: Revert "Use Timer and not AnimationFrame during Observatory UI tests" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert "Use Timer and not AnimationFrame during Observatory UI tests" 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'; 5 import 'dart:async';
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:observatory/models.dart'; 7 import 'package:observatory/models.dart';
8 import 'package:observatory/mocks.dart'; 8 import 'package:observatory/mocks.dart';
9 import 'package:observatory/src/elements/helpers/rendering_queue.dart';
10 import 'package:observatory/src/elements/nav/menu.dart'; 9 import 'package:observatory/src/elements/nav/menu.dart';
11 import 'package:observatory/src/elements/nav/isolate_menu.dart'; 10 import 'package:observatory/src/elements/nav/isolate_menu.dart';
12 11
13 main(){ 12 main(){
14 NavIsolateMenuElement.tag.ensureRegistration(); 13 NavIsolateMenuElement.tag.ensureRegistration();
15 14
16 final TimedRenderingBarrier barrier = new TimedRenderingBarrier();
17 final RenderingQueue queue = new RenderingQueue.fromBarrier(barrier);
18
19 final String tag = NavMenuElement.tag.name; 15 final String tag = NavMenuElement.tag.name;
20 16
21 StreamController<IsolateUpdateEvent> updatesController; 17 StreamController<IsolateUpdateEvent> updatesController;
22 final IsolateRefMock ref = const IsolateRefMock(id: 'i-id', name: 'old-name'); 18 final IsolateRefMock ref = const IsolateRefMock(id: 'i-id', name: 'old-name');
23 final IsolateMock obj = const IsolateMock(id: 'i-id', name: 'new-name'); 19 final IsolateMock obj = const IsolateMock(id: 'i-id', name: 'new-name');
24 setUp(() { 20 setUp(() {
25 updatesController = new StreamController<IsolateUpdateEvent>(); 21 updatesController = new StreamController<IsolateUpdateEvent>();
26 }); 22 });
27 group('instantiation', () { 23 group('instantiation', () {
28 test('IsolateRef', () { 24 test('IsolateRef', () {
29 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref, 25 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref,
30 updatesController.stream); 26 updatesController.stream);
31 expect(e, isNotNull, reason: 'element correctly created'); 27 expect(e, isNotNull, reason: 'element correctly created');
32 expect(e.isolate, equals(ref)); 28 expect(e.isolate, equals(ref));
33 }); 29 });
34 test('Isolate', () { 30 test('Isolate', () {
35 final NavIsolateMenuElement e = new NavIsolateMenuElement(obj, 31 final NavIsolateMenuElement e = new NavIsolateMenuElement(obj,
36 updatesController.stream); 32 updatesController.stream);
37 expect(e, isNotNull, reason: 'element correctly created'); 33 expect(e, isNotNull, reason: 'element correctly created');
38 expect(e.isolate, equals(obj)); 34 expect(e.isolate, equals(obj));
39 }); 35 });
40 }); 36 });
41 test('elements created after attachment', () async { 37 test('elements created after attachment', () async {
42 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref, 38 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref,
43 updatesController.stream, queue: queue); 39 updatesController.stream);
44 document.body.append(e); 40 document.body.append(e);
45 await e.onRendered.first; 41 await e.onRendered.first;
46 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements'); 42 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements');
47 e.remove(); 43 e.remove();
48 await e.onRendered.first; 44 await e.onRendered.first;
49 expect(e.shadowRoot.children.length, isZero, reason: 'is empty'); 45 expect(e.shadowRoot.children.length, isZero, reason: 'is empty');
50 }); 46 });
51 group('updates', () { 47 group('updates', () {
52 test('are correctly listen', () async { 48 test('are correctly listen', () async {
53 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref, 49 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref,
54 updatesController.stream, queue: queue); 50 updatesController.stream);
55 expect(updatesController.hasListener, isFalse); 51 expect(updatesController.hasListener, isFalse);
56 document.body.append(e); 52 document.body.append(e);
57 await e.onRendered.first; 53 await e.onRendered.first;
58 expect(updatesController.hasListener, isTrue); 54 expect(updatesController.hasListener, isTrue);
59 e.remove(); 55 e.remove();
60 await e.onRendered.first; 56 await e.onRendered.first;
61 expect(updatesController.hasListener, isFalse); 57 expect(updatesController.hasListener, isFalse);
62 }); 58 });
63 test('have effects', () async { 59 test('have effects', () async {
64 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref, 60 final NavIsolateMenuElement e = new NavIsolateMenuElement(ref,
65 updatesController.stream, queue: queue); 61 updatesController.stream);
66 document.body.append(e); 62 document.body.append(e);
67 await e.onRendered.first; 63 await e.onRendered.first;
68 expect((e.shadowRoot.querySelector(tag) as NavMenuElement) 64 expect((e.shadowRoot.querySelector(tag) as NavMenuElement)
69 .label.contains(ref.name), isTrue); 65 .label.contains(ref.name), isTrue);
70 updatesController.add(new IsolateUpdateEventMock(isolate: obj)); 66 updatesController.add(new IsolateUpdateEventMock(isolate: obj));
71 await e.onRendered.first; 67 await e.onRendered.first;
72 expect((e.shadowRoot.querySelector(tag) as NavMenuElement) 68 expect((e.shadowRoot.querySelector(tag) as NavMenuElement)
73 .label.contains(ref.name), isFalse); 69 .label.contains(ref.name), isFalse);
74 expect((e.shadowRoot.querySelector(tag) as NavMenuElement) 70 expect((e.shadowRoot.querySelector(tag) as NavMenuElement)
75 .label.contains(obj.name), isTrue); 71 .label.contains(obj.name), isTrue);
76 e.remove(); 72 e.remove();
77 await e.onRendered.first;
78 }); 73 });
79 }); 74 });
80 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698