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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.instrumentation;
6
7 import 'package:analyzer/instrumentation/instrumentation.dart';
8 import 'package:unittest/unittest.dart';
9 import '../reflective_tests.dart';
10
11 main() {
12 group('instrumentation', () {
13 runReflectiveTests(InstrumentationServiceTest);
14 });
15 }
16
17 @ReflectiveTestCase()
18 class InstrumentationServiceTest extends ReflectiveTestCase {
19 void assertNormal(TestInstrumentationServer server, String tag, String message ) {
20 String sent = server.normalChannel.toString();
21 if (!sent.endsWith(':$tag:$message\n')) {
22 fail('Expected "...:$tag:$message", found "$sent"');
23 }
24 }
25
26 void test_logError_withoutColon() {
27 TestInstrumentationServer server = new TestInstrumentationServer();
28 InstrumentationService service = new InstrumentationService(server);
29 String message = 'Error message';
30 service.logError(message);
31 assertNormal(server, InstrumentationService.TAG_ERROR, message);
32 }
33
34 void test_logError_withColon() {
35 TestInstrumentationServer server = new TestInstrumentationServer();
36 InstrumentationService service = new InstrumentationService(server);
37 service.logError('Error:message');
38 assertNormal(server, InstrumentationService.TAG_ERROR, 'Error::message');
39 }
40
41 void test_logException_noTrace() {
42 TestInstrumentationServer server = new TestInstrumentationServer();
43 InstrumentationService service = new InstrumentationService(server);
44 String message = 'exceptionMessage';
45 service.logException(message, null);
46 assertNormal(server, InstrumentationService.TAG_EXCEPTION, '$message:null');
47 }
48
49 void test_logNotification() {
50 TestInstrumentationServer server = new TestInstrumentationServer();
51 InstrumentationService service = new InstrumentationService(server);
52 String message = 'notificationText';
53 service.logNotification(message);
54 assertNormal(server, InstrumentationService.TAG_NOTIFICATION, message);
55 }
56
57 void test_logRequest() {
58 TestInstrumentationServer server = new TestInstrumentationServer();
59 InstrumentationService service = new InstrumentationService(server);
60 String message = 'requestText';
61 service.logRequest(message);
62 assertNormal(server, InstrumentationService.TAG_REQUEST, message);
63 }
64
65 void test_logResponse() {
66 TestInstrumentationServer server = new TestInstrumentationServer();
67 InstrumentationService service = new InstrumentationService(server);
68 String message = 'responseText';
69 service.logResponse(message);
70 assertNormal(server, InstrumentationService.TAG_RESPONSE, message);
71 }
72 }
73
74 class TestInstrumentationServer implements InstrumentationServer {
75 StringBuffer normalChannel = new StringBuffer();
76 StringBuffer priorityChannel = new StringBuffer();
77
78 @override
79 void log(String message) {
80 normalChannel.writeln(message);
81 }
82
83 @override
84 void logWithPriority(String message) {
85 priorityChannel.writeln(message);
86 }
87
88 @override
89 void shutdown() {
90 // Ignored
91 }
92 }
OLDNEW
« 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