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