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

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

Issue 2567113003: Send errors notification without delay. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:analysis_server/plugin/protocol/protocol.dart'; 5 import 'package:analysis_server/plugin/protocol/protocol.dart';
6 import 'package:test/test.dart'; 6 import 'package:test/test.dart';
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; 7 import 'package:test_reflective_loader/test_reflective_loader.dart';
8 8
9 import '../integration_tests.dart'; 9 import '../integration_tests.dart';
10 10
11 main() { 11 main() {
12 defineReflectiveSuite(() { 12 defineReflectiveSuite(() {
13 defineReflectiveTests(UpdateContentTest); 13 defineReflectiveTests(UpdateContentTest);
14 defineReflectiveTests(UpdateContentTest_Driver); 14 defineReflectiveTests(UpdateContentTest_Driver);
15 }); 15 });
16 } 16 }
17 17
18 class AbstractUpdateContentTest extends AbstractAnalysisServerIntegrationTest { 18 class AbstractUpdateContentTest extends AbstractAnalysisServerIntegrationTest {
19 test_updateContent() { 19 test_updateContent() async {
20 String pathname = sourcePath('test.dart'); 20 String path = sourcePath('test.dart');
21 String goodText = r''' 21 String goodText = r'''
22 main() { 22 main() {
23 print("Hello, world!"); 23 print("Hello, world!");
24 }'''; 24 }''';
25
25 String badText = goodText.replaceAll(';', ''); 26 String badText = goodText.replaceAll(';', '');
26 writeFile(pathname, badText); 27 writeFile(path, badText);
27 standardAnalysisSetup(); 28 standardAnalysisSetup();
28 return analysisFinished 29
29 .then((_) { 30 // The contents on disk (badText) are missing a semicolon.
30 // The contents on disk (badText) are missing a semicolon. 31 await analysisFinished;
31 expect(currentAnalysisErrors[pathname], isNotEmpty); 32 expect(currentAnalysisErrors[path], isNotEmpty);
32 }) 33
33 .then((_) => sendAnalysisUpdateContent( 34 // There should be no errors now because the contents on disk have been
34 {pathname: new AddContentOverlay(goodText)})) 35 // overridden with goodText.
35 .then((result) => analysisFinished) 36 sendAnalysisUpdateContent({path: new AddContentOverlay(goodText)});
36 .then((_) { 37 await analysisFinished;
37 // There should be no errors now because the contents on disk have bee n 38 expect(currentAnalysisErrors[path], isEmpty);
38 // overridden with goodText. 39
39 expect(currentAnalysisErrors[pathname], isEmpty); 40 // There should be errors now because we've removed the semicolon.
40 return sendAnalysisUpdateContent({ 41 sendAnalysisUpdateContent({
41 pathname: new ChangeContentOverlay( 42 path: new ChangeContentOverlay(
42 [new SourceEdit(goodText.indexOf(';'), 1, '')]) 43 [new SourceEdit(goodText.indexOf(';'), 1, '')])
43 }); 44 });
44 }) 45 await analysisFinished;
45 .then((result) => analysisFinished) 46 expect(currentAnalysisErrors[path], isNotEmpty);
46 .then((_) { 47
47 // There should be errors now because we've removed the semicolon. 48 // There should be no errors now because we've added the semicolon back.
48 expect(currentAnalysisErrors[pathname], isNotEmpty); 49 sendAnalysisUpdateContent({
49 return sendAnalysisUpdateContent({ 50 path: new ChangeContentOverlay(
50 pathname: new ChangeContentOverlay( 51 [new SourceEdit(goodText.indexOf(';'), 0, ';')])
51 [new SourceEdit(goodText.indexOf(';'), 0, ';')]) 52 });
52 }); 53 await analysisFinished;
53 }) 54 expect(currentAnalysisErrors[path], isEmpty);
54 .then((result) => analysisFinished) 55
55 .then((_) { 56 // Now there should be errors again, because the contents on disk are no
56 // There should be no errors now because we've added the semicolon bac k. 57 // longer overridden.
57 expect(currentAnalysisErrors[pathname], isEmpty); 58 sendAnalysisUpdateContent({path: new RemoveContentOverlay()});
58 return sendAnalysisUpdateContent( 59 await analysisFinished;
59 {pathname: new RemoveContentOverlay()}); 60 expect(currentAnalysisErrors[path], isNotEmpty);
60 })
61 .then((result) => analysisFinished)
62 .then((_) {
63 // Now there should be errors again, because the contents on disk are no
64 // longer overridden.
65 expect(currentAnalysisErrors[pathname], isNotEmpty);
66 });
67 } 61 }
68 } 62 }
69 63
70 @reflectiveTest 64 @reflectiveTest
71 class UpdateContentTest extends AbstractUpdateContentTest {} 65 class UpdateContentTest extends AbstractUpdateContentTest {}
72 66
73 @reflectiveTest 67 @reflectiveTest
74 class UpdateContentTest_Driver extends AbstractUpdateContentTest { 68 class UpdateContentTest_Driver extends AbstractUpdateContentTest {
75 @override 69 @override
76 bool get enableNewAnalysisDriver => true; 70 bool get enableNewAnalysisDriver => true;
77
78 @failingTest
79 test_updateContent() {
80 // Expected: non-empty
81 // Actual: []
82 return super.test_updateContent();
83 }
84 } 71 }
OLDNEW
« 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