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

Side by Side Diff: pkg/analysis_server/test/protocol_test.dart

Issue 176873015: update client to use channel rather than socket (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: use common json encoder Created 6 years, 10 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
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.protocol; 5 library test.protocol;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:unittest/matcher.dart'; 8 import 'package:unittest/matcher.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 main() { 11 main() {
12 group('Request', () { 12 group('Request', () {
13 test('getParameter_defined', RequestTest.getParameter_defined); 13 test('getParameter_defined', RequestTest.getParameter_defined);
14 test('getParameter_undefined', RequestTest.getParameter_undefined); 14 test('getParameter_undefined', RequestTest.getParameter_undefined);
15 test('getRequiredParameter_defined', RequestTest.getRequiredParameter_define d); 15 test('getRequiredParameter_defined', RequestTest.getRequiredParameter_define d);
16 test('getRequiredParameter_undefined', RequestTest.getRequiredParameter_unde fined); 16 test('getRequiredParameter_undefined', RequestTest.getRequiredParameter_unde fined);
17 test('toJson', RequestTest.toJson);
17 }); 18 });
18 group('Response', () { 19 group('Response', () {
19 test('create_contextDoesNotExist', ResponseTest.create_contextDoesNotExist); 20 test('create_contextDoesNotExist', ResponseTest.create_contextDoesNotExist);
20 test('create_invalidRequestFormat', ResponseTest.create_invalidRequestFormat ); 21 test('create_invalidRequestFormat', ResponseTest.create_invalidRequestFormat );
21 test('create_missingRequiredParameter', ResponseTest.create_missingRequiredP arameter); 22 test('create_missingRequiredParameter', ResponseTest.create_missingRequiredP arameter);
22 test('create_unknownRequest', ResponseTest.create_unknownRequest); 23 test('create_unknownRequest', ResponseTest.create_unknownRequest);
23 test('setResult', ResponseTest.setResult); 24 test('setResult', ResponseTest.setResult);
24 }); 25 });
25 } 26 }
26 27
(...skipping 18 matching lines...) Expand all
45 Request request = new Request('0', ''); 46 Request request = new Request('0', '');
46 request.setParameter(name, value); 47 request.setParameter(name, value);
47 expect(request.getRequiredParameter(name), equals(value)); 48 expect(request.getRequiredParameter(name), equals(value));
48 } 49 }
49 50
50 static void getRequiredParameter_undefined() { 51 static void getRequiredParameter_undefined() {
51 String name = 'name'; 52 String name = 'name';
52 Request request = new Request('0', ''); 53 Request request = new Request('0', '');
53 expect(() => request.getRequiredParameter(name), throwsA(new isInstanceOf<Re questFailure>())); 54 expect(() => request.getRequiredParameter(name), throwsA(new isInstanceOf<Re questFailure>()));
54 } 55 }
56
57 static void toJson() {
58 Request original = new Request('one', 'aMethod');
59 expect(original.toJson(), equals({
60 Request.ID: 'one',
61 Request.METHOD : 'aMethod'
62 }));
63 }
55 } 64 }
56 65
57 class ResponseTest { 66 class ResponseTest {
58 static void create_contextDoesNotExist() { 67 static void create_contextDoesNotExist() {
59 Response response = new Response.contextDoesNotExist(new Request('0', '')); 68 Response response = new Response.contextDoesNotExist(new Request('0', ''));
60 expect(response.id, equals('0')); 69 expect(response.id, equals('0'));
61 expect(response.error, isNotNull); 70 expect(response.error, isNotNull);
62 expect(response.toJson(), equals({ 71 expect(response.toJson(), equals({
63 Response.ID: '0', 72 Response.ID: '0',
64 Response.ERROR: {'code': -1, 'message': 'Context does not exist'} 73 Response.ERROR: {'code': -1, 'message': 'Context does not exist'}
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 response.setResult(resultName, resultValue); 111 response.setResult(resultName, resultValue);
103 expect(response.toJson(), equals({ 112 expect(response.toJson(), equals({
104 Response.ID: '0', 113 Response.ID: '0',
105 Response.ERROR: null, 114 Response.ERROR: null,
106 Response.RESULT: { 115 Response.RESULT: {
107 resultName: resultValue 116 resultName: resultValue
108 } 117 }
109 })); 118 }));
110 } 119 }
111 } 120 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698