Index: pkg/analysis_server/test/analysis/set_priority_files_test.dart |
diff --git a/pkg/analysis_server/test/analysis/set_priority_files_test.dart b/pkg/analysis_server/test/analysis/set_priority_files_test.dart |
index 8f09dfd4a56abbbd5f9212023eb4c7f305e33526..f25b9a7f672a6e71a6f34d1b3391cf509d70aa8f 100644 |
--- a/pkg/analysis_server/test/analysis/set_priority_files_test.dart |
+++ b/pkg/analysis_server/test/analysis/set_priority_files_test.dart |
@@ -5,9 +5,7 @@ |
import 'package:analysis_server/protocol/protocol.dart'; |
import 'package:analysis_server/protocol/protocol_generated.dart'; |
import 'package:analysis_server/src/domain_analysis.dart'; |
-import 'package:analyzer/src/generated/engine.dart' |
- show InternalAnalysisContext; |
-import 'package:analyzer/src/generated/source.dart'; |
+import 'package:analyzer/src/dart/analysis/driver.dart'; |
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; |
import 'package:test/test.dart'; |
import 'package:test_reflective_loader/test_reflective_loader.dart'; |
@@ -24,9 +22,6 @@ main() { |
@reflectiveTest |
class SetPriorityFilesTest extends AbstractAnalysisTest { |
@override |
- bool get enableNewAnalysisDriver => false; |
- |
- @override |
void setUp() { |
super.setUp(); |
server.handlers = [ |
@@ -43,38 +38,28 @@ class SetPriorityFilesTest extends AbstractAnalysisTest { |
test_fileInAnalysisRoot() async { |
addTestFile(''); |
- // wait for analysis to ensure that the file is known to the context |
- await server.onAnalysisComplete; |
// set priority files |
Response response = await _setPriorityFile(testFile); |
expect(response, isResponseSuccess('0')); |
// verify |
- InternalAnalysisContext context = server.getContainingContext(testFile); |
- List<Source> prioritySources = context.prioritySources; |
- expect(prioritySources, hasLength(1)); |
- expect(prioritySources.first.fullName, testFile); |
+ _verifyPriorityFiles(testFile); |
} |
test_fileInSdk() async { |
addTestFile(''); |
- await server.onAnalysisComplete; |
// set priority files |
String filePath = '/lib/convert/convert.dart'; |
Response response = await _setPriorityFile(filePath); |
expect(response, isResponseSuccess('0')); |
// verify |
- InternalAnalysisContext sdkContext = server.findSdk().context; |
- List<Source> prioritySources = sdkContext.prioritySources; |
- expect(prioritySources, hasLength(1)); |
- expect(prioritySources.first.fullName, filePath); |
+ _verifyPriorityFiles(filePath); |
} |
test_fileNotInAnalysisRoot() async { |
String path = '/other/file.dart'; |
addFile(path, ''); |
- Response response = await _setPriorityFile(path); |
- expect(response.error, isNotNull); |
- expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); |
+ await _setPriorityFile(path); |
+ _verifyPriorityFiles(path); |
} |
test_ignoredInAnalysisOptions() async { |
@@ -88,9 +73,8 @@ analyzer: |
'''); |
addFile(sampleFile, ''); |
// attempt to set priority file |
- Response response = await _setPriorityFile(sampleFile); |
- expect(response.error, isNotNull); |
- expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); |
+ await _setPriorityFile(sampleFile); |
+ _verifyPriorityFiles(sampleFile); |
} |
test_ignoredInAnalysisOptions_inChildContext() async { |
@@ -106,9 +90,8 @@ analyzer: |
'''); |
addFile(sampleFile, ''); |
// attempt to set priority file |
- Response response = await _setPriorityFile(sampleFile); |
- expect(response.error, isNotNull); |
- expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); |
+ await _setPriorityFile(sampleFile); |
+ _verifyPriorityFiles(sampleFile); |
} |
test_ignoredInAnalysisOptions_inRootContext() async { |
@@ -124,15 +107,12 @@ analyzer: |
'''); |
addFile(sampleFile, ''); |
// attempt to set priority file |
- Response response = await _setPriorityFile(sampleFile); |
- expect(response.error, isNotNull); |
- expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); |
+ await _setPriorityFile(sampleFile); |
+ _verifyPriorityFiles(sampleFile); |
} |
test_sentToPlugins() async { |
addTestFile(''); |
- // wait for analysis to ensure that the file is known to the context |
- await server.onAnalysisComplete; |
// set priority files |
Response response = await _setPriorityFile(testFile); |
expect(response, isResponseSuccess('0')); |
@@ -148,4 +128,11 @@ analyzer: |
new AnalysisSetPriorityFilesParams(<String>[file]).toRequest('0'); |
return await serverChannel.sendRequest(request); |
} |
+ |
+ void _verifyPriorityFiles(String path) { |
+ AnalysisDriver driver = server.getAnalysisDriver(path); |
+ List<String> prioritySources = driver.priorityFiles; |
+ expect(prioritySources, hasLength(1)); |
scheglov
2017/06/12 21:07:40
It could be just expect(driver.priorityFiles, [pat
Brian Wilkerson
2017/06/12 21:09:49
Done
|
+ expect(prioritySources.first, path); |
+ } |
} |