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

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

Issue 196993003: add sdkPath and enable tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 9 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.analysis_server;
6
7 import 'dart:async';
8
9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/domain_server.dart';
11 import 'package:analysis_server/src/protocol.dart';
12 import 'package:unittest/matcher.dart';
13 import 'package:unittest/unittest.dart';
14
15 import 'mocks.dart';
16
17 main(List<String> args) {
18 group('AnalysisServer', () {
19 setUp(AnalysisServerTest.setUp);
20 // test('createContext', AnalysisServerTest.createContext);
21 test('echo', AnalysisServerTest.echo);
22 test('shutdown', AnalysisServerTest.shutdown);
23 test('unknownRequest', AnalysisServerTest.unknownRequest);
24 });
25 }
26
27 class AnalysisServerTest {
28 static MockServerChannel channel;
29 static AnalysisServer server;
30
31 static void setUp() {
32 channel = new MockServerChannel();
33 server = new AnalysisServer(channel);
34 }
35
36 static Future createContext() {
37 server.handlers = [new ServerDomainHandler(server)];
38 var request = new Request('my27', ServerDomainHandler.CREATE_CONTEXT_METHOD) ;
39 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath);
40 return channel.sendRequest(request)
41 .timeout(new Duration(seconds: 1))
42 .then((Response response) {
43 expect(response.id, equals('my27'));
44 expect(response.error, isNull);
45 var contextId = response.result[ServerDomainHandler.CONTEXT_ID_RESULT] ;
46 expect(contextId is String, isTrue);
47 });
48 }
49
50 static Future echo() {
51 server.handlers = [new EchoHandler()];
52 var request = new Request('my22', 'echo');
53 return channel.sendRequest(request)
54 .timeout(new Duration(seconds: 1))
55 .then((Response response) {
56 expect(response.id, equals('my22'));
57 expect(response.error, isNull);
58 });
59 }
60
61 static Future shutdown() {
62 server.handlers = [new ServerDomainHandler(server)];
63 var request = new Request('my28', ServerDomainHandler.SHUTDOWN_METHOD);
64 request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, '');
65 return channel.sendRequest(request)
66 .timeout(new Duration(seconds: 1))
67 .then((Response response) {
68 expect(response.id, equals('my28'));
69 expect(response.error, isNull);
70 });
71 }
72
73 static Future unknownRequest() {
74 server.handlers = [new EchoHandler()];
75 var request = new Request('my22', 'randomRequest');
76 return channel.sendRequest(request)
77 .timeout(new Duration(seconds: 1))
78 .then((Response response) {
79 expect(response.id, equals('my22'));
80 expect(response.error, isNotNull);
81 });
82 }
83 }
84
85
86 class EchoHandler implements RequestHandler {
87 @override
88 Response handleRequest(Request request) {
89 if (request.method == 'echo') {
90 var response = new Response(request.id);
91 response.setResult('echo', true);
92 return response;
93 }
94 return null;
95 }
96 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_context.dart ('k') | pkg/analysis_server/test/domain_context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698