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

Side by Side Diff: pkg/analysis_server/test/analysis/update_content_test.dart

Issue 862133006: Add tests for additional bugs fixed by r43163. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/analysis/test_all.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, 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.updateContent;
6
7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/protocol.dart';
9 import 'package:unittest/unittest.dart';
10
11 import '../analysis_abstract.dart';
12 import '../reflective_tests.dart';
13
14
15 main() {
16 groupSep = ' | ';
17 runReflectiveTests(UpdateContentTest);
18 }
19
20
21 @reflectiveTest
22 class UpdateContentTest extends AbstractAnalysisTest {
23 Map<String, List<AnalysisError>> filesErrors = {};
24
25 @override
26 void processNotification(Notification notification) {
27 if (notification.event == ANALYSIS_ERRORS) {
28 var decoded = new AnalysisErrorsParams.fromNotification(notification);
29 filesErrors[decoded.file] = decoded.errors;
30 }
31 }
32
33 test_illegal_ChangeContentOverlay() {
34 // It should be illegal to send a ChangeContentOverlay for a file that
35 // doesn't have an overlay yet.
36 createProject();
37 addTestFile('library foo;');
38 String id = 'myId';
39 try {
40 server.updateContent(id, {
41 testFile: new ChangeContentOverlay([new SourceEdit(8, 3, 'bar')])
42 });
43 fail('Expected an exception to be thrown');
44 } on RequestFailure catch (e) {
45 expect(e.response.id, id);
46 expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE);
47 }
48 }
49
50 test_multiple_contexts() {
51 resourceProvider.newFolder('/project1');
scheglov 2015/01/27 01:05:22 You don't need to do this. MemoryResourceProvider
Paul Berry 2015/01/27 01:07:19 Ok, thanks. I've removed the unnecessary code.
52 String fooPath = '/project1/foo.dart';
53 resourceProvider.newFile(fooPath, '''
54 library foo;
55 import '../project2/baz.dart';
56 main() { f(); }''');
57 resourceProvider.newFolder('/project2');
58 String barPath = '/project2/bar.dart';
59 resourceProvider.newFile(barPath, '''
60 library bar;
61 import 'baz.dart';
62 main() { f(); }''');
63 String bazPath = '/project2/baz.dart';
64 resourceProvider.newFile(bazPath, '''
65 library baz;
66 f(int i) {}
67 ''');
68 Request request = new AnalysisSetAnalysisRootsParams(
69 ['/project1', '/project2'],
70 []).toRequest('0');
71 handleSuccessfulRequest(request);
72 return waitForTasksFinished().then((_) {
73 // Files foo.dart and bar.dart should both have errors, since they both
74 // call f() with the wrong number of arguments.
75 expect(filesErrors[fooPath], hasLength(1));
76 expect(filesErrors[barPath], hasLength(1));
77 // Overlay the content of baz.dart to eliminate the errors.
78 server.updateContent('1', {
79 bazPath: new AddContentOverlay('''
80 library baz;
81 f() {}
82 ''')
83 });
84 return waitForTasksFinished();
85 }).then((_) {
86 // The overlay should have been propagated to both contexts, causing both
87 // foo.dart and bar.dart to be reanalyzed and found to be free of errors.
88 expect(filesErrors[fooPath], isEmpty);
89 expect(filesErrors[barPath], isEmpty);
90 });
91 }
92 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis/test_all.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698