| 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 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:observatory/models.dart' as M; | 8 import 'package:observatory/models.dart' as M; |
| 9 import 'package:observatory/src/elements/allocation_profile.dart'; | 9 import 'package:observatory/src/elements/allocation_profile.dart'; |
| 10 import 'package:observatory/src/elements/class_ref.dart'; | 10 import 'package:observatory/src/elements/class_ref.dart'; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 await (() async {}()); | 121 await (() async {}()); |
| 122 e.remove(); | 122 e.remove(); |
| 123 await e.onRendered.first; | 123 await e.onRendered.first; |
| 124 expect(e.children.length, isZero, reason: 'is empty'); | 124 expect(e.children.length, isZero, reason: 'is empty'); |
| 125 }); | 125 }); |
| 126 test('to sort change', () async { | 126 test('to sort change', () async { |
| 127 const clazz1 = const ClassRefMock(name: 'class1'); | 127 const clazz1 = const ClassRefMock(name: 'class1'); |
| 128 const clazz2 = const ClassRefMock(name: 'class2'); | 128 const clazz2 = const ClassRefMock(name: 'class2'); |
| 129 const clazz3 = const ClassRefMock(name: 'class3'); | 129 const clazz3 = const ClassRefMock(name: 'class3'); |
| 130 const profile = const AllocationProfileMock(members: const [ | 130 const profile = const AllocationProfileMock(members: const [ |
| 131 const ClassHeapStatsMock(clazz: clazz1), |
| 131 const ClassHeapStatsMock( | 132 const ClassHeapStatsMock( |
| 132 clazz: clazz2, | 133 clazz: clazz2, |
| 133 newSpace: const AllocationsMock( | 134 newSpace: const AllocationsMock( |
| 134 accumulated: const AllocationCountMock(bytes: 10))), | 135 current: const AllocationCountMock(bytes: 10)), |
| 135 const ClassHeapStatsMock(clazz: clazz3), | 136 oldSpace: const AllocationsMock( |
| 137 current: const AllocationCountMock(bytes: 2))), |
| 136 const ClassHeapStatsMock( | 138 const ClassHeapStatsMock( |
| 137 clazz: clazz1, | 139 clazz: clazz3, |
| 138 newSpace: const AllocationsMock( | 140 newSpace: const AllocationsMock( |
| 139 accumulated: const AllocationCountMock(bytes: 5))) | 141 current: const AllocationCountMock(bytes: 5)), |
| 142 oldSpace: const AllocationsMock( |
| 143 current: const AllocationCountMock(bytes: 3))) |
| 140 ]); | 144 ]); |
| 141 final completer = new Completer<AllocationProfileMock>(); | 145 final completer = new Completer<AllocationProfileMock>(); |
| 142 final repo = new AllocationProfileRepositoryMock( | 146 final repo = new AllocationProfileRepositoryMock( |
| 143 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { | 147 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { |
| 144 expect(i, equals(isolate)); | 148 expect(i, equals(isolate)); |
| 145 expect(gc, isFalse); | 149 expect(gc, isFalse); |
| 146 expect(reset, isFalse); | 150 expect(reset, isFalse); |
| 147 return completer.future; | 151 return completer.future; |
| 148 }, count: 1)); | 152 }, count: 1)); |
| 149 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); | 153 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); |
| 150 document.body.append(e); | 154 document.body.append(e); |
| 151 await e.onRendered.first; | 155 await e.onRendered.first; |
| 152 completer.complete(profile); | 156 completer.complete(profile); |
| 153 await e.onRendered.first; | 157 await e.onRendered.first; |
| 158 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz2)); |
| 159 e.querySelector('button.name').click(); |
| 160 await e.onRendered.first; |
| 154 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz1)); | 161 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz1)); |
| 155 e.querySelector('button.bytes').click(); | 162 e.querySelector('button.name').click(); |
| 156 await e.onRendered.first; | |
| 157 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz2)); | |
| 158 e.querySelector('button.bytes').click(); | |
| 159 await e.onRendered.first; | 163 await e.onRendered.first; |
| 160 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz3)); | 164 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz3)); |
| 165 e.querySelectorAll('button.bytes').last.click(); |
| 166 await e.onRendered.first; |
| 167 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz3)); |
| 168 e.querySelectorAll('button.bytes').last.click(); |
| 169 await e.onRendered.first; |
| 170 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz1)); |
| 161 e.remove(); | 171 e.remove(); |
| 162 await e.onRendered.first; | 172 await e.onRendered.first; |
| 163 expect(e.children.length, isZero, reason: 'is empty'); | 173 expect(e.children.length, isZero, reason: 'is empty'); |
| 164 }); | 174 }); |
| 165 }); | 175 }); |
| 166 } | 176 } |
| OLD | NEW |