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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 '<x-foo></x-foo>' | 317 '<x-foo></x-foo>' |
318 '<script type="application/dart">main() {}</script>' | 318 '<script type="application/dart">main() {}</script>' |
319 '</body>' | 319 '</body>' |
320 '</html>', | 320 '</html>', |
321 'foo.html': '<!DOCTYPE html>' | 321 'foo.html': '<!DOCTYPE html>' |
322 '<html lang="en">' | 322 '<html lang="en">' |
323 '<head>' | 323 '<head>' |
324 '<meta charset="utf-8">' | 324 '<meta charset="utf-8">' |
325 '</head>' | 325 '</head>' |
326 '<body>' | 326 '<body>' |
327 '<element name="x-foo" constructor="Foo">' | 327 '<polymer-element name="x-foo" constructor="Foo">' |
328 '<template>' | 328 '<template>' |
329 '<style scoped>' | 329 '<style scoped>' |
330 '@import "foo.css";' | 330 '@import "foo.css";' |
331 '.main { color: var(main_color); }' | 331 '.main { color: var(main_color); }' |
332 '.test-background { ' | 332 '.test-background { ' |
333 'background: url(http://www.foo.com/bar.png);' | 333 'background: url(http://www.foo.com/bar.png);' |
334 '}' | 334 '}' |
335 '</style>' | 335 '</style>' |
336 '</template>' | 336 '</template>' |
337 '</element>' | 337 '</polymer-element>' |
338 '</body>' | 338 '</body>' |
339 '</html>', | 339 '</html>', |
340 'foo.css': r'''@main_color: var(b); | 340 'foo.css': r'''@main_color: var(b); |
341 @b: var(c); | 341 @b: var(c); |
342 @c: red; | 342 @c: red; |
343 | 343 |
344 @one: var(two); | 344 @one: var(two); |
345 @two: var(one); | 345 @two: var(one); |
346 | 346 |
347 @four: var(five); | 347 @four: var(five); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 '<style>' | 477 '<style>' |
478 '.test::x-foo { background-color: red; }' | 478 '.test::x-foo { background-color: red; }' |
479 '.test::x-foo1 { color: blue; }' | 479 '.test::x-foo1 { color: blue; }' |
480 '.test::x-foo2 { color: green; }' | 480 '.test::x-foo2 { color: green; }' |
481 '</style>' | 481 '</style>' |
482 '<body>' | 482 '<body>' |
483 '<x-foo class=test></x-foo>' | 483 '<x-foo class=test></x-foo>' |
484 '<x-foo></x-foo>' | 484 '<x-foo></x-foo>' |
485 '<script type="application/dart">main() {}</script>', | 485 '<script type="application/dart">main() {}</script>', |
486 'foo.html': '<head>' | 486 'foo.html': '<head>' |
487 '<body><element name="x-foo" constructor="Foo">' | 487 '<body><polymer-element name="x-foo" constructor="Foo">' |
488 '<template>' | 488 '<template>' |
489 '<div pseudo="x-foo">' | 489 '<div pseudo="x-foo">' |
490 '<div>Test</div>' | 490 '<div>Test</div>' |
491 '</div>' | 491 '</div>' |
492 '<div pseudo="x-foo1 x-foo2">' | 492 '<div pseudo="x-foo1 x-foo2">' |
493 '<div>Test</div>' | 493 '<div>Test</div>' |
494 '</div>' | 494 '</div>' |
495 '</template>', | 495 '</template>', |
496 }, messages); | 496 }, messages); |
497 | 497 |
498 compiler.run().then(expectAsync1((e) { | 498 compiler.run().then(expectAsync1((e) { |
499 MockFileSystem fs = compiler.fileSystem; | 499 MockFileSystem fs = compiler.fileSystem; |
500 expect(fs.readCount, equals({ | 500 expect(fs.readCount, equals({ |
501 'index.html': 1, | 501 'index.html': 1, |
502 'foo.html': 1, | 502 'foo.html': 1, |
503 }), reason: 'Actual:\n ${fs.readCount}'); | 503 }), reason: 'Actual:\n ${fs.readCount}'); |
504 | 504 |
505 var outputs = compiler.output.map((o) => o.path); | 505 var outputs = compiler.output.map((o) => o.path); |
506 expect(outputs, equals([ | 506 expect(outputs, equals([ |
507 'out/foo.html.dart', | 507 'out/foo.html.dart', |
508 'out/foo.html.dart.map', | 508 'out/foo.html.dart.map', |
509 'out/index.html.dart', | 509 'out/index.html.dart', |
510 'out/index.html.dart.map', | 510 'out/index.html.dart.map', |
511 'out/index.html_bootstrap.dart', | 511 'out/index.html_bootstrap.dart', |
512 'out/index.html', | 512 'out/index.html', |
513 ])); | 513 ])); |
514 expect(compiler.output[0].contents.contains( | 514 expect(compiler.output.last.contents, contains( |
515 '<div pseudo="x-foo_0">' | 515 '<div pseudo="x-foo_0">' |
516 '<div>Test</div>' | 516 '<div>Test</div>' |
517 '</div>' | 517 '</div>' |
518 '<div pseudo="x-foo1_1 x-foo2_2">' | 518 '<div pseudo="x-foo1_1 x-foo2_2">' |
519 '<div>Test</div>' | 519 '<div>Test</div>' |
520 '</div>'), true); | 520 '</div>')); |
521 expect(compiler.output[5].contents.contains( | 521 expect(compiler.output.last.contents, contains( |
522 '<style>.test > *[pseudo="x-foo_0"] {\n' | 522 '<style>.test > *[pseudo="x-foo_0"] {\n' |
523 ' background-color: #f00;\n' | 523 ' background-color: #f00;\n' |
524 '}\n' | 524 '}\n' |
525 '.test > *[pseudo="x-foo1_1"] {\n' | 525 '.test > *[pseudo="x-foo1_1"] {\n' |
526 ' color: #00f;\n' | 526 ' color: #00f;\n' |
527 '}\n' | 527 '}\n' |
528 '.test > *[pseudo="x-foo2_2"] {\n' | 528 '.test > *[pseudo="x-foo2_2"] {\n' |
529 ' color: #008000;\n' | 529 ' color: #008000;\n' |
530 '}' | 530 '}' |
531 '</style>'), true); | 531 '</style>')); |
532 })); | 532 })); |
533 } | 533 } |
534 | 534 |
535 main() { | 535 main() { |
536 useCompactVMConfiguration(); | 536 useCompactVMConfiguration(); |
537 | 537 |
538 test('test_simple_var', test_simple_var); | 538 test('test_simple_var', test_simple_var); |
539 test('test_var', test_var); | 539 test('test_var', test_var); |
540 test('test_simple_import', test_simple_import); | 540 test('test_simple_import', test_simple_import); |
541 test('test_imports', test_imports); | 541 test('test_imports', test_imports); |
542 test('test_component_var', test_component_var); | 542 test('test_component_var', test_component_var); |
543 test('test_pseudo_element', test_pseudo_element); | 543 test('test_pseudo_element', test_pseudo_element); |
544 } | 544 } |
OLD | NEW |