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

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

Issue 621383002: Change integration test send...() methods to use structured objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reintroduce type checking of server responses Created 6 years, 2 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
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 library test.integration.analysis.update.content; 5 library test.integration.analysis.update.content;
6 6
7 import '../../reflective_tests.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart';
10 import '../integration_tests.dart'; 11 import '../integration_tests.dart';
11 12
12 @ReflectiveTestCase() 13 @ReflectiveTestCase()
13 class Test extends AbstractAnalysisServerIntegrationTest { 14 class Test extends AbstractAnalysisServerIntegrationTest {
14 test_updateContent() { 15 test_updateContent() {
15 String pathname = sourcePath('test.dart'); 16 String pathname = sourcePath('test.dart');
16 String goodText = r''' 17 String goodText = r'''
17 main() { 18 main() {
18 print("Hello, world!"); 19 print("Hello, world!");
19 }'''; 20 }''';
20 String badText = goodText.replaceAll(';', ''); 21 String badText = goodText.replaceAll(';', '');
21 writeFile(pathname, badText); 22 writeFile(pathname, badText);
22 standardAnalysisSetup(); 23 standardAnalysisSetup();
23 return analysisFinished.then((_) { 24 return analysisFinished.then((_) {
24 // The contents on disk (badText) are missing a semicolon. 25 // The contents on disk (badText) are missing a semicolon.
25 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); 26 expect(currentAnalysisErrors[pathname], isNot(isEmpty));
26 }).then((_) => sendAnalysisUpdateContent({ 27 }).then((_) => sendAnalysisUpdateContent({
27 pathname: { 28 pathname: new AddContentOverlay(goodText)
28 'type': 'add',
29 'content': goodText
30 }
31 })).then((result) => analysisFinished).then((_) { 29 })).then((result) => analysisFinished).then((_) {
32 // There should be no errors now because the contents on disk have been 30 // There should be no errors now because the contents on disk have been
33 // overriden with goodText. 31 // overriden with goodText.
34 expect(currentAnalysisErrors[pathname], isEmpty); 32 expect(currentAnalysisErrors[pathname], isEmpty);
35 return sendAnalysisUpdateContent({ 33 return sendAnalysisUpdateContent({
36 pathname: { 34 pathname: new ChangeContentOverlay(
37 'type': 'change', 35 [new SourceEdit(goodText.indexOf(';'), 1, '')])
38 'edits': [{
39 'offset': goodText.indexOf(';'),
40 'length': 1,
41 'replacement': ''
42 }]
43 }
44 }); 36 });
45 }).then((result) => analysisFinished).then((_) { 37 }).then((result) => analysisFinished).then((_) {
46 // There should be errors now because we've removed the semicolon. 38 // There should be errors now because we've removed the semicolon.
47 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); 39 expect(currentAnalysisErrors[pathname], isNot(isEmpty));
48 return sendAnalysisUpdateContent({ 40 return sendAnalysisUpdateContent({
49 pathname: { 41 pathname: new ChangeContentOverlay(
50 'type': 'change', 42 [new SourceEdit(goodText.indexOf(';'), 0, ';')])
51 'edits': [{
52 'offset': goodText.indexOf(';'),
53 'length': 0,
54 'replacement': ';'
55 }]
56 }
57 }); 43 });
58 }).then((result) => analysisFinished).then((_) { 44 }).then((result) => analysisFinished).then((_) {
59 // There should be no errors now because we've added the semicolon back. 45 // There should be no errors now because we've added the semicolon back.
60 expect(currentAnalysisErrors[pathname], isEmpty); 46 expect(currentAnalysisErrors[pathname], isEmpty);
61 return sendAnalysisUpdateContent({ 47 return sendAnalysisUpdateContent({
62 pathname: { 48 pathname: new RemoveContentOverlay()
63 'type': 'remove'
64 }
65 }); 49 });
66 }).then((result) => analysisFinished).then((_) { 50 }).then((result) => analysisFinished).then((_) {
67 // Now there should be errors again, because the contents on disk are no 51 // Now there should be errors again, because the contents on disk are no
68 // longer overridden. 52 // longer overridden.
69 expect(currentAnalysisErrors[pathname], isNot(isEmpty)); 53 expect(currentAnalysisErrors[pathname], isNot(isEmpty));
70 }); 54 });
71 } 55 }
72 } 56 }
73 57
74 main() { 58 main() {
75 runReflectiveTests(Test); 59 runReflectiveTests(Test);
76 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698