| 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.transform.script_compactor_test; | 5 library polymer.test.transform.all_phases_test; |
| 6 | 6 |
| 7 import 'package:polymer/src/transform.dart'; | 7 import 'package:polymer/src/transform.dart'; |
| 8 import 'package:unittest/compact_vm_config.dart'; | 8 import 'package:unittest/compact_vm_config.dart'; |
| 9 | 9 |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 useCompactVMConfiguration(); | 13 useCompactVMConfiguration(); |
| 14 | 14 |
| 15 testPhases('no changes', phases, { | 15 testPhases('no changes', phases, { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 27 }); | 27 }); |
| 28 | 28 |
| 29 testPhases('single script', phases, { | 29 testPhases('single script', phases, { |
| 30 'a|web/test.html': | 30 'a|web/test.html': |
| 31 '<!DOCTYPE html><html><head>' | 31 '<!DOCTYPE html><html><head>' |
| 32 '<script type="application/dart" src="a.dart"></script>', | 32 '<script type="application/dart" src="a.dart"></script>', |
| 33 'a|web/test.dart': _sampleObservable('A', 'foo'), | 33 'a|web/test.dart': _sampleObservable('A', 'foo'), |
| 34 }, { | 34 }, { |
| 35 'a|web/test.html': | 35 'a|web/test.html': |
| 36 '<!DOCTYPE html><html><head></head><body>' | 36 '<!DOCTYPE html><html><head></head><body>' |
| 37 '$SHADOW_DOM_TAG' |
| 38 '$INTEROP_TAG' |
| 37 '<script type="application/dart" ' | 39 '<script type="application/dart" ' |
| 38 'src="test.html_bootstrap.dart"></script>' | 40 'src="test.html_bootstrap.dart"></script>' |
| 39 '<script type="text/javascript" ' | 41 '<script type="text/javascript" ' |
| 40 'src="packages/browser/dart.js"></script>' | 42 'src="packages/browser/dart.js"></script>' |
| 41 '</body></html>', | 43 '</body></html>', |
| 42 | 44 |
| 43 'a|web/test.html_bootstrap.dart': | 45 'a|web/test.html_bootstrap.dart': |
| 44 '''library app_bootstrap; | 46 '''library app_bootstrap; |
| 45 | 47 |
| 46 import 'package:polymer/polymer.dart'; | 48 import 'package:polymer/polymer.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 }); | 60 }); |
| 59 | 61 |
| 60 testPhases('single inline script', phases, { | 62 testPhases('single inline script', phases, { |
| 61 'a|web/test.html': | 63 'a|web/test.html': |
| 62 '<!DOCTYPE html><html><head>' | 64 '<!DOCTYPE html><html><head>' |
| 63 '<script type="application/dart">' | 65 '<script type="application/dart">' |
| 64 '${_sampleObservable("B", "bar")}</script>', | 66 '${_sampleObservable("B", "bar")}</script>', |
| 65 }, { | 67 }, { |
| 66 'a|web/test.html': | 68 'a|web/test.html': |
| 67 '<!DOCTYPE html><html><head></head><body>' | 69 '<!DOCTYPE html><html><head></head><body>' |
| 70 '$SHADOW_DOM_TAG' |
| 71 '$INTEROP_TAG' |
| 68 '<script type="application/dart" ' | 72 '<script type="application/dart" ' |
| 69 'src="test.html_bootstrap.dart"></script>' | 73 'src="test.html_bootstrap.dart"></script>' |
| 70 '<script type="text/javascript" ' | 74 '<script type="text/javascript" ' |
| 71 'src="packages/browser/dart.js"></script>' | 75 'src="packages/browser/dart.js"></script>' |
| 72 '</body></html>', | 76 '</body></html>', |
| 73 | 77 |
| 74 'a|web/test.html_bootstrap.dart': | 78 'a|web/test.html_bootstrap.dart': |
| 75 '''library app_bootstrap; | 79 '''library app_bootstrap; |
| 76 | 80 |
| 77 import 'package:polymer/polymer.dart'; | 81 import 'package:polymer/polymer.dart'; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 95 '<script type="application/dart">' | 99 '<script type="application/dart">' |
| 96 '${_sampleObservable("B", "bar")}</script>' | 100 '${_sampleObservable("B", "bar")}</script>' |
| 97 '</head><body><div>' | 101 '</head><body><div>' |
| 98 '<script type="application/dart">' | 102 '<script type="application/dart">' |
| 99 '${_sampleObservable("C", "car")}</script>' | 103 '${_sampleObservable("C", "car")}</script>' |
| 100 '</div>' | 104 '</div>' |
| 101 '<script type="application/dart" src="d.dart"></script>', | 105 '<script type="application/dart" src="d.dart"></script>', |
| 102 'a|web/a.dart': _sampleObservable('A', 'foo'), | 106 'a|web/a.dart': _sampleObservable('A', 'foo'), |
| 103 }, { | 107 }, { |
| 104 'a|web/test.html': | 108 'a|web/test.html': |
| 105 '<!DOCTYPE html><html><head></head><body><div></div>' | 109 '<!DOCTYPE html><html><head></head><body>' |
| 110 '$SHADOW_DOM_TAG' |
| 111 '$INTEROP_TAG' |
| 112 '<div></div>' |
| 106 '<script type="application/dart" ' | 113 '<script type="application/dart" ' |
| 107 'src="test.html_bootstrap.dart"></script>' | 114 'src="test.html_bootstrap.dart"></script>' |
| 108 '<script type="text/javascript" ' | 115 '<script type="text/javascript" ' |
| 109 'src="packages/browser/dart.js"></script>' | 116 'src="packages/browser/dart.js"></script>' |
| 110 '</body></html>', | 117 '</body></html>', |
| 111 | 118 |
| 112 'a|web/test.html_bootstrap.dart': | 119 'a|web/test.html_bootstrap.dart': |
| 113 '''library app_bootstrap; | 120 '''library app_bootstrap; |
| 114 | 121 |
| 115 import 'package:polymer/polymer.dart'; | 122 import 'package:polymer/polymer.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 testPhases('with imports', phases, { | 144 testPhases('with imports', phases, { |
| 138 'a|web/index.html': | 145 'a|web/index.html': |
| 139 '<!DOCTYPE html><html><head>' | 146 '<!DOCTYPE html><html><head>' |
| 140 '<link rel="import" href="test2.html">' | 147 '<link rel="import" href="test2.html">' |
| 141 '</head><body>' | 148 '</head><body>' |
| 142 '<script type="application/dart" src="b.dart"></script>' | 149 '<script type="application/dart" src="b.dart"></script>' |
| 143 '<script type="application/dart">' | 150 '<script type="application/dart">' |
| 144 '${_sampleObservable("C", "car")}</script>', | 151 '${_sampleObservable("C", "car")}</script>', |
| 145 'a|web/b.dart': _sampleObservable('B', 'bar'), | 152 'a|web/b.dart': _sampleObservable('B', 'bar'), |
| 146 'a|web/test2.html': | 153 'a|web/test2.html': |
| 147 '<!DOCTYPE html><html><head>' | 154 '<!DOCTYPE html><html><head></head><body>' |
| 148 '</head><body><polymer-element>1' | 155 '<polymer-element>1' |
| 149 '<script type="application/dart">' | 156 '<script type="application/dart">' |
| 150 '${_sampleObservable("A", "foo")}</script>' | 157 '${_sampleObservable("A", "foo")}</script>' |
| 151 '</polymer-element></html>', | 158 '</polymer-element></html>', |
| 152 }, { | 159 }, { |
| 153 'a|web/index.html': | 160 'a|web/index.html': |
| 154 '<!DOCTYPE html><html><head></head><body>' | 161 '<!DOCTYPE html><html><head></head><body>' |
| 162 '$SHADOW_DOM_TAG' |
| 163 '$INTEROP_TAG' |
| 155 '<polymer-element>1</polymer-element>' | 164 '<polymer-element>1</polymer-element>' |
| 156 '<script type="application/dart" ' | 165 '<script type="application/dart" ' |
| 157 'src="index.html_bootstrap.dart"></script>' | 166 'src="index.html_bootstrap.dart"></script>' |
| 158 '<script type="text/javascript" ' | 167 '<script type="text/javascript" ' |
| 159 'src="packages/browser/dart.js"></script>' | 168 'src="packages/browser/dart.js"></script>' |
| 160 '</body></html>', | 169 '</body></html>', |
| 161 'a|web/index.html_bootstrap.dart': | 170 'a|web/index.html_bootstrap.dart': |
| 162 '''library app_bootstrap; | 171 '''library app_bootstrap; |
| 163 | 172 |
| 164 import 'package:polymer/polymer.dart'; | 173 import 'package:polymer/polymer.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); | 185 ], currentMirrorSystem().isolate.rootLibrary.uri.toString()); |
| 177 } | 186 } |
| 178 '''.replaceAll('\n ', '\n'), | 187 '''.replaceAll('\n ', '\n'), |
| 179 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), | 188 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), |
| 180 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), | 189 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), |
| 181 'a|web/index.html.0.dart': _sampleObservableOutput("C", "car"), | 190 'a|web/index.html.0.dart': _sampleObservableOutput("C", "car"), |
| 182 }); | 191 }); |
| 183 } | 192 } |
| 184 | 193 |
| 185 String _sampleObservable(String className, String fieldName) => ''' | 194 String _sampleObservable(String className, String fieldName) => ''' |
| 195 library ${className}_$fieldName; |
| 186 import 'package:observe/observe.dart'; | 196 import 'package:observe/observe.dart'; |
| 187 | 197 |
| 188 class $className extends ObservableBase { | 198 class $className extends ObservableBase { |
| 189 @observable int $fieldName; | 199 @observable int $fieldName; |
| 190 $className(this.$fieldName); | 200 $className(this.$fieldName); |
| 191 } | 201 } |
| 192 '''; | 202 '''; |
| 193 | 203 |
| 194 String _sampleObservableOutput(String className, String fieldName) => ''' | 204 String _sampleObservableOutput(String className, String fieldName) => ''' |
| 205 library ${className}_$fieldName; |
| 195 import 'package:observe/observe.dart'; | 206 import 'package:observe/observe.dart'; |
| 196 | 207 |
| 197 class $className extends ChangeNotifierBase { | 208 class $className extends ChangeNotifierBase { |
| 198 int __\$$fieldName; | 209 int __\$$fieldName; |
| 199 int get $fieldName => __\$$fieldName; | 210 int get $fieldName => __\$$fieldName; |
| 200 set $fieldName(int value) { | 211 set $fieldName(int value) { |
| 201 __\$$fieldName = notifyPropertyChange(const Symbol('$fieldName'), __\$$field
Name, value); | 212 __\$$fieldName = notifyPropertyChange(const Symbol('$fieldName'), __\$$field
Name, value); |
| 202 } | 213 } |
| 203 | 214 |
| 204 $className($fieldName) : __\$$fieldName = $fieldName; | 215 $className($fieldName) : __\$$fieldName = $fieldName; |
| 205 } | 216 } |
| 206 '''; | 217 '''; |
| OLD | NEW |