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

Side by Side Diff: pkg/analysis_services/test/completion/completion_computer_test.dart

Issue 440343003: incremental improvement to top level code completion results (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 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.services.completion.suggestion; 5 library test.services.completion.suggestion;
6 6
7 import 'dart:async';
8
7 import 'package:analysis_services/completion/completion_computer.dart'; 9 import 'package:analysis_services/completion/completion_computer.dart';
8 import 'package:analysis_testing/reflective_tests.dart'; 10 import 'package:analysis_testing/reflective_tests.dart';
9 import 'package:analyzer/src/generated/source.dart'; 11 import 'package:analyzer/src/generated/source.dart';
10 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
11 13
12 import 'completion_test_util.dart'; 14 import 'completion_test_util.dart';
13 import 'dart:async';
14 15
15 main() { 16 main() {
16 groupSep = ' | '; 17 groupSep = ' | ';
17 runReflectiveTests(CompletionManagerTest); 18 runReflectiveTests(CompletionManagerTest);
18 runReflectiveTests(DartCompletionManagerTest); 19 runReflectiveTests(DartCompletionManagerTest);
19 } 20 }
20 21
21 @ReflectiveTestCase() 22 @ReflectiveTestCase()
22 class CompletionManagerTest extends AbstractCompletionTest { 23 class CompletionManagerTest extends AbstractCompletionTest {
23 24
24 test_dart() { 25 test_dart() {
25 Source source = addSource('/does/not/exist.dart', ''); 26 Source source = addSource('/does/not/exist.dart', '');
26 var manager = CompletionManager.create(source, 0, null); 27 var manager = CompletionManager.create(context, source, 0, null);
27 expect(manager.runtimeType, DartCompletionManager); 28 expect(manager.runtimeType, DartCompletionManager);
28 } 29 }
29 30
30 test_html() { 31 test_html() {
31 Source source = addSource('/does/not/exist.html', ''); 32 Source source = addSource('/does/not/exist.html', '');
32 var manager = CompletionManager.create(source, 0, null); 33 var manager = CompletionManager.create(context, source, 0, null);
34 expect(manager.runtimeType, NoOpCompletionManager);
35 }
36
37 test_null_context() {
38 Source source = addSource('/does/not/exist.dart', '');
39 var manager = CompletionManager.create(null, source, 0, null);
33 expect(manager.runtimeType, NoOpCompletionManager); 40 expect(manager.runtimeType, NoOpCompletionManager);
34 } 41 }
35 42
36 test_other() { 43 test_other() {
37 Source source = addSource('/does/not/exist.foo', ''); 44 Source source = addSource('/does/not/exist.foo', '');
38 var manager = CompletionManager.create(source, 0, null); 45 var manager = CompletionManager.create(context, source, 0, null);
39 expect(manager.runtimeType, NoOpCompletionManager); 46 expect(manager.runtimeType, NoOpCompletionManager);
40 } 47 }
41 } 48 }
42 49
43 @ReflectiveTestCase() 50 @ReflectiveTestCase()
44 class DartCompletionManagerTest extends AbstractCompletionTest { 51 class DartCompletionManagerTest extends AbstractCompletionTest {
45 52
46 /// Assert that the list contains exactly one of the given type 53 /// Assert that the list contains exactly one of the given type
47 void assertContainsType(List computers, Type type) { 54 void assertContainsType(List computers, Type type) {
48 int count = 0; 55 int count = 0;
49 computers.forEach((c) { 56 computers.forEach((c) {
50 if (c.runtimeType == type) { 57 if (c.runtimeType == type) {
51 ++count; 58 ++count;
52 } 59 }
53 }); 60 });
54 if (count != 1) { 61 if (count != 1) {
55 var msg = new StringBuffer(); 62 var msg = new StringBuffer();
56 msg.writeln('Expected $type, but found:'); 63 msg.writeln('Expected $type, but found:');
57 computers.forEach((c) { 64 computers.forEach((c) {
58 msg.writeln(' ${c.runtimeType}'); 65 msg.writeln(' ${c.runtimeType}');
59 }); 66 });
60 fail(msg.toString()); 67 fail(msg.toString());
61 } 68 }
62 } 69 }
63 70
64 test_topLevel() { 71 test_topLevel() {
65 Source source = addSource('/does/not/exist.dart', ''); 72 Source source = addSource('/does/not/exist.dart', '');
66 var manager = new DartCompletionManager(source, 0, searchEngine); 73 var manager = new DartCompletionManager(context, source, 0, searchEngine);
67 bool anyResult; 74 bool anyResult;
68 manager.results().forEach((_) { 75 manager.results().forEach((_) {
69 anyResult = true; 76 anyResult = true;
70 }); 77 });
71 return new Future.delayed(Duration.ZERO, () { 78 return new Future.delayed(Duration.ZERO, () {
72 expect(anyResult, isTrue); 79 expect(anyResult, isTrue);
73 }); 80 });
74 } 81 }
75 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698