| OLD | NEW |
| 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.domain.context; | 5 library test.domain.context; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/domain_context.dart'; | 12 import 'package:analysis_server/src/domain_context.dart'; |
| 12 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analysis_server/src/resource.dart'; | 14 import 'package:analysis_server/src/resource.dart'; |
| 14 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 15 | 16 |
| 16 import 'mocks.dart'; | 17 import 'mocks.dart'; |
| 17 | 18 |
| 18 main() { | 19 main() { |
| 19 group('ContextDomainHandlerTest', () { | 20 group('ContextDomainHandlerTest', () { |
| 20 // TODO(scheglov) remove or move to the 'analysis' domain | 21 // TODO(scheglov) remove or move to the 'analysis' domain |
| (...skipping 30 matching lines...) Expand all Loading... |
| 51 // expect(server.contextWorkQueue, hasLength(1)); | 52 // expect(server.contextWorkQueue, hasLength(1)); |
| 52 // expect(response.toJson(), equals({ | 53 // expect(response.toJson(), equals({ |
| 53 // Response.ID: '0' | 54 // Response.ID: '0' |
| 54 // })); | 55 // })); |
| 55 // } | 56 // } |
| 56 | 57 |
| 57 static void createChangeSet() { | 58 static void createChangeSet() { |
| 58 AnalysisServer server = new AnalysisServer( | 59 AnalysisServer server = new AnalysisServer( |
| 59 new MockServerChannel(), | 60 new MockServerChannel(), |
| 60 PhysicalResourceProvider.INSTANCE); | 61 PhysicalResourceProvider.INSTANCE); |
| 61 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); | 62 Request request = new Request('0', APPLY_CHANGES_NAME); |
| 62 ContextDomainHandler handler = new ContextDomainHandler(server); | 63 ContextDomainHandler handler = new ContextDomainHandler(server); |
| 63 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); | 64 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 64 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, | 65 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, |
| 65 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, { | 66 new RequestDatum(request, CHANGES_PARAM, { |
| 66 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'], | 67 ADDED: ['ffile:/one.dart'], |
| 67 ContextDomainHandler.MODIFIED_PARAM: [], | 68 MODIFIED_PARAM: [], |
| 68 ContextDomainHandler.REMOVED_PARAM: ['ffile:/two.dart', | 69 REMOVED: ['ffile:/two.dart', 'ffile:/three.dart'] |
| 69 'ffile:/three.dart'] | |
| 70 })); | 70 })); |
| 71 expect(changeSet.addedSources, hasLength(equals(1))); | 71 expect(changeSet.addedSources, hasLength(equals(1))); |
| 72 expect(changeSet.changedSources, hasLength(equals(0))); | 72 expect(changeSet.changedSources, hasLength(equals(0))); |
| 73 expect(changeSet.removedSources, hasLength(equals(2))); | 73 expect(changeSet.removedSources, hasLength(equals(2))); |
| 74 } | 74 } |
| 75 | 75 |
| 76 static void createChangeSet_onlyAdded() { | 76 static void createChangeSet_onlyAdded() { |
| 77 AnalysisServer server = new AnalysisServer( | 77 AnalysisServer server = new AnalysisServer( |
| 78 new MockServerChannel(), | 78 new MockServerChannel(), |
| 79 PhysicalResourceProvider.INSTANCE); | 79 PhysicalResourceProvider.INSTANCE); |
| 80 Request request = new Request('0', ContextDomainHandler.APPLY_CHANGES_NAME); | 80 Request request = new Request('0', APPLY_CHANGES_NAME); |
| 81 ContextDomainHandler handler = new ContextDomainHandler(server); | 81 ContextDomainHandler handler = new ContextDomainHandler(server); |
| 82 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); | 82 SourceFactory sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 83 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, | 83 ChangeSet changeSet = handler.createChangeSet(request, sourceFactory, |
| 84 new RequestDatum(request, ContextDomainHandler.CHANGES_PARAM, { | 84 new RequestDatum(request, CHANGES_PARAM, { |
| 85 ContextDomainHandler.ADDED_PARAM: ['ffile:/one.dart'], | 85 ADDED: ['ffile:/one.dart'], |
| 86 })); | 86 })); |
| 87 expect(changeSet.addedSources, hasLength(equals(1))); | 87 expect(changeSet.addedSources, hasLength(equals(1))); |
| 88 expect(changeSet.changedSources, hasLength(equals(0))); | 88 expect(changeSet.changedSources, hasLength(equals(0))); |
| 89 expect(changeSet.removedSources, hasLength(equals(0))); | 89 expect(changeSet.removedSources, hasLength(equals(0))); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // TODO(scheglov) remove or move to the 'analysis' domain | 92 // TODO(scheglov) remove or move to the 'analysis' domain |
| 93 // static void setOptions() { | 93 // static void setOptions() { |
| 94 // AnalysisServer server = new AnalysisServer(new MockServerChannel()); | 94 // AnalysisServer server = new AnalysisServer(new MockServerChannel()); |
| 95 // String contextId = _createContext(server); | 95 // String contextId = _createContext(server); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METH
OD); | 145 // Request request = new Request('0', ServerDomainHandler.CREATE_CONTEXT_METH
OD); |
| 146 // request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath); | 146 // request.setParameter(ServerDomainHandler.SDK_DIRECTORY_PARAM, sdkPath); |
| 147 // request.setParameter(AnalysisServer.CONTEXT_ID_PARAM, contextId); | 147 // request.setParameter(AnalysisServer.CONTEXT_ID_PARAM, contextId); |
| 148 // Response response = handler.handleRequest(request); | 148 // Response response = handler.handleRequest(request); |
| 149 // if (response.error != null) { | 149 // if (response.error != null) { |
| 150 // fail('Unexpected error: ${response.error.toJson()}'); | 150 // fail('Unexpected error: ${response.error.toJson()}'); |
| 151 // } | 151 // } |
| 152 // return contextId; | 152 // return contextId; |
| 153 // } | 153 // } |
| 154 } | 154 } |
| OLD | NEW |