| 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.all_phases_test; | 5 library polymer.test.build.all_phases_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/script_compactor.dart' show MAIN_HEADER; | 8 import 'package:polymer/src/build/script_compactor.dart' show MAIN_HEADER; |
| 9 import 'package:polymer/transformer.dart'; | 9 import 'package:polymer/transformer.dart'; |
| 10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 'a|web/test.html': | 38 'a|web/test.html': |
| 39 '<!DOCTYPE html><html><head>' | 39 '<!DOCTYPE html><html><head>' |
| 40 '$SHADOW_DOM_TAG' | 40 '$SHADOW_DOM_TAG' |
| 41 '$CUSTOM_ELEMENT_TAG' | 41 '$CUSTOM_ELEMENT_TAG' |
| 42 '$INTEROP_TAG' | 42 '$INTEROP_TAG' |
| 43 '<script src="test.html_bootstrap.dart.js"></script>' | 43 '<script src="test.html_bootstrap.dart.js"></script>' |
| 44 '</head><body></body></html>', | 44 '</head><body></body></html>', |
| 45 | 45 |
| 46 'a|web/test.html_bootstrap.dart': | 46 'a|web/test.html_bootstrap.dart': |
| 47 '''$MAIN_HEADER | 47 '''$MAIN_HEADER |
| 48 import 'a.dart_modified.dart' as i0; | 48 import 'a.dart' as i0; |
| 49 | 49 |
| 50 void main() { | 50 void main() { |
| 51 configureForDeployment([ | 51 configureForDeployment([ |
| 52 'a.dart_modified.dart', | 52 'a.dart', |
| 53 ]); | 53 ]); |
| 54 i0.polymerMainWrapper(); | 54 i0.main(); |
| 55 } | 55 } |
| 56 '''.replaceAll('\n ', '\n'), | 56 '''.replaceAll('\n ', '\n'), |
| 57 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), | 57 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), |
| 58 'a|web/a.dart_modified.dart': | |
| 59 _sampleObservableOutput('A', 'foo', includeMain: true), | |
| 60 }); | 58 }); |
| 61 | 59 |
| 62 testPhases('single inline script', phases, { | 60 testPhases('single inline script', phases, { |
| 63 'a|web/test.html': | 61 'a|web/test.html': |
| 64 '<!DOCTYPE html><html><head>' | 62 '<!DOCTYPE html><html><head>' |
| 65 '<script type="application/dart">' | 63 '<script type="application/dart">' |
| 66 '${_sampleObservable("B", "bar")}</script>', | 64 '${_sampleObservable("B", "bar")}</script>', |
| 67 }, { | 65 }, { |
| 68 'a|web/test.html': | 66 'a|web/test.html': |
| 69 '<!DOCTYPE html><html><head>' | 67 '<!DOCTYPE html><html><head>' |
| 70 '$SHADOW_DOM_TAG' | 68 '$SHADOW_DOM_TAG' |
| 71 '$CUSTOM_ELEMENT_TAG' | 69 '$CUSTOM_ELEMENT_TAG' |
| 72 '$INTEROP_TAG' | 70 '$INTEROP_TAG' |
| 73 '<script src="test.html_bootstrap.dart.js"></script>' | 71 '<script src="test.html_bootstrap.dart.js"></script>' |
| 74 '</head><body></body></html>', | 72 '</head><body></body></html>', |
| 75 | 73 |
| 76 'a|web/test.html_bootstrap.dart': | 74 'a|web/test.html_bootstrap.dart': |
| 77 '''$MAIN_HEADER | 75 '''$MAIN_HEADER |
| 78 import 'test.html.0.dart_modified.dart' as i0; | 76 import 'test.html.0.dart' as i0; |
| 79 | 77 |
| 80 void main() { | 78 void main() { |
| 81 configureForDeployment([ | 79 configureForDeployment([ |
| 82 'test.html.0.dart_modified.dart', | 80 'test.html.0.dart', |
| 83 ]); | 81 ]); |
| 84 i0.polymerMainWrapper(); | 82 i0.main(); |
| 85 } | 83 } |
| 86 '''.replaceAll('\n ', '\n'), | 84 '''.replaceAll('\n ', '\n'), |
| 87 'a|web/test.html.0.dart': | 85 'a|web/test.html.0.dart': |
| 88 _sampleObservableOutput("B", "bar"), | 86 _sampleObservableOutput("B", "bar"), |
| 89 'a|web/test.html.0.dart_modified.dart': | |
| 90 _sampleObservableOutput("B", "bar", includeMain: true), | |
| 91 }); | 87 }); |
| 92 | 88 |
| 93 testPhases('several scripts', phases, { | 89 testPhases('several scripts', phases, { |
| 94 'a|web/test.html': | 90 'a|web/test.html': |
| 95 '<!DOCTYPE html><html><head>' | 91 '<!DOCTYPE html><html><head>' |
| 96 '<script type="application/dart" src="a.dart"></script>' | 92 '<script type="application/dart" src="a.dart"></script>' |
| 97 // TODO(sigmund): provide a way to see logging warnings and errors. | 93 // TODO(sigmund): provide a way to see logging warnings and errors. |
| 98 // For example, these extra tags produce warnings and are then removed | 94 // For example, these extra tags produce warnings and are then removed |
| 99 // by the transformers. The test below checks that the output looks | 95 // by the transformers. The test below checks that the output looks |
| 100 // correct, but we should also validate the messages logged. | 96 // correct, but we should also validate the messages logged. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 '$SHADOW_DOM_TAG' | 108 '$SHADOW_DOM_TAG' |
| 113 '$CUSTOM_ELEMENT_TAG' | 109 '$CUSTOM_ELEMENT_TAG' |
| 114 '$INTEROP_TAG' | 110 '$INTEROP_TAG' |
| 115 '<script src="test.html_bootstrap.dart.js"></script>' | 111 '<script src="test.html_bootstrap.dart.js"></script>' |
| 116 '</head><body>' | 112 '</head><body>' |
| 117 '<div></div>' | 113 '<div></div>' |
| 118 '</body></html>', | 114 '</body></html>', |
| 119 | 115 |
| 120 'a|web/test.html_bootstrap.dart': | 116 'a|web/test.html_bootstrap.dart': |
| 121 '''$MAIN_HEADER | 117 '''$MAIN_HEADER |
| 122 import 'a.dart_modified.dart' as i0; | 118 import 'a.dart' as i0; |
| 123 | 119 |
| 124 void main() { | 120 void main() { |
| 125 configureForDeployment([ | 121 configureForDeployment([ |
| 126 'a.dart_modified.dart', | 122 'a.dart', |
| 127 ]); | 123 ]); |
| 128 i0.polymerMainWrapper(); | 124 i0.main(); |
| 129 } | 125 } |
| 130 '''.replaceAll('\n ', '\n'), | 126 '''.replaceAll('\n ', '\n'), |
| 131 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), | 127 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), |
| 132 'a|web/a.dart_modified.dart': | |
| 133 _sampleObservableOutput('A', 'foo', includeMain: true), | |
| 134 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), | 128 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), |
| 135 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"), | 129 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"), |
| 136 }); | 130 }); |
| 137 | 131 |
| 138 testPhases('with imports', phases, { | 132 testPhases('with imports', phases, { |
| 139 'a|web/index.html': | 133 'a|web/index.html': |
| 140 '<!DOCTYPE html><html><head>' | 134 '<!DOCTYPE html><html><head>' |
| 141 '<link rel="import" href="test2.html">' | 135 '<link rel="import" href="test2.html">' |
| 142 '</head><body>' | 136 '</head><body>' |
| 143 '<script type="application/dart" src="b.dart"></script>', | 137 '<script type="application/dart" src="b.dart"></script>', |
| 144 'a|web/b.dart': _sampleObservable('B', 'bar'), | 138 'a|web/b.dart': _sampleObservable('B', 'bar'), |
| 145 'a|web/test2.html': | 139 'a|web/test2.html': |
| 146 '<!DOCTYPE html><html><head></head><body>' | 140 '<!DOCTYPE html><html><head></head><body>' |
| 147 '<polymer-element>1' | 141 '<polymer-element>1' |
| 148 '<script type="application/dart">' | 142 '<script type="application/dart">' |
| 149 '${_sampleObservable("A", "foo")}</script>' | 143 '${_sampleObservable("A", "foo")}</script>' |
| 150 '</polymer-element></html>', | 144 '</polymer-element></html>', |
| 151 }, { | 145 }, { |
| 152 'a|web/index.html': | 146 'a|web/index.html': |
| 153 '<!DOCTYPE html><html><head>' | 147 '<!DOCTYPE html><html><head>' |
| 154 '$SHADOW_DOM_TAG' | 148 '$SHADOW_DOM_TAG' |
| 155 '$CUSTOM_ELEMENT_TAG' | 149 '$CUSTOM_ELEMENT_TAG' |
| 156 '$INTEROP_TAG' | 150 '$INTEROP_TAG' |
| 157 '</head><body><polymer-element>1</polymer-element>' | 151 '</head><body><polymer-element>1</polymer-element>' |
| 158 '<script src="index.html_bootstrap.dart.js"></script>' | 152 '<script src="index.html_bootstrap.dart.js"></script>' |
| 159 '</body></html>', | 153 '</body></html>', |
| 160 'a|web/index.html_bootstrap.dart': | 154 'a|web/index.html_bootstrap.dart': |
| 161 '''$MAIN_HEADER | 155 '''$MAIN_HEADER |
| 162 import 'test2.html.0.dart' as i0; | 156 import 'test2.html.0.dart' as i0; |
| 163 import 'b.dart_modified.dart' as i1; | 157 import 'b.dart' as i1; |
| 164 | 158 |
| 165 void main() { | 159 void main() { |
| 166 configureForDeployment([ | 160 configureForDeployment([ |
| 167 'test2.html.0.dart', | 161 'test2.html.0.dart', |
| 168 'b.dart_modified.dart', | 162 'b.dart', |
| 169 ]); | 163 ]); |
| 170 i1.polymerMainWrapper(); | 164 i1.main(); |
| 171 } | 165 } |
| 172 '''.replaceAll('\n ', '\n'), | 166 '''.replaceAll('\n ', '\n'), |
| 173 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), | 167 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), |
| 174 'a|web/test2.html.0.dart_modified.dart': | |
| 175 _sampleObservableOutput("A", "foo", includeMain: true), | |
| 176 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), | 168 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), |
| 177 }); | 169 }); |
| 178 } | 170 } |
| 179 | 171 |
| 180 String _sampleObservable(String className, String fieldName) => ''' | 172 String _sampleObservable(String className, String fieldName) => ''' |
| 181 library ${className}_$fieldName; | 173 library ${className}_$fieldName; |
| 182 import 'package:observe/observe.dart'; | 174 import 'package:observe/observe.dart'; |
| 183 | 175 |
| 184 class $className extends Observable { | 176 class $className extends Observable { |
| 185 @observable int $fieldName; | 177 @observable int $fieldName; |
| 186 $className(this.$fieldName); | 178 $className(this.$fieldName); |
| 187 } | 179 } |
| 188 '''; | 180 '''; |
| 189 | 181 |
| 190 String _sampleObservableOutput(String className, String field, | 182 String _sampleObservableOutput(String className, String field, |
| 191 {bool includeMain: false}) => | 183 {bool includeMain: false}) => |
| 192 "library ${className}_$field;\n" | 184 "library ${className}_$field;\n" |
| 193 "import 'package:observe/observe.dart';\n\n" | 185 "import 'package:observe/observe.dart';\n\n" |
| 194 "class $className extends ChangeNotifier {\n" | 186 "class $className extends ChangeNotifier {\n" |
| 195 " @reflectable @observable int get $field => __\$$field; " | 187 " @reflectable @observable int get $field => __\$$field; " |
| 196 "int __\$$field; " | 188 "int __\$$field; " |
| 197 "@reflectable set $field(int value) { " | 189 "@reflectable set $field(int value) { " |
| 198 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); " | 190 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); " |
| 199 "}\n" | 191 "}\n" |
| 200 " $className($field) : __\$$field = $field;\n" | 192 " $className($field) : __\$$field = $field;\n" |
| 201 "}\n" | 193 "}\n"; |
| 202 "${includeMain ? '\n\npolymerMainWrapper() => main();\n' : ''}"; | |
| OLD | NEW |