Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: pkg/analysis_server/test/analysis/update_content_test.dart

Issue 1042923002: Issue 22617. Add/remove overlay-only sources to their containing contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/analysis/update_content_test.dart
diff --git a/pkg/analysis_server/test/analysis/update_content_test.dart b/pkg/analysis_server/test/analysis/update_content_test.dart
index 694b9e2834269291b815ec2199ad27f1693dbf9e..226b6c1196bb2d1129bd1bd4e871915e1c10632a 100644
--- a/pkg/analysis_server/test/analysis/update_content_test.dart
+++ b/pkg/analysis_server/test/analysis/update_content_test.dart
@@ -7,7 +7,10 @@ library test.analysis.updateContent;
import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
import 'package:analysis_server/src/services/index/index.dart';
+import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/ast.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/source.dart';
import 'package:typed_mock/typed_mock.dart';
import 'package:unittest/unittest.dart';
@@ -104,7 +107,7 @@ class UpdateContentTest extends AbstractAnalysisTest {
verify(server.index.indexUnit(anyObject, testUnitMatcher)).times(2);
}
- test_multiple_contexts() {
+ test_multiple_contexts() async {
String fooPath = '/project1/foo.dart';
resourceProvider.newFile(fooPath, '''
library foo;
@@ -123,7 +126,8 @@ f(int i) {}
Request request = new AnalysisSetAnalysisRootsParams(
['/project1', '/project2'], []).toRequest('0');
handleSuccessfulRequest(request);
- return waitForTasksFinished().then((_) {
+ {
+ await server.onAnalysisComplete;
// Files foo.dart and bar.dart should both have errors, since they both
// call f() with the wrong number of arguments.
expect(filesErrors[fooPath], hasLength(1));
@@ -135,13 +139,42 @@ library baz;
f() {}
''')
});
- return waitForTasksFinished();
- }).then((_) {
+ }
+ {
+ await server.onAnalysisComplete;
// The overlay should have been propagated to both contexts, causing both
// foo.dart and bar.dart to be reanalyzed and found to be free of errors.
expect(filesErrors[fooPath], isEmpty);
expect(filesErrors[barPath], isEmpty);
- });
+ }
+ }
+
+ test_overlayOnly() async {
+ String filePath = '/User/project1/test.dart';
+ Folder folder1 = resourceProvider.newFolder('/User/project1');
+ Folder folder2 = resourceProvider.newFolder('/User/project2');
+ Request request = new AnalysisSetAnalysisRootsParams(
+ [folder1.path, folder2.path], []).toRequest('0');
+ handleSuccessfulRequest(request);
+ // exactly 2 contexts
+ expect(server.folderMap, hasLength(2));
+ AnalysisContext context1 = server.folderMap[folder1];
+ AnalysisContext context2 = server.folderMap[folder2];
+ // no sources
+ expect(_getUserSources(context1), isEmpty);
+ expect(_getUserSources(context2), isEmpty);
+ // add an overlay - new Source in context1
+ server.updateContent('1', {filePath: new AddContentOverlay('')});
+ {
+ List<Source> sources = _getUserSources(context1);
+ expect(sources, hasLength(1));
+ expect(sources[0].fullName, filePath);
+ }
+ expect(_getUserSources(context2), isEmpty);
+ // remove the overlay - no sources
+ server.updateContent('2', {filePath: new RemoveContentOverlay()});
+ expect(_getUserSources(context1), isEmpty);
+ expect(_getUserSources(context2), isEmpty);
}
test_sendNoticesAfterNopChange() async {
@@ -180,6 +213,16 @@ f() {}
// errors should have been resent
expect(filesErrors, isNotEmpty);
}
+
+ List<Source> _getUserSources(AnalysisContext context) {
+ List<Source> sources = <Source>[];
+ context.sources.forEach((source) {
+ if (source.fullName.startsWith('/User/')) {
+ sources.add(source);
+ }
+ });
+ return sources;
+ }
}
class _ArgumentMatcher_CompilationUnit extends ArgumentMatcher {
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698