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

Side by Side Diff: pkg/analysis_server/test/integration/completion/get_suggestions_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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/protocol/protocol_generated.dart'; 5 import 'package:analysis_server/protocol/protocol_generated.dart';
6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 6 import 'package:analyzer_plugin/protocol/protocol_common.dart';
7 import 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; 8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 9
10 import '../support/integration_tests.dart'; 10 import '../support/integration_tests.dart';
(...skipping 15 matching lines...) Expand all
26 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); 26 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once');
27 completionOffset = content.indexOf('^'); 27 completionOffset = content.indexOf('^');
28 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 28 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
29 int nextOffset = content.indexOf('^', completionOffset + 1); 29 int nextOffset = content.indexOf('^', completionOffset + 1);
30 expect(nextOffset, equals(-1), reason: 'too many ^'); 30 expect(nextOffset, equals(-1), reason: 'too many ^');
31 this.content = content.substring(0, completionOffset) + 31 this.content = content.substring(0, completionOffset) +
32 content.substring(completionOffset + 1); 32 content.substring(completionOffset + 1);
33 } 33 }
34 34
35 test_getSuggestions() async { 35 test_getSuggestions() async {
36 setTestSource( 36 setTestSource('test.dart', r'''
37 'test.dart',
38 r'''
39 String test = ''; 37 String test = '';
40 main() { 38 main() {
41 test.^ 39 test.^
42 } 40 }
43 '''); 41 ''');
44 writeFile(path, content); 42 writeFile(path, content);
45 await standardAnalysisSetup(); 43 await standardAnalysisSetup();
46 await analysisFinished; 44 await analysisFinished;
47 CompletionGetSuggestionsResult result = 45 CompletionGetSuggestionsResult result =
48 await sendCompletionGetSuggestions(path, completionOffset); 46 await sendCompletionGetSuggestions(path, completionOffset);
49 String completionId = result.id; 47 String completionId = result.id;
50 CompletionResultsParams param = await onCompletionResults.firstWhere( 48 CompletionResultsParams param = await onCompletionResults.firstWhere(
51 (CompletionResultsParams param) => 49 (CompletionResultsParams param) =>
52 param.id == completionId && param.isLast); 50 param.id == completionId && param.isLast);
53 expect(param.replacementOffset, completionOffset); 51 expect(param.replacementOffset, completionOffset);
54 expect(param.replacementLength, 0); 52 expect(param.replacementLength, 0);
55 param.results.firstWhere( 53 param.results.firstWhere(
56 (CompletionSuggestion suggestion) => suggestion.completion == 'length'); 54 (CompletionSuggestion suggestion) => suggestion.completion == 'length');
57 } 55 }
58 56
59 test_getSuggestions_onlyOverlay() async { 57 test_getSuggestions_onlyOverlay() async {
60 setTestSource( 58 setTestSource('test.dart', r'''
61 'test.dart',
62 r'''
63 String test = ''; 59 String test = '';
64 main() { 60 main() {
65 test.^ 61 test.^
66 } 62 }
67 '''); 63 ''');
68 // Create an overlay but do not write the file to "disk" 64 // Create an overlay but do not write the file to "disk"
69 // writeFile(pathname, text); 65 // writeFile(pathname, text);
70 await standardAnalysisSetup(); 66 await standardAnalysisSetup();
71 await sendAnalysisUpdateContent({path: new AddContentOverlay(content)}); 67 await sendAnalysisUpdateContent({path: new AddContentOverlay(content)});
72 await analysisFinished; 68 await analysisFinished;
73 CompletionGetSuggestionsResult result = 69 CompletionGetSuggestionsResult result =
74 await sendCompletionGetSuggestions(path, completionOffset); 70 await sendCompletionGetSuggestions(path, completionOffset);
75 String completionId = result.id; 71 String completionId = result.id;
76 CompletionResultsParams param = await onCompletionResults.firstWhere( 72 CompletionResultsParams param = await onCompletionResults.firstWhere(
77 (CompletionResultsParams param) => 73 (CompletionResultsParams param) =>
78 param.id == completionId && param.isLast); 74 param.id == completionId && param.isLast);
79 expect(param.replacementOffset, completionOffset); 75 expect(param.replacementOffset, completionOffset);
80 expect(param.replacementLength, 0); 76 expect(param.replacementLength, 0);
81 param.results.firstWhere( 77 param.results.firstWhere(
82 (CompletionSuggestion suggestion) => suggestion.completion == 'length'); 78 (CompletionSuggestion suggestion) => suggestion.completion == 'length');
83 } 79 }
84 80
85 test_getSuggestions_onlyOverlay_noWait() async { 81 test_getSuggestions_onlyOverlay_noWait() async {
86 setTestSource( 82 setTestSource('test.dart', r'''
87 'test.dart',
88 r'''
89 String test = ''; 83 String test = '';
90 main() { 84 main() {
91 test.^ 85 test.^
92 } 86 }
93 '''); 87 ''');
94 // Create an overlay but do not write the file to "disk" 88 // Create an overlay but do not write the file to "disk"
95 // writeFile(pathname, text); 89 // writeFile(pathname, text);
96 // Don't wait for any results except the completion notifications 90 // Don't wait for any results except the completion notifications
97 standardAnalysisSetup(subscribeStatus: false); 91 standardAnalysisSetup(subscribeStatus: false);
98 sendAnalysisUpdateContent({path: new AddContentOverlay(content)}); 92 sendAnalysisUpdateContent({path: new AddContentOverlay(content)});
(...skipping 16 matching lines...) Expand all
115 //sendAnalysisUpdateContent({path: new AddContentOverlay(content)}); 109 //sendAnalysisUpdateContent({path: new AddContentOverlay(content)});
116 var errorToken = 'exception from server'; 110 var errorToken = 'exception from server';
117 return sendCompletionGetSuggestions(path, 0).catchError((e) { 111 return sendCompletionGetSuggestions(path, 0).catchError((e) {
118 // Exception expected 112 // Exception expected
119 return errorToken; 113 return errorToken;
120 }).then((result) { 114 }).then((result) {
121 expect(result, new isInstanceOf<CompletionGetSuggestionsResult>()); 115 expect(result, new isInstanceOf<CompletionGetSuggestionsResult>());
122 }); 116 });
123 } 117 }
124 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698