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

Side by Side Diff: pkg/analyzer/test/src/dart/analysis/file_state_test.dart

Issue 2671513002: Revert "Encode URIs stored in unlinked summaries to make them Uri.parse() safe." (Closed)
Patch Set: Created 3 years, 10 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 import 'dart:convert'; 5 import 'dart:convert';
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 test_getFileForPath_import_invalidUri() { 289 test_getFileForPath_import_invalidUri() {
290 String a = _p('/aaa/lib/a.dart'); 290 String a = _p('/aaa/lib/a.dart');
291 String a1 = _p('/aaa/lib/a1.dart'); 291 String a1 = _p('/aaa/lib/a1.dart');
292 String a2 = _p('/aaa/lib/a2.dart'); 292 String a2 = _p('/aaa/lib/a2.dart');
293 String a3 = _p('/aaa/lib/a3.dart'); 293 String a3 = _p('/aaa/lib/a3.dart');
294 String content_a1 = r''' 294 String content_a1 = r'''
295 import 'package:aaa/a1.dart'; 295 import 'package:aaa/a1.dart';
296 import '[invalid uri]'; 296 import '[invalid uri]';
297 297
298 export '[invalid uri]';
298 export 'package:aaa/a2.dart'; 299 export 'package:aaa/a2.dart';
299 export '[invalid uri]';
300 300
301 part 'a3.dart'; 301 part 'a3.dart';
302 part '[invalid uri]'; 302 part '[invalid uri]';
303 '''; 303 ''';
304 provider.newFile(a, content_a1); 304 provider.newFile(a, content_a1);
305 Uri invalidUri = Uri.parse(Uri.encodeFull('package:aaa/[invalid uri]'));
306 305
307 FileState file = fileSystemState.getFileForPath(a); 306 FileState file = fileSystemState.getFileForPath(a);
308 307
309 expect(_excludeSdk(file.importedFiles), hasLength(2)); 308 expect(_excludeSdk(file.importedFiles), hasLength(1));
310 expect(file.importedFiles[0].path, a1); 309 expect(file.importedFiles[0].path, a1);
311 expect(file.importedFiles[0].uri, Uri.parse('package:aaa/a1.dart')); 310 expect(file.importedFiles[0].uri, Uri.parse('package:aaa/a1.dart'));
312 expect(file.importedFiles[0].source, isNotNull); 311 expect(file.importedFiles[0].source, isNotNull);
313 expect(file.importedFiles[1].path, isNotNull);
314 expect(file.importedFiles[1].uri, invalidUri);
315 expect(file.importedFiles[1].source, isNotNull);
316 312
317 expect(_excludeSdk(file.exportedFiles), hasLength(2)); 313 expect(_excludeSdk(file.exportedFiles), hasLength(1));
318 expect(file.exportedFiles[0].path, a2); 314 expect(file.exportedFiles[0].path, a2);
319 expect(file.exportedFiles[0].uri, Uri.parse('package:aaa/a2.dart')); 315 expect(file.exportedFiles[0].uri, Uri.parse('package:aaa/a2.dart'));
320 expect(file.exportedFiles[0].source, isNotNull); 316 expect(file.exportedFiles[0].source, isNotNull);
321 expect(file.exportedFiles[1].path, isNotNull);
322 expect(file.exportedFiles[1].uri, invalidUri);
323 expect(file.exportedFiles[1].source, isNotNull);
324 317
325 expect(_excludeSdk(file.partedFiles), hasLength(2)); 318 expect(_excludeSdk(file.partedFiles), hasLength(1));
326 expect(file.partedFiles[0].path, a3); 319 expect(file.partedFiles[0].path, a3);
327 expect(file.partedFiles[0].uri, Uri.parse('package:aaa/a3.dart')); 320 expect(file.partedFiles[0].uri, Uri.parse('package:aaa/a3.dart'));
328 expect(file.partedFiles[0].source, isNotNull); 321 expect(file.partedFiles[0].source, isNotNull);
329 expect(file.partedFiles[1].path, isNotNull);
330 expect(file.partedFiles[1].uri, invalidUri);
331 expect(file.partedFiles[1].source, isNotNull);
332 } 322 }
333 323
334 test_getFileForPath_library() { 324 test_getFileForPath_library() {
335 String a1 = _p('/aaa/lib/a1.dart'); 325 String a1 = _p('/aaa/lib/a1.dart');
336 String a2 = _p('/aaa/lib/a2.dart'); 326 String a2 = _p('/aaa/lib/a2.dart');
337 String a3 = _p('/aaa/lib/a3.dart'); 327 String a3 = _p('/aaa/lib/a3.dart');
338 String a4 = _p('/aaa/lib/a4.dart'); 328 String a4 = _p('/aaa/lib/a4.dart');
339 String b1 = _p('/bbb/lib/b1.dart'); 329 String b1 = _p('/bbb/lib/b1.dart');
340 String b2 = _p('/bbb/lib/b2.dart'); 330 String b2 = _p('/bbb/lib/b2.dart');
341 String content_a1 = r''' 331 String content_a1 = r'''
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 String _p(String path) => provider.convertPath(path); 766 String _p(String path) => provider.convertPath(path);
777 767
778 static String _md5(String content) { 768 static String _md5(String content) {
779 return hex.encode(md5.convert(UTF8.encode(content)).bytes); 769 return hex.encode(md5.convert(UTF8.encode(content)).bytes);
780 } 770 }
781 } 771 }
782 772
783 class _GeneratedUriResolverMock extends TypedMock implements UriResolver {} 773 class _GeneratedUriResolverMock extends TypedMock implements UriResolver {}
784 774
785 class _SourceMock extends TypedMock implements Source {} 775 class _SourceMock extends TypedMock implements Source {}
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/analysis/driver_test.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698