| 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/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; | 8 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 group('events', () { | 135 group('events', () { |
| 136 test('onModeChange', () async { | 136 test('onModeChange', () async { |
| 137 final e = new StackTraceTreeConfigElement(); | 137 final e = new StackTraceTreeConfigElement(); |
| 138 document.body.append(e); | 138 document.body.append(e); |
| 139 await e.onRendered.first; | 139 await e.onRendered.first; |
| 140 expect(e.mode, equals(ProfileTreeMode.function)); | 140 expect(e.mode, equals(ProfileTreeMode.function)); |
| 141 e.onModeChange.listen(expectAsync((_) { | 141 e.onModeChange.listen(expectAsync((_) { |
| 142 expect(e.mode, equals(ProfileTreeMode.code)); | 142 expect(e.mode, equals(ProfileTreeMode.code)); |
| 143 }, count: 1)); | 143 }, count: 1)); |
| 144 final select = (e.querySelector('.mode-select') as SelectElement); | 144 final select = (e.querySelector('.mode-select') as SelectElement); |
| 145 select.selectedIndex = select.options.indexOf((select.options.toSet() | 145 select.selectedIndex = select.options.indexOf( |
| 146 ..removeAll(select.selectedOptions)) | 146 (select.options.toSet() |
| 147 .toList() | 147 ..removeAll(select.selectedOptions)).toList().first |
| 148 .first); | 148 ); |
| 149 select.dispatchEvent(new Event("change")); | 149 select.dispatchEvent(new Event("change")); |
| 150 e.remove(); | 150 e.remove(); |
| 151 await e.onRendered.first; | 151 await e.onRendered.first; |
| 152 }); | 152 }); |
| 153 test('onDirectionChange', () async { | 153 test('onDirectionChange', () async { |
| 154 final e = new StackTraceTreeConfigElement(); | 154 final e = new StackTraceTreeConfigElement(); |
| 155 document.body.append(e); | 155 document.body.append(e); |
| 156 await e.onRendered.first; | 156 await e.onRendered.first; |
| 157 expect(e.direction, equals(M.ProfileTreeDirection.exclusive)); | 157 expect(e.direction, equals(M.ProfileTreeDirection.exclusive)); |
| 158 e.onDirectionChange.listen(expectAsync((_) { | 158 e.onDirectionChange.listen(expectAsync((_) { |
| 159 expect(e.direction, equals(M.ProfileTreeDirection.inclusive)); | 159 expect(e.direction, equals(M.ProfileTreeDirection.inclusive)); |
| 160 }, count: 1)); | 160 }, count: 1)); |
| 161 final select = (e.querySelector('.direction-select') as SelectElement); | 161 final select = (e.querySelector('.direction-select') as SelectElement); |
| 162 select.selectedIndex = select.options.indexOf((select.options.toSet() | 162 select.selectedIndex = select.options.indexOf( |
| 163 ..removeAll(select.selectedOptions)) | 163 (select.options.toSet() |
| 164 .toList() | 164 ..removeAll(select.selectedOptions)).toList().first |
| 165 .first); | 165 ); |
| 166 select.dispatchEvent(new Event("change")); | 166 select.dispatchEvent(new Event("change")); |
| 167 e.remove(); | 167 e.remove(); |
| 168 await e.onRendered.first; | 168 await e.onRendered.first; |
| 169 }); | 169 }); |
| 170 test('onFilterChange', () async { | 170 test('onFilterChange', () async { |
| 171 final e = new StackTraceTreeConfigElement(); | 171 final e = new StackTraceTreeConfigElement(); |
| 172 document.body.append(e); | 172 document.body.append(e); |
| 173 await e.onRendered.first; | 173 await e.onRendered.first; |
| 174 expect(e.direction, equals(M.ProfileTreeDirection.exclusive)); | 174 expect(e.direction, equals(M.ProfileTreeDirection.exclusive)); |
| 175 e.onFilterChange.listen(expectAsync((_) { | 175 e.onFilterChange.listen(expectAsync((_) { |
| 176 expect(e.filter, equals('value')); | 176 expect(e.filter, equals('value')); |
| 177 }, count: 1)); | 177 }, count: 1)); |
| 178 var input = (e.querySelector('input') as TextInputElement); | 178 var input = (e.querySelector('input') as TextInputElement); |
| 179 input.value = 'value'; | 179 input.value = 'value'; |
| 180 input.dispatchEvent(new Event("change")); | 180 input.dispatchEvent(new Event("change")); |
| 181 e.remove(); | 181 e.remove(); |
| 182 await e.onRendered.first; | 182 await e.onRendered.first; |
| 183 }); | 183 }); |
| 184 }); | 184 }); |
| 185 } | 185 } |
| OLD | NEW |