| 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 library test.src.task.model_test; | 5 library test.src.task.model_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; | 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | |
| 10 import 'package:analyzer/src/task/model.dart'; | 9 import 'package:analyzer/src/task/model.dart'; |
| 11 import 'package:analyzer/src/task/targets.dart'; | |
| 12 import 'package:analyzer/task/model.dart'; | 10 import 'package:analyzer/task/model.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 14 | 12 |
| 15 import '../../generated/test_support.dart'; | 13 import '../../generated/test_support.dart'; |
| 16 import '../../reflective_tests.dart'; | 14 import '../../reflective_tests.dart'; |
| 17 import 'test_support.dart'; | 15 import 'test_support.dart'; |
| 18 | 16 |
| 19 main() { | 17 main() { |
| 20 groupSep = ' | '; | 18 groupSep = ' | '; |
| 21 runReflectiveTests(AnalysisTaskTest); | 19 runReflectiveTests(AnalysisTaskTest); |
| 22 runReflectiveTests(ContributionPointImplTest); | 20 runReflectiveTests(ContributionPointImplTest); |
| 23 runReflectiveTests(ResultDescriptorImplTest); | 21 runReflectiveTests(ResultDescriptorImplTest); |
| 24 runReflectiveTests(TaskDescriptorImplTest); | 22 runReflectiveTests(TaskDescriptorImplTest); |
| 25 } | 23 } |
| 26 | 24 |
| 27 @reflectiveTest | 25 @reflectiveTest |
| 28 class AnalysisTaskTest extends EngineTestCase { | 26 class AnalysisTaskTest extends EngineTestCase { |
| 29 test_getRequiredInput_missingKey() { | 27 test_getRequiredInput_missingKey() { |
| 30 SourceTarget target = new SourceTarget(new TestSource()); | 28 AnalysisTarget target = new TestSource(); |
| 31 AnalysisTask task = new TestAnalysisTask(null, target); | 29 AnalysisTask task = new TestAnalysisTask(null, target); |
| 32 task.inputs = { | 30 task.inputs = { |
| 33 'a': 'b' | 31 'a': 'b' |
| 34 }; | 32 }; |
| 35 expect( | 33 expect( |
| 36 () => task.getRequiredInput('c'), | 34 () => task.getRequiredInput('c'), |
| 37 throwsA(new isInstanceOf<AnalysisException>())); | 35 throwsA(new isInstanceOf<AnalysisException>())); |
| 38 } | 36 } |
| 39 | 37 |
| 40 test_getRequiredInput_noInputs() { | 38 test_getRequiredInput_noInputs() { |
| 41 SourceTarget target = new SourceTarget(new TestSource()); | 39 AnalysisTarget target = new TestSource(); |
| 42 AnalysisTask task = new TestAnalysisTask(null, target); | 40 AnalysisTask task = new TestAnalysisTask(null, target); |
| 43 expect( | 41 expect( |
| 44 () => task.getRequiredInput('x'), | 42 () => task.getRequiredInput('x'), |
| 45 throwsA(new isInstanceOf<AnalysisException>())); | 43 throwsA(new isInstanceOf<AnalysisException>())); |
| 46 } | 44 } |
| 47 | 45 |
| 48 test_getRequiredInput_valid() { | 46 test_getRequiredInput_valid() { |
| 49 SourceTarget target = new SourceTarget(new TestSource()); | 47 AnalysisTarget target = new TestSource(); |
| 50 AnalysisTask task = new TestAnalysisTask(null, target); | 48 AnalysisTask task = new TestAnalysisTask(null, target); |
| 51 String key = 'a'; | 49 String key = 'a'; |
| 52 String value = 'b'; | 50 String value = 'b'; |
| 53 task.inputs = { | 51 task.inputs = { |
| 54 key: value | 52 key: value |
| 55 }; | 53 }; |
| 56 expect(task.getRequiredInput(key), value); | 54 expect(task.getRequiredInput(key), value); |
| 57 } | 55 } |
| 58 | 56 |
| 59 test_getRequiredSource() { | 57 test_getRequiredSource() { |
| 60 Source source = new TestSource(); | 58 AnalysisTarget target = new TestSource(); |
| 61 SourceTarget target = new SourceTarget(source); | |
| 62 AnalysisTask task = new TestAnalysisTask(null, target); | 59 AnalysisTask task = new TestAnalysisTask(null, target); |
| 63 expect(task.getRequiredSource(), source); | 60 expect(task.getRequiredSource(), target); |
| 64 } | 61 } |
| 65 } | 62 } |
| 66 | 63 |
| 67 @reflectiveTest | 64 @reflectiveTest |
| 68 class ContributionPointImplTest extends EngineTestCase { | 65 class ContributionPointImplTest extends EngineTestCase { |
| 69 test_contributors_empty() { | 66 test_contributors_empty() { |
| 70 ContributionPointImpl point = new ContributionPointImpl('point'); | 67 ContributionPointImpl point = new ContributionPointImpl('point'); |
| 71 List<ResultDescriptor> contributors = point.contributors; | 68 List<ResultDescriptor> contributors = point.contributors; |
| 72 expect(contributors, isEmpty); | 69 expect(contributors, isEmpty); |
| 73 } | 70 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 expect(result, isNotNull); | 104 expect(result, isNotNull); |
| 108 List<ResultDescriptor> contributors = point.contributors; | 105 List<ResultDescriptor> contributors = point.contributors; |
| 109 expect(contributors, unorderedEquals([result])); | 106 expect(contributors, unorderedEquals([result])); |
| 110 } | 107 } |
| 111 | 108 |
| 112 test_create_withoutContribution() { | 109 test_create_withoutContribution() { |
| 113 expect(new ResultDescriptorImpl('name', null), isNotNull); | 110 expect(new ResultDescriptorImpl('name', null), isNotNull); |
| 114 } | 111 } |
| 115 | 112 |
| 116 test_inputFor() { | 113 test_inputFor() { |
| 117 SourceTarget target = new SourceTarget(null); | 114 AnalysisTarget target = new TestSource(); |
| 118 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); | 115 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); |
| 119 TaskInput input = result.inputFor(target); | 116 TaskInput input = result.inputFor(target); |
| 120 expect(input, isNotNull); | 117 expect(input, isNotNull); |
| 121 } | 118 } |
| 122 | 119 |
| 123 test_name() { | 120 test_name() { |
| 124 String name = 'result'; | 121 String name = 'result'; |
| 125 ResultDescriptorImpl result = new ResultDescriptorImpl(name, null); | 122 ResultDescriptorImpl result = new ResultDescriptorImpl(name, null); |
| 126 expect(result.name, name); | 123 expect(result.name, name); |
| 127 } | 124 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 144 } | 141 } |
| 145 | 142 |
| 146 test_createTask() { | 143 test_createTask() { |
| 147 BuildTask buildTask = | 144 BuildTask buildTask = |
| 148 (context, target) => new TestAnalysisTask(context, target); | 145 (context, target) => new TestAnalysisTask(context, target); |
| 149 CreateTaskInputs createTaskInputs = (target) {}; | 146 CreateTaskInputs createTaskInputs = (target) {}; |
| 150 List<ResultDescriptor> results = <ResultDescriptor>[]; | 147 List<ResultDescriptor> results = <ResultDescriptor>[]; |
| 151 TaskDescriptorImpl descriptor = | 148 TaskDescriptorImpl descriptor = |
| 152 new TaskDescriptorImpl('name', buildTask, createTaskInputs, results); | 149 new TaskDescriptorImpl('name', buildTask, createTaskInputs, results); |
| 153 AnalysisContext context = null; | 150 AnalysisContext context = null; |
| 154 SourceTarget target = new SourceTarget(null); | 151 AnalysisTarget target = new TestSource(); |
| 155 Map<String, dynamic> inputs = {}; | 152 Map<String, dynamic> inputs = {}; |
| 156 AnalysisTask createTask = descriptor.createTask(context, target, inputs); | 153 AnalysisTask createTask = descriptor.createTask(context, target, inputs); |
| 157 expect(createTask, isNotNull); | 154 expect(createTask, isNotNull); |
| 158 expect(createTask.context, context); | 155 expect(createTask.context, context); |
| 159 expect(createTask.inputs, inputs); | 156 expect(createTask.inputs, inputs); |
| 160 expect(createTask.target, target); | 157 expect(createTask.target, target); |
| 161 } | 158 } |
| 162 } | 159 } |
| OLD | NEW |