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

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

Issue 23757034: Rearranges the polymer package now that the old compiler is gone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library polymer.test.transform.all_phases_test;
6
7 import 'package:polymer/src/transform.dart';
8 import 'package:unittest/compact_vm_config.dart';
9
10 import 'common.dart';
11
12 void main() {
13 useCompactVMConfiguration();
14 var phases = createDeployPhases(new TransformOptions());
15
16 testPhases('no changes', phases, {
17 'a|web/test.html': '<!DOCTYPE html><html></html>',
18 }, {
19 'a|web/test.html': '<!DOCTYPE html><html></html>',
20 });
21
22 testPhases('observable changes', phases, {
23 'a|web/test.dart': _sampleObservable('A', 'foo'),
24 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'),
25 }, {
26 'a|web/test.dart': _sampleObservableOutput('A', 'foo'),
27 'a|web/test2.dart': _sampleObservableOutput('B', 'bar'),
28 });
29
30 testPhases('single script', phases, {
31 'a|web/test.html':
32 '<!DOCTYPE html><html><head>'
33 '<script type="application/dart" src="a.dart"></script>',
34 'a|web/test.dart': _sampleObservable('A', 'foo'),
35 }, {
36 'a|web/test.html':
37 '<!DOCTYPE html><html><head></head><body>'
38 '$SHADOW_DOM_TAG'
39 '$INTEROP_TAG'
40 '$PKG_JS_INTEROP_TAG'
41 '<script type="application/dart" '
42 'src="test.html_bootstrap.dart"></script>'
43 '<script src="packages/browser/dart.js"></script>'
44 '</body></html>',
45
46 'a|web/test.html_bootstrap.dart':
47 '''library app_bootstrap;
48
49 import 'package:polymer/polymer.dart';
50 import 'dart:mirrors' show currentMirrorSystem;
51
52 import 'a.dart' as i0;
53
54 void main() {
55 initPolymer([
56 'a.dart',
57 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
58 }
59 '''.replaceAll('\n ', '\n'),
60 'a|web/test.dart': _sampleObservableOutput('A', 'foo'),
61 });
62
63 testPhases('single inline script', phases, {
64 'a|web/test.html':
65 '<!DOCTYPE html><html><head>'
66 '<script type="application/dart">'
67 '${_sampleObservable("B", "bar")}</script>',
68 }, {
69 'a|web/test.html':
70 '<!DOCTYPE html><html><head></head><body>'
71 '$SHADOW_DOM_TAG'
72 '$INTEROP_TAG'
73 '$PKG_JS_INTEROP_TAG'
74 '<script type="application/dart" '
75 'src="test.html_bootstrap.dart"></script>'
76 '<script src="packages/browser/dart.js"></script>'
77 '</body></html>',
78
79 'a|web/test.html_bootstrap.dart':
80 '''library app_bootstrap;
81
82 import 'package:polymer/polymer.dart';
83 import 'dart:mirrors' show currentMirrorSystem;
84
85 import 'test.html.0.dart' as i0;
86
87 void main() {
88 initPolymer([
89 'test.html.0.dart',
90 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
91 }
92 '''.replaceAll('\n ', '\n'),
93 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
94 });
95
96 testPhases('several scripts', phases, {
97 'a|web/test.html':
98 '<!DOCTYPE html><html><head>'
99 '<script type="application/dart" src="a.dart"></script>'
100 '<script type="application/dart">'
101 '${_sampleObservable("B", "bar")}</script>'
102 '</head><body><div>'
103 '<script type="application/dart">'
104 '${_sampleObservable("C", "car")}</script>'
105 '</div>'
106 '<script type="application/dart" src="d.dart"></script>',
107 'a|web/a.dart': _sampleObservable('A', 'foo'),
108 }, {
109 'a|web/test.html':
110 '<!DOCTYPE html><html><head></head><body>'
111 '$SHADOW_DOM_TAG'
112 '$INTEROP_TAG'
113 '$PKG_JS_INTEROP_TAG'
114 '<div></div>'
115 '<script type="application/dart" '
116 'src="test.html_bootstrap.dart"></script>'
117 '<script src="packages/browser/dart.js"></script>'
118 '</body></html>',
119
120 'a|web/test.html_bootstrap.dart':
121 '''library app_bootstrap;
122
123 import 'package:polymer/polymer.dart';
124 import 'dart:mirrors' show currentMirrorSystem;
125
126 import 'a.dart' as i0;
127 import 'test.html.0.dart' as i1;
128 import 'test.html.1.dart' as i2;
129 import 'd.dart' as i3;
130
131 void main() {
132 initPolymer([
133 'a.dart',
134 'test.html.0.dart',
135 'test.html.1.dart',
136 'd.dart',
137 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
138 }
139 '''.replaceAll('\n ', '\n'),
140 'a|web/a.dart': _sampleObservableOutput('A', 'foo'),
141 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
142 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"),
143 });
144
145 testPhases('with imports', phases, {
146 'a|web/index.html':
147 '<!DOCTYPE html><html><head>'
148 '<link rel="import" href="test2.html">'
149 '</head><body>'
150 '<script type="application/dart" src="b.dart"></script>'
151 '<script type="application/dart">'
152 '${_sampleObservable("C", "car")}</script>',
153 'a|web/b.dart': _sampleObservable('B', 'bar'),
154 'a|web/test2.html':
155 '<!DOCTYPE html><html><head></head><body>'
156 '<polymer-element>1'
157 '<script type="application/dart">'
158 '${_sampleObservable("A", "foo")}</script>'
159 '</polymer-element></html>',
160 }, {
161 'a|web/index.html':
162 '<!DOCTYPE html><html><head></head><body>'
163 '$SHADOW_DOM_TAG'
164 '$INTEROP_TAG'
165 '$PKG_JS_INTEROP_TAG'
166 '<polymer-element>1</polymer-element>'
167 '<script type="application/dart" '
168 'src="index.html_bootstrap.dart"></script>'
169 '<script src="packages/browser/dart.js"></script>'
170 '</body></html>',
171 'a|web/index.html_bootstrap.dart':
172 '''library app_bootstrap;
173
174 import 'package:polymer/polymer.dart';
175 import 'dart:mirrors' show currentMirrorSystem;
176
177 import 'test2.html.0.dart' as i0;
178 import 'b.dart' as i1;
179 import 'index.html.0.dart' as i2;
180
181 void main() {
182 initPolymer([
183 'test2.html.0.dart',
184 'b.dart',
185 'index.html.0.dart',
186 ], currentMirrorSystem().isolate.rootLibrary.uri.toString());
187 }
188 '''.replaceAll('\n ', '\n'),
189 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"),
190 'a|web/b.dart': _sampleObservableOutput('B', 'bar'),
191 'a|web/index.html.0.dart': _sampleObservableOutput("C", "car"),
192 });
193 }
194
195 String _sampleObservable(String className, String fieldName) => '''
196 library ${className}_$fieldName;
197 import 'package:observe/observe.dart';
198
199 class $className extends ObservableBase {
200 @observable int $fieldName;
201 $className(this.$fieldName);
202 }
203 ''';
204
205 String _sampleObservableOutput(String className, String fieldName) => '''
206 library ${className}_$fieldName;
207 import 'package:observe/observe.dart';
208
209 class $className extends ChangeNotifierBase {
210 int __\$$fieldName;
211 int get $fieldName => __\$$fieldName;
212 set $fieldName(int value) {
213 __\$$fieldName = notifyPropertyChange(const Symbol('$fieldName'), __\$$field Name, value);
214 }
215
216 $className($fieldName) : __\$$fieldName = $fieldName;
217 }
218 ''';
OLDNEW
« no previous file with comments | « pkg/polymer/test/build/utils_test.dart ('k') | pkg/polymer/test/transform/code_extractor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698