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

Side by Side Diff: pkg/analyzer/test/src/context/abstract_context.dart

Issue 1185443002: Support for parsing HTML in the new task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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) 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.abstract_context_test; 5 library test.src.task.abstract_context_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/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/context/context.dart'; 10 import 'package:analyzer/src/context/context.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/engine.dart' 12 import 'package:analyzer/src/generated/engine.dart'
13 hide AnalysisCache, AnalysisContextImpl, AnalysisTask; 13 hide AnalysisCache, AnalysisContextImpl, AnalysisTask;
14 import 'package:analyzer/src/generated/sdk.dart'; 14 import 'package:analyzer/src/generated/sdk.dart';
15 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
16 import 'package:analyzer/src/task/driver.dart'; 16 import 'package:analyzer/src/task/driver.dart';
17 import 'package:analyzer/task/model.dart';
17 import 'package:unittest/unittest.dart'; 18 import 'package:unittest/unittest.dart';
18 19
19 import 'mock_sdk.dart'; 20 import 'mock_sdk.dart';
20 21
21 class AbstractContextTest { 22 class AbstractContextTest {
22 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 23 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
23 24
24 DartSdk sdk = new MockSdk(); 25 DartSdk sdk = new MockSdk();
25 SourceFactory sourceFactory; 26 SourceFactory sourceFactory;
26 AnalysisContextImpl context; 27 AnalysisContextImpl context;
27 AnalysisCache analysisCache; 28 AnalysisCache analysisCache;
28 AnalysisDriver analysisDriver; 29 AnalysisDriver analysisDriver;
29 30
31 AnalysisTask task;
32 Map<ResultDescriptor<dynamic>, dynamic> oldOutputs;
33 Map<ResultDescriptor<dynamic>, dynamic> outputs;
34
30 Source addSource(String path, String contents) { 35 Source addSource(String path, String contents) {
31 Source source = newSource(path, contents); 36 Source source = newSource(path, contents);
32 ChangeSet changeSet = new ChangeSet(); 37 ChangeSet changeSet = new ChangeSet();
33 changeSet.addedSource(source); 38 changeSet.addedSource(source);
34 context.applyChanges(changeSet); 39 context.applyChanges(changeSet);
35 return source; 40 return source;
36 } 41 }
37 42
38 /** 43 /**
39 * Assert that the given [elements] has the same number of items as the number 44 * Assert that the given [elements] has the same number of items as the number
(...skipping 17 matching lines...) Expand all
57 for (Element elem in elements) { 62 for (Element elem in elements) {
58 buffer.write(elem.name); 63 buffer.write(elem.name);
59 buffer.write(", "); 64 buffer.write(", ");
60 } 65 }
61 fail(buffer.toString()); 66 fail(buffer.toString());
62 } 67 }
63 } 68 }
64 expect(elements, hasLength(names.length)); 69 expect(elements, hasLength(names.length));
65 } 70 }
66 71
72 /**
73 * Compute the given [result] for the given [target].
74 */
75 void computeResult(AnalysisTarget target, ResultDescriptor result) {
76 oldOutputs = outputs;
77 task = analysisDriver.computeResult(target, result);
78 expect(task, isNotNull);
79 expect(task.caughtException, isNull);
80 outputs = task.outputs;
81 }
82
67 AnalysisContextImpl createAnalysisContext() { 83 AnalysisContextImpl createAnalysisContext() {
68 return new AnalysisContextImpl(); 84 return new AnalysisContextImpl();
69 } 85 }
70 86
71 Source newSource(String path, [String content = '']) { 87 Source newSource(String path, [String content = '']) {
72 File file = resourceProvider.newFile(path, content); 88 File file = resourceProvider.newFile(path, content);
73 return file.createSource(); 89 return file.createSource();
74 } 90 }
75 91
76 List<Source> newSources(Map<String, String> sourceMap) { 92 List<Source> newSources(Map<String, String> sourceMap) {
(...skipping 12 matching lines...) Expand all
89 new ResourceUriResolver(resourceProvider) 105 new ResourceUriResolver(resourceProvider)
90 ]); 106 ]);
91 context = createAnalysisContext(); 107 context = createAnalysisContext();
92 context.sourceFactory = sourceFactory; 108 context.sourceFactory = sourceFactory;
93 analysisCache = context.analysisCache; 109 analysisCache = context.analysisCache;
94 analysisDriver = context.driver; 110 analysisDriver = context.driver;
95 } 111 }
96 112
97 void tearDown() {} 113 void tearDown() {}
98 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698