| 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:code_transformers/tests.dart' show testingDartSdkDirectory; | 7 import 'package:code_transformers/tests.dart' show testingDartSdkDirectory; |
| 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' show COMPONENT_WARNING; | 9 import 'package:polymer/src/build/linter.dart' show USE_POLYMER_HTML, |
| 10 import 'package:polymer/src/build/linter.dart' show USE_POLYMER_HTML; | 10 USE_INIT_DART, ONLY_ONE_TAG; |
| 11 import 'package:polymer/src/build/script_compactor.dart' show MAIN_HEADER; | 11 import 'package:polymer/src/build/script_compactor.dart' show MAIN_HEADER; |
| 12 import 'package:polymer/transformer.dart'; | 12 import 'package:polymer/transformer.dart'; |
| 13 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS; | 13 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS; |
| 14 import 'package:unittest/compact_vm_config.dart'; | 14 import 'package:unittest/compact_vm_config.dart'; |
| 15 | 15 |
| 16 import 'common.dart'; | 16 import 'common.dart'; |
| 17 | 17 |
| 18 void main() { | 18 void main() { |
| 19 useCompactVMConfiguration(); | 19 useCompactVMConfiguration(); |
| 20 var phases = createDeployPhases(new TransformOptions(), | 20 var phases = createDeployPhases(new TransformOptions(), |
| 21 sdkDir: testingDartSdkDirectory); | 21 sdkDir: testingDartSdkDirectory); |
| 22 | 22 |
| 23 testPhases('no changes', phases, { | 23 testPhases('no changes', phases, { |
| 24 'a|web/test.html': '<!DOCTYPE html><html></html>', | 24 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 25 }, {}, [ | 25 }, {}, [ |
| 26 'warning: $USE_POLYMER_HTML' | 26 'warning: $USE_POLYMER_HTML', |
| 27 'warning: $USE_INIT_DART' |
| 27 ]); | 28 ]); |
| 28 | 29 |
| 29 testPhases('observable changes', phases, { | 30 testPhases('observable changes', phases, { |
| 30 'a|web/test.dart': _sampleInput('A', 'foo'), | 31 'a|web/test.dart': _sampleInput('A', 'foo'), |
| 31 'a|web/test2.dart': _sampleOutput('B', 'bar'), | 32 'a|web/test2.dart': _sampleOutput('B', 'bar'), |
| 32 }, { | 33 }, { |
| 33 'a|web/test.dart': _sampleOutput('A', 'foo'), | 34 'a|web/test.dart': _sampleOutput('A', 'foo'), |
| 34 'a|web/test2.dart': _sampleOutput('B', 'bar'), | 35 'a|web/test2.dart': _sampleOutput('B', 'bar'), |
| 35 }); | 36 }); |
| 36 | 37 |
| 37 testPhases('single script', phases, { | 38 testPhases('single script', phases, { |
| 38 'a|web/test.html': | 39 'a|web/test.html': |
| 39 '<!DOCTYPE html><html><head>' | 40 '<!DOCTYPE html><html><head>' |
| 40 '<link rel="import" href="packages/polymer/polymer.html">' | 41 '<link rel="import" href="packages/polymer/polymer.html">' |
| 41 '<script type="application/dart;component=1" src="a.dart"></script>', | 42 '<script type="application/dart" src="a.dart"></script>', |
| 42 'a|web/a.dart': _sampleInput('A', 'foo'), | 43 'a|web/a.dart': _sampleInput('A', 'foo'), |
| 43 }, { | 44 }, { |
| 44 'a|web/test.html': | 45 'a|web/test.html': |
| 45 '<!DOCTYPE html><html><head>' | 46 '<!DOCTYPE html><html><head>' |
| 46 '$WEB_COMPONENTS_TAG' | 47 '$WEB_COMPONENTS_TAG' |
| 47 '</head><body>' | 48 '</head><body>' |
| 48 '<script src="test.html_bootstrap.dart.js"></script>' | 49 '<script src="test.html_bootstrap.dart.js"></script>' |
| 49 '</body></html>', | 50 '</body></html>', |
| 50 | 51 |
| 51 'a|web/test.html_bootstrap.dart': | 52 'a|web/test.html_bootstrap.dart': |
| 52 '''$MAIN_HEADER | 53 '''$MAIN_HEADER |
| 53 import 'a.dart' as i0; | 54 import 'a.dart' as i0; |
| 54 ${DEFAULT_IMPORTS.join('\n')} | 55 ${DEFAULT_IMPORTS.join('\n')} |
| 55 import 'a.dart' as smoke_0; | 56 import 'a.dart' as smoke_0; |
| 56 import 'package:polymer/polymer.dart' as smoke_1; | 57 import 'package:polymer/polymer.dart' as smoke_1; |
| 57 | 58 |
| 58 void main() { | 59 void main() { |
| 59 useGeneratedCode(new StaticConfiguration( | 60 useGeneratedCode(new StaticConfiguration( |
| 60 checkedMode: false, | 61 checkedMode: false, |
| 61 parents: { | 62 parents: { |
| 62 smoke_0.XA: smoke_1.PolymerElement, | 63 smoke_0.XA: smoke_1.PolymerElement, |
| 63 }, | 64 }, |
| 64 declarations: { | 65 declarations: { |
| 65 smoke_0.XA: const {}, | 66 smoke_0.XA: const {}, |
| 66 })); | 67 })); |
| 67 startPolymer([ | 68 configureForDeployment([ |
| 68 i0.m_foo, | 69 i0.m_foo, |
| 69 () => Polymer.register('x-A', i0.XA), | 70 () => Polymer.register('x-A', i0.XA), |
| 70 ]); | 71 ]); |
| 72 i0.main(); |
| 71 } | 73 } |
| 72 '''.replaceAll('\n ', '\n'), | 74 '''.replaceAll('\n ', '\n'), |
| 73 'a|web/a.dart': _sampleOutput('A', 'foo'), | 75 'a|web/a.dart': _sampleOutput('A', 'foo'), |
| 74 }); | 76 }, []); |
| 75 | 77 |
| 76 testPhases('single inline script', phases, { | 78 testPhases('single inline script', phases, { |
| 77 'a|web/test.html': | 79 'a|web/test.html': |
| 78 '<!DOCTYPE html><html><head>' | 80 '<!DOCTYPE html><html><head>' |
| 79 '<link rel="import" href="packages/polymer/polymer.html">' | 81 '<link rel="import" href="packages/polymer/polymer.html">' |
| 80 '<script type="application/dart;component=1">' | 82 '<script type="application/dart">' |
| 81 '${_sampleInput("B", "bar")}</script>', | 83 '${_sampleInput("B", "bar")}</script>', |
| 82 }, { | 84 }, { |
| 83 'a|web/test.html': | 85 'a|web/test.html': |
| 84 '<!DOCTYPE html><html><head>' | 86 '<!DOCTYPE html><html><head>' |
| 85 '$WEB_COMPONENTS_TAG' | 87 '$WEB_COMPONENTS_TAG' |
| 86 '</head><body>' | 88 '</head><body>' |
| 87 '<script src="test.html_bootstrap.dart.js"></script>' | 89 '<script src="test.html_bootstrap.dart.js"></script>' |
| 88 '</body></html>', | 90 '</body></html>', |
| 89 | 91 |
| 90 'a|web/test.html_bootstrap.dart': | 92 'a|web/test.html_bootstrap.dart': |
| 91 '''$MAIN_HEADER | 93 '''$MAIN_HEADER |
| 92 import 'test.html.0.dart' as i0; | 94 import 'test.html.0.dart' as i0; |
| 93 ${DEFAULT_IMPORTS.join('\n')} | 95 ${DEFAULT_IMPORTS.join('\n')} |
| 94 import 'test.html.0.dart' as smoke_0; | 96 import 'test.html.0.dart' as smoke_0; |
| 95 import 'package:polymer/polymer.dart' as smoke_1; | 97 import 'package:polymer/polymer.dart' as smoke_1; |
| 96 | 98 |
| 97 void main() { | 99 void main() { |
| 98 useGeneratedCode(new StaticConfiguration( | 100 useGeneratedCode(new StaticConfiguration( |
| 99 checkedMode: false, | 101 checkedMode: false, |
| 100 parents: { | 102 parents: { |
| 101 smoke_0.XB: smoke_1.PolymerElement, | 103 smoke_0.XB: smoke_1.PolymerElement, |
| 102 }, | 104 }, |
| 103 declarations: { | 105 declarations: { |
| 104 smoke_0.XB: const {}, | 106 smoke_0.XB: const {}, |
| 105 })); | 107 })); |
| 106 startPolymer([ | 108 configureForDeployment([ |
| 107 i0.m_bar, | 109 i0.m_bar, |
| 108 () => Polymer.register('x-B', i0.XB), | 110 () => Polymer.register('x-B', i0.XB), |
| 109 ]); | 111 ]); |
| 112 i0.main(); |
| 110 } | 113 } |
| 111 '''.replaceAll('\n ', '\n'), | 114 '''.replaceAll('\n ', '\n'), |
| 112 'a|web/test.html.0.dart': | 115 'a|web/test.html.0.dart': |
| 113 _sampleOutput("B", "bar"), | 116 _sampleOutput("B", "bar"), |
| 114 }); | 117 }); |
| 115 | 118 |
| 116 testPhases('several application scripts', phases, { | 119 testPhases('several scripts', phases, { |
| 117 'a|web/test.html': | 120 'a|web/test.html': |
| 118 '<!DOCTYPE html><html><head>' | 121 '<!DOCTYPE html><html><head>' |
| 119 '<link rel="import" href="packages/polymer/polymer.html">' | 122 '<link rel="import" href="packages/polymer/polymer.html">\n' |
| 120 '<script type="application/dart;component=1" src="a.dart"></script>' | 123 '<script type="application/dart" src="a.dart"></script>\n' |
| 121 '<script type="application/dart">' | 124 '<script type="application/dart">' |
| 122 '${_sampleInput("B", "bar")}</script>' | 125 '${_sampleInput("B", "bar")}</script>' |
| 123 '</head><body><div>' | 126 '</head><body><div>\n' |
| 124 '<script type="application/dart">' | 127 '<script type="application/dart">' |
| 125 '${_sampleInput("C", "car")}</script>' | 128 '${_sampleInput("C", "car")}</script>' |
| 126 '</div>' | 129 '</div>\n' |
| 127 '<script type="application/dart" src="d.dart"></script>', | 130 '<script type="application/dart" src="d.dart"></script>', |
| 128 'a|web/a.dart': _sampleInput('A', 'foo'), | 131 'a|web/a.dart': _sampleInput('A', 'foo'), |
| 129 }, { | 132 }, { |
| 130 'a|web/test.html': | 133 'a|web/test.html': |
| 131 '<!DOCTYPE html><html><head>' | 134 '<!DOCTYPE html><html><head>' |
| 132 '$WEB_COMPONENTS_TAG' | 135 '$WEB_COMPONENTS_TAG\n\n' |
| 133 '</head><body>' | 136 '</head><body>' |
| 134 '<script src="test.html.0.dart.js"></script>' | 137 '<div>\n</div>\n' |
| 135 '<div>' | |
| 136 '<script src="test.html.1.dart.js"></script>' | |
| 137 '</div>' | |
| 138 '<script src="d.dart.js"></script>' | |
| 139 '<script src="test.html_bootstrap.dart.js"></script>' | 138 '<script src="test.html_bootstrap.dart.js"></script>' |
| 140 '</body></html>', | 139 '</body></html>', |
| 141 | |
| 142 'a|web/test.html_bootstrap.dart': | |
| 143 '''$MAIN_HEADER | |
| 144 import 'a.dart' as i0; | |
| 145 ${DEFAULT_IMPORTS.join('\n')} | |
| 146 import 'a.dart' as smoke_0; | |
| 147 import 'package:polymer/polymer.dart' as smoke_1; | |
| 148 | |
| 149 void main() { | |
| 150 useGeneratedCode(new StaticConfiguration( | |
| 151 checkedMode: false, | |
| 152 parents: { | |
| 153 smoke_0.XA: smoke_1.PolymerElement, | |
| 154 }, | |
| 155 declarations: { | |
| 156 smoke_0.XA: const {}, | |
| 157 })); | |
| 158 startPolymer([ | |
| 159 i0.m_foo, | |
| 160 () => Polymer.register('x-A', i0.XA), | |
| 161 ]); | |
| 162 } | |
| 163 '''.replaceAll('\n ', '\n'), | |
| 164 'a|web/a.dart': _sampleOutput('A', 'foo'), | |
| 165 }, [ | |
| 166 // These should not be emitted multiple times. See: | |
| 167 // https://code.google.com/p/dart/issues/detail?id=17197 | |
| 168 'warning: $COMPONENT_WARNING (web/test.html 14 27)', | |
| 169 'warning: $COMPONENT_WARNING (web/test.html 28 15)' | |
| 170 ]); | |
| 171 | |
| 172 testPhases('several component scripts', phases, { | |
| 173 'a|web/test.html': | |
| 174 '<!DOCTYPE html><html><head>' | |
| 175 '<link rel="import" href="packages/polymer/polymer.html">' | |
| 176 '<script type="application/dart;component=1" src="a.dart"></script>' | |
| 177 '<script type="application/dart;component=1">' | |
| 178 '${_sampleInput("B", "bar")}</script>' | |
| 179 '</head><body><div>' | |
| 180 '<script type="application/dart;component=1">' | |
| 181 '${_sampleInput("C", "car")}</script>' | |
| 182 '</div>', | |
| 183 'a|web/a.dart': _sampleInput('A', 'foo'), | |
| 184 }, { | |
| 185 'a|web/test.html': | |
| 186 '<!DOCTYPE html><html><head>' | |
| 187 '$WEB_COMPONENTS_TAG' | |
| 188 '</head><body>' | |
| 189 '<div></div>' | |
| 190 '<script src="test.html_bootstrap.dart.js"></script>' | |
| 191 '</body></html>', | |
| 192 | |
| 193 'a|web/test.html_bootstrap.dart': | 140 'a|web/test.html_bootstrap.dart': |
| 194 '''$MAIN_HEADER | 141 '''$MAIN_HEADER |
| 195 import 'a.dart' as i0; | 142 import 'a.dart' as i0; |
| 196 import 'test.html.0.dart' as i1; | 143 import 'test.html.0.dart' as i1; |
| 197 import 'test.html.1.dart' as i2; | 144 import 'test.html.1.dart' as i2; |
| 198 ${DEFAULT_IMPORTS.join('\n')} | 145 ${DEFAULT_IMPORTS.join('\n')} |
| 199 import 'a.dart' as smoke_0; | 146 import 'a.dart' as smoke_0; |
| 200 import 'package:polymer/polymer.dart' as smoke_1; | 147 import 'package:polymer/polymer.dart' as smoke_1; |
| 201 import 'test.html.0.dart' as smoke_2; | 148 import 'test.html.0.dart' as smoke_2; |
| 202 import 'test.html.1.dart' as smoke_3; | 149 import 'test.html.1.dart' as smoke_3; |
| 203 | 150 |
| 204 void main() { | 151 void main() { |
| 205 useGeneratedCode(new StaticConfiguration( | 152 useGeneratedCode(new StaticConfiguration( |
| 206 checkedMode: false, | 153 checkedMode: false, |
| 207 parents: { | 154 parents: { |
| 208 smoke_0.XA: smoke_1.PolymerElement, | 155 smoke_0.XA: smoke_1.PolymerElement, |
| 209 smoke_2.XB: smoke_1.PolymerElement, | 156 smoke_2.XB: smoke_1.PolymerElement, |
| 210 smoke_3.XC: smoke_1.PolymerElement, | 157 smoke_3.XC: smoke_1.PolymerElement, |
| 211 }, | 158 }, |
| 212 declarations: { | 159 declarations: { |
| 213 smoke_0.XA: const {}, | 160 smoke_0.XA: const {}, |
| 214 smoke_2.XB: const {}, | 161 smoke_2.XB: const {}, |
| 215 smoke_3.XC: const {}, | 162 smoke_3.XC: const {}, |
| 216 })); | 163 })); |
| 217 startPolymer([ | 164 configureForDeployment([ |
| 218 i0.m_foo, | 165 i0.m_foo, |
| 219 () => Polymer.register('x-A', i0.XA), | 166 () => Polymer.register('x-A', i0.XA), |
| 220 i1.m_bar, | 167 i1.m_bar, |
| 221 () => Polymer.register('x-B', i1.XB), | 168 () => Polymer.register('x-B', i1.XB), |
| 222 i2.m_car, | 169 i2.m_car, |
| 223 () => Polymer.register('x-C', i2.XC), | 170 () => Polymer.register('x-C', i2.XC), |
| 224 ]); | 171 ]); |
| 172 i2.main(); |
| 225 } | 173 } |
| 226 '''.replaceAll('\n ', '\n'), | 174 '''.replaceAll('\n ', '\n'), |
| 227 'a|web/a.dart': _sampleOutput('A', 'foo'), | 175 'a|web/a.dart': _sampleOutput('A', 'foo'), |
| 228 }, []); | 176 }, [ |
| 177 // These should not be emitted multiple times. See: |
| 178 // https://code.google.com/p/dart/issues/detail?id=17197 |
| 179 'warning: $ONLY_ONE_TAG (web/test.html 2 0)', |
| 180 'warning: $ONLY_ONE_TAG (web/test.html 18 0)', |
| 181 'warning: $ONLY_ONE_TAG (web/test.html 34 0)', |
| 182 'warning: Script file at "d.dart" not found. (web/test.html 34 0)', |
| 183 ]); |
| 229 | 184 |
| 230 testPhases('with imports', phases, { | 185 testPhases('with imports', phases, { |
| 231 'a|web/index.html': | 186 'a|web/index.html': |
| 232 '<!DOCTYPE html><html><head>' | 187 '<!DOCTYPE html><html><head>' |
| 233 '<link rel="import" href="packages/polymer/polymer.html">' | 188 '<link rel="import" href="packages/polymer/polymer.html">' |
| 234 '<link rel="import" href="test2.html">' | 189 '<link rel="import" href="packages/a/test2.html">' |
| 235 '</head><body>' | 190 '</head><body>' |
| 236 '<script type="application/dart;component=1" src="b.dart"></script>', | 191 '<script type="application/dart" src="b.dart"></script>', |
| 237 'a|web/b.dart': _sampleInput('B', 'bar'), | 192 'a|web/b.dart': _sampleInput('B', 'bar'), |
| 238 'a|web/test2.html': | 193 'a|lib/test2.html': |
| 239 '<!DOCTYPE html><html><head></head><body>' | 194 '<!DOCTYPE html><html><head></head><body>' |
| 240 '<polymer-element name="x-a">1' | 195 '<polymer-element name="x-a">1' |
| 241 '<script type="application/dart;component=1">' | 196 '<script type="application/dart">' |
| 242 '${_sampleInput("A", "foo")}</script>' | 197 '${_sampleInput("A", "foo")}</script>' |
| 243 '</polymer-element></html>', | 198 '</polymer-element></html>', |
| 244 }, { | 199 }, { |
| 245 'a|web/index.html': | 200 'a|web/index.html': |
| 246 '<!DOCTYPE html><html><head>' | 201 '<!DOCTYPE html><html><head>' |
| 202 '$WEB_COMPONENTS_TAG' |
| 203 '</head><body><polymer-element name="x-a">1</polymer-element>' |
| 204 '<script src="index.html_bootstrap.dart.js"></script>' |
| 205 '</body></html>', |
| 206 'a|web/index.html_bootstrap.dart': |
| 207 '''$MAIN_HEADER |
| 208 import 'index.html.0.dart' as i0; |
| 209 import 'b.dart' as i1; |
| 210 ${DEFAULT_IMPORTS.join('\n')} |
| 211 import 'index.html.0.dart' as smoke_0; |
| 212 import 'package:polymer/polymer.dart' as smoke_1; |
| 213 import 'b.dart' as smoke_2; |
| 214 |
| 215 void main() { |
| 216 useGeneratedCode(new StaticConfiguration( |
| 217 checkedMode: false, |
| 218 parents: { |
| 219 smoke_2.XB: smoke_1.PolymerElement, |
| 220 smoke_0.XA: smoke_1.PolymerElement, |
| 221 }, |
| 222 declarations: { |
| 223 smoke_2.XB: const {}, |
| 224 smoke_0.XA: const {}, |
| 225 })); |
| 226 configureForDeployment([ |
| 227 i0.m_foo, |
| 228 () => Polymer.register('x-A', i0.XA), |
| 229 i1.m_bar, |
| 230 () => Polymer.register('x-B', i1.XB), |
| 231 ]); |
| 232 i1.main(); |
| 233 } |
| 234 '''.replaceAll('\n ', '\n'), |
| 235 'a|web/index.html.0.dart': _sampleOutput("A", "foo"), |
| 236 'a|web/b.dart': _sampleOutput('B', 'bar'), |
| 237 }, []); |
| 238 |
| 239 testPhases('experimental bootstrap', phases, { |
| 240 'a|web/index.html': |
| 241 '<!DOCTYPE html><html><head>' |
| 242 '<link rel="import" ' |
| 243 'href="packages/polymer/polymer_experimental.html">' |
| 244 '<link rel="import" href="packages/a/test2.html">' |
| 245 '<link rel="import" href="packages/a/load_b.html">', |
| 246 'a|lib/b.dart': _sampleInput('B', 'bar'), |
| 247 'a|lib/test2.html': |
| 248 '<!DOCTYPE html><html><head></head><body>' |
| 249 '<polymer-element name="x-a">1' |
| 250 '<script type="application/dart">' |
| 251 '${_sampleInput("A", "foo")}</script>' |
| 252 '</polymer-element></html>', |
| 253 'a|lib/load_b.html': |
| 254 '<!DOCTYPE html><html><head></head><body>' |
| 255 '<script type="application/dart" src="b.dart"></script>', |
| 256 }, { |
| 257 'a|web/index.html': |
| 258 '<!DOCTYPE html><html><head>' |
| 247 '$WEB_COMPONENTS_TAG' | 259 '$WEB_COMPONENTS_TAG' |
| 248 '</head><body><polymer-element name="x-a">1</polymer-element>' | 260 '</head><body><polymer-element name="x-a">1</polymer-element>' |
| 249 '<script src="index.html_bootstrap.dart.js"></script>' | 261 '<script src="index.html_bootstrap.dart.js"></script>' |
| 250 '</body></html>', | 262 '</body></html>', |
| 251 'a|web/index.html_bootstrap.dart': | 263 'a|web/index.html_bootstrap.dart': |
| 252 '''$MAIN_HEADER | 264 '''$MAIN_HEADER |
| 253 import 'index.html.0.dart' as i0; | 265 import 'index.html.0.dart' as i0; |
| 254 import 'b.dart' as i1; | 266 import 'package:a/b.dart' as i1; |
| 255 ${DEFAULT_IMPORTS.join('\n')} | 267 ${DEFAULT_IMPORTS.join('\n')} |
| 256 import 'index.html.0.dart' as smoke_0; | 268 import 'index.html.0.dart' as smoke_0; |
| 257 import 'package:polymer/polymer.dart' as smoke_1; | 269 import 'package:polymer/polymer.dart' as smoke_1; |
| 258 import 'b.dart' as smoke_2; | 270 import 'package:a/b.dart' as smoke_2; |
| 259 | 271 |
| 260 void main() { | 272 void main() { |
| 261 useGeneratedCode(new StaticConfiguration( | 273 useGeneratedCode(new StaticConfiguration( |
| 262 checkedMode: false, | 274 checkedMode: false, |
| 263 parents: { | 275 parents: { |
| 276 smoke_0.XA: smoke_1.PolymerElement, |
| 264 smoke_2.XB: smoke_1.PolymerElement, | 277 smoke_2.XB: smoke_1.PolymerElement, |
| 265 smoke_0.XA: smoke_1.PolymerElement, | |
| 266 }, | 278 }, |
| 267 declarations: { | 279 declarations: { |
| 280 smoke_0.XA: const {}, |
| 268 smoke_2.XB: const {}, | 281 smoke_2.XB: const {}, |
| 269 smoke_0.XA: const {}, | |
| 270 })); | 282 })); |
| 271 startPolymer([ | 283 startPolymer([ |
| 272 i0.m_foo, | 284 i0.m_foo, |
| 273 () => Polymer.register('x-A', i0.XA), | 285 () => Polymer.register('x-A', i0.XA), |
| 274 i1.m_bar, | 286 i1.m_bar, |
| 275 () => Polymer.register('x-B', i1.XB), | 287 () => Polymer.register('x-B', i1.XB), |
| 276 ]); | 288 ]); |
| 277 } | 289 } |
| 278 '''.replaceAll('\n ', '\n'), | 290 '''.replaceAll('\n ', '\n'), |
| 279 'a|web/index.html.0.dart': _sampleOutput("A", "foo"), | 291 'a|web/index.html.0.dart': _sampleOutput("A", "foo"), |
| 280 'a|web/b.dart': _sampleOutput('B', 'bar'), | 292 'a|lib/b.dart': _sampleOutput('B', 'bar'), |
| 281 }); | 293 }, []); |
| 282 } | 294 } |
| 283 | 295 |
| 284 String _sampleInput(String className, String fieldName) => ''' | 296 String _sampleInput(String className, String fieldName) => ''' |
| 285 library ${className}_$fieldName; | 297 library ${className}_$fieldName; |
| 286 import 'package:observe/observe.dart'; | 298 import 'package:observe/observe.dart'; |
| 287 import 'package:polymer/polymer.dart'; | 299 import 'package:polymer/polymer.dart'; |
| 288 | 300 |
| 289 class $className extends Observable { | 301 class $className extends Observable { |
| 290 @observable int $fieldName; | 302 @observable int $fieldName; |
| 291 $className(this.$fieldName); | 303 $className(this.$fieldName); |
| 292 } | 304 } |
| 293 | 305 |
| 294 @CustomTag('x-$className') | 306 @CustomTag('x-$className') |
| 295 class X${className} extends PolymerElement { | 307 class X${className} extends PolymerElement { |
| 296 X${className}.created() : super.created(); | 308 X${className}.created() : super.created(); |
| 297 } | 309 } |
| 298 @initMethod m_$fieldName() {} | 310 @initMethod m_$fieldName() {} |
| 311 main() {} |
| 299 '''; | 312 '''; |
| 300 | 313 |
| 301 | 314 |
| 302 String _sampleOutput(String className, String fieldName) { | 315 String _sampleOutput(String className, String fieldName) { |
| 303 var fieldReplacement = '@reflectable @observable ' | 316 var fieldReplacement = '@reflectable @observable ' |
| 304 'int get $fieldName => __\$$fieldName; ' | 317 'int get $fieldName => __\$$fieldName; ' |
| 305 'int __\$$fieldName; ' | 318 'int __\$$fieldName; ' |
| 306 '@reflectable set $fieldName(int value) { ' | 319 '@reflectable set $fieldName(int value) { ' |
| 307 '__\$$fieldName = notifyPropertyChange(#$fieldName, ' | 320 '__\$$fieldName = notifyPropertyChange(#$fieldName, ' |
| 308 '__\$$fieldName, value); }'; | 321 '__\$$fieldName, value); }'; |
| 309 return ''' | 322 return ''' |
| 310 library ${className}_$fieldName; | 323 library ${className}_$fieldName; |
| 311 import 'package:observe/observe.dart'; | 324 import 'package:observe/observe.dart'; |
| 312 import 'package:polymer/polymer.dart'; | 325 import 'package:polymer/polymer.dart'; |
| 313 | 326 |
| 314 class $className extends ChangeNotifier { | 327 class $className extends ChangeNotifier { |
| 315 $fieldReplacement | 328 $fieldReplacement |
| 316 $className($fieldName) : __\$$fieldName = $fieldName; | 329 $className($fieldName) : __\$$fieldName = $fieldName; |
| 317 } | 330 } |
| 318 | 331 |
| 319 @CustomTag('x-$className') | 332 @CustomTag('x-$className') |
| 320 class X${className} extends PolymerElement { | 333 class X${className} extends PolymerElement { |
| 321 X${className}.created() : super.created(); | 334 X${className}.created() : super.created(); |
| 322 } | 335 } |
| 323 @initMethod m_$fieldName() {} | 336 @initMethod m_$fieldName() {} |
| 337 main() {} |
| 324 '''; | 338 '''; |
| 325 } | 339 } |
| OLD | NEW |