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