OLD | NEW |
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/context_view.dart'; | 7 import 'package:observatory/src/elements/context_view.dart'; |
8 import 'package:observatory/src/elements/nav/refresh.dart'; | 8 import 'package:observatory/src/elements/nav/refresh.dart'; |
9 import 'package:observatory/src/elements/object_common.dart'; | 9 import 'package:observatory/src/elements/object_common.dart'; |
10 import '../mocks.dart'; | 10 import '../mocks.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 final notifs = new NotificationRepositoryMock(); | 21 final notifs = new NotificationRepositoryMock(); |
22 final context = const ContextMock(); | 22 final context = const ContextMock(); |
23 final contexts = new ContextRepositoryMock(); | 23 final contexts = new ContextRepositoryMock(); |
24 final reachableSizes = new ReachableSizeRepositoryMock(); | 24 final reachableSizes = new ReachableSizeRepositoryMock(); |
25 final retainedSizes = new RetainedSizeRepositoryMock(); | 25 final retainedSizes = new RetainedSizeRepositoryMock(); |
26 final inbounds = new InboundReferencesRepositoryMock(); | 26 final inbounds = new InboundReferencesRepositoryMock(); |
27 final paths = new RetainingPathRepositoryMock(); | 27 final paths = new RetainingPathRepositoryMock(); |
28 final instances = new InstanceRepositoryMock(); | 28 final instances = new InstanceRepositoryMock(); |
29 test('instantiation', () { | 29 test('instantiation', () { |
30 final e = new ContextViewElement(vm, isolate, context, events, notifs, | 30 final e = new ContextViewElement(vm, isolate, context, events, notifs, |
31 contexts, retainedSizes, reachableSizes, inbounds, paths, instances); | 31 contexts, retainedSizes, reachableSizes, |
| 32 inbounds, paths, instances); |
32 expect(e, isNotNull, reason: 'element correctly created'); | 33 expect(e, isNotNull, reason: 'element correctly created'); |
33 expect(e.isolate, equals(isolate)); | 34 expect(e.isolate, equals(isolate)); |
34 expect(e.context, equals(context)); | 35 expect(e.context, equals(context)); |
35 }); | 36 }); |
36 test('elements created after attachment', () async { | 37 test('elements created after attachment', () async { |
37 final contexts = new ContextRepositoryMock( | 38 final contexts = new ContextRepositoryMock( |
38 getter: expectAsync((i, id) async { | 39 getter: expectAsync((i, id) async { |
39 expect(i, equals(isolate)); | 40 expect(i, equals(isolate)); |
40 expect(id, equals(context.id)); | 41 expect(id, equals(context.id)); |
41 return context; | 42 return context; |
42 }, count: 1)); | 43 }, count: 1) |
| 44 ); |
43 final e = new ContextViewElement(vm, isolate, context, events, notifs, | 45 final e = new ContextViewElement(vm, isolate, context, events, notifs, |
44 contexts, retainedSizes, reachableSizes, inbounds, paths, instances); | 46 contexts, retainedSizes, reachableSizes, |
| 47 inbounds, paths, instances); |
45 document.body.append(e); | 48 document.body.append(e); |
46 await e.onRendered.first; | 49 await e.onRendered.first; |
47 expect(e.children.length, isNonZero, reason: 'has elements'); | 50 expect(e.children.length, isNonZero, reason: 'has elements'); |
48 expect(e.querySelectorAll(cTag).length, equals(1)); | 51 expect(e.querySelectorAll(cTag).length, equals(1)); |
49 (e.querySelector(rTag) as NavRefreshElement).refresh(); | 52 (e.querySelector(rTag) as NavRefreshElement).refresh(); |
50 await e.onRendered.first; | 53 await e.onRendered.first; |
51 e.remove(); | 54 e.remove(); |
52 await e.onRendered.first; | 55 await e.onRendered.first; |
53 expect(e.children.length, isZero, reason: 'is empty'); | 56 expect(e.children.length, isZero, reason: 'is empty'); |
54 }); | 57 }); |
55 } | 58 } |
OLD | NEW |