Index: pkg/analysis_server/test/domain_analysis_test.dart |
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart |
index 9cb3f54e3601876960bf3ca68ce67cec96dfb5e9..5807c0c5f7cc0445bbdd900f79067ccf630edcc0 100644 |
--- a/pkg/analysis_server/test/domain_analysis_test.dart |
+++ b/pkg/analysis_server/test/domain_analysis_test.dart |
@@ -10,14 +10,14 @@ import 'package:analysis_server/src/analysis_server.dart'; |
import 'package:analysis_server/src/constants.dart'; |
import 'package:analysis_server/src/domain_analysis.dart'; |
import 'package:analysis_server/src/protocol.dart'; |
-import 'mock_sdk.dart'; |
-import 'reflective_tests.dart'; |
import 'package:analyzer/file_system/memory_file_system.dart'; |
import 'package:path/path.dart'; |
import 'package:unittest/unittest.dart'; |
import 'analysis_abstract.dart'; |
+import 'mock_sdk.dart'; |
import 'mocks.dart'; |
+import 'reflective_tests.dart'; |
main() { |
@@ -49,8 +49,8 @@ main() { |
group('setAnalysisRoots', () { |
Response testSetAnalysisRoots(List<String> included, |
List<String> excluded) { |
- Request request = new AnalysisSetAnalysisRootsParams(included, |
- excluded).toRequest('0'); |
+ Request request = |
+ new AnalysisSetAnalysisRootsParams(included, excluded).toRequest('0'); |
return handler.handleRequest(request); |
} |
@@ -93,8 +93,8 @@ main() { |
test('invalid', () { |
// TODO(paulberry): under the "eventual consistency" model this request |
// should not be invalid. |
- var request = new AnalysisSetPriorityFilesParams( |
- ['/project/lib.dart']).toRequest('0'); |
+ var request = |
+ new AnalysisSetPriorityFilesParams(['/project/lib.dart']).toRequest('0'); |
var response = handler.handleRequest(request); |
expect(response, isResponseFailure('0')); |
}); |
@@ -106,14 +106,14 @@ main() { |
resourceProvider.newFile('/p2/b.dart', 'library b;'); |
resourceProvider.newFile('/p2/c.dart', 'library c;'); |
- var setRootsRequest = new AnalysisSetAnalysisRootsParams( |
- ['/p1', '/p2'], []).toRequest('0'); |
+ var setRootsRequest = |
+ new AnalysisSetAnalysisRootsParams(['/p1', '/p2'], []).toRequest('0'); |
var setRootsResponse = handler.handleRequest(setRootsRequest); |
expect(setRootsResponse, isResponseSuccess('0')); |
void setPriorityFiles(List<String> fileList) { |
- var request = new AnalysisSetPriorityFilesParams( |
- fileList).toRequest('0'); |
+ var request = |
+ new AnalysisSetPriorityFilesParams(fileList).toRequest('0'); |
var response = handler.handleRequest(request); |
expect(response, isResponseSuccess('0')); |
// TODO(brianwilkerson) Enable the line below after getPriorityFiles |
@@ -129,9 +129,11 @@ main() { |
group('updateOptions', () { |
test('invalid', () { |
- var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, {OPTIONS: { |
- 'not-an-option': true |
- }}); |
+ var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, { |
+ OPTIONS: { |
+ 'not-an-option': true |
+ } |
+ }); |
var response = handler.handleRequest(request); |
// Invalid options should be silently ignored. |
expect(response, isResponseSuccess('0')); |
@@ -139,12 +141,14 @@ main() { |
test('null', () { |
// null is allowed as a synonym for {}. |
- var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, {OPTIONS: null}); |
+ var request = new Request('0', ANALYSIS_UPDATE_OPTIONS, { |
+ OPTIONS: null |
+ }); |
var response = handler.handleRequest(request); |
expect(response, isResponseSuccess('0')); |
}); |
- |
- // TODO(paulberry): disabled because analyzeAngular is currently not in the API. |
+ // TODO(paulberry): disabled because analyzeAngular is currently not in |
+ // the API. |
// test('valid', () { |
// engine.AnalysisOptions oldOptions = server.contextDirectoryManager.defaultOptions; |
// bool analyzeAngular = !oldOptions.analyzeAngular; |
@@ -162,6 +166,70 @@ main() { |
} |
+void test_setSubscriptions() { |
+ test('before analysis', () { |
+ AnalysisTestHelper helper = new AnalysisTestHelper(); |
+ // subscribe |
+ helper.addAnalysisSubscriptionHighlights(helper.testFile); |
+ // create project |
+ helper.createSingleFileProject('int V = 42;'); |
+ // wait, there are highlight regions |
+ helper.waitForOperationsFinished().then((_) { |
+ var highlights = helper.getHighlights(helper.testFile); |
+ expect(highlights, isNot(isEmpty)); |
+ }); |
+ }); |
+ |
+ test('after analysis', () { |
+ AnalysisTestHelper helper = new AnalysisTestHelper(); |
+ // create project |
+ helper.createSingleFileProject('int V = 42;'); |
+ // wait, no regions initially |
+ return helper.waitForOperationsFinished().then((_) { |
+ var highlights = helper.getHighlights(helper.testFile); |
+ expect(highlights, isEmpty); |
+ // subscribe |
+ helper.addAnalysisSubscriptionHighlights(helper.testFile); |
+ // wait, has regions |
+ return helper.waitForOperationsFinished().then((_) { |
+ var highlights = helper.getHighlights(helper.testFile); |
+ expect(highlights, isNot(isEmpty)); |
+ }); |
+ }); |
+ }); |
+ |
+ test('after analysis, no such file', () { |
+ AnalysisTestHelper helper = new AnalysisTestHelper(); |
+ helper.createSingleFileProject('int V = 42;'); |
+ return helper.waitForOperationsFinished().then((_) { |
+ String noFile = '/no-such-file.dart'; |
+ helper.addAnalysisSubscriptionHighlights(noFile); |
+ return helper.waitForOperationsFinished().then((_) { |
+ var highlights = helper.getHighlights(noFile); |
+ expect(highlights, isEmpty); |
+ }); |
+ }); |
+ }); |
+ |
+ test('after analysis, SDK file', () { |
+ AnalysisTestHelper helper = new AnalysisTestHelper(); |
+ helper.createSingleFileProject(''' |
+main() { |
+ print(42); |
+} |
+'''); |
+ return helper.waitForOperationsFinished().then((_) { |
+ String file = '/lib/core/core.dart'; |
+ helper.addAnalysisSubscriptionNavigation(file); |
+ return helper.waitForOperationsFinished().then((_) { |
+ var navigationRegions = helper.getNavigation(file); |
+ expect(navigationRegions, isNot(isEmpty)); |
+ }); |
+ }); |
+ }); |
+} |
+ |
+ |
testUpdateContent() { |
test('bad type', () { |
AnalysisTestHelper helper = new AnalysisTestHelper(); |
@@ -207,8 +275,9 @@ testUpdateContent() { |
// Add the file to the cache |
helper.sendContentChange(new AddContentOverlay(initialContent)); |
// update code |
- helper.sendContentChange(new ChangeContentOverlay([ |
- new SourceEdit('library '.length, 'A;'.length, 'lib')])); |
+ helper.sendContentChange( |
+ new ChangeContentOverlay( |
+ [new SourceEdit('library '.length, 'A;'.length, 'lib')])); |
// wait, there is an error |
return helper.waitForOperationsFinished().then((_) { |
List<AnalysisError> errors = helper.getTestErrors(); |
@@ -269,10 +338,12 @@ testUpdateContent() { |
return helper.waitForOperationsFinished().then((_) { |
ChangeContentOverlay contentChange = new ChangeContentOverlay([edit]); |
Request request = new AnalysisUpdateContentParams({ |
- helper.testFile: contentChange}).toRequest('0'); |
+ helper.testFile: contentChange |
+ }).toRequest('0'); |
Response response = helper.handler.handleRequest(request); |
- expect(response, isResponseFailure('0', |
- RequestErrorCode.INVALID_OVERLAY_CHANGE)); |
+ expect( |
+ response, |
+ isResponseFailure('0', RequestErrorCode.INVALID_OVERLAY_CHANGE)); |
}); |
}); |
} |
@@ -292,70 +363,6 @@ testUpdateContent() { |
} |
-void test_setSubscriptions() { |
- test('before analysis', () { |
- AnalysisTestHelper helper = new AnalysisTestHelper(); |
- // subscribe |
- helper.addAnalysisSubscriptionHighlights(helper.testFile); |
- // create project |
- helper.createSingleFileProject('int V = 42;'); |
- // wait, there are highlight regions |
- helper.waitForOperationsFinished().then((_) { |
- var highlights = helper.getHighlights(helper.testFile); |
- expect(highlights, isNot(isEmpty)); |
- }); |
- }); |
- |
- test('after analysis', () { |
- AnalysisTestHelper helper = new AnalysisTestHelper(); |
- // create project |
- helper.createSingleFileProject('int V = 42;'); |
- // wait, no regions initially |
- return helper.waitForOperationsFinished().then((_) { |
- var highlights = helper.getHighlights(helper.testFile); |
- expect(highlights, isEmpty); |
- // subscribe |
- helper.addAnalysisSubscriptionHighlights(helper.testFile); |
- // wait, has regions |
- return helper.waitForOperationsFinished().then((_) { |
- var highlights = helper.getHighlights(helper.testFile); |
- expect(highlights, isNot(isEmpty)); |
- }); |
- }); |
- }); |
- |
- test('after analysis, no such file', () { |
- AnalysisTestHelper helper = new AnalysisTestHelper(); |
- helper.createSingleFileProject('int V = 42;'); |
- return helper.waitForOperationsFinished().then((_) { |
- String noFile = '/no-such-file.dart'; |
- helper.addAnalysisSubscriptionHighlights(noFile); |
- return helper.waitForOperationsFinished().then((_) { |
- var highlights = helper.getHighlights(noFile); |
- expect(highlights, isEmpty); |
- }); |
- }); |
- }); |
- |
- test('after analysis, SDK file', () { |
- AnalysisTestHelper helper = new AnalysisTestHelper(); |
- helper.createSingleFileProject(''' |
-main() { |
- print(42); |
-} |
-'''); |
- return helper.waitForOperationsFinished().then((_) { |
- String file = '/lib/core/core.dart'; |
- helper.addAnalysisSubscriptionNavigation(file); |
- return helper.waitForOperationsFinished().then((_) { |
- var navigationRegions = helper.getNavigation(file); |
- expect(navigationRegions, isNot(isEmpty)); |
- }); |
- }); |
- }); |
-} |
- |
- |
int _getSafeInt(Map<String, Object> json, String key, int defaultValue) { |
Object value = json[key]; |
if (value is int) { |
@@ -416,8 +423,8 @@ f(A a) { |
library lib_a; |
class A {} |
'''); |
- packageMapProvider.packageMap['pkgA'] = [ |
- resourceProvider.getResource('/packages/pkgA')]; |
+ packageMapProvider.packageMap['pkgA'] = |
+ [resourceProvider.getResource('/packages/pkgA')]; |
addTestFile(''' |
import 'package:pkgA/libA.dart'; |
main(A a) { |
@@ -472,11 +479,13 @@ class AnalysisTestHelper { |
filesErrors[decoded.file] = decoded.errors; |
} |
if (notification.event == ANALYSIS_HIGHLIGHTS) { |
- var params = new AnalysisHighlightsParams.fromNotification(notification); |
+ var params = |
+ new AnalysisHighlightsParams.fromNotification(notification); |
filesHighlights[params.file] = params.regions; |
} |
if (notification.event == ANALYSIS_NAVIGATION) { |
- var params = new AnalysisNavigationParams.fromNotification(notification); |
+ var params = |
+ new AnalysisNavigationParams.fromNotification(notification); |
filesNavigation[params.file] = params.regions; |
} |
}); |
@@ -491,8 +500,8 @@ class AnalysisTestHelper { |
} |
files.add(file); |
// set subscriptions |
- Request request = new AnalysisSetSubscriptionsParams( |
- analysisSubscriptions).toRequest('0'); |
+ Request request = |
+ new AnalysisSetSubscriptionsParams(analysisSubscriptions).toRequest('0'); |
handleSuccessfulRequest(request); |
} |
@@ -509,8 +518,8 @@ class AnalysisTestHelper { |
*/ |
void createEmptyProject() { |
resourceProvider.newFolder('/project'); |
- Request request = new AnalysisSetAnalysisRootsParams(['/project'], |
- []).toRequest('0'); |
+ Request request = |
+ new AnalysisSetAnalysisRootsParams(['/project'], []).toRequest('0'); |
handleSuccessfulRequest(request); |
} |
@@ -522,8 +531,8 @@ class AnalysisTestHelper { |
this.testCode = _getCodeString(code); |
resourceProvider.newFolder('/project'); |
resourceProvider.newFile(testFile, testCode); |
- Request request = new AnalysisSetAnalysisRootsParams(['/project'], |
- []).toRequest('0'); |
+ Request request = |
+ new AnalysisSetAnalysisRootsParams(['/project'], []).toRequest('0'); |
handleSuccessfulRequest(request); |
} |
@@ -610,7 +619,8 @@ class AnalysisTestHelper { |
*/ |
void sendContentChange(dynamic contentChange) { |
Request request = new AnalysisUpdateContentParams({ |
- testFile: contentChange}).toRequest('0'); |
+ testFile: contentChange |
+ }).toRequest('0'); |
handleSuccessfulRequest(request); |
} |