| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analyzer.test.src.summary.in_summary_source_test; |
| 6 |
| 7 import 'package:analyzer/src/generated/source_io.dart'; |
| 8 import 'package:analyzer/src/summary/idl.dart'; |
| 9 import 'package:analyzer/src/summary/package_bundle_reader.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import '../../reflective_tests.dart'; |
| 13 |
| 14 main() { |
| 15 groupSep = ' | '; |
| 16 runReflectiveTests(InSummarySourceTest); |
| 17 } |
| 18 |
| 19 @reflectiveTest |
| 20 class InSummarySourceTest extends ReflectiveTest { |
| 21 test_InSummarySource() { |
| 22 var sourceFactory = new SourceFactory([ |
| 23 new InSummaryPackageUriResolver(new MockSummaryDataStore.fake({ |
| 24 'package:foo/foo.dart': 'foo.sum', |
| 25 'package:foo/src/foo_impl.dart': 'foo.sum', |
| 26 'package:bar/baz.dart': 'bar.sum', |
| 27 })) |
| 28 ]); |
| 29 |
| 30 InSummarySource source = sourceFactory.forUri('package:foo/foo.dart'); |
| 31 expect(source.summaryPath, 'foo.sum'); |
| 32 |
| 33 source = sourceFactory.forUri('package:foo/src/foo_impl.dart'); |
| 34 expect(source.summaryPath, 'foo.sum'); |
| 35 |
| 36 source = sourceFactory.forUri('package:bar/baz.dart'); |
| 37 expect(source.summaryPath, 'bar.sum'); |
| 38 } |
| 39 } |
| 40 |
| 41 class MockSummaryDataStore implements SummaryDataStore { |
| 42 final Map<String, LinkedLibrary> linkedMap; |
| 43 final Map<String, UnlinkedUnit> unlinkedMap; |
| 44 final Map<String, String> uriToSummaryPath; |
| 45 |
| 46 MockSummaryDataStore(this.linkedMap, this.unlinkedMap, this.uriToSummaryPath); |
| 47 |
| 48 factory MockSummaryDataStore.fake(Map<String, String> uriToSummary) { |
| 49 // Create fake unlinked map. |
| 50 // We don't populate the values as it is not needed for the test. |
| 51 var unlinkedMap = new Map<String, UnlinkedUnit>.fromIterable( |
| 52 uriToSummary.keys, |
| 53 value: (k) => null); |
| 54 return new MockSummaryDataStore(null, unlinkedMap, uriToSummary); |
| 55 } |
| 56 } |
| OLD | NEW |