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

Side by Side Diff: utils/tests/css/declaration_tests.dart

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

Powered by Google App Engine
This is Rietveld 408576698