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

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

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master 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 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
6 import 'package:observatory/src/elements/nav/menu.dart'; 6 import 'package:observatory/src/elements/nav/menu.dart';
7 7
8 main() { 8 main() {
9 NavMenuElement.tag.ensureRegistration(); 9 NavMenuElement.tag.ensureRegistration();
10 10
11 group('instantiation', () { 11 group('instantiation', () {
12 final label = 'custom-label'; 12 final label = 'custom-label';
13 test('label', () { 13 test('label', () {
14 final NavMenuElement e = new NavMenuElement(label); 14 final e = new NavMenuElement(label);
15 expect(e, isNotNull, reason: 'element correctly created'); 15 expect(e, isNotNull, reason: 'element correctly created');
16 expect(e.label, equals(label), reason: 'element correctly created'); 16 expect(e.label, equals(label), reason: 'element correctly created');
17 }); 17 });
18 test('not last', () { 18 test('not last', () {
19 final NavMenuElement e = new NavMenuElement(label, last: false); 19 final e = new NavMenuElement(label, last: false);
20 expect(e, isNotNull, reason: 'element correctly created'); 20 expect(e, isNotNull, reason: 'element correctly created');
21 expect(e.last, isFalse, reason: 'element correctly created'); 21 expect(e.last, isFalse, reason: 'element correctly created');
22 }); 22 });
23 test('last', () { 23 test('last', () {
24 final NavMenuElement e = new NavMenuElement(label, last: true); 24 final e = new NavMenuElement(label, last: true);
25 expect(e, isNotNull, reason: 'element correctly created'); 25 expect(e, isNotNull, reason: 'element correctly created');
26 expect(e.last, isTrue, reason: 'element correctly created'); 26 expect(e.last, isTrue, reason: 'element correctly created');
27 }); 27 });
28 }); 28 });
29 group('elements', () { 29 group('elements', () {
30 test('created', () async { 30 test('created', () async {
31 final label = 'custom-label'; 31 final label = 'custom-label';
32 final NavMenuElement e = new NavMenuElement(label); 32 final e = new NavMenuElement(label);
33 document.body.append(e); 33 document.body.append(e);
34 await e.onRendered.first; 34 await e.onRendered.first;
35 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements'); 35 expect(e.shadowRoot.children.length, isNonZero, reason: 'has elements');
36 expect(e.shadowRoot.querySelector('content'), isNotNull, 36 expect(e.shadowRoot.querySelector('content'), isNotNull,
37 reason: 'has content elements') ; 37 reason: 'has content elements') ;
38 e.remove(); 38 e.remove();
39 await e.onRendered.first; 39 await e.onRendered.first;
40 expect(e.shadowRoot.children.length, isZero, reason: 'is empty'); 40 expect(e.shadowRoot.children.length, isZero, reason: 'is empty');
41 }); 41 });
42 test('react to label change', () async { 42 test('react to label change', () async {
43 final label1 = 'custom-label-1'; 43 final label1 = 'custom-label-1';
44 final label2 = 'custom-label-2'; 44 final label2 = 'custom-label-2';
45 final NavMenuElement e = new NavMenuElement(label1); 45 final e = new NavMenuElement(label1);
46 document.body.append(e); 46 document.body.append(e);
47 await e.onRendered.first; 47 await e.onRendered.first;
48 expect(e.shadowRoot.innerHtml.contains(label1), isTrue); 48 expect(e.shadowRoot.innerHtml.contains(label1), isTrue);
49 expect(e.shadowRoot.innerHtml.contains(label2), isFalse); 49 expect(e.shadowRoot.innerHtml.contains(label2), isFalse);
50 e.label = label2; 50 e.label = label2;
51 await e.onRendered.first; 51 await e.onRendered.first;
52 expect(e.shadowRoot.innerHtml.contains(label1), isFalse); 52 expect(e.shadowRoot.innerHtml.contains(label1), isFalse);
53 expect(e.shadowRoot.innerHtml.contains(label2), isTrue); 53 expect(e.shadowRoot.innerHtml.contains(label2), isTrue);
54 e.remove(); 54 e.remove();
55 await e.onRendered.first; 55 await e.onRendered.first;
56 }); 56 });
57 test('react to last change', () async { 57 test('react to last change', () async {
58 final label = 'custom-label'; 58 final label = 'custom-label';
59 final NavMenuElement e = new NavMenuElement(label, last: false); 59 final e = new NavMenuElement(label, last: false);
60 document.body.append(e); 60 document.body.append(e);
61 await e.onRendered.first; 61 await e.onRendered.first;
62 expect(e.shadowRoot.innerHtml.contains('>'), isTrue); 62 expect(e.shadowRoot.innerHtml.contains('>'), isTrue);
63 e.last = true; 63 e.last = true;
64 await e.onRendered.first; 64 await e.onRendered.first;
65 expect(e.shadowRoot.innerHtml.contains('>'), isFalse); 65 expect(e.shadowRoot.innerHtml.contains('>'), isFalse);
66 e.last = false; 66 e.last = false;
67 await e.onRendered.first; 67 await e.onRendered.first;
68 expect(e.shadowRoot.innerHtml.contains('>'), isTrue); 68 expect(e.shadowRoot.innerHtml.contains('>'), isTrue);
69 e.remove(); 69 e.remove();
70 await e.onRendered.first; 70 await e.onRendered.first;
71 }); 71 });
72 }); 72 });
73 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698