| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.instrumentation; | 5 library analyzer.test.instrumentation.instrumentation_test; |
| 6 |
| 7 import 'dart:async'; |
| 6 | 8 |
| 7 import 'package:analyzer/instrumentation/instrumentation.dart'; | 9 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 9 | 12 |
| 10 import '../reflective_tests.dart'; | |
| 11 | |
| 12 main() { | 13 main() { |
| 13 group('instrumentation', () { | 14 group('instrumentation', () { |
| 14 runReflectiveTests(InstrumentationServiceTest); | 15 defineReflectiveTests(InstrumentationServiceTest); |
| 15 runReflectiveTests(MulticastInstrumentationServerTest); | 16 defineReflectiveTests(MulticastInstrumentationServerTest); |
| 16 }); | 17 }); |
| 17 } | 18 } |
| 18 | 19 |
| 19 @reflectiveTest | 20 @reflectiveTest |
| 20 class InstrumentationServiceTest { | 21 class InstrumentationServiceTest { |
| 21 void assertNormal( | 22 void assertNormal( |
| 22 TestInstrumentationServer server, String tag, String message) { | 23 TestInstrumentationServer server, String tag, String message) { |
| 23 String sent = server.normalChannel.toString(); | 24 String sent = server.normalChannel.toString(); |
| 24 if (!sent.endsWith(':$tag:$message\n')) { | 25 if (!sent.endsWith(':$tag:$message\n')) { |
| 25 fail('Expected "...:$tag:$message", found "$sent"'); | 26 fail('Expected "...:$tag:$message", found "$sent"'); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 fail('Expected "...$message", found "$sent"'); | 158 fail('Expected "...$message", found "$sent"'); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 | 162 |
| 162 class TestInstrumentationServer implements InstrumentationServer { | 163 class TestInstrumentationServer implements InstrumentationServer { |
| 163 StringBuffer normalChannel = new StringBuffer(); | 164 StringBuffer normalChannel = new StringBuffer(); |
| 164 StringBuffer priorityChannel = new StringBuffer(); | 165 StringBuffer priorityChannel = new StringBuffer(); |
| 165 | 166 |
| 166 @override | 167 @override |
| 168 String get sessionId => ''; |
| 169 |
| 170 @override |
| 167 void log(String message) { | 171 void log(String message) { |
| 168 normalChannel.writeln(message); | 172 normalChannel.writeln(message); |
| 169 } | 173 } |
| 170 | 174 |
| 171 @override | 175 @override |
| 172 void logWithPriority(String message) { | 176 void logWithPriority(String message) { |
| 173 priorityChannel.writeln(message); | 177 priorityChannel.writeln(message); |
| 174 } | 178 } |
| 175 | 179 |
| 176 @override | 180 @override |
| 177 void shutdown() { | 181 Future shutdown() async { |
| 178 // Ignored | 182 // Ignored |
| 179 } | 183 } |
| 180 } | 184 } |
| OLD | NEW |