@Test
 public void invalidDirective() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_DECL5A, null);
   assertEquals("One property is accepted (second one is invalid)", 1, ss.get(0).size());
   ss = CSSFactory.parseString(TEST_DECL5B, null);
   assertEquals("One property is accepted (first one is invalid)", 1, ss.get(0).size());
 }
 @Test
 public void vendorSpecificDash() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_DECL2A, null);
   assertEquals("Both properties are accepted (second one is extension)", 2, ss.get(0).size());
   ss = CSSFactory.parseString(TEST_DECL2B, null);
   assertEquals("Both properties are accepted (first one is extension)", 2, ss.get(0).size());
 }
 @Test
 public void invalidSelector() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_DECL6A, null);
   assertEquals("One declaration is accepted (second one is invalid)", 1, ss.size());
   ss = CSSFactory.parseString(TEST_DECL6B, null);
   assertEquals("One declaration is accepted (first one is invalid)", 1, ss.size());
 }
示例#4
0
  @Test
  public void missingQuery() throws IOException, CSSException {
    StyleSheet ss = CSSFactory.parseString(TEST_NO_QUERY, null);
    assertEquals("There are three rules", 3, ss.size());
    assertEquals("There is one rule in media", 1, ss.get(1).size());

    List<MediaQuery> queries = ((RuleMedia) ss.get(1)).getMediaQueries();
    assertEquals("There are no media queries", 0, queries.size());
  }
 @Test
 public void invalidSelectorMedia() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_DECL7A, null);
   assertEquals("Style sheet contains one media rule", 1, ss.size());
   assertEquals("One declaration is accepted (second one is invalid)", 1, ss.get(0).size());
   ss = CSSFactory.parseString(TEST_DECL7B, null);
   assertEquals("Style sheet contains one media rule", 1, ss.size());
   assertEquals("One declaration is accepted (first one is invalid)", 1, ss.get(0).size());
 }
示例#6
0
  @Test
  public void simpleMedia() throws IOException, CSSException {
    StyleSheet ss = CSSFactory.parseString(TEST_SIMPLE_MEDIA, null);
    assertEquals("There are three rules", 3, ss.size());
    assertEquals("There is one rule in media", 1, ss.get(1).size());

    List<MediaQuery> queries = ((RuleMedia) ss.get(1)).getMediaQueries();
    assertEquals("There are two media queries", 2, queries.size());
    assertEquals("The first media query is for screen", "screen", queries.get(0).getType());
    assertEquals("The second media query is for print", "print", queries.get(1).getType());
  }
示例#7
0
  @Test
  public void expressionWithNoValue() throws IOException, CSSException {
    StyleSheet ss = CSSFactory.parseString(TEST_MEDIA_EXPR_NO_VALUE, null);
    assertEquals("There are two rules", 2, ss.size());
    assertEquals("There is one rule in media", 1, ss.get(0).size());

    List<MediaQuery> queries = ((RuleMedia) ss.get(0)).getMediaQueries();
    assertEquals("There is one media query", 1, queries.size());
    assertEquals("There is one expression", 1, queries.get(0).size());
    assertEquals(
        "The expression is for transform-3d", "transform-3d", queries.get(0).get(0).getFeature());
    assertEquals("The expression has no terms", 0, queries.get(0).get(0).size());
  }
示例#8
0
  @Test
  public void mediaWithExpressions() throws IOException, CSSException {
    StyleSheet ss = CSSFactory.parseString(TEST_MEDIA_EXPR, null);
    assertEquals("There are three rules", 3, ss.size());
    assertEquals("There is one rule in media", 1, ss.get(1).size());

    List<MediaQuery> queries = ((RuleMedia) ss.get(1)).getMediaQueries();
    assertEquals("There are two media queries", 2, queries.size());
    assertEquals("The first media query is for screen", "screen", queries.get(0).getType());
    assertEquals("There are two expressions", 2, queries.get(0).size());
    assertEquals(
        "The first expression is for min-width", "min-width", queries.get(0).get(0).getFeature());
    assertEquals("The first expression has one term", 1, queries.get(0).get(0).size());
  }
示例#9
0
  @Test
  public void malformedQueries3() throws IOException, CSSException {
    StyleSheet ss;
    List<MediaQuery> queries;

    ss = CSSFactory.parseString(TEST_MALFORMED3, null);
    assertEquals("There are three rules", 3, ss.size());
    assertEquals("There is one rule in media", 1, ss.get(1).size());

    queries = ((RuleMedia) ss.get(1)).getMediaQueries();
    assertEquals("There is one media query", 1, queries.size());
    assertEquals("First of them is NOT all", true, queries.get(0).isNegative());
    assertEquals("First of them is NOT ALL", "all", queries.get(0).getType());
  }
示例#10
0
 @Test
 public void malformedQueries4() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_MALFORMED4, null);
   assertEquals("There are three rules", 3, ss.size());
 }
示例#11
0
 public static StyleSheet getEmptyStyleSheet() {
   final StyleSheet css = rf.createStyleSheet();
   css.unlock();
   return css;
 }
 @Test
 public void invalidSelectorSyntax() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_DECL8A, null);
   assertEquals("Style sheet contains two rules (the middle one is invalid)", 2, ss.size());
 }