OLD | NEW |
(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.set_priority_files; |
| 6 |
| 7 import 'package:analysis_server/src/domain_analysis.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart'; |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import '../analysis_abstract.dart'; |
| 13 import '../mocks.dart'; |
| 14 import '../utils.dart'; |
| 15 |
| 16 main() { |
| 17 initializeTestEnvironment(); |
| 18 defineReflectiveTests(SetPriorityFilesTest); |
| 19 } |
| 20 |
| 21 @reflectiveTest |
| 22 class SetPriorityFilesTest extends AbstractAnalysisTest { |
| 23 @override |
| 24 void setUp() { |
| 25 super.setUp(); |
| 26 server.handlers = [new AnalysisDomainHandler(server),]; |
| 27 createProject(); |
| 28 } |
| 29 |
| 30 test_fileDoesNotExist() async { |
| 31 String file = '$projectPath/doesNotExist.dart'; |
| 32 Response response = await _setPriorityFile(file); |
| 33 expect(response, isResponseSuccess('0')); |
| 34 } |
| 35 |
| 36 test_fileInAnalysisRoot() async { |
| 37 addTestFile(''); |
| 38 Response response = await _setPriorityFile(testFile); |
| 39 expect(response, isResponseSuccess('0')); |
| 40 } |
| 41 |
| 42 test_fileInSdk() async { |
| 43 addTestFile(''); |
| 44 await server.onAnalysisComplete; |
| 45 Response response = await _setPriorityFile('/lib/convert/convert.dart'); |
| 46 expect(response, isResponseSuccess('0')); |
| 47 } |
| 48 |
| 49 test_fileNotInAnalysisRoot() async { |
| 50 String path = '/other/file.dart'; |
| 51 addFile(path, ''); |
| 52 Response response = await _setPriorityFile(path); |
| 53 expect(response.error, isNotNull); |
| 54 expect(response.error.code, RequestErrorCode.UNANALYZED_PRIORITY_FILES); |
| 55 } |
| 56 |
| 57 _setPriorityFile(String file) async { |
| 58 Request request = |
| 59 new AnalysisSetPriorityFilesParams(<String>[file]).toRequest('0'); |
| 60 return await serverChannel.sendRequest(request); |
| 61 } |
| 62 } |
OLD | NEW |