Chromium Code Reviews| 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 import 'dart:html'; | |
|
rmacnak
2016/08/09 20:51:06
blank line after copyright
cbernaschina
2016/08/09 21:16:55
Done.
| |
| 5 import 'dart:async'; | |
| 6 import 'package:unittest/unittest.dart'; | |
| 7 import 'package:observatory/models.dart' as M; | |
| 8 import 'package:observatory/src/elements/cpu_profile.dart'; | |
| 9 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; | |
| 10 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; | |
| 11 import 'package:observatory/src/elements/sample_buffer_control.dart'; | |
| 12 import '../mocks.dart'; | |
| 13 | |
| 14 main() { | |
| 15 CpuProfileElement.tag.ensureRegistration(); | |
| 16 | |
| 17 final sTag = SampleBufferControlElement.tag.name; | |
| 18 final cTag = StackTraceTreeConfigElement.tag.name; | |
| 19 final tTag = CpuProfileVirtualTreeElement.tag.name; | |
| 20 | |
| 21 const vm = const VMMock(); | |
| 22 const isolate = const IsolateRefMock(); | |
| 23 final events = new EventRepositoryMock(); | |
| 24 final notifs = new NotificationRepositoryMock(); | |
| 25 test('instantiation', () { | |
| 26 final profiles = new IsolateSampleProfileRepositoryMock(); | |
| 27 final e = new CpuProfileElement(vm, isolate, events, notifs, profiles); | |
| 28 expect(e, isNotNull, reason: 'element correctly created'); | |
| 29 }); | |
| 30 test('elements created', () async { | |
| 31 final controller | |
| 32 = new StreamController<M.SampleProfileLoadingProgressEvent>.broadcast(); | |
| 33 final profiles = new IsolateSampleProfileRepositoryMock( | |
| 34 getter: (M.IsolateRef i, M.SampleProfileTag t, bool clear, | |
| 35 bool forceFetch) { | |
| 36 expect(i, equals(isolate)); | |
| 37 expect(t, isNotNull); | |
| 38 expect(clear, isFalse); | |
| 39 expect(forceFetch, isFalse); | |
| 40 return controller.stream; | |
| 41 } | |
| 42 ); | |
| 43 final e = new CpuProfileElement(vm, isolate, events, notifs, profiles); | |
| 44 document.body.append(e); | |
| 45 await e.onRendered.first; | |
| 46 expect(e.children.length, isNonZero, reason: 'has elements'); | |
| 47 expect(e.querySelectorAll(sTag).length, isZero); | |
| 48 expect(e.querySelectorAll(cTag).length, isZero); | |
| 49 expect(e.querySelectorAll(tTag).length, isZero); | |
| 50 controller.add(new SampleProfileLoadingProgressEventMock( | |
| 51 progress: new SampleProfileLoadingProgressMock( | |
| 52 status: M.SampleProfileLoadingStatus.fetching | |
| 53 ) | |
| 54 )); | |
| 55 await e.onRendered.first; | |
| 56 expect(e.querySelectorAll(sTag).length, equals(1)); | |
| 57 expect(e.querySelectorAll(cTag).length, isZero); | |
| 58 expect(e.querySelectorAll(tTag).length, isZero); | |
| 59 controller.add(new SampleProfileLoadingProgressEventMock( | |
| 60 progress: new SampleProfileLoadingProgressMock( | |
| 61 status: M.SampleProfileLoadingStatus.loading | |
| 62 ) | |
| 63 )); | |
| 64 controller.add(new SampleProfileLoadingProgressEventMock( | |
| 65 progress: new SampleProfileLoadingProgressMock( | |
| 66 status: M.SampleProfileLoadingStatus.loaded, | |
| 67 profile: new SampleProfileMock() | |
| 68 ) | |
| 69 )); | |
| 70 controller.close(); | |
| 71 await e.onRendered.first; | |
| 72 expect(e.querySelectorAll(sTag).length, equals(1)); | |
| 73 expect(e.querySelectorAll(cTag).length, equals(1)); | |
| 74 expect(e.querySelectorAll(tTag).length, equals(1)); | |
| 75 e.remove(); | |
| 76 await e.onRendered.first; | |
| 77 expect(e.children.length, isZero, reason: 'is empty'); | |
| 78 }); | |
| 79 } | |
| OLD | NEW |