Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: pkg/polymer/test/build/all_phases_test.dart

Issue 47933006: Build fixes: adds arguments to the pub-build plugin to configure whether 'js' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
26 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'), 26 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'),
27 }, { 27 }, {
28 'a|web/test.dart': _sampleObservableOutput('A', 'foo'), 28 'a|web/test.dart': _sampleObservableOutput('A', 'foo'),
29 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'), 29 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'),
30 }); 30 });
31 31
32 testPhases('single script', phases, { 32 testPhases('single script', phases, {
33 'a|web/test.html': 33 'a|web/test.html':
34 '<!DOCTYPE html><html><head>' 34 '<!DOCTYPE html><html><head>'
35 '<script type="application/dart" src="a.dart"></script>', 35 '<script type="application/dart" src="a.dart"></script>',
36 'a|web/test.dart': _sampleObservable('A', 'foo'), 36 'a|web/a.dart': _sampleObservable('A', 'foo'),
37 }, { 37 }, {
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' as i0; 48 import 'a.dart_modified.dart' as i0;
49 49
50 void main() { 50 void main() {
51 configureForDeployment([ 51 configureForDeployment([
52 'a.dart', 52 'a.dart_modified.dart',
53 ]); 53 ]);
54 i0.main(); 54 i0.polymerMainWrapper();
55 } 55 }
56 '''.replaceAll('\n ', '\n'), 56 '''.replaceAll('\n ', '\n'),
57 'a|web/test.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),
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>' 69 '<!DOCTYPE html><html><head>'
68 '$SHADOW_DOM_TAG' 70 '$SHADOW_DOM_TAG'
69 '$CUSTOM_ELEMENT_TAG' 71 '$CUSTOM_ELEMENT_TAG'
70 '$INTEROP_TAG' 72 '$INTEROP_TAG'
71 '<script src="test.html_bootstrap.dart.js"></script>' 73 '<script src="test.html_bootstrap.dart.js"></script>'
72 '</head><body></body></html>', 74 '</head><body></body></html>',
73 75
74 'a|web/test.html_bootstrap.dart': 76 'a|web/test.html_bootstrap.dart':
75 '''$MAIN_HEADER 77 '''$MAIN_HEADER
76 import 'test.html.0.dart' as i0; 78 import 'test.html.0.dart_modified.dart' as i0;
77 79
78 void main() { 80 void main() {
79 configureForDeployment([ 81 configureForDeployment([
80 'test.html.0.dart', 82 'test.html.0.dart_modified.dart',
81 ]); 83 ]);
82 i0.main(); 84 i0.polymerMainWrapper();
83 } 85 }
84 '''.replaceAll('\n ', '\n'), 86 '''.replaceAll('\n ', '\n'),
85 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), 87 'a|web/test.html.0.dart':
88 _sampleObservableOutput("B", "bar"),
89 'a|web/test.html.0.dart_modified.dart':
90 _sampleObservableOutput("B", "bar", includeMain: true),
86 }); 91 });
87 92
88 testPhases('several scripts', phases, { 93 testPhases('several scripts', phases, {
89 'a|web/test.html': 94 'a|web/test.html':
90 '<!DOCTYPE html><html><head>' 95 '<!DOCTYPE html><html><head>'
91 '<script type="application/dart" src="a.dart"></script>' 96 '<script type="application/dart" src="a.dart"></script>'
92 // TODO(sigmund): provide a way to see logging warnings and errors. 97 // TODO(sigmund): provide a way to see logging warnings and errors.
93 // For example, these extra tags produce warnings and are then removed 98 // For example, these extra tags produce warnings and are then removed
94 // by the transformers. The test below checks that the output looks 99 // by the transformers. The test below checks that the output looks
95 // correct, but we should also validate the messages logged. 100 // correct, but we should also validate the messages logged.
(...skipping 11 matching lines...) Expand all
107 '$SHADOW_DOM_TAG' 112 '$SHADOW_DOM_TAG'
108 '$CUSTOM_ELEMENT_TAG' 113 '$CUSTOM_ELEMENT_TAG'
109 '$INTEROP_TAG' 114 '$INTEROP_TAG'
110 '<script src="test.html_bootstrap.dart.js"></script>' 115 '<script src="test.html_bootstrap.dart.js"></script>'
111 '</head><body>' 116 '</head><body>'
112 '<div></div>' 117 '<div></div>'
113 '</body></html>', 118 '</body></html>',
114 119
115 'a|web/test.html_bootstrap.dart': 120 'a|web/test.html_bootstrap.dart':
116 '''$MAIN_HEADER 121 '''$MAIN_HEADER
117 import 'a.dart' as i0; 122 import 'a.dart_modified.dart' as i0;
118 123
119 void main() { 124 void main() {
120 configureForDeployment([ 125 configureForDeployment([
121 'a.dart', 126 'a.dart_modified.dart',
122 ]); 127 ]);
123 i0.main(); 128 i0.polymerMainWrapper();
124 } 129 }
125 '''.replaceAll('\n ', '\n'), 130 '''.replaceAll('\n ', '\n'),
126 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), 131 'a|web/a.dart': _sampleObservableOutput('A', 'foo'),
132 'a|web/a.dart_modified.dart':
133 _sampleObservableOutput('A', 'foo', includeMain: true),
127 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), 134 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
128 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"), 135 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"),
129 }); 136 });
130 137
131 testPhases('with imports', phases, { 138 testPhases('with imports', phases, {
132 'a|web/index.html': 139 'a|web/index.html':
133 '<!DOCTYPE html><html><head>' 140 '<!DOCTYPE html><html><head>'
134 '<link rel="import" href="test2.html">' 141 '<link rel="import" href="test2.html">'
135 '</head><body>' 142 '</head><body>'
136 '<script type="application/dart" src="b.dart"></script>', 143 '<script type="application/dart" src="b.dart"></script>',
137 'a|web/b.dart': _sampleObservable('B', 'bar'), 144 'a|web/b.dart': _sampleObservable('B', 'bar'),
138 'a|web/test2.html': 145 'a|web/test2.html':
139 '<!DOCTYPE html><html><head></head><body>' 146 '<!DOCTYPE html><html><head></head><body>'
140 '<polymer-element>1' 147 '<polymer-element>1'
141 '<script type="application/dart">' 148 '<script type="application/dart">'
142 '${_sampleObservable("A", "foo")}</script>' 149 '${_sampleObservable("A", "foo")}</script>'
143 '</polymer-element></html>', 150 '</polymer-element></html>',
144 }, { 151 }, {
145 'a|web/index.html': 152 'a|web/index.html':
146 '<!DOCTYPE html><html><head>' 153 '<!DOCTYPE html><html><head>'
147 '$SHADOW_DOM_TAG' 154 '$SHADOW_DOM_TAG'
148 '$CUSTOM_ELEMENT_TAG' 155 '$CUSTOM_ELEMENT_TAG'
149 '$INTEROP_TAG' 156 '$INTEROP_TAG'
150 '</head><body><polymer-element>1</polymer-element>' 157 '</head><body><polymer-element>1</polymer-element>'
151 '<script src="index.html_bootstrap.dart.js"></script>' 158 '<script src="index.html_bootstrap.dart.js"></script>'
152 '</body></html>', 159 '</body></html>',
153 'a|web/index.html_bootstrap.dart': 160 'a|web/index.html_bootstrap.dart':
154 '''$MAIN_HEADER 161 '''$MAIN_HEADER
155 import 'test2.html.0.dart' as i0; 162 import 'test2.html.0.dart' as i0;
156 import 'b.dart' as i1; 163 import 'b.dart_modified.dart' as i1;
157 164
158 void main() { 165 void main() {
159 configureForDeployment([ 166 configureForDeployment([
160 'test2.html.0.dart', 167 'test2.html.0.dart',
161 'b.dart', 168 'b.dart_modified.dart',
162 ]); 169 ]);
163 i1.main(); 170 i1.polymerMainWrapper();
164 } 171 }
165 '''.replaceAll('\n ', '\n'), 172 '''.replaceAll('\n ', '\n'),
166 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), 173 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"),
174 'a|web/test2.html.0.dart_modified.dart':
175 _sampleObservableOutput("A", "foo", includeMain: true),
167 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), 176 'a|web/b.dart': _sampleObservableOutput('B', 'bar'),
168 }); 177 });
169 } 178 }
170 179
171 String _sampleObservable(String className, String fieldName) => ''' 180 String _sampleObservable(String className, String fieldName) => '''
172 library ${className}_$fieldName; 181 library ${className}_$fieldName;
173 import 'package:observe/observe.dart'; 182 import 'package:observe/observe.dart';
174 183
175 class $className extends Observable { 184 class $className extends Observable {
176 @observable int $fieldName; 185 @observable int $fieldName;
177 $className(this.$fieldName); 186 $className(this.$fieldName);
178 } 187 }
179 '''; 188 ''';
180 189
181 String _sampleObservableOutput(String className, String field) => 190 String _sampleObservableOutput(String className, String field,
191 {bool includeMain: false}) =>
182 "library ${className}_$field;\n" 192 "library ${className}_$field;\n"
183 "import 'package:observe/observe.dart';\n\n" 193 "import 'package:observe/observe.dart';\n\n"
184 "class $className extends ChangeNotifier {\n" 194 "class $className extends ChangeNotifier {\n"
185 " @reflectable @observable int get $field => __\$$field; " 195 " @reflectable @observable int get $field => __\$$field; "
186 "int __\$$field; " 196 "int __\$$field; "
187 "@reflectable set $field(int value) { " 197 "@reflectable set $field(int value) { "
188 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); " 198 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); "
189 "}\n" 199 "}\n"
190 " $className($field) : __\$$field = $field;\n" 200 " $className($field) : __\$$field = $field;\n"
191 "}\n"; 201 "}\n"
202 "${includeMain ? '\n\npolymerMainWrapper() => main();\n' : ''}";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698