@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());
 }
 @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());
 }
Beispiel #3
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());
  }
Beispiel #4
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());
  }
Beispiel #5
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());
  }
Beispiel #6
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());
  }
Beispiel #7
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());
  }
Beispiel #8
0
 @Test
 public void malformedQueries4() throws IOException, CSSException {
   StyleSheet ss = CSSFactory.parseString(TEST_MALFORMED4, null);
   assertEquals("There are three rules", 3, ss.size());
 }
 @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());
 }