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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/build/common.dart
diff --git a/pkg/polymer/test/build/common.dart b/pkg/polymer/test/build/common.dart
index 91e6b11a76472965b4f235a83366ee4d9b63cab8..f97ddc09107f4b4231e89e770b4ac1b1b76c8c54 100644
--- a/pkg/polymer/test/build/common.dart
+++ b/pkg/polymer/test/build/common.dart
@@ -36,8 +36,11 @@ class TestHelper implements PackageProvider {
var resultSubscription;
var logSubscription;
- Future<Asset> getAsset(AssetId id) =>
- new Future.value(new Asset.fromString(id, files[idToString(id)]));
+ Future<Asset> getAsset(AssetId id) {
+ var content = files[idToString(id)];
+ if (content == null) fail('error: requested $id, but $id is not available');
+ return new Future.value(new Asset.fromString(id, content));
+ }
TestHelper(List<List<Transformer>> transformers, Map<String, String> files,
this.messages)
@@ -124,6 +127,10 @@ class TestHelper implements PackageProvider {
testPhases(String testName, List<List<Transformer>> phases,
Map<String, String> inputFiles, Map<String, String> expectedFiles,
[List<String> expectedMessages, bool solo = false]) {
+
+ // Include mock versions of the polymer library that can be used to test
+ // resolver-based code generation.
+ POLYMER_MOCKS.forEach((file, contents) { inputFiles[file] = contents; });
(solo ? solo_test : test)(testName, () {
var helper = new TestHelper(phases, inputFiles, expectedMessages)..run();
return helper.checkAll(expectedFiles).whenComplete(() => helper.tearDown());
@@ -137,3 +144,42 @@ const WEB_COMPONENTS_TAG =
const INTEROP_TAG = '<script src="packages/browser/interop.js"></script>\n';
const DART_JS_TAG = '<script src="packages/browser/dart.js"></script>';
+const POLYMER_MOCKS = const {
+ 'polymer|lib/polymer.dart':
+ 'library polymer;\n'
+ 'import "dart:html";\n'
+ 'export "package:observe/observe.dart";\n' // for @observable
+ 'part "src/loader.dart";\n' // for @CustomTag and @initMethod
+ 'part "src/instance.dart";\n', // for @published and @ObserveProperty
+
+ 'polymer|lib/src/loader.dart':
+ 'part of polymer;\n'
+ 'class CustomTag {\n'
+ ' final String tagName;\n'
+ ' const CustomTag(this.tagName);'
+ '}\n'
+ 'class InitMethodAnnotation { const InitMethodAnnotation(); }\n'
+ 'const initMethod = const InitMethodAnnotation();\n',
+
+ 'polymer|lib/src/instance.dart':
+ 'part of polymer;\n'
+ 'class PublishedProperty { const PublishedProperty(); }\n'
+ 'const published = const PublishedProperty();\n'
+ 'class ObserveProperty { const ObserveProperty(); }\n'
+ 'abstract class Polymer {}\n'
+ 'class PolymerElement extends HtmlElement with Polymer {}\n',
+
+ 'polymer|lib/init.dart':
+ 'library polymer.init;\n'
+ 'import "package:polymer/polymer.dart";\n'
+ 'main() {};\n',
+
+ 'observe|lib/observe.dart':
+ 'library observe;\n'
+ 'export "src/metadata.dart";',
+
+ 'observe|lib/src/metadata.dart':
+ 'library observe.src.metadata;\n'
+ 'class ObservableProperty { const ObservableProperty(); }\n'
+ 'const observable = const ObservableProperty();\n',
+};
« 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