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

Side by Side Diff: pkg/analysis_server/test/services/correction/util_test.dart

Issue 2614033003: Make subclasses of AbstractContextTest asynchronous. (Closed)
Patch Set: Created 3 years, 11 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.correction.util; 5 library test.services.correction.util;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/services/correction/strings.dart'; 8 import 'package:analysis_server/src/services/correction/strings.dart';
9 import 'package:analysis_server/src/services/correction/util.dart'; 9 import 'package:analysis_server/src/services/correction/util.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
11 import 'package:test/test.dart'; 11 import 'package:test/test.dart';
12 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
13 13
14 import '../../abstract_single_unit.dart'; 14 import '../../abstract_single_unit.dart';
15 15
16 main() { 16 main() {
17 defineReflectiveSuite(() { 17 defineReflectiveSuite(() {
18 defineReflectiveTests(UtilTest); 18 defineReflectiveTests(UtilTest);
19 }); 19 });
20 } 20 }
21 21
22 @reflectiveTest 22 @reflectiveTest
23 class UtilTest extends AbstractSingleUnitTest { 23 class UtilTest extends AbstractSingleUnitTest {
24 test_addLibraryImports_dart_hasImports_between() { 24 test_addLibraryImports_dart_hasImports_between() async {
25 resolveTestUnit(''' 25 await resolveTestUnit('''
26 import 'dart:async'; 26 import 'dart:async';
27 import 'dart:math'; 27 import 'dart:math';
28 '''); 28 ''');
29 Source newLibrary = _getDartSource('dart:collection'); 29 Source newLibrary = _getDartSource('dart:collection');
30 _assertAddLibraryImport( 30 _assertAddLibraryImport(
31 <Source>[newLibrary], 31 <Source>[newLibrary],
32 ''' 32 '''
33 import 'dart:async'; 33 import 'dart:async';
34 import 'dart:collection'; 34 import 'dart:collection';
35 import 'dart:math'; 35 import 'dart:math';
36 '''); 36 ''');
37 } 37 }
38 38
39 test_addLibraryImports_dart_hasImports_first() { 39 test_addLibraryImports_dart_hasImports_first() async {
40 resolveTestUnit(''' 40 await resolveTestUnit('''
41 import 'dart:collection'; 41 import 'dart:collection';
42 import 'dart:math'; 42 import 'dart:math';
43 '''); 43 ''');
44 Source newLibrary = _getDartSource('dart:async'); 44 Source newLibrary = _getDartSource('dart:async');
45 _assertAddLibraryImport( 45 _assertAddLibraryImport(
46 <Source>[newLibrary], 46 <Source>[newLibrary],
47 ''' 47 '''
48 import 'dart:async'; 48 import 'dart:async';
49 import 'dart:collection'; 49 import 'dart:collection';
50 import 'dart:math'; 50 import 'dart:math';
51 '''); 51 ''');
52 } 52 }
53 53
54 test_addLibraryImports_dart_hasImports_last() { 54 test_addLibraryImports_dart_hasImports_last() async {
55 resolveTestUnit(''' 55 await resolveTestUnit('''
56 import 'dart:async'; 56 import 'dart:async';
57 import 'dart:collection'; 57 import 'dart:collection';
58 '''); 58 ''');
59 Source newLibrary = _getDartSource('dart:math'); 59 Source newLibrary = _getDartSource('dart:math');
60 _assertAddLibraryImport( 60 _assertAddLibraryImport(
61 <Source>[newLibrary], 61 <Source>[newLibrary],
62 ''' 62 '''
63 import 'dart:async'; 63 import 'dart:async';
64 import 'dart:collection'; 64 import 'dart:collection';
65 import 'dart:math'; 65 import 'dart:math';
66 '''); 66 ''');
67 } 67 }
68 68
69 test_addLibraryImports_dart_hasImports_multiple() { 69 test_addLibraryImports_dart_hasImports_multiple() async {
70 resolveTestUnit(''' 70 await resolveTestUnit('''
71 import 'dart:collection'; 71 import 'dart:collection';
72 import 'dart:math'; 72 import 'dart:math';
73 '''); 73 ''');
74 Source newLibrary1 = _getDartSource('dart:async'); 74 Source newLibrary1 = _getDartSource('dart:async');
75 Source newLibrary2 = _getDartSource('dart:html'); 75 Source newLibrary2 = _getDartSource('dart:html');
76 _assertAddLibraryImport( 76 _assertAddLibraryImport(
77 <Source>[newLibrary1, newLibrary2], 77 <Source>[newLibrary1, newLibrary2],
78 ''' 78 '''
79 import 'dart:async'; 79 import 'dart:async';
80 import 'dart:collection'; 80 import 'dart:collection';
81 import 'dart:html'; 81 import 'dart:html';
82 import 'dart:math'; 82 import 'dart:math';
83 '''); 83 ''');
84 } 84 }
85 85
86 test_addLibraryImports_dart_hasImports_multiple_first() { 86 test_addLibraryImports_dart_hasImports_multiple_first() async {
87 resolveTestUnit(''' 87 await resolveTestUnit('''
88 import 'dart:html'; 88 import 'dart:html';
89 import 'dart:math'; 89 import 'dart:math';
90 '''); 90 ''');
91 Source newLibrary1 = _getDartSource('dart:async'); 91 Source newLibrary1 = _getDartSource('dart:async');
92 Source newLibrary2 = _getDartSource('dart:collection'); 92 Source newLibrary2 = _getDartSource('dart:collection');
93 _assertAddLibraryImport( 93 _assertAddLibraryImport(
94 <Source>[newLibrary1, newLibrary2], 94 <Source>[newLibrary1, newLibrary2],
95 ''' 95 '''
96 import 'dart:async'; 96 import 'dart:async';
97 import 'dart:collection'; 97 import 'dart:collection';
98 import 'dart:html'; 98 import 'dart:html';
99 import 'dart:math'; 99 import 'dart:math';
100 '''); 100 ''');
101 } 101 }
102 102
103 test_addLibraryImports_dart_hasImports_multiple_last() { 103 test_addLibraryImports_dart_hasImports_multiple_last() async {
104 resolveTestUnit(''' 104 await resolveTestUnit('''
105 import 'dart:async'; 105 import 'dart:async';
106 import 'dart:collection'; 106 import 'dart:collection';
107 '''); 107 ''');
108 Source newLibrary1 = _getDartSource('dart:html'); 108 Source newLibrary1 = _getDartSource('dart:html');
109 Source newLibrary2 = _getDartSource('dart:math'); 109 Source newLibrary2 = _getDartSource('dart:math');
110 _assertAddLibraryImport( 110 _assertAddLibraryImport(
111 <Source>[newLibrary1, newLibrary2], 111 <Source>[newLibrary1, newLibrary2],
112 ''' 112 '''
113 import 'dart:async'; 113 import 'dart:async';
114 import 'dart:collection'; 114 import 'dart:collection';
115 import 'dart:html'; 115 import 'dart:html';
116 import 'dart:math'; 116 import 'dart:math';
117 '''); 117 ''');
118 } 118 }
119 119
120 test_addLibraryImports_dart_hasLibraryDirective() { 120 test_addLibraryImports_dart_hasLibraryDirective() async {
121 resolveTestUnit(''' 121 await resolveTestUnit('''
122 library test; 122 library test;
123 123
124 class A {} 124 class A {}
125 '''); 125 ''');
126 Source newLibrary1 = _getDartSource('dart:math'); 126 Source newLibrary1 = _getDartSource('dart:math');
127 Source newLibrary2 = _getDartSource('dart:async'); 127 Source newLibrary2 = _getDartSource('dart:async');
128 _assertAddLibraryImport( 128 _assertAddLibraryImport(
129 <Source>[newLibrary1, newLibrary2], 129 <Source>[newLibrary1, newLibrary2],
130 ''' 130 '''
131 library test; 131 library test;
132 132
133 import 'dart:async'; 133 import 'dart:async';
134 import 'dart:math'; 134 import 'dart:math';
135 135
136 class A {} 136 class A {}
137 '''); 137 ''');
138 } 138 }
139 139
140 test_addLibraryImports_dart_noDirectives_hasComment() { 140 test_addLibraryImports_dart_noDirectives_hasComment() async {
141 resolveTestUnit(''' 141 await resolveTestUnit('''
142 /// Comment. 142 /// Comment.
143 143
144 class A {} 144 class A {}
145 '''); 145 ''');
146 Source newLibrary1 = _getDartSource('dart:math'); 146 Source newLibrary1 = _getDartSource('dart:math');
147 Source newLibrary2 = _getDartSource('dart:async'); 147 Source newLibrary2 = _getDartSource('dart:async');
148 _assertAddLibraryImport( 148 _assertAddLibraryImport(
149 <Source>[newLibrary1, newLibrary2], 149 <Source>[newLibrary1, newLibrary2],
150 ''' 150 '''
151 /// Comment. 151 /// Comment.
152 152
153 import 'dart:async'; 153 import 'dart:async';
154 import 'dart:math'; 154 import 'dart:math';
155 155
156 class A {} 156 class A {}
157 '''); 157 ''');
158 } 158 }
159 159
160 test_addLibraryImports_dart_noDirectives_hasShebang() { 160 test_addLibraryImports_dart_noDirectives_hasShebang() async {
161 resolveTestUnit(''' 161 await resolveTestUnit('''
162 #!/bin/dart 162 #!/bin/dart
163 163
164 class A {} 164 class A {}
165 '''); 165 ''');
166 Source newLibrary1 = _getDartSource('dart:math'); 166 Source newLibrary1 = _getDartSource('dart:math');
167 Source newLibrary2 = _getDartSource('dart:async'); 167 Source newLibrary2 = _getDartSource('dart:async');
168 _assertAddLibraryImport( 168 _assertAddLibraryImport(
169 <Source>[newLibrary1, newLibrary2], 169 <Source>[newLibrary1, newLibrary2],
170 ''' 170 '''
171 #!/bin/dart 171 #!/bin/dart
172 172
173 import 'dart:async'; 173 import 'dart:async';
174 import 'dart:math'; 174 import 'dart:math';
175 175
176 class A {} 176 class A {}
177 '''); 177 ''');
178 } 178 }
179 179
180 test_addLibraryImports_dart_noDirectives_noShebang() { 180 test_addLibraryImports_dart_noDirectives_noShebang() async {
181 resolveTestUnit(''' 181 await resolveTestUnit('''
182 class A {} 182 class A {}
183 '''); 183 ''');
184 Source newLibrary1 = _getDartSource('dart:math'); 184 Source newLibrary1 = _getDartSource('dart:math');
185 Source newLibrary2 = _getDartSource('dart:async'); 185 Source newLibrary2 = _getDartSource('dart:async');
186 _assertAddLibraryImport( 186 _assertAddLibraryImport(
187 <Source>[newLibrary1, newLibrary2], 187 <Source>[newLibrary1, newLibrary2],
188 ''' 188 '''
189 import 'dart:async'; 189 import 'dart:async';
190 import 'dart:math'; 190 import 'dart:math';
191 191
192 class A {} 192 class A {}
193 '''); 193 ''');
194 } 194 }
195 195
196 test_addLibraryImports_package_hasDart_hasPackages_insertAfter() { 196 test_addLibraryImports_package_hasDart_hasPackages_insertAfter() async {
197 resolveTestUnit(''' 197 await resolveTestUnit('''
198 import 'dart:async'; 198 import 'dart:async';
199 199
200 import 'package:aaa/aaa.dart'; 200 import 'package:aaa/aaa.dart';
201 '''); 201 ''');
202 Source newLibrary = _getSource('/lib/bbb.dart', 'package:bbb/bbb.dart'); 202 Source newLibrary = _getSource('/lib/bbb.dart', 'package:bbb/bbb.dart');
203 _assertAddLibraryImport( 203 _assertAddLibraryImport(
204 <Source>[newLibrary], 204 <Source>[newLibrary],
205 ''' 205 '''
206 import 'dart:async'; 206 import 'dart:async';
207 207
208 import 'package:aaa/aaa.dart'; 208 import 'package:aaa/aaa.dart';
209 import 'package:bbb/bbb.dart'; 209 import 'package:bbb/bbb.dart';
210 '''); 210 ''');
211 } 211 }
212 212
213 test_addLibraryImports_package_hasDart_hasPackages_insertBefore() { 213 test_addLibraryImports_package_hasDart_hasPackages_insertBefore() async {
214 resolveTestUnit(''' 214 await resolveTestUnit('''
215 import 'dart:async'; 215 import 'dart:async';
216 216
217 import 'package:bbb/bbb.dart'; 217 import 'package:bbb/bbb.dart';
218 '''); 218 ''');
219 Source newLibrary = _getSource('/lib/aaa.dart', 'package:aaa/aaa.dart'); 219 Source newLibrary = _getSource('/lib/aaa.dart', 'package:aaa/aaa.dart');
220 _assertAddLibraryImport( 220 _assertAddLibraryImport(
221 <Source>[newLibrary], 221 <Source>[newLibrary],
222 ''' 222 '''
223 import 'dart:async'; 223 import 'dart:async';
224 224
225 import 'package:aaa/aaa.dart'; 225 import 'package:aaa/aaa.dart';
226 import 'package:bbb/bbb.dart'; 226 import 'package:bbb/bbb.dart';
227 '''); 227 ''');
228 } 228 }
229 229
230 test_addLibraryImports_package_hasImports_between() { 230 test_addLibraryImports_package_hasImports_between() async {
231 resolveTestUnit(''' 231 await resolveTestUnit('''
232 import 'package:aaa/aaa.dart'; 232 import 'package:aaa/aaa.dart';
233 import 'package:ddd/ddd.dart'; 233 import 'package:ddd/ddd.dart';
234 '''); 234 ''');
235 Source newLibrary1 = _getSource('/lib/bbb.dart', 'package:bbb/bbb.dart'); 235 Source newLibrary1 = _getSource('/lib/bbb.dart', 'package:bbb/bbb.dart');
236 Source newLibrary2 = _getSource('/lib/ccc.dart', 'package:ccc/ccc.dart'); 236 Source newLibrary2 = _getSource('/lib/ccc.dart', 'package:ccc/ccc.dart');
237 _assertAddLibraryImport( 237 _assertAddLibraryImport(
238 <Source>[newLibrary1, newLibrary2], 238 <Source>[newLibrary1, newLibrary2],
239 ''' 239 '''
240 import 'package:aaa/aaa.dart'; 240 import 'package:aaa/aaa.dart';
241 import 'package:bbb/bbb.dart'; 241 import 'package:bbb/bbb.dart';
(...skipping 25 matching lines...) Expand all
267 @override 267 @override
268 final String fullName; 268 final String fullName;
269 269
270 @override 270 @override
271 final Uri uri; 271 final Uri uri;
272 272
273 _SourceMock(this.fullName, this.uri); 273 _SourceMock(this.fullName, this.uri);
274 274
275 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 275 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
276 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698