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

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

Issue 849863002: Replace @ReflectiveTestCase() with @reflectiveTest. (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
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 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 12
13 import 'reflective_tests.dart'; 13 import 'reflective_tests.dart';
14 14
15 15
16 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); 16 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>());
17 17
18 18
19 main() { 19 main() {
20 groupSep = ' | '; 20 groupSep = ' | ';
21 runReflectiveTests(NotificationTest); 21 runReflectiveTests(NotificationTest);
22 runReflectiveTests(RequestTest); 22 runReflectiveTests(RequestTest);
23 runReflectiveTests(RequestErrorTest); 23 runReflectiveTests(RequestErrorTest);
24 runReflectiveTests(ResponseTest); 24 runReflectiveTests(ResponseTest);
25 } 25 }
26 26
27 27
28 @ReflectiveTestCase() 28 @reflectiveTest
29 class InvalidParameterResponseMatcher extends Matcher { 29 class InvalidParameterResponseMatcher extends Matcher {
30 static const String ERROR_CODE = 'INVALID_PARAMETER'; 30 static const String ERROR_CODE = 'INVALID_PARAMETER';
31 31
32 @override 32 @override
33 Description describe(Description description) => 33 Description describe(Description description) =>
34 description.add("an 'invalid parameter' response (code $ERROR_CODE)"); 34 description.add("an 'invalid parameter' response (code $ERROR_CODE)");
35 35
36 @override 36 @override
37 bool matches(item, Map matchState) { 37 bool matches(item, Map matchState) {
38 if (item is! RequestFailure) { 38 if (item is! RequestFailure) {
39 return false; 39 return false;
40 } 40 }
41 var response = item.response; 41 var response = item.response;
42 if (response is! Response) { 42 if (response is! Response) {
43 return false; 43 return false;
44 } 44 }
45 if (response.error is! RequestError) { 45 if (response.error is! RequestError) {
46 return false; 46 return false;
47 } 47 }
48 RequestError requestError = response.error; 48 RequestError requestError = response.error;
49 if (requestError.code != ERROR_CODE) { 49 if (requestError.code != ERROR_CODE) {
50 return false; 50 return false;
51 } 51 }
52 return true; 52 return true;
53 } 53 }
54 } 54 }
55 55
56 56
57 @ReflectiveTestCase() 57 @reflectiveTest
58 class NotificationTest { 58 class NotificationTest {
59 void test_fromJson() { 59 void test_fromJson() {
60 Notification original = new Notification('foo'); 60 Notification original = new Notification('foo');
61 Notification notification = new Notification.fromJson(original.toJson()); 61 Notification notification = new Notification.fromJson(original.toJson());
62 expect(notification.event, equals('foo')); 62 expect(notification.event, equals('foo'));
63 expect(notification.toJson().keys, isNot(contains('params'))); 63 expect(notification.toJson().keys, isNot(contains('params')));
64 } 64 }
65 65
66 void test_fromJson_withParams() { 66 void test_fromJson_withParams() {
67 Notification original = new Notification('foo', { 67 Notification original = new Notification('foo', {
(...skipping 26 matching lines...) Expand all
94 expect(notification.toJson(), equals({ 94 expect(notification.toJson(), equals({
95 'event': 'foo', 95 'event': 'foo',
96 'params': { 96 'params': {
97 'x': 'y' 97 'x': 'y'
98 } 98 }
99 })); 99 }));
100 } 100 }
101 } 101 }
102 102
103 103
104 @ReflectiveTestCase() 104 @reflectiveTest
105 class RequestErrorTest { 105 class RequestErrorTest {
106 void test_create() { 106 void test_create() {
107 RequestError error = 107 RequestError error =
108 new RequestError(RequestErrorCode.INVALID_REQUEST, 'msg'); 108 new RequestError(RequestErrorCode.INVALID_REQUEST, 'msg');
109 expect(error.code, RequestErrorCode.INVALID_REQUEST); 109 expect(error.code, RequestErrorCode.INVALID_REQUEST);
110 expect(error.message, "msg"); 110 expect(error.message, "msg");
111 expect(error.toJson(), equals({ 111 expect(error.toJson(), equals({
112 CODE: 'INVALID_REQUEST', 112 CODE: 'INVALID_REQUEST',
113 MESSAGE: "msg" 113 MESSAGE: "msg"
114 })); 114 }));
(...skipping 19 matching lines...) Expand all
134 new RequestError(RequestErrorCode.UNKNOWN_REQUEST, 'msg', stackTrace: tr ace); 134 new RequestError(RequestErrorCode.UNKNOWN_REQUEST, 'msg', stackTrace: tr ace);
135 expect(error.toJson(), { 135 expect(error.toJson(), {
136 CODE: 'UNKNOWN_REQUEST', 136 CODE: 'UNKNOWN_REQUEST',
137 MESSAGE: 'msg', 137 MESSAGE: 'msg',
138 STACK_TRACE: trace 138 STACK_TRACE: trace
139 }); 139 });
140 } 140 }
141 } 141 }
142 142
143 143
144 @ReflectiveTestCase() 144 @reflectiveTest
145 class RequestTest { 145 class RequestTest {
146 void test_fromJson() { 146 void test_fromJson() {
147 Request original = new Request('one', 'aMethod'); 147 Request original = new Request('one', 'aMethod');
148 String json = JSON.encode(original.toJson()); 148 String json = JSON.encode(original.toJson());
149 Request request = new Request.fromString(json); 149 Request request = new Request.fromString(json);
150 expect(request.id, equals('one')); 150 expect(request.id, equals('one'));
151 expect(request.method, equals('aMethod')); 151 expect(request.method, equals('aMethod'));
152 } 152 }
153 153
154 void test_fromJson_invalidId() { 154 void test_fromJson_invalidId() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 Request.ID: 'one', 200 Request.ID: 'one',
201 Request.METHOD: 'aMethod', 201 Request.METHOD: 'aMethod',
202 Request.PARAMS: { 202 Request.PARAMS: {
203 'foo': 'bar' 203 'foo': 'bar'
204 } 204 }
205 })); 205 }));
206 } 206 }
207 } 207 }
208 208
209 209
210 @ReflectiveTestCase() 210 @reflectiveTest
211 class ResponseTest { 211 class ResponseTest {
212 void test_create_invalidRequestFormat() { 212 void test_create_invalidRequestFormat() {
213 Response response = new Response.invalidRequestFormat(); 213 Response response = new Response.invalidRequestFormat();
214 expect(response.id, equals('')); 214 expect(response.id, equals(''));
215 expect(response.error, isNotNull); 215 expect(response.error, isNotNull);
216 expect(response.toJson(), equals({ 216 expect(response.toJson(), equals({
217 Response.ID: '', 217 Response.ID: '',
218 Response.ERROR: { 218 Response.ERROR: {
219 'code': 'INVALID_REQUEST', 219 'code': 'INVALID_REQUEST',
220 'message': 'Invalid request' 220 'message': 'Invalid request'
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 Response original = new Response('myId', result: { 269 Response original = new Response('myId', result: {
270 'foo': 'bar' 270 'foo': 'bar'
271 }); 271 });
272 Response response = new Response.fromJson(original.toJson()); 272 Response response = new Response.fromJson(original.toJson());
273 expect(response.id, equals('myId')); 273 expect(response.id, equals('myId'));
274 Map<String, Object> result = response.toJson()['result']; 274 Map<String, Object> result = response.toJson()['result'];
275 expect(result.length, equals(1)); 275 expect(result.length, equals(1));
276 expect(result['foo'], equals('bar')); 276 expect(result['foo'], equals('bar'));
277 } 277 }
278 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698