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