Chromium Code Reviews| 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 'dart:convert'; |
| 8 import 'package:polymer/src/build/common.dart'; | 8 import 'package:polymer/src/build/common.dart'; |
| 9 import 'package:polymer/src/build/import_inliner.dart'; | 9 import 'package:polymer/src/build/import_inliner.dart'; |
| 10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import 'common.dart'; | 12 import 'common.dart'; |
| 13 | 13 |
| 14 part 'code_extractor.dart'; | 14 part 'code_extractor.dart'; |
| 15 | 15 |
| 16 final phases = [[new ImportInliner(new TransformOptions())]]; | 16 final phases = [[new ImportInliner(new TransformOptions())]]; |
| 17 | 17 |
| 18 void main() { | 18 void main() { |
| 19 useCompactVMConfiguration(); | 19 useCompactVMConfiguration(); |
| 20 group('rel=import', importTests); | 20 group('rel=import', importTests); |
| 21 group('rel=stylesheet', stylesheetTests); | 21 group('rel=stylesheet', stylesheetTests); |
| 22 group('script type=dart', codeExtractorTests); | 22 group('script type=dart', codeExtractorTests); |
| 23 group('url attributes', urlAttributeTests); | 23 group('url attributes', urlAttributeTests); |
| 24 group('deep entrypoints', entryPointTests); | 24 group('deep entrypoints', entryPointTests); |
| 25 group('output logs', logOutputTests); | |
| 25 } | 26 } |
| 26 | 27 |
| 27 void importTests() { | 28 void importTests() { |
| 28 testPhases('no changes', phases, { | 29 testPhases('no changes', phases, { |
| 29 'a|web/test.html': '<!DOCTYPE html><html></html>', | 30 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 30 }, { | 31 }, { |
| 31 'a|web/test.html': '<!DOCTYPE html><html></html>', | 32 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 32 'a|web/test.html._data': EMPTY_DATA, | 33 'a|web/test.html._data': EMPTY_DATA, |
| 33 }); | 34 }); |
| 34 | 35 |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 'warning: Failed to inline stylesheet: ' | 669 'warning: Failed to inline stylesheet: ' |
| 669 'Could not find asset a|web/foo.css. (web/test.html 0 27)', | 670 'Could not find asset a|web/foo.css. (web/test.html 0 27)', |
| 670 ]); | 671 ]); |
| 671 | 672 |
| 672 testPhases("missing html imports throw errors", phases, { | 673 testPhases("missing html imports throw errors", phases, { |
| 673 'a|web/test.html': | 674 'a|web/test.html': |
| 674 '<!DOCTYPE html><html><head>' | 675 '<!DOCTYPE html><html><head>' |
| 675 '<link rel="import" href="foo.html">' | 676 '<link rel="import" href="foo.html">' |
| 676 '</head></html>', | 677 '</head></html>', |
| 677 }, {}, [ | 678 }, {}, [ |
| 678 'error: Failed to inline html import: ' | 679 // We are wrapping errors and converting to warnings. |
|
Siggi Cherem (dart-lang)
2014/08/05 19:37:21
I think we should repeat this test two or three ti
jakemac
2014/08/05 22:58:23
Done.
| |
| 680 'warning: Failed to inline html import: ' | |
| 679 'Could not find asset a|web/foo.html. (web/test.html 0 27)', | 681 'Could not find asset a|web/foo.html. (web/test.html 0 27)', |
| 680 ]); | 682 ]); |
| 681 } | 683 } |
| 682 | 684 |
| 683 void stylesheetTests() { | 685 void stylesheetTests() { |
| 684 | 686 |
| 685 testPhases('empty stylesheet', phases, { | 687 testPhases('empty stylesheet', phases, { |
| 686 'a|web/test.html': | 688 'a|web/test.html': |
| 687 '<!DOCTYPE html><html><head>' | 689 '<!DOCTYPE html><html><head>' |
| 688 '<link rel="stylesheet" href="">' // empty href | 690 '<link rel="stylesheet" href="">' // empty href |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1076 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>', | 1078 '<script rel="import" href="../../../packages/b/bar/bar.js"></script>', |
| 1077 'b|lib/bar/bar.js': | 1079 'b|lib/bar/bar.js': |
| 1078 'console.log("here");', | 1080 'console.log("here");', |
| 1079 }, { | 1081 }, { |
| 1080 'a|web/test/well/test.html': | 1082 'a|web/test/well/test.html': |
| 1081 '<!DOCTYPE html><html><head></head><body>' | 1083 '<!DOCTYPE html><html><head></head><body>' |
| 1082 '<script rel="import" href="../../packages/b/bar/bar.js"></script>' | 1084 '<script rel="import" href="../../packages/b/bar/bar.js"></script>' |
| 1083 '</body></html>', | 1085 '</body></html>', |
| 1084 }); | 1086 }); |
| 1085 } | 1087 } |
| 1088 | |
| 1089 void logOutputTests() { | |
| 1090 final outputLogsPhases = [[new ImportInliner( | |
| 1091 new TransformOptions(injectBuildLogsInOutput: true))]]; | |
| 1092 | |
| 1093 testPhases("logs are output and converted to warnings", outputLogsPhases, { | |
| 1094 'a|web/test.html': | |
| 1095 '<!DOCTYPE html><html><head>' | |
| 1096 '<link rel="import" href="foo.html">' | |
| 1097 '</head></html>', | |
| 1098 }, { | |
| 1099 'a|web/test.html._buildLogs.1': | |
| 1100 '[{' | |
| 1101 '"level":"Error",' | |
| 1102 '"message":"Failed to inline html import: ' | |
| 1103 'Could not find asset a|web/foo.html.",' | |
| 1104 '"assetId":{"package":"a","path":"web/foo.html"},' | |
| 1105 '"span":{' | |
| 1106 '"location":"web/test.html:1:28",' | |
| 1107 '"text":"${new HtmlEscape().convert( | |
| 1108 '<link rel="import" href="foo.html">')}"' | |
| 1109 '}' | |
| 1110 '}]', | |
| 1111 }, [ | |
| 1112 // We are wrapping errors and converting to warnings. | |
| 1113 'warning: Failed to inline html import: ' | |
| 1114 'Could not find asset a|web/foo.html. (web/test.html 0 27)', | |
| 1115 ]); | |
| 1116 } | |
| OLD | NEW |