OLD | NEW |
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 css_test; | 5 library css_test; |
6 | 6 |
7 import 'package:html5lib/dom.dart'; | 7 import 'package:html5lib/dom.dart'; |
8 import 'package:logging/logging.dart' show Level; | 8 import 'package:logging/logging.dart' show Level; |
9 import 'package:unittest/compact_vm_config.dart'; | 9 import 'package:unittest/compact_vm_config.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 19 matching lines...) Expand all Loading... |
30 '<style>' | 30 '<style>' |
31 '.test { color: var(main_color); }' | 31 '.test { color: var(main_color); }' |
32 '</style>' | 32 '</style>' |
33 '<script type="application/dart">main() {}</script>' | 33 '<script type="application/dart">main() {}</script>' |
34 '</body>' | 34 '</body>' |
35 '</html>', | 35 '</html>', |
36 }; | 36 }; |
37 } | 37 } |
38 | 38 |
39 var messages = new Messages.silent(); | 39 var messages = new Messages.silent(); |
40 var compiler = createCompiler(createFiles(), messages, errors: true); | 40 var compiler = createCompiler(createFiles(), messages, errors: true, |
| 41 scopedCss: true); |
41 | 42 |
42 compiler.run().then(expectAsync1((e) { | 43 compiler.run().then(expectAsync1((e) { |
43 MockFileSystem fs = compiler.fileSystem; | 44 MockFileSystem fs = compiler.fileSystem; |
44 expect(fs.readCount, equals({ | 45 expect(fs.readCount, equals({ |
45 'index.html': 1, | 46 'index.html': 1, |
46 }), reason: 'Actual:\n ${fs.readCount}'); | 47 }), reason: 'Actual:\n ${fs.readCount}'); |
47 | 48 |
48 var htmlInfo = compiler.info['index.html']; | 49 var htmlInfo = compiler.info['index.html']; |
49 expect(htmlInfo.styleSheets.length, 2); | 50 expect(htmlInfo.styleSheets.length, 2); |
50 expect(prettyPrintCss(htmlInfo.styleSheets[0]), ''); | 51 expect(prettyPrintCss(htmlInfo.styleSheets[0]), ''); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 '.test-20 { border: var(border-2);}' | 109 '.test-20 { border: var(border-2);}' |
109 '.test-21 { border: var(blue-border);}' | 110 '.test-21 { border: var(blue-border);}' |
110 '</style>' | 111 '</style>' |
111 '<script type="application/dart">main() {}</script>' | 112 '<script type="application/dart">main() {}</script>' |
112 '</body>' | 113 '</body>' |
113 '</html>', | 114 '</html>', |
114 }; | 115 }; |
115 } | 116 } |
116 | 117 |
117 var messages = new Messages.silent(); | 118 var messages = new Messages.silent(); |
118 var compiler = createCompiler(createFiles(), messages, errors: true); | 119 var compiler = createCompiler(createFiles(), messages, errors: true, |
| 120 scopedCss: true); |
119 | 121 |
120 compiler.run().then(expectAsync1((e) { | 122 compiler.run().then(expectAsync1((e) { |
121 MockFileSystem fs = compiler.fileSystem; | 123 MockFileSystem fs = compiler.fileSystem; |
122 expect(fs.readCount, equals({ | 124 expect(fs.readCount, equals({ |
123 'index.html': 1, | 125 'index.html': 1, |
124 }), reason: 'Actual:\n ${fs.readCount}'); | 126 }), reason: 'Actual:\n ${fs.readCount}'); |
125 | 127 |
126 var htmlInfo = compiler.info['index.html']; | 128 var htmlInfo = compiler.info['index.html']; |
127 expect(htmlInfo.styleSheets.length, 2); | 129 expect(htmlInfo.styleSheets.length, 2); |
128 expect(prettyPrintCss(htmlInfo.styleSheets[0]), ''); | 130 expect(prettyPrintCss(htmlInfo.styleSheets[0]), ''); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 '@import "foo.css";' | 177 '@import "foo.css";' |
176 '.test { color: var(main_color); }' | 178 '.test { color: var(main_color); }' |
177 '</style>' | 179 '</style>' |
178 '<script type="application/dart">main() {}</script>' | 180 '<script type="application/dart">main() {}</script>' |
179 '</body>' | 181 '</body>' |
180 '</html>', | 182 '</html>', |
181 }; | 183 }; |
182 } | 184 } |
183 | 185 |
184 var messages = new Messages.silent(); | 186 var messages = new Messages.silent(); |
185 var compiler = createCompiler(createFiles(), messages, errors: true); | 187 var compiler = createCompiler(createFiles(), messages, errors: true, |
| 188 scopedCss: true); |
186 | 189 |
187 compiler.run().then(expectAsync1((e) { | 190 compiler.run().then(expectAsync1((e) { |
188 MockFileSystem fs = compiler.fileSystem; | 191 MockFileSystem fs = compiler.fileSystem; |
189 expect(fs.readCount, equals({ | 192 expect(fs.readCount, equals({ |
190 'foo.css': 1, | 193 'foo.css': 1, |
191 'index.html': 1, | 194 'index.html': 1, |
192 }), reason: 'Actual:\n ${fs.readCount}'); | 195 }), reason: 'Actual:\n ${fs.readCount}'); |
193 | 196 |
194 var cssInfo = compiler.info['foo.css']; | 197 var cssInfo = compiler.info['foo.css']; |
195 expect(cssInfo.styleSheets.length, 1); | 198 expect(cssInfo.styleSheets.length, 1); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 '.test-1 { color: var(main-color); }' | 249 '.test-1 { color: var(main-color); }' |
247 '.test-2 { width: var(main-width); }' | 250 '.test-2 { width: var(main-width); }' |
248 '</style>' | 251 '</style>' |
249 '<script type="application/dart">main() {}</script>' | 252 '<script type="application/dart">main() {}</script>' |
250 '</body>' | 253 '</body>' |
251 '</html>', | 254 '</html>', |
252 }; | 255 }; |
253 } | 256 } |
254 | 257 |
255 var messages = new Messages.silent(); | 258 var messages = new Messages.silent(); |
256 var compiler = createCompiler(createFiles(), messages, errors: true); | 259 var compiler = createCompiler(createFiles(), messages, errors: true, |
| 260 scopedCss: true); |
257 | 261 |
258 compiler.run().then(expectAsync1((e) { | 262 compiler.run().then(expectAsync1((e) { |
259 MockFileSystem fs = compiler.fileSystem; | 263 MockFileSystem fs = compiler.fileSystem; |
260 expect(fs.readCount, equals({ | 264 expect(fs.readCount, equals({ |
261 'first.css': 1, | 265 'first.css': 1, |
262 'second.css': 1, | 266 'second.css': 1, |
263 'third.css': 1, | 267 'third.css': 1, |
264 'fourth.css': 1, | 268 'fourth.css': 1, |
265 'index.html': 1, | 269 'index.html': 1, |
266 }), reason: 'Actual:\n ${fs.readCount}'); | 270 }), reason: 'Actual:\n ${fs.readCount}'); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 @six: var(four); | 353 @six: var(four); |
350 | 354 |
351 @def-1: var(def-2); | 355 @def-1: var(def-2); |
352 @def-2: var(def-3); | 356 @def-2: var(def-3); |
353 @def-3: var(def-2);''', | 357 @def-3: var(def-2);''', |
354 }; | 358 }; |
355 } | 359 } |
356 | 360 |
357 test('var- and Less @define', () { | 361 test('var- and Less @define', () { |
358 var messages = new Messages.silent(); | 362 var messages = new Messages.silent(); |
359 var compiler = createCompiler(createFiles(), messages, errors: true); | 363 var compiler = createCompiler(createFiles(), messages, errors: true, |
| 364 scopedCss: true); |
360 | 365 |
361 compiler.run().then(expectAsync1((e) { | 366 compiler.run().then(expectAsync1((e) { |
362 MockFileSystem fs = compiler.fileSystem; | 367 MockFileSystem fs = compiler.fileSystem; |
363 expect(fs.readCount, equals({ | 368 expect(fs.readCount, equals({ |
364 'index.html': 1, | 369 'index.html': 1, |
365 'foo.html': 1, | 370 'foo.html': 1, |
366 'foo.css': 1 | 371 'foo.css': 1 |
367 }), reason: 'Actual:\n ${fs.readCount}'); | 372 }), reason: 'Actual:\n ${fs.readCount}'); |
368 | 373 |
369 var cssInfo = compiler.info['foo.css']; | 374 var cssInfo = compiler.info['foo.css']; |
(...skipping 17 matching lines...) Expand all Loading... |
387 | 392 |
388 for (var file in compiler.output) { | 393 for (var file in compiler.output) { |
389 if (file.path == 'out/index.html.css') { | 394 if (file.path == 'out/index.html.css') { |
390 expect(file.contents, | 395 expect(file.contents, |
391 '/* Auto-generated from components style tags. */\n' | 396 '/* Auto-generated from components style tags. */\n' |
392 '/* DO NOT EDIT. */\n\n' | 397 '/* DO NOT EDIT. */\n\n' |
393 '/* ==================================================== \n' | 398 '/* ==================================================== \n' |
394 ' Component x-foo stylesheet \n' | 399 ' Component x-foo stylesheet \n' |
395 ' ==================================================== */\n' | 400 ' ==================================================== */\n' |
396 '@import "foo.css";\n' | 401 '@import "foo.css";\n' |
397 '.x-foo_main {\n' | 402 '[is="x-foo"] .main {\n' |
398 ' color: #f00;\n' | 403 ' color: #f00;\n' |
399 '}\n' | 404 '}\n' |
400 '.x-foo_test-background {\n' | 405 '[is="x-foo"] .test-background {\n' |
401 ' background: url("http://www.foo.com/bar.png");\n' | 406 ' background: url("http://www.foo.com/bar.png");\n' |
402 '}\n\n'); | 407 '}\n\n'); |
403 } else if (file.path == 'out/foo.css') { | 408 } else if (file.path == 'out/foo.css') { |
404 expect(file.contents, | 409 expect(file.contents, |
405 '/* Auto-generated from style sheet href = foo.css */\n' | 410 '/* Auto-generated from style sheet href = foo.css */\n' |
406 '/* DO NOT EDIT. */\n\n\n\n'); | 411 '/* DO NOT EDIT. */\n\n\n\n'); |
407 } | 412 } |
408 } | 413 } |
409 | 414 |
410 // Check for warning messages about var- cycles. | 415 // Check for warning messages about var- cycles. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 'foo.html': '<head>' | 491 'foo.html': '<head>' |
487 '<body><polymer-element name="x-foo" constructor="Foo">' | 492 '<body><polymer-element name="x-foo" constructor="Foo">' |
488 '<template>' | 493 '<template>' |
489 '<div pseudo="x-foo">' | 494 '<div pseudo="x-foo">' |
490 '<div>Test</div>' | 495 '<div>Test</div>' |
491 '</div>' | 496 '</div>' |
492 '<div pseudo="x-foo1 x-foo2">' | 497 '<div pseudo="x-foo1 x-foo2">' |
493 '<div>Test</div>' | 498 '<div>Test</div>' |
494 '</div>' | 499 '</div>' |
495 '</template>', | 500 '</template>', |
496 }, messages); | 501 }, messages, scopedCss: true); |
497 | 502 |
498 compiler.run().then(expectAsync1((e) { | 503 compiler.run().then(expectAsync1((e) { |
499 MockFileSystem fs = compiler.fileSystem; | 504 MockFileSystem fs = compiler.fileSystem; |
500 expect(fs.readCount, equals({ | 505 expect(fs.readCount, equals({ |
501 'index.html': 1, | 506 'index.html': 1, |
502 'foo.html': 1, | 507 'foo.html': 1, |
503 }), reason: 'Actual:\n ${fs.readCount}'); | 508 }), reason: 'Actual:\n ${fs.readCount}'); |
504 | 509 |
505 var outputs = compiler.output.map((o) => o.path); | 510 var outputs = compiler.output.map((o) => o.path); |
506 expect(outputs, equals([ | 511 expect(outputs, equals([ |
(...skipping 28 matching lines...) Expand all Loading... |
535 main() { | 540 main() { |
536 useCompactVMConfiguration(); | 541 useCompactVMConfiguration(); |
537 | 542 |
538 test('test_simple_var', test_simple_var); | 543 test('test_simple_var', test_simple_var); |
539 test('test_var', test_var); | 544 test('test_var', test_var); |
540 test('test_simple_import', test_simple_import); | 545 test('test_simple_import', test_simple_import); |
541 test('test_imports', test_imports); | 546 test('test_imports', test_imports); |
542 test('test_component_var', test_component_var); | 547 test('test_component_var', test_component_var); |
543 test('test_pseudo_element', test_pseudo_element); | 548 test('test_pseudo_element', test_pseudo_element); |
544 } | 549 } |
OLD | NEW |