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

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

Issue 2310003004: Removed polymer & mirror from Observatory (Closed)
Patch Set: Fixed crash in heap-map page Created 4 years, 3 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/nav/menu.dart';
8 import 'package:observatory/src/elements/nav/isolate_menu.dart'; 7 import 'package:observatory/src/elements/nav/isolate_menu.dart';
9 import '../../mocks.dart'; 8 import '../../mocks.dart';
10 9
11 main() { 10 main() {
12 NavIsolateMenuElement.tag.ensureRegistration(); 11 NavIsolateMenuElement.tag.ensureRegistration();
13 12
14 final tag = NavMenuElement.tag.name; 13 final tag = '.nav-menu_label > a';
15 14
16 EventRepositoryMock events; 15 EventRepositoryMock events;
17 final ref = const IsolateRefMock(id: 'i-id', name: 'old-name'); 16 final ref = const IsolateRefMock(id: 'i-id', name: 'old-name');
18 final obj = const IsolateMock(id: 'i-id', name: 'new-name'); 17 final obj = const IsolateMock(id: 'i-id', name: 'new-name');
19 setUp(() { 18 setUp(() {
20 events = new EventRepositoryMock(); 19 events = new EventRepositoryMock();
21 }); 20 });
22 group('instantiation', () { 21 group('instantiation', () {
23 test('IsolateRef', () { 22 test('IsolateRef', () {
24 final e = new NavIsolateMenuElement(ref, events); 23 final e = new NavIsolateMenuElement(ref, events);
25 expect(e, isNotNull, reason: 'element correctly created'); 24 expect(e, isNotNull, reason: 'element correctly created');
26 expect(e.isolate, equals(ref)); 25 expect(e.isolate, equals(ref));
27 }); 26 });
28 test('Isolate', () { 27 test('Isolate', () {
29 final e = new NavIsolateMenuElement(obj, events); 28 final e = new NavIsolateMenuElement(obj, events);
30 expect(e, isNotNull, reason: 'element correctly created'); 29 expect(e, isNotNull, reason: 'element correctly created');
31 expect(e.isolate, equals(obj)); 30 expect(e.isolate, equals(obj));
32 }); 31 });
33 }); 32 });
34 test('elements created after attachment', () async { 33 test('elements created after attachment', () async {
35 final e = new NavIsolateMenuElement(ref, events); 34 final e = new NavIsolateMenuElement(ref, events);
36 document.body.append(e); 35 document.body.append(e);
37 await e.onRendered.first; 36 await e.onRendered.first;
38 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements'); 37 expect(e.children.length, isNonZero, reason: 'has elements');
39 e.remove(); 38 e.remove();
40 await e.onRendered.first; 39 await e.onRendered.first;
41 expect(e.shadowRoot.children.length, isZero, reason: 'is empty'); 40 expect(e.children.length, isZero, reason: 'is empty');
42 }); 41 });
43 group('updates', () { 42 group('updates', () {
44 test('are correctly listen', () async { 43 test('are correctly listen', () async {
45 final e = new NavIsolateMenuElement(ref, events); 44 final e = new NavIsolateMenuElement(ref, events);
46 expect(events.onIsolateUpdateHasListener, isFalse); 45 expect(events.onIsolateUpdateHasListener, isFalse);
47 document.body.append(e); 46 document.body.append(e);
48 await e.onRendered.first; 47 await e.onRendered.first;
49 expect(events.onIsolateUpdateHasListener, isTrue); 48 expect(events.onIsolateUpdateHasListener, isTrue);
50 e.remove(); 49 e.remove();
51 await e.onRendered.first; 50 await e.onRendered.first;
52 expect(events.onIsolateUpdateHasListener, isFalse); 51 expect(events.onIsolateUpdateHasListener, isFalse);
53 }); 52 });
54 test('have effects', () async { 53 test('have effects', () async {
55 final e = new NavIsolateMenuElement(ref, events); 54 final e = new NavIsolateMenuElement(ref, events);
56 document.body.append(e); 55 document.body.append(e);
57 await e.onRendered.first; 56 await e.onRendered.first;
58 expect((e.shadowRoot.querySelector(tag) as NavMenuElement) 57 expect(e.querySelector(tag).text.contains(ref.name), isTrue);
59 .label.contains(ref.name), isTrue);
60 events.add(new IsolateUpdateEventMock(isolate: obj)); 58 events.add(new IsolateUpdateEventMock(isolate: obj));
61 await e.onRendered.first; 59 await e.onRendered.first;
62 expect((e.shadowRoot.querySelector(tag) as NavMenuElement) 60 expect(e.querySelector(tag).text.contains(ref.name), isFalse);
63 .label.contains(ref.name), isFalse); 61 expect(e.querySelector(tag).text.contains(obj.name), isTrue);
64 expect((e.shadowRoot.querySelector(tag) as NavMenuElement)
65 .label.contains(obj.name), isTrue);
66 e.remove(); 62 e.remove();
67 }); 63 });
68 }); 64 });
69 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698