コード例 #1
0
  private static Style createStyle(String stylesheetText) {

    Stylesheet stylesheet = CSSParser.getInstance().parse(stylesheetText);
    Rule rule = stylesheet.getRules().get(0);
    Selector sel = rule.getUnobservedSelectorList().get(0);
    Declaration decl = rule.getUnobservedDeclarationList().get(0);
    return new Style(sel, decl);
  }
コード例 #2
0
 @Test
 public void testGetStylesheet() {
   Rule instance = new Rule(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
   Stylesheet expResult = new Stylesheet();
   expResult.getRules().add(instance);
   Stylesheet result = instance.getStylesheet();
   assertEquals(expResult, result);
 }
コード例 #3
0
 @Test
 public void testGetOriginAfterRemovingRuleFromStylesheet() {
   Rule instance = new Rule(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
   Stylesheet stylesheet = new Stylesheet();
   stylesheet.getRules().add(instance);
   stylesheet.setOrigin(StyleOrigin.INLINE);
   stylesheet.getRules().remove(instance);
   StyleOrigin result = instance.getOrigin();
   assertNull(result);
 }
コード例 #4
0
 @Test
 public void testGetOriginAfterSettingOriginBeforeAddingRuleToStylesheet() {
   Rule instance = new Rule(Collections.EMPTY_LIST, Collections.EMPTY_LIST);
   Stylesheet stylesheet = new Stylesheet();
   stylesheet.setOrigin(StyleOrigin.INLINE);
   stylesheet.getRules().add(instance);
   StyleOrigin expResult = StyleOrigin.INLINE;
   StyleOrigin result = instance.getOrigin();
   assertEquals(expResult, result);
 }