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

Unified Diff: packages/web_components/test/build/transformer_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/transformer_test.dart
diff --git a/packages/web_components/test/build/transformer_test.dart b/packages/web_components/test/build/transformer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..446ecede51881a610eaef35bcd18bf295e6c896d
--- /dev/null
+++ b/packages/web_components/test/build/transformer_test.dart
@@ -0,0 +1,206 @@
+// 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.transformer_test;
+
+import 'package:code_transformers/tests.dart';
+import 'package:web_components/transformer.dart';
+import 'package:unittest/compact_vm_config.dart';
+import 'common.dart';
+
+var transformer = new WebComponentsTransformerGroup(
+ new TransformOptions(['web/index.html', 'test/index.html'], false));
+var phases = [[transformer]];
+
+main() {
+ useCompactVMConfiguration();
+
+ testPhases('full app', phases, {
+ 'a|web/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="import" href="packages/b/foo.html">
+ </head>
+ <body>
+ <script type="application/dart" src="index.dart"></script>
+ </body>
+ </html>
+ ''',
+ 'a|web/index.dart': '''
+ library a;
+
+ import 'package:initialize/initialize.dart';
+
+ @initMethod
+ startup() {}
+ ''',
+ 'b|lib/foo.html': '''
+ <link rel="import" href="bar.html">
+ <script type="application/dart" src="foo.dart"></script>
+ <div>foo</div>
+ ''',
+ 'b|lib/foo.dart': '''
+ library b.foo;
+ ''',
+ 'b|lib/bar.html': '''
+ <script type="application/dart">
+ // Must use package:urls inside inline script tags,
+ @HtmlImport('package:b/bar_nodart.html')
+ library b.bar;
+
+ import 'package:web_components/html_import_annotation.dart';
+
+ import 'package:initialize/initialize.dart';
+
+ @initMethod
+ bar() {}
+ </script>
+ <div>bar</div>
+ ''',
+ 'b|lib/bar_nodart.html': '''
+ <div>bar no_dart!</div>
+ ''',
+ 'initialize|lib/initialize.dart': mockInitialize,
+ 'web_components|lib/html_import_annotation.dart': mockHtmlImportAnnotation,
+ }, {
+ 'a|web/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head></head>
+ <body>
+ <div hidden="">
+ <div>bar</div>
+ <div>foo</div>
+ <div>bar no_dart!</div>
+ </div>
+ <script type="application/dart" src="index.bootstrap.initialize.dart">
+ </script>
+ </body>
+ </html>
+ ''',
+ 'a|web/index.bootstrap.initialize.dart': '''
+ import 'package:initialize/src/static_loader.dart';
+ import 'package:initialize/initialize.dart';
+ import 'index.bootstrap.dart' as i0;
+ import 'index.html.0.dart' as i1;
+ import 'package:web_components/html_import_annotation.dart' as i2;
+ import 'package:initialize/initialize.dart' as i3;
+ import 'index.dart' as i4;
+
+ main() {
+ initializers.addAll([
+ new InitEntry(i3.initMethod, i1.bar),
+ new InitEntry(i3.initMethod, i4.startup),
+ ]);
+ return i0.main();
+ }
+ ''',
+ 'a|web/index.bootstrap.dart': '''
+ library a.web.index_bootstrap_dart;
+
+ import 'index.html.0.dart' as i0;
+ import 'package:b/foo.dart' as i1;
+ import 'index.dart' as i2;
+
+ main() => i2.main();
+ ''',
+ 'a|web/index.html.0.dart': '''
+ // Must use package:urls inside inline script tags,
+ @HtmlImport('package:b/bar_nodart.html')
+ library b.bar;
+
+ import 'package:web_components/html_import_annotation.dart';
+
+ import 'package:initialize/initialize.dart';
+
+ @initMethod
+ bar() {}
+ ''',
+ }, [], StringFormatter.noNewlinesOrSurroundingWhitespace);
+
+ testPhases('imports go above the dart script', phases, {
+ 'b|web/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <script>var x;</script>
+ <script type="application/dart" src="index.dart"></script>
+ <script>var y;</script>
+ </head>
+ <body>
+ </body>
+ </html>
+ ''',
+ 'b|web/index.dart': '''
+ @HtmlImport('package:b/b.html')
+ library b;
+
+ import 'package:web_components/html_import_annotation.dart';
+ import 'package:c/c.dart';
+ ''',
+ 'b|lib/b.html': '''
+ <div>b</div>
+ ''',
+ 'c|lib/c.dart': '''
+ @HtmlImport('c.html')
+ library c;
+
+ import 'package:web_components/html_import_annotation.dart';
+ ''',
+ 'c|lib/c.html': '''
+ <div>c</div>
+ ''',
+ 'initialize|lib/initialize.dart': mockInitialize,
+ 'web_components|lib/html_import_annotation.dart': mockHtmlImportAnnotation,
+ }, {
+ 'b|web/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <script>var x;</script>
+ </head>
+ <body>
+ <div hidden="">
+ <div>c</div>
+ <div>b</div>
+ <script type="application/dart" src="index.bootstrap.initialize.dart">
+ </script>
+ <script>var y;</script>
+ </div>
+ </body>
+ </html>
+ ''',
+ }, [], StringFormatter.noNewlinesOrSurroundingWhitespace);
+
+ testPhases('test compatibility', phases, {
+ 'a|test/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="x-dart-test" href="index.dart">
+ <script src="packages/test/dart.js"></script>
+ </head>
+ <body></body>
+ </html>
+ ''',
+ 'a|test/index.dart': '''
+ library a;
+
+ main() {}
+ ''',
+ 'initialize|lib/initialize.dart': mockInitialize,
+ 'web_components|lib/html_import_annotation.dart': mockHtmlImportAnnotation,
+ }, {
+ 'a|test/index.html': '''
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="x-dart-test" href="index.bootstrap.initialize.dart">
+ <script src="packages/test/dart.js"></script>
+ </head>
+ <body></body>
+ </html>
+ ''',
+ }, [], StringFormatter.noNewlinesOrSurroundingWhitespace);
+}

Powered by Google App Engine
This is Rietveld 408576698