OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:html'; | |
6 import 'package:unittest/unittest.dart'; | |
7 import 'package:observatory/src/elements/context_view.dart'; | |
8 import 'package:observatory/src/elements/nav/refresh.dart'; | |
9 import 'package:observatory/src/elements/object_common.dart'; | |
10 import '../mocks.dart'; | |
11 | |
12 main() { | |
13 ContextViewElement.tag.ensureRegistration(); | |
14 | |
15 final cTag = ObjectCommonElement.tag.name; | |
16 final rTag = NavRefreshElement.tag.name; | |
17 | |
18 const vm = const VMMock(); | |
19 const isolate = const IsolateRefMock(); | |
20 final events = new EventRepositoryMock(); | |
21 final notifs = new NotificationRepositoryMock(); | |
22 final context = const ContextMock(); | |
23 final contexts = new ContextRepositoryMock(); | |
24 final reachableSizes = new ReachableSizeRepositoryMock(); | |
25 final retainedSizes = new RetainedSizeRepositoryMock(); | |
26 final inbounds = new InboundReferencesRepositoryMock(); | |
27 final paths = new RetainingPathRepositoryMock(); | |
28 final instances = new InstanceRepositoryMock(); | |
29 test('instantiation', () { | |
30 final e = new ContextViewElement(vm, isolate, context, events, notifs, | |
31 contexts, retainedSizes, reachableSizes, | |
32 inbounds, paths, instances); | |
33 expect(e, isNotNull, reason: 'element correctly created'); | |
34 expect(e.isolate, equals(isolate)); | |
35 expect(e.context, equals(context)); | |
36 }); | |
37 test('elements created after attachment', () async { | |
38 final contexts = new ContextRepositoryMock( | |
39 getter: expectAsync((i, id) async { | |
40 expect(i, equals(isolate)); | |
41 expect(id, equals(context.id)); | |
42 return context; | |
43 }, count: 1) | |
44 ); | |
45 final e = new ContextViewElement(vm, isolate, context, events, notifs, | |
46 contexts, retainedSizes, reachableSizes, | |
47 inbounds, paths, instances); | |
48 document.body.append(e); | |
49 await e.onRendered.first; | |
50 expect(e.children.length, isNonZero, reason: 'has elements'); | |
51 expect(e.querySelectorAll(cTag).length, equals(1)); | |
52 (e.querySelector(rTag) as NavRefreshElement).refresh(); | |
53 await e.onRendered.first; | |
54 e.remove(); | |
55 await e.onRendered.first; | |
56 expect(e.children.length, isZero, reason: 'is empty'); | |
57 }); | |
58 } | |
OLD | NEW |