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

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

Issue 299513003: improve analysis server notifications (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove analysis.complete notification Created 6 years, 7 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/domain_server.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.analysis_server; 5 library test.analysis_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 MockAnalysisContext context = new MockAnalysisContext(); 58 MockAnalysisContext context = new MockAnalysisContext();
59 server.addContextToWorkQueue(context); 59 server.addContextToWorkQueue(context);
60 // Pump the event queue to make sure the server doesn't try to do any 60 // Pump the event queue to make sure the server doesn't try to do any
61 // analysis. 61 // analysis.
62 return pumpEventQueue(); 62 return pumpEventQueue();
63 } 63 }
64 64
65 static Future addContextToWorkQueue_whenRunning() { 65 static Future addContextToWorkQueue_whenRunning() {
66 MockAnalysisContext context = new MockAnalysisContext(); 66 MockAnalysisContext context = new MockAnalysisContext();
67 server.addContextToWorkQueue(context); 67 server.addContextToWorkQueue(context);
68 server.contextIdMap[context] = 'context-27';
68 MockSource source = new MockSource(); 69 MockSource source = new MockSource();
69 source.when(callsTo('get encoding')).alwaysReturn('foo.dart'); 70 source.when(callsTo('get encoding')).alwaysReturn('foo.dart');
70 ChangeNoticeImpl changeNoticeImpl = new ChangeNoticeImpl(source); 71 ChangeNoticeImpl changeNoticeImpl = new ChangeNoticeImpl(source);
71 LineInfo lineInfo = new LineInfo([0]); 72 LineInfo lineInfo = new LineInfo([0]);
72 AnalysisError analysisError = new AnalysisError.con1(source, 73 AnalysisError analysisError = new AnalysisError.con1(source,
73 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER, ['Foo']); 74 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER, ['Foo']);
74 changeNoticeImpl.setErrors([analysisError], lineInfo); 75 changeNoticeImpl.setErrors([analysisError], lineInfo);
75 context.when(callsTo('performAnalysisTask')).thenReturn( 76 context.when(callsTo('performAnalysisTask')).thenReturn(
76 new AnalysisResult([changeNoticeImpl], 0, 'myClass', 0)); 77 new AnalysisResult([changeNoticeImpl], 0, 'myClass', 0));
77 context.when(callsTo('performAnalysisTask')).thenReturn( 78 context.when(callsTo('performAnalysisTask')).thenReturn(
78 new AnalysisResult(null, 0, null, 0)); 79 new AnalysisResult(null, 0, null, 0));
79 return pumpEventQueue().then((_) { 80 return pumpEventQueue().then((_) {
80 context.getLogs(callsTo('performAnalysisTask')).verify(happenedExactly(2)) ; 81 context.getLogs(callsTo('performAnalysisTask')).verify(happenedExactly(2)) ;
81 expect(channel.notificationsReceived, hasLength(2)); 82 var notifications = channel.notificationsReceived;
82 expect(channel.notificationsReceived[0].event, equals('server.connected') 83 expect(notifications, hasLength(2));
83 ); 84 expect(notifications[0].event, equals('server.connected'));
84 expect(channel.notificationsReceived[1].event, equals('context.errors')); 85 expect(notifications[1].event, equals('context.errors'));
85 expect(channel.notificationsReceived[1].params['source'], equals( 86 expect(notifications[1].params['source'], equals('foo.dart'));
86 'foo.dart')); 87 expect(notifications[1].params['contextId'], equals('context-27'));
87 List<AnalysisError> errors = 88 List<AnalysisError> errors = notifications[1].params['errors'];
88 channel.notificationsReceived[1].params['errors'];
89 expect(errors, hasLength(1)); 89 expect(errors, hasLength(1));
90 expect(errors[0], equals(AnalysisServer.errorToJson(analysisError))); 90 expect(errors[0], equals(AnalysisServer.errorToJson(analysisError)));
91 }); 91 });
92 } 92 }
93 93
94 static Future addContextToWorkQueue_twice() { 94 static Future addContextToWorkQueue_twice() {
95 // The context should only be asked to perform its analysis task once. 95 // The context should only be asked to perform its analysis task once.
96 MockAnalysisContext context = new MockAnalysisContext(); 96 MockAnalysisContext context = new MockAnalysisContext();
97 server.addContextToWorkQueue(context); 97 server.addContextToWorkQueue(context);
98 server.addContextToWorkQueue(context); 98 server.addContextToWorkQueue(context);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 @override 206 @override
207 Response handleRequest(Request request) { 207 Response handleRequest(Request request) {
208 if (request.method == 'echo') { 208 if (request.method == 'echo') {
209 var response = new Response(request.id); 209 var response = new Response(request.id);
210 response.setResult('echo', true); 210 response.setResult('echo', true);
211 return response; 211 return response;
212 } 212 }
213 return null; 213 return null;
214 } 214 }
215 } 215 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698