| OLD | NEW |
| 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.import_inliner_test; | 5 library polymer.test.build.import_inliner_test; |
| 6 | 6 |
| 7 import 'dart:convert' show JSON; |
| 7 import 'package:polymer/src/build/common.dart'; | 8 import 'package:polymer/src/build/common.dart'; |
| 8 import 'package:polymer/src/build/import_inliner.dart'; | 9 import 'package:polymer/src/build/import_inliner.dart'; |
| 9 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import 'common.dart'; |
| 11 | 13 |
| 12 import 'common.dart'; | 14 part 'code_extractor.dart'; |
| 13 | 15 |
| 14 final phases = [[new ImportInliner(new TransformOptions())]]; | 16 final phases = [[new ImportInliner(new TransformOptions())]]; |
| 15 | 17 |
| 16 void main() { | 18 void main() { |
| 17 useCompactVMConfiguration(); | 19 useCompactVMConfiguration(); |
| 18 group('rel=import', importTests); | 20 group('rel=import', importTests); |
| 19 group('rel=stylesheet', stylesheetTests); | 21 group('rel=stylesheet', stylesheetTests); |
| 22 group('script type=dart', codeExtractorTests); |
| 20 } | 23 } |
| 21 | 24 |
| 22 void importTests() { | 25 void importTests() { |
| 23 testPhases('no changes', phases, { | 26 testPhases('no changes', phases, { |
| 24 'a|web/test.html': '<!DOCTYPE html><html></html>', | 27 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 25 }, { | 28 }, { |
| 26 'a|web/test.html': '<!DOCTYPE html><html></html>', | 29 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 27 'a|web/test.html.scriptUrls': '[]', | 30 'a|web/test.html.scriptUrls': '[]', |
| 28 }); | 31 }); |
| 29 | 32 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 '</head><body><polymer-element>2</polymer-element></html>', | 105 '</head><body><polymer-element>2</polymer-element></html>', |
| 103 'a|web/second.js': '/*second*/' | 106 'a|web/second.js': '/*second*/' |
| 104 }, { | 107 }, { |
| 105 'a|web/test.html': | 108 'a|web/test.html': |
| 106 '<!DOCTYPE html><html><head>' | 109 '<!DOCTYPE html><html><head>' |
| 107 '</head><body>' | 110 '</head><body>' |
| 108 '<script type="text/javascript">/*first*/</script>' | 111 '<script type="text/javascript">/*first*/</script>' |
| 109 '<script src="second.js"></script>' | 112 '<script src="second.js"></script>' |
| 110 '<script>/*third*/</script>' | 113 '<script>/*third*/</script>' |
| 111 '<polymer-element>2</polymer-element>' | 114 '<polymer-element>2</polymer-element>' |
| 112 '<script type="application/dart">/*forth*/</script>' | 115 '<script type="application/dart" src="test.html.0.dart"></script>' |
| 113 '</body></html>', | 116 '</body></html>', |
| 114 'a|web/test.html.scriptUrls': '[]', | 117 'a|web/test.html.scriptUrls': '[]', |
| 118 'a|web/test.html.0.dart': 'library a.web.test_html;\n/*forth*/', |
| 115 'a|web/test2.html': | 119 'a|web/test2.html': |
| 116 '<!DOCTYPE html><html><head><script>/*third*/</script>' | 120 '<!DOCTYPE html><html><head><script>/*third*/</script>' |
| 117 '</head><body><polymer-element>2</polymer-element></html>', | 121 '</head><body><polymer-element>2</polymer-element></html>', |
| 118 'a|web/test2.html.scriptUrls': '[]', | 122 'a|web/test2.html.scriptUrls': '[]', |
| 119 'a|web/second.js': '/*second*/' | 123 'a|web/second.js': '/*second*/' |
| 120 }); | 124 }); |
| 121 | 125 |
| 122 testPhases('no transformation outside web/', phases, | 126 testPhases('no transformation outside web/', phases, |
| 123 { | 127 { |
| 124 'a|lib/test.html': | 128 'a|lib/test.html': |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 '</style>' | 640 '</style>' |
| 637 '</polymer-element>' | 641 '</polymer-element>' |
| 638 '</body></html>', | 642 '</body></html>', |
| 639 'b|asset/test3.css': | 643 'b|asset/test3.css': |
| 640 'body {\n background: #eaeaea url("assets/b/test4.png");\n}\n' | 644 'body {\n background: #eaeaea url("assets/b/test4.png");\n}\n' |
| 641 '.foo {\n background: url("../../packages/c/test5.png");\n}', | 645 '.foo {\n background: url("../../packages/c/test5.png");\n}', |
| 642 'b|asset/test4.png': 'PNG', | 646 'b|asset/test4.png': 'PNG', |
| 643 'c|lib/test5.png': 'PNG', | 647 'c|lib/test5.png': 'PNG', |
| 644 }); | 648 }); |
| 645 | 649 |
| 650 testPhases('deep, inlines css, multiple nesting', phases, { |
| 651 'a|web/test.html': |
| 652 '<!DOCTYPE html><html><head>' |
| 653 '<link rel="import" href="foo/test2.html">' |
| 654 '</head></html>', |
| 655 'a|web/foo/test2.html': |
| 656 '<link rel="import" href="bar/test3.html">' |
| 657 '<polymer-element>2' |
| 658 '<link rel="stylesheet" href="test.css">' |
| 659 '</polymer-element>', |
| 660 'a|web/foo/bar/test3.html': |
| 661 '<img src="qux.png">', |
| 662 'a|web/foo/test.css': |
| 663 'body {\n background: #eaeaea url("test4.png");\n}\n' |
| 664 '.foo {\n background: url("test5.png");\n}', |
| 665 }, { |
| 666 'a|web/test.html': |
| 667 '<!DOCTYPE html><html><head></head><body>' |
| 668 '<img src="foo/bar/qux.png">' |
| 669 '<polymer-element>2' |
| 670 '<style>' |
| 671 'body {\n background: #eaeaea url(foo/test4.png);\n}\n' |
| 672 '.foo {\n background: url(foo/test5.png);\n}' |
| 673 '</style></polymer-element></body></html>', |
| 674 'a|web/foo/test2.html': |
| 675 '<html><head></head><body>' |
| 676 '<img src="bar/qux.png">' |
| 677 '<polymer-element>2' |
| 678 '<style>' |
| 679 'body {\n background: #eaeaea url(test4.png);\n}\n' |
| 680 '.foo {\n background: url(test5.png);\n}' |
| 681 '</style></polymer-element></body></html>', |
| 682 'a|web/foo/bar/test3.html': |
| 683 '<img src="qux.png">', |
| 684 'a|web/foo/test.css': |
| 685 'body {\n background: #eaeaea url("test4.png");\n}\n' |
| 686 '.foo {\n background: url("test5.png");\n}', |
| 687 }); |
| 646 | 688 |
| 647 testPhases('shallow, inlines css and preserves order', phases, { | 689 testPhases('shallow, inlines css and preserves order', phases, { |
| 648 'a|web/test.html': | 690 'a|web/test.html': |
| 649 '<!DOCTYPE html><html><head>' | 691 '<!DOCTYPE html><html><head>' |
| 650 '<style>.first { color: black }</style>' | 692 '<style>.first { color: black }</style>' |
| 651 '<link rel="stylesheet" href="test2.css">' | 693 '<link rel="stylesheet" href="test2.css">' |
| 652 '<style>.second { color: black }</style>' | 694 '<style>.second { color: black }</style>' |
| 653 '</head></html>', | 695 '</head></html>', |
| 654 'a|web/test2.css': | 696 'a|web/test2.css': |
| 655 'h1 { font-size: 70px; }', | 697 'h1 { font-size: 70px; }', |
| 656 }, { | 698 }, { |
| 657 'a|web/test.html': | 699 'a|web/test.html': |
| 658 '<!DOCTYPE html><html><head></head><body>' | 700 '<!DOCTYPE html><html><head></head><body>' |
| 659 '<style>.first { color: black }</style>' | 701 '<style>.first { color: black }</style>' |
| 660 '<style>h1 { font-size: 70px; }</style>' | 702 '<style>h1 { font-size: 70px; }</style>' |
| 661 '<style>.second { color: black }</style>' | 703 '<style>.second { color: black }</style>' |
| 662 '</body></html>', | 704 '</body></html>', |
| 663 'a|web/test.html.scriptUrls': '[]', | 705 'a|web/test.html.scriptUrls': '[]', |
| 664 'a|web/test2.css': | 706 'a|web/test2.css': |
| 665 'h1 { font-size: 70px; }', | 707 'h1 { font-size: 70px; }', |
| 666 }); | 708 }); |
| 667 | 709 |
| 668 } | 710 } |
| 711 |
| OLD | NEW |