|
Lines 77-80
Link Here
|
| 77 |
String colorString = ((CSSPrimitiveValue) value).getStringValue(); |
77 |
String colorString = ((CSSPrimitiveValue) value).getStringValue(); |
| 78 |
assertEquals("Verdana", colorString); |
78 |
assertEquals("Verdana", colorString); |
| 79 |
} |
79 |
} |
|
|
80 |
|
| 81 |
public void testTestFontItalic() throws Exception { |
| 82 |
String css = "Label { font: Arial 12px; font-style: italic }"; |
| 83 |
CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); |
| 84 |
CSSRuleList rules = styleSheet.getCssRules(); |
| 85 |
CSSRule rule = rules.item(0); |
| 86 |
assertEquals(CSSRule.STYLE_RULE, rule.getType()); |
| 87 |
CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); |
| 88 |
CSSValue value = style.getPropertyCSSValue("font-style"); |
| 89 |
assertTrue(value instanceof CSSPrimitiveValue); |
| 90 |
String colorString = ((CSSPrimitiveValue) value).getStringValue(); |
| 91 |
assertEquals("italic", colorString); |
| 92 |
} |
| 93 |
|
| 94 |
public void testTestFontBold() throws Exception{ |
| 95 |
String css = "Label { font: Arial 12px; font-style: bold }"; |
| 96 |
CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); |
| 97 |
CSSRuleList rules = styleSheet.getCssRules(); |
| 98 |
CSSRule rule = rules.item(0); |
| 99 |
assertEquals(CSSRule.STYLE_RULE, rule.getType()); |
| 100 |
CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); |
| 101 |
CSSValue value = style.getPropertyCSSValue("font-style"); |
| 102 |
assertTrue(value instanceof CSSPrimitiveValue); |
| 103 |
String colorString = ((CSSPrimitiveValue) value).getStringValue(); |
| 104 |
assertEquals("bold", colorString); |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
public void testBackgroundNameColor() throws Exception{ |
| 109 |
String css = "Label { background-color: green }"; |
| 110 |
CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); |
| 111 |
CSSRuleList rules = styleSheet.getCssRules(); |
| 112 |
CSSRule rule = rules.item(0); |
| 113 |
assertEquals(CSSRule.STYLE_RULE, rule.getType()); |
| 114 |
CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); |
| 115 |
CSSValue value = style.getPropertyCSSValue("background-color"); |
| 116 |
assertTrue(value instanceof CSSPrimitiveValue); |
| 117 |
String colorString = ((CSSPrimitiveValue) value).getStringValue(); |
| 118 |
assertEquals("green", colorString); |
| 119 |
} |
| 120 |
|
| 121 |
public void testBackgroundHexColor() throws Exception { |
| 122 |
String css = "Label { background-color: #FF0220 }"; |
| 123 |
CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); |
| 124 |
CSSRuleList rules = styleSheet.getCssRules(); |
| 125 |
CSSRule rule = rules.item(0); |
| 126 |
assertEquals(CSSRule.STYLE_RULE, rule.getType()); |
| 127 |
CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); |
| 128 |
CSSValue value = style.getPropertyCSSValue("background-color"); |
| 129 |
assertTrue(value instanceof CSSPrimitiveValue); |
| 130 |
RGBColor colorValue = ((CSSPrimitiveValue) value).getRGBColorValue(); |
| 131 |
assertEquals(255.0f, colorValue.getRed().getFloatValue( |
| 132 |
CSSPrimitiveValue.CSS_NUMBER), 0f); |
| 133 |
assertEquals(2.0f, colorValue.getGreen().getFloatValue( |
| 134 |
CSSPrimitiveValue.CSS_NUMBER), 0f); |
| 135 |
assertEquals(32.0f, colorValue.getBlue().getFloatValue( |
| 136 |
CSSPrimitiveValue.CSS_NUMBER), 0f); |
| 137 |
} |
| 80 |
} |
138 |
} |