OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 declaration_test; | 5 library declaration_test; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 import 'testing.dart'; | 8 import 'testing.dart'; |
9 | 9 |
10 | |
11 /** CSS compiler options no checks in in memory style sheet. */ | 10 /** CSS compiler options no checks in in memory style sheet. */ |
12 List options = ['--no-colors', 'memory']; | 11 List options = ['--no-colors', 'memory']; |
13 | 12 |
14 void testSimpleTerms() { | 13 void testSimpleTerms() { |
15 var errors = []; | 14 var errors = []; |
16 final String input = r''' | 15 final String input = r''' |
17 @ import url("test.css"); | 16 @ import url("test.css"); |
18 .foo { | 17 .foo { |
19 background-color: #191919; | 18 background-color: #191919; |
20 width: 10PX; | 19 width: 10PX; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 } | 357 } |
359 @media print and (min-resolution: 280dpcm) { | 358 @media print and (min-resolution: 280dpcm) { |
360 #finalId { | 359 #finalId { |
361 color: #aaa; | 360 color: #aaa; |
362 } | 361 } |
363 .class2 { | 362 .class2 { |
364 border: 20px; | 363 border: 20px; |
365 } | 364 } |
366 }'''; | 365 }'''; |
367 generated = | 366 generated = |
368 '''@media handheld AND (min-width:20em), screen AND (min-width:20em) { | 367 '''@media handheld AND (min-width:20em), screen AND (min-width:20em) { |
369 #id { | 368 #id { |
370 color: #f00; | 369 color: #f00; |
371 } | 370 } |
372 .myclass { | 371 .myclass { |
373 height: 20px; | 372 height: 20px; |
374 } | 373 } |
375 } @media print AND (min-resolution:300dpi) { | 374 } @media print AND (min-resolution:300dpi) { |
376 #anotherId { | 375 #anotherId { |
377 color: #fff; | 376 color: #fff; |
378 } | 377 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 expect(stylesheet != null, true); | 473 expect(stylesheet != null, true); |
475 expect(errors.isEmpty, true, reason: errors.toString()); | 474 expect(errors.isEmpty, true, reason: errors.toString()); |
476 expect(prettyPrint(stylesheet), generated1); | 475 expect(prettyPrint(stylesheet), generated1); |
477 | 476 |
478 final String input2 = ''' | 477 final String input2 = ''' |
479 @font-face { | 478 @font-face { |
480 src: url(ideal-sans-serif.woff) format("woff"), | 479 src: url(ideal-sans-serif.woff) format("woff"), |
481 url(basic-sans-serif.ttf) format("opentype"), | 480 url(basic-sans-serif.ttf) format("opentype"), |
482 local(Gentium Bold); | 481 local(Gentium Bold); |
483 }'''; | 482 }'''; |
484 final String generated2 = | 483 final String generated2 = '@font-face {\n' |
485 '@font-face {\n' | |
486 ' src: url("ideal-sans-serif.woff") ' | 484 ' src: url("ideal-sans-serif.woff") ' |
487 'format("woff"), url("basic-sans-serif.ttf") ' | 485 'format("woff"), url("basic-sans-serif.ttf") ' |
488 'format("opentype"), local(Gentium Bold);\n}'; | 486 'format("opentype"), local(Gentium Bold);\n}'; |
489 | 487 |
490 stylesheet = parseCss(input2, errors: errors..clear(), opts: options); | 488 stylesheet = parseCss(input2, errors: errors..clear(), opts: options); |
491 | 489 |
492 expect(stylesheet != null, true); | 490 expect(stylesheet != null, true); |
493 expect(errors.isEmpty, true, reason: errors.toString()); | 491 expect(errors.isEmpty, true, reason: errors.toString()); |
494 expect(prettyPrint(stylesheet), generated2); | 492 expect(prettyPrint(stylesheet), generated2); |
495 | 493 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 554 |
557 .foobar { | 555 .foobar { |
558 grid-columns: 10px ("content" 1fr 10px)[4]; | 556 grid-columns: 10px ("content" 1fr 10px)[4]; |
559 } | 557 } |
560 | 558 |
561 .test-background { | 559 .test-background { |
562 background: url(http://www.foo.com/bar.png); | 560 background: url(http://www.foo.com/bar.png); |
563 } | 561 } |
564 '''; | 562 '''; |
565 | 563 |
566 final String generated = | 564 final String generated = '@import "simple.css"; ' |
567 '@import "simple.css"; ' | |
568 '@import "test.css" print; ' | 565 '@import "test.css" print; ' |
569 '@import "test.css" screen, print; ' | 566 '@import "test.css" screen, print; ' |
570 '@import "http://google.com/maps/maps.css";\n' | 567 '@import "http://google.com/maps/maps.css";\n' |
571 'div[href^="test"] {\n' | 568 'div[href^="test"] {\n' |
572 ' height: 10px;\n' | 569 ' height: 10px;\n' |
573 '}\n' | 570 '}\n' |
574 '@-webkit-keyframes pulsate {\n' | 571 '@-webkit-keyframes pulsate {\n' |
575 ' from {\n' | 572 ' from {\n' |
576 ' -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n' | 573 ' -webkit-transform: translate3d(0, 0, 0) scale(1.0);\n' |
577 ' }\n' | 574 ' }\n' |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 | 705 |
709 var stylesheet = parseCss(input, errors: errors, opts: options); | 706 var stylesheet = parseCss(input, errors: errors, opts: options); |
710 | 707 |
711 expect(stylesheet != null, true); | 708 expect(stylesheet != null, true); |
712 expect(errors.isEmpty, true, reason: errors.toString()); | 709 expect(errors.isEmpty, true, reason: errors.toString()); |
713 expect(prettyPrint(stylesheet), generated); | 710 expect(prettyPrint(stylesheet), generated); |
714 } | 711 } |
715 | 712 |
716 void testIE() { | 713 void testIE() { |
717 var errors = []; | 714 var errors = []; |
718 final String input = | 715 final String input = ".test {\n" |
719 ".test {\n" | 716 " filter: progid:DXImageTransform.Microsoft.gradient" |
720 " filter: progid:DXImageTransform.Microsoft.gradient" | 717 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n" |
721 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n" | 718 "}"; |
722 "}"; | 719 final String generated = ".test {\n" |
723 final String generated = | 720 " filter: progid:DXImageTransform.Microsoft.gradient" |
724 ".test {\n" | 721 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n" |
725 " filter: progid:DXImageTransform.Microsoft.gradient" | 722 "}"; |
726 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');\n" | |
727 "}"; | |
728 | 723 |
729 var stylesheet = parseCss(input, errors: errors, opts: options); | 724 var stylesheet = parseCss(input, errors: errors, opts: options); |
730 | 725 |
731 expect(stylesheet != null, true); | 726 expect(stylesheet != null, true); |
732 expect(errors.isEmpty, true, reason: errors.toString()); | 727 expect(errors.isEmpty, true, reason: errors.toString()); |
733 expect(prettyPrint(stylesheet), generated); | 728 expect(prettyPrint(stylesheet), generated); |
734 | 729 |
735 final String input2 = | 730 final String input2 = ".test {\n" |
736 ".test {\n" | 731 " filter: progid:DXImageTransform.Microsoft.gradient" |
737 " filter: progid:DXImageTransform.Microsoft.gradient" | 732 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n" |
738 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n" | 733 " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1
);\n" |
739 " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n" | 734 "}"; |
740 "}"; | |
741 | 735 |
742 final String generated2 = | 736 final String generated2 = ".test {\n" |
743 ".test {\n" | 737 " filter: progid:DXImageTransform.Microsoft.gradient" |
744 " filter: progid:DXImageTransform.Microsoft.gradient" | 738 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n" |
745 "(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670')\n" | 739 " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=
1);\n" |
746 " progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);\n" | 740 "}"; |
747 "}"; | |
748 | 741 |
749 stylesheet = parseCss(input2, errors: errors..clear(), opts: options); | 742 stylesheet = parseCss(input2, errors: errors..clear(), opts: options); |
750 | 743 |
751 expect(stylesheet != null, true); | 744 expect(stylesheet != null, true); |
752 expect(errors.isEmpty, true, reason: errors.toString()); | 745 expect(errors.isEmpty, true, reason: errors.toString()); |
753 expect(prettyPrint(stylesheet), generated2); | 746 expect(prettyPrint(stylesheet), generated2); |
754 | 747 |
755 final String input3 = ''' | 748 final String input3 = ''' |
756 div { | 749 div { |
757 filter: alpha(opacity=80); /* IE7 and under */ | 750 filter: alpha(opacity=80); /* IE7 and under */ |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 test('Newer CSS', testNewerCss); | 1018 test('Newer CSS', testNewerCss); |
1026 test('Media Queries', testMediaQueries); | 1019 test('Media Queries', testMediaQueries); |
1027 test('Font-Face', testFontFace); | 1020 test('Font-Face', testFontFace); |
1028 test('CSS file', testCssFile); | 1021 test('CSS file', testCssFile); |
1029 test('Compact Emitter', testCompactEmitter); | 1022 test('Compact Emitter', testCompactEmitter); |
1030 test('Selector Negation', testNotSelectors); | 1023 test('Selector Negation', testNotSelectors); |
1031 test('IE stuff', testIE); | 1024 test('IE stuff', testIE); |
1032 test('IE declaration syntax', testIEDeclaration); | 1025 test('IE declaration syntax', testIEDeclaration); |
1033 test('Hanging bugs', testHangs); | 1026 test('Hanging bugs', testHangs); |
1034 } | 1027 } |
OLD | NEW |