Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: pkg/analyzer/test/instrumentation/instrumentation_test.dart

Issue 835213002: Escape field separator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/instrumentation/instrumentation_test.dart
diff --git a/pkg/analyzer/test/instrumentation/instrumentation_test.dart b/pkg/analyzer/test/instrumentation/instrumentation_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..332531817362963ffc775498455fb633fe6e5ec8
--- /dev/null
+++ b/pkg/analyzer/test/instrumentation/instrumentation_test.dart
@@ -0,0 +1,92 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.instrumentation;
+
+import 'package:analyzer/instrumentation/instrumentation.dart';
+import 'package:unittest/unittest.dart';
+import '../reflective_tests.dart';
+
+main() {
+ group('instrumentation', () {
+ runReflectiveTests(InstrumentationServiceTest);
+ });
+}
+
+@ReflectiveTestCase()
+class InstrumentationServiceTest extends ReflectiveTestCase {
+ void assertNormal(TestInstrumentationServer server, String tag, String message) {
+ String sent = server.normalChannel.toString();
+ if (!sent.endsWith(':$tag:$message\n')) {
+ fail('Expected "...:$tag:$message", found "$sent"');
+ }
+ }
+
+ void test_logError_withoutColon() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ String message = 'Error message';
+ service.logError(message);
+ assertNormal(server, InstrumentationService.TAG_ERROR, message);
+ }
+
+ void test_logError_withColon() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ service.logError('Error:message');
+ assertNormal(server, InstrumentationService.TAG_ERROR, 'Error::message');
+ }
+
+ void test_logException_noTrace() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ String message = 'exceptionMessage';
+ service.logException(message, null);
+ assertNormal(server, InstrumentationService.TAG_EXCEPTION, '$message:null');
+ }
+
+ void test_logNotification() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ String message = 'notificationText';
+ service.logNotification(message);
+ assertNormal(server, InstrumentationService.TAG_NOTIFICATION, message);
+ }
+
+ void test_logRequest() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ String message = 'requestText';
+ service.logRequest(message);
+ assertNormal(server, InstrumentationService.TAG_REQUEST, message);
+ }
+
+ void test_logResponse() {
+ TestInstrumentationServer server = new TestInstrumentationServer();
+ InstrumentationService service = new InstrumentationService(server);
+ String message = 'responseText';
+ service.logResponse(message);
+ assertNormal(server, InstrumentationService.TAG_RESPONSE, message);
+ }
+}
+
+class TestInstrumentationServer implements InstrumentationServer {
+ StringBuffer normalChannel = new StringBuffer();
+ StringBuffer priorityChannel = new StringBuffer();
+
+ @override
+ void log(String message) {
+ normalChannel.writeln(message);
+ }
+
+ @override
+ void logWithPriority(String message) {
+ priorityChannel.writeln(message);
+ }
+
+ @override
+ void shutdown() {
+ // Ignored
+ }
+}
« no previous file with comments | « pkg/analyzer/lib/instrumentation/instrumentation.dart ('k') | pkg/analyzer/test/instrumentation/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698