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

Side by Side Diff: utils/tests/css/src/DeclarationTest.dart

Issue 9168008: Enabled CSS tests, added CSS tests to buildbot, fixed tooling with nodejs, and added more tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More coding convention changes (consistency). Created 8 years, 11 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
« no previous file with comments | « utils/tests/css/css.status ('k') | utils/tests/css/src/ExpressionTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, 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 #import("../../../css/css.dart");
6 #import('../../../../frog/lang.dart', prefix:'lang');
7
8 class DeclarationTest {
9
10 static testMain() {
11 initCssWorld();
12
13 testSimpleTerms();
14 testMoreDecls();
15 testIdentifiers();
16 testComposites();
17 testNewerCss();
18 testCssFile();
19 }
20
21 static void testSimpleTerms() {
22 final String input =
23 ".foo {\n" +
24 " background-color: #191919;\n" +
25 " width: 10PX;\n" +
26 " height: 22mM !important;\n" +
27 " border-width: 20cm;\n" +
28 " margin-width: 33%;\n" +
29 " border-height: 30EM;\n" +
30 " width: .6in;\n" +
31 " length: 1.2in;\n" +
32 " -web-stuff: -10Px;\n" +
33 "}\n";
34 final String generated =
35 "\n" +
36 ".foo {\n" +
37 " background-color: #191919;\n" +
38 " width: 10px;\n" +
39 " height: 22mm !important;\n" +
40 " border-width: 20cm;\n" +
41 " margin-width: 33%;\n" +
42 " border-height: 30em;\n" +
43 " width: .6in;\n" + // Check double values.
44 " length: 1.2in;\n" +
45 " -web-stuff: -10px;\n" +
46 "}\n";
47
48 Parser parser =
49 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
50
51 Stylesheet stylesheet = parser.parse();
52 Expect.isNotNull(stylesheet);
53
54 Expect.equals(generated, stylesheet.toString());
55 }
56
57 static void testMoreDecls() {
58 final String input =
59 ".more {\n" +
60 " color: red;\n" +
61 " color: #aabbcc; /* test -- 3 */\n" +
62 " color: blue;\n" +
63 " background-image: url(http://test.jpeg);\n" +
64 " background-image: url(\"http://double_quote.html\");\n" +
65 " background-image: url('http://single_quote.html');\n" +
66 " color: rgba(10,20,255); <!-- test CDO/CDC -->\n" +
67 " color: #123aef; /* hex # part integer and part identifier */\n" +
68 "}\n";
69 final String generated =
70 "\n" +
71 ".more {\n" +
72 " color: #ff0000;\n" +
73 " color: #aabbcc;\n" +
74 " color: #ff;\n" +
75 " background-image: url(http://test.jpeg);\n" +
76 " background-image: url(http://double_quote.html);\n" +
77 " background-image: url(http://single_quote.html);\n" +
78 " color: rgba(10, 20, 255);\n" +
79 " color: #123aef;\n" +
80 "}\n";
81
82 Parser parser =
83 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
84
85 Stylesheet stylesheet = parser.parse();
86 Expect.isNotNull(stylesheet);
87
88 Expect.equals(generated, stylesheet.toString());
89 }
90
91 static void testIdentifiers() {
92 final String input =
93 // Make sure identifiers that could look like hex are handled.
94 "#da {\n" +
95 " height: 100px;\n" +
96 "}\n" +
97 // Make sure elements that contain a leading dash (negative) are valid.
98 "#-foo {\n" +
99 " width: 10px;\n" +
100 " color: #ff00cc;\n" +
101 "}\n";
102 final String generated =
103 "\n" +
104 "#da {\n" +
105 " height: 100px;\n" +
106 "}\n" +
107 "\n" +
108 "#-foo {\n" +
109 " width: 10px;\n" +
110 " color: #ff00cc;\n" +
111 "}\n";
112
113 Parser parser =
114 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
115
116 Stylesheet stylesheet = parser.parse();
117 Expect.isNotNull(stylesheet);
118
119 Expect.equals(generated, stylesheet.toString());
120 }
121
122 static void testComposites() {
123 final String input =
124 // Composites
125 ".xyzzy {\n" +
126 " border: 10px 80px 90px 100px;\n" +
127 " width: 99%;\n" +
128 "}\n" +
129 "@-webkit-keyframes pulsate {\n" +
130 " 0% {\n" +
131 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
132 " }\n" +
133 "}\n";
134 final String generated =
135 "\n" +
136 ".xyzzy {\n" +
137 " border: 10px 80px 90px 100px;\n" +
138 " width: 99%;\n" +
139 "}\n" +
140 "@-webkit-keyframes pulsate {\n" +
141 " 0% {\n" +
142 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
143 " }\n" +
144 "}\n";
145 Parser parser =
146 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
147
148 Stylesheet stylesheet = parser.parse();
149 Expect.isNotNull(stylesheet);
150
151 Expect.equals(generated, stylesheet.toString());
152 }
153
154 static void testNewerCss() {
155 final String input =
156 // Newer things in CSS
157 "@media screen,print {\n" +
158 " .foobar_screen {\n" +
159 " width: 10px;\n" +
160 " }\n" +
161 "}\n" +
162 "@page : test {\n" +
163 " width: 10px;\n" +
164 "}\n" +
165 "@page {\n" +
166 " height: 22px;\n" +
167 "}\n";
168 final String generated =
169 "@media screen,print {\n" +
170 "\n" +
171 ".foobar_screen {\n" +
172 " width: 10px;\n" +
173 "}\n" +
174 "\n" +
175 "}\n" +
176 "@page : test {\n" +
177 " width: 10px;\n" +
178 "\n" +
179 "}\n" +
180 "@page {\n" +
181 " height: 22px;\n" +
182 "\n" +
183 "}\n";
184
185 Parser parser =
186 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, input));
187
188 Stylesheet stylesheet = parser.parse();
189 Expect.isNotNull(stylesheet);
190
191 Expect.equals(generated, stylesheet.toString());
192 }
193
194 static void testCssFile() {
195 final String scss =
196 "@import 'simple.css'\n" +
197 "@import \"test.css\" print\n" +
198 "@import url(test.css) screen, print\n" +
199
200 "div[href^='test'] {\n" +
201 " height: 10px;\n" +
202 "}\n" +
203
204 "@-webkit-keyframes pulsate {\n" +
205 " from {\n" +
206 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
207 " }\n" +
208 " 10% {\n" +
209 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
210 " }\n" +
211 " 30% {\n" +
212 " -webkit-transform: translate3d(0, 2, 0) scale(1.0);\n" +
213 " }\n" +
214 "}\n" +
215
216 ".foobar {\n" +
217 " grid-columns: 10px (\"content\" 1fr 10px)[4];\n" +
218 "}\n";
219
220 final String generated =
221 "@import url(simple.css)\n" +
222 "@import url(test.css) print\n" +
223 "@import url(test.css) screen,print\n" +
224 "\n" +
225 "div[href ^= \"test\"] {\n" +
226 " height: 10px;\n" +
227 "}\n" +
228 "@-webkit-keyframes pulsate {\n" +
229 " from {\n" +
230 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
231 " }\n" +
232 " 10% {\n" +
233 " -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n" +
234 " }\n" +
235 " 30% {\n" +
236 " -webkit-transform: translate3d(0, 2, 0) scale(1.0);\n" +
237 " }\n" +
238 "}\n" +
239 "\n" +
240 ".foobar {\n" +
241 " grid-columns: 10px (\"content\" 1fr 10px) [4];\n" +
242 "}\n";
243
244 Parser parser =
245 new Parser(new lang.SourceFile(lang.SourceFile.IN_MEMORY_FILE, scss));
246
247 Stylesheet stylesheet = parser.parse();
248 Expect.isNotNull(stylesheet);
249
250 Expect.equals(generated, stylesheet.toString());
251 }
252 }
253
254 main() {
255 DeclarationTest.testMain();
256 }
OLDNEW
« no previous file with comments | « utils/tests/css/css.status ('k') | utils/tests/css/src/ExpressionTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698