|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008, 2010 Innoopract Informationssysteme GmbH. |
2 |
* Copyright (c) 2008, 2011 Innoopract Informationssysteme GmbH. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 77-82
Link Here
|
| 77 |
} |
77 |
} |
| 78 |
} |
78 |
} |
| 79 |
|
79 |
|
|
|
80 |
public void testColorWithAlpha() throws Exception { |
| 81 |
String input = "rgba( 1, 2, 3, 0.25 )"; |
| 82 |
QxColor result |
| 83 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 84 |
assertNotNull( result ); |
| 85 |
assertEquals( 1, result.red ); |
| 86 |
assertEquals( 2, result.green ); |
| 87 |
assertEquals( 3, result.blue ); |
| 88 |
assertEquals( 0.25, result.alpha, 0 ); |
| 89 |
} |
| 90 |
|
| 91 |
public void testColorWithAlpha_Percents() throws Exception { |
| 92 |
String input = "rgba( 0%, 50%, 100%, 0.25 )"; |
| 93 |
QxColor result |
| 94 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 95 |
assertNotNull( result ); |
| 96 |
assertEquals( 0, result.red ); |
| 97 |
assertEquals( 127, result.green ); |
| 98 |
assertEquals( 255, result.blue ); |
| 99 |
assertEquals( 0.25, result.alpha, 0 ); |
| 100 |
} |
| 101 |
|
| 102 |
public void testColorWithAlpha_NoTransparency() throws Exception { |
| 103 |
String input = "rgba( 0, 0, 0, 1 )"; |
| 104 |
QxColor result |
| 105 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 106 |
assertSame( QxColor.BLACK, result ); |
| 107 |
} |
| 108 |
|
| 109 |
public void testColorWithAlpha_NormalizeNegativeAlpha() throws Exception { |
| 110 |
String input = "rgba( 1, 2, 3, -0.1 )"; |
| 111 |
QxColor result |
| 112 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 113 |
assertNotNull( result ); |
| 114 |
assertEquals( 1, result.red ); |
| 115 |
assertEquals( 2, result.green ); |
| 116 |
assertEquals( 3, result.blue ); |
| 117 |
assertEquals( 0f, result.alpha, 0 ); |
| 118 |
} |
| 119 |
|
| 120 |
public void testColorWithAlpha_NormalizePositiveAlpha() throws Exception { |
| 121 |
String input = "rgba( 1, 2, 3, 1.1 )"; |
| 122 |
QxColor result |
| 123 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 124 |
assertNotNull( result ); |
| 125 |
assertEquals( 1, result.red ); |
| 126 |
assertEquals( 2, result.green ); |
| 127 |
assertEquals( 3, result.blue ); |
| 128 |
assertEquals( 1f, result.alpha, 0 ); |
| 129 |
} |
| 130 |
|
| 131 |
public void testColorWithAlpha_NormalizeColorValue() throws Exception { |
| 132 |
String input = "rgba( -10, 127, 300, 0.25 )"; |
| 133 |
QxColor result |
| 134 |
= PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 135 |
assertNotNull( result ); |
| 136 |
assertEquals( 0, result.red ); |
| 137 |
assertEquals( 127, result.green ); |
| 138 |
assertEquals( 255, result.blue ); |
| 139 |
assertEquals( 0.25, result.alpha, 0 ); |
| 140 |
} |
| 141 |
|
| 142 |
public void testColorWithAlpha_MixedValues() throws Exception { |
| 143 |
String input = "rgba( 0%, 50, 100, 0.25 )"; |
| 144 |
try { |
| 145 |
PropertyResolver.readColorWithAlpha( parseProperty( input ) ); |
| 146 |
fail(); |
| 147 |
} catch( IllegalArgumentException e ) { |
| 148 |
// expected |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 80 |
public void testDimension() throws Exception { |
152 |
public void testDimension() throws Exception { |
| 81 |
QxDimension zero = PropertyResolver.readDimension( parseProperty( "0px" ) ); |
153 |
QxDimension zero = PropertyResolver.readDimension( parseProperty( "0px" ) ); |
| 82 |
assertNotNull( zero ); |
154 |
assertNotNull( zero ); |
|
Lines 652-657
Link Here
|
| 652 |
} |
724 |
} |
| 653 |
} |
725 |
} |
| 654 |
|
726 |
|
|
|
727 |
public void testShadow_XYOffsetOnlyNotation() throws Exception { |
| 728 |
String input = "1px 2px"; |
| 729 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 730 |
assertNotNull( result ); |
| 731 |
assertEquals( 1, result.offsetX ); |
| 732 |
assertEquals( 2, result.offsetY ); |
| 733 |
assertEquals( 0, result.blur ); |
| 734 |
assertEquals( 0, result.spread ); |
| 735 |
assertEquals( "#000000", result.color ); |
| 736 |
assertEquals( 1f, result.opacity, 0 ); |
| 737 |
} |
| 738 |
|
| 739 |
public void testShadow_OffsetXYBlurNotation() throws Exception { |
| 740 |
String input = "1px 2px 3px"; |
| 741 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 742 |
assertNotNull( result ); |
| 743 |
assertEquals( 1, result.offsetX ); |
| 744 |
assertEquals( 2, result.offsetY ); |
| 745 |
assertEquals( 3, result.blur ); |
| 746 |
assertEquals( 0, result.spread ); |
| 747 |
assertEquals( "#000000", result.color ); |
| 748 |
assertEquals( 1f, result.opacity, 0 ); |
| 749 |
} |
| 750 |
|
| 751 |
public void testShadow_XYOffsetBlurSpreadNotation() throws Exception { |
| 752 |
String input = "1px 2px 0 0"; |
| 753 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 754 |
assertNotNull( result ); |
| 755 |
assertEquals( 1, result.offsetX ); |
| 756 |
assertEquals( 2, result.offsetY ); |
| 757 |
assertEquals( 0, result.blur ); |
| 758 |
assertEquals( 0, result.spread ); |
| 759 |
assertEquals( "#000000", result.color ); |
| 760 |
assertEquals( 1f, result.opacity, 0 ); |
| 761 |
} |
| 762 |
|
| 763 |
public void testShadow_FullNotation_NamedColor() throws Exception { |
| 764 |
String input = "1px 2px 0px 0 red"; |
| 765 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 766 |
assertNotNull( result ); |
| 767 |
assertEquals( 1, result.offsetX ); |
| 768 |
assertEquals( 2, result.offsetY ); |
| 769 |
assertEquals( 0, result.blur ); |
| 770 |
assertEquals( 0, result.spread ); |
| 771 |
assertEquals( "#ff0000", result.color ); |
| 772 |
assertEquals( 1f, result.opacity, 0 ); |
| 773 |
} |
| 774 |
|
| 775 |
public void testShadow_FullNotation_HexColor() throws Exception { |
| 776 |
String input = "1px 2px 0px 0 #FF0000"; |
| 777 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 778 |
assertNotNull( result ); |
| 779 |
assertEquals( 1, result.offsetX ); |
| 780 |
assertEquals( 2, result.offsetY ); |
| 781 |
assertEquals( 0, result.blur ); |
| 782 |
assertEquals( 0, result.spread ); |
| 783 |
assertEquals( "#ff0000", result.color ); |
| 784 |
assertEquals( 1f, result.opacity, 0 ); |
| 785 |
} |
| 786 |
|
| 787 |
public void testShadow_FullNotation_RgbColor() throws Exception { |
| 788 |
String input = "1px 2px 3px 0 rgb( 1, 2, 3 )"; |
| 789 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 790 |
assertNotNull( result ); |
| 791 |
assertEquals( 1, result.offsetX ); |
| 792 |
assertEquals( 2, result.offsetY ); |
| 793 |
assertEquals( 3, result.blur ); |
| 794 |
assertEquals( 0, result.spread ); |
| 795 |
assertEquals( "#010203", result.color ); |
| 796 |
assertEquals( 1f, result.opacity, 0 ); |
| 797 |
} |
| 798 |
|
| 799 |
public void testShadow_FullNotation_RgbaColor() throws Exception { |
| 800 |
String input = "1px 2px 0px 0 rgba( 1, 2, 3, 0.25 )"; |
| 801 |
QxShadow result = PropertyResolver.readShadow( parseProperty( input ) ); |
| 802 |
assertNotNull( result ); |
| 803 |
assertEquals( 1, result.offsetX ); |
| 804 |
assertEquals( 2, result.offsetY ); |
| 805 |
assertEquals( 0, result.blur ); |
| 806 |
assertEquals( 0, result.spread ); |
| 807 |
assertEquals( "#010203", result.color ); |
| 808 |
assertEquals( 0.25, result.opacity, 0 ); |
| 809 |
} |
| 810 |
|
| 811 |
public void testShadow_WithoutOffsetY() throws Exception { |
| 812 |
try { |
| 813 |
PropertyResolver.readShadow( parseProperty( "1px" ) ); |
| 814 |
fail(); |
| 815 |
} catch( IllegalArgumentException e ) { |
| 816 |
// expected |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
public void testShadow_MissingRgbaParameters() throws Exception { |
| 821 |
String input = "1px 2px 0px 0 rgba( 1, 2, 0.25 )"; |
| 822 |
try { |
| 823 |
PropertyResolver.readShadow( parseProperty( input ) ); |
| 824 |
fail(); |
| 825 |
} catch( IllegalArgumentException e ) { |
| 826 |
// expected |
| 827 |
} |
| 828 |
} |
| 829 |
|
| 830 |
public void testShadow_NonZeroSpread() throws Exception { |
| 831 |
String input = "1px 2px 3px 3px rgba( 1, 2, 3, 0.25 )"; |
| 832 |
try { |
| 833 |
PropertyResolver.readShadow( parseProperty( input ) ); |
| 834 |
fail(); |
| 835 |
} catch( IllegalArgumentException e ) { |
| 836 |
// expected |
| 837 |
} |
| 838 |
} |
| 839 |
|
| 655 |
public void testIsColorProperty() { |
840 |
public void testIsColorProperty() { |
| 656 |
assertFalse( PropertyResolver.isColorProperty( "border" ) ); |
841 |
assertFalse( PropertyResolver.isColorProperty( "border" ) ); |
| 657 |
assertTrue( PropertyResolver.isColorProperty( "color" ) ); |
842 |
assertTrue( PropertyResolver.isColorProperty( "color" ) ); |
|
Lines 685-690
Link Here
|
| 685 |
assertTrue( PropertyResolver.isAnimationProperty( "animation" ) ); |
870 |
assertTrue( PropertyResolver.isAnimationProperty( "animation" ) ); |
| 686 |
} |
871 |
} |
| 687 |
|
872 |
|
|
|
873 |
public void testIsShadowProperty() { |
| 874 |
assertTrue( PropertyResolver.isShadowProperty( "box-shadow" ) ); |
| 875 |
} |
| 876 |
|
| 688 |
public void testResolveProperty() throws Exception { |
877 |
public void testResolveProperty() throws Exception { |
| 689 |
LexicalUnit unit = parseProperty( "white" ); |
878 |
LexicalUnit unit = parseProperty( "white" ); |
| 690 |
QxType value = PropertyResolver.resolveProperty( "color", unit, null ); |
879 |
QxType value = PropertyResolver.resolveProperty( "color", unit, null ); |