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

Side by Side Diff: pkg/polymer/test/build/common.dart

Issue 211393006: Enables codegen support in polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 polymer.test.build.common; 5 library polymer.test.build.common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
(...skipping 18 matching lines...) Expand all
29 final Iterable<String> packages; 29 final Iterable<String> packages;
30 final List<String> messages; 30 final List<String> messages;
31 int messagesSeen = 0; 31 int messagesSeen = 0;
32 bool errorSeen = false; 32 bool errorSeen = false;
33 33
34 Barback barback; 34 Barback barback;
35 var errorSubscription; 35 var errorSubscription;
36 var resultSubscription; 36 var resultSubscription;
37 var logSubscription; 37 var logSubscription;
38 38
39 Future<Asset> getAsset(AssetId id) => 39 Future<Asset> getAsset(AssetId id) {
40 new Future.value(new Asset.fromString(id, files[idToString(id)])); 40 var content = files[idToString(id)];
41 if (content == null) fail('error: requested $id, but $id is not available');
42 return new Future.value(new Asset.fromString(id, content));
43 }
41 44
42 TestHelper(List<List<Transformer>> transformers, Map<String, String> files, 45 TestHelper(List<List<Transformer>> transformers, Map<String, String> files,
43 this.messages) 46 this.messages)
44 : files = files, 47 : files = files,
45 packages = files.keys.map((s) => idFromString(s).package) { 48 packages = files.keys.map((s) => idFromString(s).package) {
46 barback = new Barback(this); 49 barback = new Barback(this);
47 for (var p in packages) { 50 for (var p in packages) {
48 barback.updateTransformers(p, transformers); 51 barback.updateTransformers(p, transformers);
49 } 52 }
50 53
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (messages == null) return; 120 if (messages == null) return;
118 expect(messages.length, messagesSeen, 121 expect(messages.length, messagesSeen,
119 reason: 'less messages than expected'); 122 reason: 'less messages than expected');
120 }); 123 });
121 } 124 }
122 } 125 }
123 126
124 testPhases(String testName, List<List<Transformer>> phases, 127 testPhases(String testName, List<List<Transformer>> phases,
125 Map<String, String> inputFiles, Map<String, String> expectedFiles, 128 Map<String, String> inputFiles, Map<String, String> expectedFiles,
126 [List<String> expectedMessages, bool solo = false]) { 129 [List<String> expectedMessages, bool solo = false]) {
130
131 // Include mock versions of the polymer library that can be used to test
132 // resolver-based code generation.
133 POLYMER_MOCKS.forEach((file, contents) { inputFiles[file] = contents; });
127 (solo ? solo_test : test)(testName, () { 134 (solo ? solo_test : test)(testName, () {
128 var helper = new TestHelper(phases, inputFiles, expectedMessages)..run(); 135 var helper = new TestHelper(phases, inputFiles, expectedMessages)..run();
129 return helper.checkAll(expectedFiles).whenComplete(() => helper.tearDown()); 136 return helper.checkAll(expectedFiles).whenComplete(() => helper.tearDown());
130 }); 137 });
131 } 138 }
132 139
133 const WEB_COMPONENTS_TAG = 140 const WEB_COMPONENTS_TAG =
134 '<script src="packages/web_components/platform.js"></script>\n' 141 '<script src="packages/web_components/platform.js"></script>\n'
135 '<script src="packages/web_components/dart_support.js"></script>\n'; 142 '<script src="packages/web_components/dart_support.js"></script>\n';
136 143
137 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n'; 144 const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n';
138 const DART_JS_TAG = '<script src="packages/browser/dart.js"></script>'; 145 const DART_JS_TAG = '<script src="packages/browser/dart.js"></script>';
139 146
147 const POLYMER_MOCKS = const {
148 'polymer|lib/polymer.dart':
149 'library polymer;\n'
150 'import "dart:html";\n'
151 'export "package:observe/observe.dart";\n' // for @observable
152 'part "src/loader.dart";\n' // for @CustomTag and @initMethod
153 'part "src/instance.dart";\n', // for @published and @ObserveProperty
154
155 'polymer|lib/src/loader.dart':
156 'part of polymer;\n'
157 'class CustomTag {\n'
158 ' final String tagName;\n'
159 ' const CustomTag(this.tagName);'
160 '}\n'
161 'class InitMethodAnnotation { const InitMethodAnnotation(); }\n'
162 'const initMethod = const InitMethodAnnotation();\n',
163
164 'polymer|lib/src/instance.dart':
165 'part of polymer;\n'
166 'class PublishedProperty { const PublishedProperty(); }\n'
167 'const published = const PublishedProperty();\n'
168 'class ObserveProperty { const ObserveProperty(); }\n'
169 'abstract class Polymer {}\n'
170 'class PolymerElement extends HtmlElement with Polymer {}\n',
171
172 'polymer|lib/init.dart':
173 'library polymer.init;\n'
174 'import "package:polymer/polymer.dart";\n'
175 'main() {};\n',
176
177 'observe|lib/observe.dart':
178 'library observe;\n'
179 'export "src/metadata.dart";',
180
181 'observe|lib/src/metadata.dart':
182 'library observe.src.metadata;\n'
183 'class ObservableProperty { const ObservableProperty(); }\n'
184 'const observable = const ObservableProperty();\n',
185 };
OLDNEW
« no previous file with comments | « pkg/polymer/test/build/all_phases_test.dart ('k') | pkg/polymer/test/build/script_compactor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698