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, | 31 contexts, retainedSizes, reachableSizes, inbounds, paths, instances); |
32 inbounds, paths, instances); | |
33 expect(e, isNotNull, reason: 'element correctly created'); | 32 expect(e, isNotNull, reason: 'element correctly created'); |
34 expect(e.isolate, equals(isolate)); | 33 expect(e.isolate, equals(isolate)); |
35 expect(e.context, equals(context)); | 34 expect(e.context, equals(context)); |
36 }); | 35 }); |
37 test('elements created after attachment', () async { | 36 test('elements created after attachment', () async { |
38 final contexts = new ContextRepositoryMock( | 37 final contexts = new ContextRepositoryMock( |
39 getter: expectAsync((i, id) async { | 38 getter: expectAsync((i, id) async { |
40 expect(i, equals(isolate)); | 39 expect(i, equals(isolate)); |
41 expect(id, equals(context.id)); | 40 expect(id, equals(context.id)); |
42 return context; | 41 return context; |
43 }, count: 1) | 42 }, count: 1)); |
44 ); | |
45 final e = new ContextViewElement(vm, isolate, context, events, notifs, | 43 final e = new ContextViewElement(vm, isolate, context, events, notifs, |
46 contexts, retainedSizes, reachableSizes, | 44 contexts, retainedSizes, reachableSizes, inbounds, paths, instances); |
47 inbounds, paths, instances); | |
48 document.body.append(e); | 45 document.body.append(e); |
49 await e.onRendered.first; | 46 await e.onRendered.first; |
50 expect(e.children.length, isNonZero, reason: 'has elements'); | 47 expect(e.children.length, isNonZero, reason: 'has elements'); |
51 expect(e.querySelectorAll(cTag).length, equals(1)); | 48 expect(e.querySelectorAll(cTag).length, equals(1)); |
52 (e.querySelector(rTag) as NavRefreshElement).refresh(); | 49 (e.querySelector(rTag) as NavRefreshElement).refresh(); |
53 await e.onRendered.first; | 50 await e.onRendered.first; |
54 e.remove(); | 51 e.remove(); |
55 await e.onRendered.first; | 52 await e.onRendered.first; |
56 expect(e.children.length, isZero, reason: 'is empty'); | 53 expect(e.children.length, isZero, reason: 'is empty'); |
57 }); | 54 }); |
58 } | 55 } |
OLD | NEW |