| 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.completion; | 5 library test.domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/domain_completion.dart'; | 11 import 'package:analysis_server/src/domain_completion.dart'; |
| 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 13 import 'package:analysis_server/src/services/index/index.dart' show Index; | 13 import 'package:analysis_server/src/services/index/index.dart' show Index; |
| 14 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 14 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 16 | 16 |
| 17 import 'analysis_abstract.dart'; | 17 import 'analysis_abstract.dart'; |
| 18 import 'mocks.dart'; | 18 import 'mocks.dart'; |
| 19 | 19 |
| 20 class AbstractCompletionDomainTest extends AbstractAnalysisTest { | 20 class AbstractCompletionDomainTest extends AbstractAnalysisTest { |
| 21 String completionId; | 21 String completionId; |
| 22 int completionOffset; | 22 int completionOffset; |
| 23 int replacementOffset; | 23 int replacementOffset; |
| 24 int replacementLength; | 24 int replacementLength; |
| 25 List<CompletionSuggestion> suggestions = []; | 25 List<CompletionSuggestion> suggestions = []; |
| 26 bool suggestionsDone = false; | 26 bool suggestionsDone = false; |
| 27 Map<String,List<CompletionSuggestion>> allSuggestions = {}; |
| 27 | 28 |
| 28 String addTestFile(String content, {int offset}) { | 29 String addTestFile(String content, {int offset}) { |
| 29 completionOffset = content.indexOf('^'); | 30 completionOffset = content.indexOf('^'); |
| 30 if (offset != null) { | 31 if (offset != null) { |
| 31 expect(completionOffset, -1, reason: 'cannot supply offset and ^'); | 32 expect(completionOffset, -1, reason: 'cannot supply offset and ^'); |
| 32 completionOffset = offset; | 33 completionOffset = offset; |
| 33 return super.addTestFile(content); | 34 return super.addTestFile(content); |
| 34 } | 35 } |
| 35 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | 36 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); |
| 36 int nextOffset = content.indexOf('^', completionOffset + 1); | 37 int nextOffset = content.indexOf('^', completionOffset + 1); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 String id = params.id; | 103 String id = params.id; |
| 103 assertValidId(id); | 104 assertValidId(id); |
| 104 if (id == completionId) { | 105 if (id == completionId) { |
| 105 expect(suggestionsDone, isFalse); | 106 expect(suggestionsDone, isFalse); |
| 106 replacementOffset = params.replacementOffset; | 107 replacementOffset = params.replacementOffset; |
| 107 replacementLength = params.replacementLength; | 108 replacementLength = params.replacementLength; |
| 108 suggestionsDone = params.isLast; | 109 suggestionsDone = params.isLast; |
| 109 expect(suggestionsDone, isNotNull); | 110 expect(suggestionsDone, isNotNull); |
| 110 suggestions = params.results; | 111 suggestions = params.results; |
| 111 } | 112 } |
| 113 allSuggestions[id] = params.results; |
| 112 } else if (notification.event == SERVER_ERROR) { | 114 } else if (notification.event == SERVER_ERROR) { |
| 113 fail('server error: ${notification.toJson()}'); | 115 fail('server error: ${notification.toJson()}'); |
| 114 } | 116 } |
| 115 } | 117 } |
| 116 | 118 |
| 117 @override | 119 @override |
| 118 void setUp() { | 120 void setUp() { |
| 119 super.setUp(); | 121 super.setUp(); |
| 120 createProject(); | 122 createProject(); |
| 121 handler = new CompletionDomainHandler(server); | 123 handler = new CompletionDomainHandler(server); |
| 122 } | 124 } |
| 123 } | 125 } |
| OLD | NEW |