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

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

Issue 27903006: Improves how to initialize polymer apps and fixes polymer build and linter to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months 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/transformer.dart'; 7 import 'package:polymer/transformer.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:unittest/compact_vm_config.dart'; 9 import 'package:unittest/compact_vm_config.dart';
10 10
(...skipping 17 matching lines...) Expand all
28 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'), 28 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'),
29 }); 29 });
30 30
31 testPhases('single script', phases, { 31 testPhases('single script', phases, {
32 'a|web/test.html': 32 'a|web/test.html':
33 '<!DOCTYPE html><html><head>' 33 '<!DOCTYPE html><html><head>'
34 '<script type="application/dart" src="a.dart"></script>', 34 '<script type="application/dart" src="a.dart"></script>',
35 'a|web/test.dart': _sampleObservable('A', 'foo'), 35 'a|web/test.dart': _sampleObservable('A', 'foo'),
36 }, { 36 }, {
37 'a|web/test.html': 37 'a|web/test.html':
38 '<!DOCTYPE html><html><head></head><body>' 38 '<!DOCTYPE html><html><head>'
39 '$SHADOW_DOM_TAG' 39 '$SHADOW_DOM_TAG'
40 '$CUSTOM_ELEMENT_TAG' 40 '$CUSTOM_ELEMENT_TAG'
41 '$INTEROP_TAG' 41 '$INTEROP_TAG'
42 '<script type="application/dart" ' 42 '<script type="application/dart" '
43 'src="test.html_bootstrap.dart"></script>' 43 'src="test.html_bootstrap.dart"></script>'
44 '<script src="packages/browser/dart.js"></script>' 44 '</head><body><script src="packages/browser/dart.js"></script>'
45 '</body></html>', 45 '</body></html>',
46 46
47 'a|web/test.html_bootstrap.dart': 47 'a|web/test.html_bootstrap.dart':
48 '''$MAIN_HEADER 48 '''$MAIN_HEADER
49 import 'a.dart' as i0; 49 import 'a.dart' as i0;
50 50
51 void main() { 51 void main() {
52 initPolymer([ 52 librariesToLoad = [
53 'a.dart', 53 'a.dart',
54 ]); 54 ];
55 i0.main();
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>'
68 '$SHADOW_DOM_TAG' 69 '$SHADOW_DOM_TAG'
69 '$CUSTOM_ELEMENT_TAG' 70 '$CUSTOM_ELEMENT_TAG'
70 '$INTEROP_TAG' 71 '$INTEROP_TAG'
71 '<script type="application/dart" ' 72 '<script type="application/dart" '
72 'src="test.html_bootstrap.dart"></script>' 73 'src="test.html_bootstrap.dart"></script>'
73 '<script src="packages/browser/dart.js"></script>' 74 '</head><body><script src="packages/browser/dart.js"></script>'
74 '</body></html>', 75 '</body></html>',
75 76
76 'a|web/test.html_bootstrap.dart': 77 'a|web/test.html_bootstrap.dart':
77 '''$MAIN_HEADER 78 '''$MAIN_HEADER
78 import 'test.html.0.dart' as i0; 79 import 'test.html.0.dart' as i0;
79 80
80 void main() { 81 void main() {
81 initPolymer([ 82 librariesToLoad = [
82 'test.html.0.dart', 83 'test.html.0.dart',
83 ]); 84 ];
85 i0.main();
84 } 86 }
85 '''.replaceAll('\n ', '\n'), 87 '''.replaceAll('\n ', '\n'),
86 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), 88 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
87 }); 89 });
88 90
89 testPhases('several scripts', phases, { 91 testPhases('several scripts', phases, {
90 'a|web/test.html': 92 'a|web/test.html':
91 '<!DOCTYPE html><html><head>' 93 '<!DOCTYPE html><html><head>'
92 '<script type="application/dart" src="a.dart"></script>' 94 '<script type="application/dart" src="a.dart"></script>'
95 // TODO(sigmund): provide a way to see logging warnings and errors.
96 // For example, these extra tags produce warnings and are then removed
97 // by the transformers. The test below checks that the output looks
98 // correct, but we should also validate the messages logged.
93 '<script type="application/dart">' 99 '<script type="application/dart">'
94 '${_sampleObservable("B", "bar")}</script>' 100 '${_sampleObservable("B", "bar")}</script>'
95 '</head><body><div>' 101 '</head><body><div>'
96 '<script type="application/dart">' 102 '<script type="application/dart">'
97 '${_sampleObservable("C", "car")}</script>' 103 '${_sampleObservable("C", "car")}</script>'
98 '</div>' 104 '</div>'
99 '<script type="application/dart" src="d.dart"></script>', 105 '<script type="application/dart" src="d.dart"></script>',
100 'a|web/a.dart': _sampleObservable('A', 'foo'), 106 'a|web/a.dart': _sampleObservable('A', 'foo'),
101 }, { 107 }, {
102 'a|web/test.html': 108 'a|web/test.html':
103 '<!DOCTYPE html><html><head></head><body>' 109 '<!DOCTYPE html><html><head>'
104 '$SHADOW_DOM_TAG' 110 '$SHADOW_DOM_TAG'
105 '$CUSTOM_ELEMENT_TAG' 111 '$CUSTOM_ELEMENT_TAG'
106 '$INTEROP_TAG' 112 '$INTEROP_TAG'
107 '<div></div>'
108 '<script type="application/dart" ' 113 '<script type="application/dart" '
109 'src="test.html_bootstrap.dart"></script>' 114 'src="test.html_bootstrap.dart"></script>'
115 '</head><body>'
116 '<div></div>'
110 '<script src="packages/browser/dart.js"></script>' 117 '<script src="packages/browser/dart.js"></script>'
111 '</body></html>', 118 '</body></html>',
112 119
113 'a|web/test.html_bootstrap.dart': 120 'a|web/test.html_bootstrap.dart':
114 '''$MAIN_HEADER 121 '''$MAIN_HEADER
115 import 'a.dart' as i0; 122 import 'a.dart' as i0;
116 import 'test.html.0.dart' as i1;
117 import 'test.html.1.dart' as i2;
118 import 'd.dart' as i3;
119 123
120 void main() { 124 void main() {
121 initPolymer([ 125 librariesToLoad = [
122 'a.dart', 126 'a.dart',
123 'test.html.0.dart', 127 ];
124 'test.html.1.dart', 128 i0.main();
125 'd.dart',
126 ]);
127 } 129 }
128 '''.replaceAll('\n ', '\n'), 130 '''.replaceAll('\n ', '\n'),
129 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), 131 'a|web/a.dart': _sampleObservableOutput('A', 'foo'),
130 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"), 132 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
131 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"), 133 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"),
132 }); 134 });
133 135
134 testPhases('with imports', phases, { 136 testPhases('with imports', phases, {
135 'a|web/index.html': 137 'a|web/index.html':
136 '<!DOCTYPE html><html><head>' 138 '<!DOCTYPE html><html><head>'
137 '<link rel="import" href="test2.html">' 139 '<link rel="import" href="test2.html">'
138 '</head><body>' 140 '</head><body>'
139 '<script type="application/dart" src="b.dart"></script>' 141 '<script type="application/dart" src="b.dart"></script>',
140 '<script type="application/dart">'
141 '${_sampleObservable("C", "car")}</script>',
142 'a|web/b.dart': _sampleObservable('B', 'bar'), 142 'a|web/b.dart': _sampleObservable('B', 'bar'),
143 'a|web/test2.html': 143 'a|web/test2.html':
144 '<!DOCTYPE html><html><head></head><body>' 144 '<!DOCTYPE html><html><head></head><body>'
145 '<polymer-element>1' 145 '<polymer-element>1'
146 '<script type="application/dart">' 146 '<script type="application/dart">'
147 '${_sampleObservable("A", "foo")}</script>' 147 '${_sampleObservable("A", "foo")}</script>'
148 '</polymer-element></html>', 148 '</polymer-element></html>',
149 }, { 149 }, {
150 'a|web/index.html': 150 'a|web/index.html':
151 '<!DOCTYPE html><html><head></head><body>' 151 '<!DOCTYPE html><html><head>'
152 '$SHADOW_DOM_TAG' 152 '$SHADOW_DOM_TAG'
153 '$CUSTOM_ELEMENT_TAG' 153 '$CUSTOM_ELEMENT_TAG'
154 '$INTEROP_TAG' 154 '$INTEROP_TAG'
155 '<polymer-element>1</polymer-element>' 155 '</head><body><polymer-element>1</polymer-element>'
156 '<script type="application/dart" ' 156 '<script type="application/dart" '
157 'src="index.html_bootstrap.dart"></script>' 157 'src="index.html_bootstrap.dart"></script>'
158 '<script src="packages/browser/dart.js"></script>' 158 '<script src="packages/browser/dart.js"></script>'
159 '</body></html>', 159 '</body></html>',
160 'a|web/index.html_bootstrap.dart': 160 'a|web/index.html_bootstrap.dart':
161 '''$MAIN_HEADER 161 '''$MAIN_HEADER
162 import 'test2.html.0.dart' as i0; 162 import 'test2.html.0.dart' as i0;
163 import 'b.dart' as i1; 163 import 'b.dart' as i1;
164 import 'index.html.0.dart' as i2;
165 164
166 void main() { 165 void main() {
167 initPolymer([ 166 librariesToLoad = [
168 'test2.html.0.dart', 167 'test2.html.0.dart',
169 'b.dart', 168 'b.dart',
170 'index.html.0.dart', 169 ];
171 ]); 170 i1.main();
172 } 171 }
173 '''.replaceAll('\n ', '\n'), 172 '''.replaceAll('\n ', '\n'),
174 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), 173 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"),
175 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), 174 'a|web/b.dart': _sampleObservableOutput('B', 'bar'),
176 'a|web/index.html.0.dart': _sampleObservableOutput("C", "car"),
177 }); 175 });
178 } 176 }
179 177
180 String _sampleObservable(String className, String fieldName) => ''' 178 String _sampleObservable(String className, String fieldName) => '''
181 library ${className}_$fieldName; 179 library ${className}_$fieldName;
182 import 'package:observe/observe.dart'; 180 import 'package:observe/observe.dart';
183 181
184 class $className extends Observable { 182 class $className extends Observable {
185 @observable int $fieldName; 183 @observable int $fieldName;
186 $className(this.$fieldName); 184 $className(this.$fieldName);
187 } 185 }
188 '''; 186 ''';
189 187
190 String _sampleObservableOutput(String className, String field) => 188 String _sampleObservableOutput(String className, String field) =>
191 "library ${className}_$field;\n" 189 "library ${className}_$field;\n"
192 "import 'package:observe/observe.dart';\n\n" 190 "import 'package:observe/observe.dart';\n\n"
193 "class $className extends ChangeNotifier {\n" 191 "class $className extends ChangeNotifier {\n"
194 " @reflectable @observable int get $field => __\$$field; " 192 " @reflectable @observable int get $field => __\$$field; "
195 "int __\$$field; " 193 "int __\$$field; "
196 "@reflectable set $field(int value) { " 194 "@reflectable set $field(int value) { "
197 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); " 195 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); "
198 "}\n" 196 "}\n"
199 " $className($field) : __\$$field = $field;\n" 197 " $className($field) : __\$$field = $field;\n"
200 "}\n"; 198 "}\n";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698