OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/vm_connect_target.dart'; | 7 import 'package:observatory/src/elements/vm_connect_target.dart'; |
8 import '../mocks.dart'; | 8 import '../mocks.dart'; |
9 | 9 |
10 main() { | 10 main() { |
11 VMConnectTargetElement.tag.ensureRegistration(); | 11 VMConnectTargetElement.tag.ensureRegistration(); |
12 | 12 |
13 TargetMock t; | 13 TargetMock t; |
14 setUp(() { | 14 setUp(() { |
15 t = new TargetMock(name: "a network address"); | 15 t = new TargetMock(name: "a network address"); |
16 }); | 16 }); |
17 group('instantiation', () { | 17 group('instantiation', () { |
18 test('no other parameters', () { | 18 test('no other parameters', () { |
19 final e = new VMConnectTargetElement(t); | 19 final e = new VMConnectTargetElement(t); |
20 expect(e, isNotNull, reason: 'element correctly created'); | 20 expect(e, isNotNull, reason: 'element correctly created'); |
21 expect(e.target, t, reason: 'target not setted'); | 21 expect(e.target, t, reason: 'target not setted'); |
22 expect(e.current, isFalse, reason: 'default to not current'); | 22 expect(e.current, isFalse, reason: 'default to not current'); |
23 }); | 23 }); |
24 test('isCurrent: false', () { | 24 test('isCurrent: false', () { |
25 final e = new VMConnectTargetElement(t, current: false); | 25 final e = new VMConnectTargetElement(t, current:false); |
26 expect(e, isNotNull, reason: 'element correctly created'); | 26 expect(e, isNotNull, reason: 'element correctly created'); |
27 expect(e.target, t, reason: 'target not setted'); | 27 expect(e.target, t, reason: 'target not setted'); |
28 expect(e.current, isFalse, reason: 'default to not current'); | 28 expect(e.current, isFalse, reason: 'default to not current'); |
29 }); | 29 }); |
30 test('isCurrent: true', () { | 30 test('isCurrent: true', () { |
31 final e = new VMConnectTargetElement(t, current: true); | 31 final e = new VMConnectTargetElement(t, current:true); |
32 expect(e, isNotNull, reason: 'element correctly created'); | 32 expect(e, isNotNull, reason: 'element correctly created'); |
33 expect(e.target, t, reason: 'target not setted'); | 33 expect(e.target, t, reason: 'target not setted'); |
34 expect(e.current, isTrue, reason: 'default to not current'); | 34 expect(e.current, isTrue, reason: 'default to not current'); |
35 }); | 35 }); |
36 }); | 36 }); |
37 test('elements created after attachment', () async { | 37 test('elements created after attachment', () async { |
38 final e = new VMConnectTargetElement(t); | 38 final e = new VMConnectTargetElement(t); |
39 document.body.append(e); | 39 document.body.append(e); |
40 await e.onRendered.first; | 40 await e.onRendered.first; |
41 expect(e.children.length, isNonZero, reason: 'has elements'); | 41 expect(e.children.length, isNonZero, reason: 'has elements'); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 }); | 77 }); |
78 test('onRemove events (code)', () async { | 78 test('onRemove events (code)', () async { |
79 e.onDelete.listen(expectAsync((TargetEvent event) { | 79 e.onDelete.listen(expectAsync((TargetEvent event) { |
80 expect(event, isNotNull, reason: 'event is passed'); | 80 expect(event, isNotNull, reason: 'event is passed'); |
81 expect(event.target, t, reason: 'target is the same'); | 81 expect(event.target, t, reason: 'target is the same'); |
82 }, count: 1, reason: 'event is fired')); | 82 }, count: 1, reason: 'event is fired')); |
83 e.delete(); | 83 e.delete(); |
84 }); | 84 }); |
85 }); | 85 }); |
86 } | 86 } |
OLD | NEW |