OLD | NEW |
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.timing.simple; | 5 library test.timing.simple; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 f(C c) { | 74 f(C c) { |
75 return c; | 75 return c; |
76 } | 76 } |
77 '''; | 77 '''; |
78 cursorOffset = originalContent.indexOf('c;') + 1; | 78 cursorOffset = originalContent.indexOf('c;') + 1; |
79 writeFile(mainFilePath, originalContent); | 79 writeFile(mainFilePath, originalContent); |
80 }); | 80 }); |
81 } | 81 } |
82 | 82 |
83 @override | 83 @override |
| 84 Future perform() { |
| 85 sendAnalysisUpdateContent({ |
| 86 mainFilePath: new ChangeContentOverlay( |
| 87 [new SourceEdit(cursorOffset, 0, '.')]) |
| 88 }); |
| 89 sendCompletionGetSuggestions(mainFilePath, cursorOffset + 1); |
| 90 return completionReceived.future; |
| 91 } |
| 92 |
| 93 @override |
84 Future setUp() { | 94 Future setUp() { |
85 completionReceived = new Completer(); | 95 completionReceived = new Completer(); |
86 onCompletionResults.listen((_) { | 96 onCompletionResults.listen((_) { |
87 // We only care about the time to the first response. | 97 // We only care about the time to the first response. |
88 if (!completionReceived.isCompleted) { | 98 if (!completionReceived.isCompleted) { |
89 completionReceived.complete(); | 99 completionReceived.complete(); |
90 } | 100 } |
91 }); | 101 }); |
92 sendAnalysisSetAnalysisRoots([dirname(mainFilePath)], []); | 102 sendAnalysisSetAnalysisRoots([dirname(mainFilePath)], []); |
93 sendAnalysisUpdateContent({ | 103 sendAnalysisUpdateContent({ |
94 mainFilePath: new AddContentOverlay(originalContent) | 104 mainFilePath: new AddContentOverlay(originalContent) |
95 }); | 105 }); |
96 return new Future.value(); | 106 return new Future.value(); |
97 } | 107 } |
98 | 108 |
99 @override | 109 @override |
100 Future perform() { | |
101 sendAnalysisUpdateContent({ | |
102 mainFilePath: new ChangeContentOverlay( | |
103 [new SourceEdit(cursorOffset, 0, '.')]) | |
104 }); | |
105 sendCompletionGetSuggestions(mainFilePath, cursorOffset + 1); | |
106 return completionReceived.future; | |
107 } | |
108 | |
109 @override | |
110 Future tearDown() { | 110 Future tearDown() { |
111 sendAnalysisSetAnalysisRoots([], []); | 111 sendAnalysisSetAnalysisRoots([], []); |
112 return new Future.value(); | 112 return new Future.value(); |
113 } | 113 } |
114 } | 114 } |
OLD | NEW |