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

Unified Diff: packages/web_components/test/build/html_import_annotation_recorder_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
Index: packages/web_components/test/build/html_import_annotation_recorder_test.dart
diff --git a/packages/web_components/test/build/html_import_annotation_recorder_test.dart b/packages/web_components/test/build/html_import_annotation_recorder_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a6e832c9d2473169cda98dddce9cb728c0fc9e80
--- /dev/null
+++ b/packages/web_components/test/build/html_import_annotation_recorder_test.dart
@@ -0,0 +1,105 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+library web_components.test.build.html_import_annotation_recorder_test;
+
+import 'package:code_transformers/tests.dart' hide testPhases;
+import 'package:web_components/build/html_import_annotation_recorder.dart';
+import 'package:initialize/transformer.dart';
+import 'package:unittest/compact_vm_config.dart';
+import 'package:unittest/unittest.dart';
+import 'common.dart';
+
+testPhases(String name, Map<String, String> inputs,
+ Map<String, String> expected, List<String> expectedPaths) {
+ var plugin = new HtmlImportAnnotationRecorder();
+ var transformer =
+ new InitializeTransformer(['web/index.dart'], plugins: [plugin]);
+
+ test(name, () {
+ // Run the transformer and test the output.
+ return applyTransformers([[transformer]],
+ inputs: inputs,
+ results: expected,
+ formatter: StringFormatter.noNewlinesOrSurroundingWhitespace).then((_) {
+ // Check that we recorded the right html imports.
+ expect(plugin.importPaths, expectedPaths);
+ });
+ });
+}
+
+main() {
+ useCompactVMConfiguration();
+
+ testPhases('basic', {
+ 'a|web/index.dart': '''
+ @HtmlImport('index.html')
+ library index;
+
+ import 'package:web_components/html_import_annotation.dart';
+ import 'foo.dart';
+ ''',
+ 'a|web/foo.dart': '''
+ @HtmlImport(fooHtml)
+ library foo;
+
+ import 'package:initialize/initialize.dart';
+ import 'package:web_components/html_import_annotation.dart';
+ import 'package:bar/bar.dart';
+
+ const String fooHtml = 'foo.html';
+
+ @initMethod
+ foo() {}
+ ''',
+ 'bar|lib/bar.dart': '''
+ @HtmlImport(barHtml)
+ library bar;
+
+ import 'package:initialize/initialize.dart';
+ import 'package:web_components/html_import_annotation.dart';
+ import 'src/zap.dart';
+
+ const String barHtml = 'bar.html';
+
+ @initMethod
+ bar() {}
+ ''',
+ 'bar|lib/src/zap.dart': '''
+ @zapImport
+ library bar.src.zap;
+
+ import 'package:web_components/html_import_annotation.dart';
+
+ const zapImport = const HtmlImport('zap.html');
+ ''',
+ // Mock out the Initialize package plus some initializers.
+ 'initialize|lib/initialize.dart': mockInitialize,
+ 'web_components|lib/html_import_annotation.dart': mockHtmlImportAnnotation,
+ }, {
+ 'a|web/index.initialize.dart': '''
+ import 'package:initialize/src/static_loader.dart';
+ import 'package:initialize/initialize.dart';
+ import 'index.dart' as i0;
+ import 'package:bar/src/zap.dart' as i1;
+ import 'package:bar/bar.dart' as i2;
+ import 'package:web_components/html_import_annotation.dart' as i3;
+ import 'package:initialize/initialize.dart' as i4;
+ import 'foo.dart' as i5;
+
+ main() {
+ initializers.addAll([
+ new InitEntry(i4.initMethod, i2.bar),
+ new InitEntry(i4.initMethod, i5.foo),
+ ]);
+
+ return i0.main();
+ }
+ '''
+ }, [
+ 'packages/bar/src/zap.html',
+ 'packages/bar/bar.html',
+ 'foo.html',
+ 'index.html',
+ ]);
+}
« no previous file with comments | « packages/web_components/test/build/common.dart ('k') | packages/web_components/test/build/import_crawler_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698