OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library analyzer.test.generated.source_factory; | 8 library analyzer.test.generated.source_factory; |
9 | 9 |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 import '../reflective_tests.dart'; | 27 import '../reflective_tests.dart'; |
28 import 'test_support.dart'; | 28 import 'test_support.dart'; |
29 | 29 |
30 main() { | 30 main() { |
31 groupSep = ' | '; | 31 groupSep = ' | '; |
32 runReflectiveTests(SourceFactoryTest); | 32 runReflectiveTests(SourceFactoryTest); |
33 runPackageMapTests(); | 33 runPackageMapTests(); |
34 } | 34 } |
35 | 35 |
36 Source createSource({String path, String uri}) => new MemoryResourceProvider() | |
37 .getFile(path) | |
38 .createSource(uri != null ? Uri.parse(uri) : null); | |
39 | |
36 void runPackageMapTests() { | 40 void runPackageMapTests() { |
37 final Uri baseUri = new Uri.file('test/base'); | 41 final Uri baseUri = new Uri.file('test/base'); |
38 final List<UriResolver> testResolvers = [new FileUriResolver()]; | 42 final List<UriResolver> testResolvers = [new FileUriResolver()]; |
39 | 43 |
40 Packages createPackageMap(Uri base, String configFileContents) { | 44 Packages createPackageMap(Uri base, String configFileContents) { |
41 List<int> bytes = UTF8.encode(configFileContents); | 45 List<int> bytes = UTF8.encode(configFileContents); |
42 Map<String, Uri> map = pkgfile.parse(bytes, base); | 46 Map<String, Uri> map = pkgfile.parse(bytes, base); |
43 return new MapPackages(map); | 47 return new MapPackages(map); |
44 } | 48 } |
45 | 49 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 isTrue); | 167 isTrue); |
164 expect(utils.startsWith(Uri.parse('/foo/bar/'), Uri.parse('/foo/bar/')), | 168 expect(utils.startsWith(Uri.parse('/foo/bar/'), Uri.parse('/foo/bar/')), |
165 isTrue); | 169 isTrue); |
166 expect(utils.startsWith(Uri.parse('/foo/bar'), Uri.parse('/foo/b')), | 170 expect(utils.startsWith(Uri.parse('/foo/bar'), Uri.parse('/foo/b')), |
167 isFalse); | 171 isFalse); |
168 }); | 172 }); |
169 }); | 173 }); |
170 }); | 174 }); |
171 } | 175 } |
172 | 176 |
173 Source createSource({String path, String uri}) => new MemoryResourceProvider() | |
174 .getFile(path) | |
175 .createSource(uri != null ? Uri.parse(uri) : null); | |
176 | |
177 class CustomUriResolver extends UriResolver { | 177 class CustomUriResolver extends UriResolver { |
178 String uriPath; | 178 String uriPath; |
179 CustomUriResolver({this.uriPath}); | 179 CustomUriResolver({this.uriPath}); |
180 | 180 |
181 @override | 181 @override |
182 Source resolveAbsolute(Uri uri) => createSource(path: uriPath); | 182 Source resolveAbsolute(Uri uri, [Uri actualUri]) => |
183 createSource(path: uriPath); | |
Paul Berry
2015/07/21 19:39:27
Not sure if it matters because this is test code,
pquitslund
2015/07/21 20:55:10
I thought about that. At the moment there's no A
| |
183 } | 184 } |
184 | 185 |
185 @reflectiveTest | 186 @reflectiveTest |
186 class SourceFactoryTest { | 187 class SourceFactoryTest { |
187 void test_creation() { | 188 void test_creation() { |
188 expect(new SourceFactory([]), isNotNull); | 189 expect(new SourceFactory([]), isNotNull); |
189 } | 190 } |
190 | 191 |
191 void test_fromEncoding_invalidUri() { | 192 void test_fromEncoding_invalidUri() { |
192 SourceFactory factory = new SourceFactory([]); | 193 SourceFactory factory = new SourceFactory([]); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 expect(factory.restoreUri(source2), same(null)); | 276 expect(factory.restoreUri(source2), same(null)); |
276 } | 277 } |
277 } | 278 } |
278 | 279 |
279 class UriResolver_absolute extends UriResolver { | 280 class UriResolver_absolute extends UriResolver { |
280 bool invoked = false; | 281 bool invoked = false; |
281 | 282 |
282 UriResolver_absolute(); | 283 UriResolver_absolute(); |
283 | 284 |
284 @override | 285 @override |
285 Source resolveAbsolute(Uri uri) { | 286 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
286 invoked = true; | 287 invoked = true; |
287 return null; | 288 return null; |
288 } | 289 } |
289 } | 290 } |
290 | 291 |
291 class UriResolver_nonAbsolute_absolute extends UriResolver { | 292 class UriResolver_nonAbsolute_absolute extends UriResolver { |
292 @override | 293 @override |
293 Source resolveAbsolute(Uri uri) { | 294 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
294 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 295 return new FileBasedSource(new JavaFile.fromUri(uri), actualUri); |
295 } | 296 } |
296 } | 297 } |
297 | 298 |
298 class UriResolver_nonAbsolute_relative extends UriResolver { | 299 class UriResolver_nonAbsolute_relative extends UriResolver { |
299 @override | 300 @override |
300 Source resolveAbsolute(Uri uri) { | 301 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
301 return new FileBasedSource(new JavaFile.fromUri(uri), uri); | 302 return new FileBasedSource(new JavaFile.fromUri(uri), actualUri); |
302 } | 303 } |
303 } | 304 } |
304 | 305 |
305 class UriResolver_restoreUri extends UriResolver { | 306 class UriResolver_restoreUri extends UriResolver { |
306 Source source1; | 307 Source source1; |
307 Uri expected1; | 308 Uri expected1; |
308 UriResolver_restoreUri(this.source1, this.expected1); | 309 UriResolver_restoreUri(this.source1, this.expected1); |
309 | 310 |
310 @override | 311 @override |
311 Source resolveAbsolute(Uri uri) => null; | 312 Source resolveAbsolute(Uri uri, [Uri actualUri]) => null; |
312 | 313 |
313 @override | 314 @override |
314 Uri restoreAbsolute(Source source) { | 315 Uri restoreAbsolute(Source source) { |
315 if (identical(source, source1)) { | 316 if (identical(source, source1)) { |
316 return expected1; | 317 return expected1; |
317 } | 318 } |
318 return null; | 319 return null; |
319 } | 320 } |
320 } | 321 } |
321 | 322 |
322 class UriResolver_SourceFactoryTest_test_fromEncoding_valid | 323 class UriResolver_SourceFactoryTest_test_fromEncoding_valid |
323 extends UriResolver { | 324 extends UriResolver { |
324 String encoding; | 325 String encoding; |
325 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); | 326 UriResolver_SourceFactoryTest_test_fromEncoding_valid(this.encoding); |
326 | 327 |
327 @override | 328 @override |
328 Source resolveAbsolute(Uri uri) { | 329 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
329 if (uri.toString() == encoding) { | 330 if (uri.toString() == encoding) { |
330 return new TestSource(); | 331 return new TestSource(); |
331 } | 332 } |
332 return null; | 333 return null; |
333 } | 334 } |
334 } | 335 } |
OLD | NEW |