| 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.domain.completion; | 5 library test.domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 @override | 109 @override |
| 110 void setUp() { | 110 void setUp() { |
| 111 super.setUp(); | 111 super.setUp(); |
| 112 createProject(); | 112 createProject(); |
| 113 handler = new CompletionDomainHandler(server); | 113 handler = new CompletionDomainHandler(server); |
| 114 } | 114 } |
| 115 | 115 |
| 116 test_suggestions_html() { | 116 test_html() { |
| 117 testFile = '/project/web/test.html'; | 117 testFile = '/project/web/test.html'; |
| 118 addTestFile(''' | 118 addTestFile(''' |
| 119 <html>^</html> | 119 <html>^</html> |
| 120 '''); | 120 '''); |
| 121 return getSuggestions().then((_) { | 121 return getSuggestions().then((_) { |
| 122 expect(replacementOffset, equals(completionOffset)); | 122 expect(replacementOffset, equals(completionOffset)); |
| 123 expect(replacementLength, equals(0)); | 123 expect(replacementLength, equals(0)); |
| 124 expect(suggestions, hasLength(0)); | 124 expect(suggestions, hasLength(0)); |
| 125 }); | 125 }); |
| 126 } | 126 } |
| 127 | 127 |
| 128 test_suggestions_importedType() { | 128 test_imports() { |
| 129 addTestFile(''' | 129 addTestFile(''' |
| 130 import 'dart:html'; | 130 import 'dart:html'; |
| 131 main() {^} | 131 main() {^} |
| 132 '''); | 132 '''); |
| 133 return getSuggestions().then((_) { | 133 return getSuggestions().then((_) { |
| 134 expect(replacementOffset, equals(completionOffset)); | 134 expect(replacementOffset, equals(completionOffset)); |
| 135 expect(replacementLength, equals(0)); | 135 expect(replacementLength, equals(0)); |
| 136 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 136 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 137 assertHasResult(CompletionSuggestionKind.CLASS, 'HtmlElement'); | 137 assertHasResult(CompletionSuggestionKind.CLASS, 'HtmlElement'); |
| 138 assertNoResult('test'); | 138 assertNoResult('test'); |
| 139 }); | 139 }); |
| 140 } | 140 } |
| 141 | 141 |
| 142 test_suggestions_topLevel() { | 142 test_locals() { |
| 143 addTestFile('class A {var a; x() {var b;^}}'); |
| 144 return getSuggestions().then((_) { |
| 145 expect(replacementOffset, equals(completionOffset)); |
| 146 expect(replacementLength, equals(0)); |
| 147 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); |
| 148 assertHasResult(CompletionSuggestionKind.FIELD, 'a'); |
| 149 assertHasResult(CompletionSuggestionKind.VARIABLE, 'b'); |
| 150 assertHasResult(CompletionSuggestionKind.METHOD_NAME, 'x'); |
| 151 }); |
| 152 } |
| 153 |
| 154 test_topLevel() { |
| 143 addTestFile(''' | 155 addTestFile(''' |
| 144 typedef foo(); | 156 typedef foo(); |
| 145 var test = ''; | 157 var test = ''; |
| 146 main() {tes^t} | 158 main() {tes^t} |
| 147 '''); | 159 '''); |
| 148 return getSuggestions().then((_) { | 160 return getSuggestions().then((_) { |
| 149 // expect(replacementOffset, equals(completionOffset - 3)); | 161 // expect(replacementOffset, equals(completionOffset - 3)); |
| 150 // expect(replacementLength, equals(4)); | 162 // expect(replacementLength, equals(4)); |
| 151 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 163 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 152 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); | 164 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); |
| 153 assertNoResult('HtmlElement'); | 165 assertNoResult('HtmlElement'); |
| 154 }); | 166 }); |
| 155 } | 167 } |
| 156 } | 168 } |
| OLD | NEW |