| OLD | NEW |
| 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 analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/plugin/options.dart'; | 9 import 'package:analyzer/plugin/options.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 Uri _relativeUri(String path, {String from}) { | 667 Uri _relativeUri(String path, {String from}) { |
| 668 String relativePath = pathContext.relative(path, from: from); | 668 String relativePath = pathContext.relative(path, from: from); |
| 669 return pathContext.toUri(relativePath); | 669 return pathContext.toUri(relativePath); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| 673 @reflectiveTest | 673 @reflectiveTest |
| 674 class EmbedderYamlLocatorTest extends EmbedderRelatedTest { | 674 class EmbedderYamlLocatorTest extends EmbedderRelatedTest { |
| 675 void test_empty() { | 675 void test_empty() { |
| 676 EmbedderYamlLocator locator = new EmbedderYamlLocator({ | 676 EmbedderYamlLocator locator = new EmbedderYamlLocator({ |
| 677 'fox': [pathTranslator.getResource(emptyPath)] | 677 'fox': <Folder>[pathTranslator.getResource(emptyPath)] |
| 678 }); | 678 }); |
| 679 expect(locator.embedderYamls, hasLength(0)); | 679 expect(locator.embedderYamls, hasLength(0)); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void test_invalid() { | 682 void test_invalid() { |
| 683 EmbedderYamlLocator locator = new EmbedderYamlLocator(null); | 683 EmbedderYamlLocator locator = new EmbedderYamlLocator(null); |
| 684 locator.addEmbedderYaml(null, r'''{{{,{{}}},}}'''); | 684 locator.addEmbedderYaml(null, r'''{{{,{{}}},}}'''); |
| 685 expect(locator.embedderYamls, hasLength(0)); | 685 expect(locator.embedderYamls, hasLength(0)); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void test_valid() { | 688 void test_valid() { |
| 689 EmbedderYamlLocator locator = new EmbedderYamlLocator({ | 689 EmbedderYamlLocator locator = new EmbedderYamlLocator({ |
| 690 'fox': [pathTranslator.getResource(foxLib)] | 690 'fox': <Folder>[pathTranslator.getResource(foxLib)] |
| 691 }); | 691 }); |
| 692 expect(locator.embedderYamls, hasLength(1)); | 692 expect(locator.embedderYamls, hasLength(1)); |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 class _TestOptionsProcessor implements OptionsProcessor { | 696 class _TestOptionsProcessor implements OptionsProcessor { |
| 697 Map<String, Object> expectedOptions = null; | 697 Map<String, Object> expectedOptions = null; |
| 698 | 698 |
| 699 int errorCount = 0; | 699 int errorCount = 0; |
| 700 | 700 |
| 701 @override | 701 @override |
| 702 void onError(Exception exception) { | 702 void onError(Exception exception) { |
| 703 errorCount++; | 703 errorCount++; |
| 704 } | 704 } |
| 705 | 705 |
| 706 @override | 706 @override |
| 707 void optionsProcessed(AnalysisContext context, Map<String, Object> options) { | 707 void optionsProcessed(AnalysisContext context, Map<String, Object> options) { |
| 708 if (expectedOptions == null) { | 708 if (expectedOptions == null) { |
| 709 fail('Unexpected invocation of optionsProcessed'); | 709 fail('Unexpected invocation of optionsProcessed'); |
| 710 } | 710 } |
| 711 expect(options, hasLength(expectedOptions.length)); | 711 expect(options, hasLength(expectedOptions.length)); |
| 712 for (String key in expectedOptions.keys) { | 712 for (String key in expectedOptions.keys) { |
| 713 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); | 713 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); |
| 714 expect(options[key], expectedOptions[key], | 714 expect(options[key], expectedOptions[key], |
| 715 reason: 'values for key $key do not match'); | 715 reason: 'values for key $key do not match'); |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 } | 718 } |
| OLD | NEW |