Example #1
0
 private CssFunctionNode createRgbFunctionNode(String r, String g, String b) {
   CssFunctionNode function =
       new CssFunctionNode(CssFunctionNode.Function.byName("rgb"), null /* sourceCodeLocation */);
   List<CssValueNode> values = Lists.newArrayList();
   values.add(createNumericNode(r));
   values.add(createNumericNode(g));
   values.add(createNumericNode(b));
   CssFunctionArgumentsNode args = new CssFunctionArgumentsNode(values);
   function.setArguments(args);
   return function;
 }
Example #2
0
  public void testParseRgbArgumentsBadArgs() {
    CssFunctionNode function =
        new CssFunctionNode(CssFunctionNode.Function.byName("rgb"), null /* sourceCodeLocation */);
    List<CssValueNode> values = Lists.newArrayList();
    values.add(createNumericNode("0"));
    CssFunctionArgumentsNode args = new CssFunctionArgumentsNode(values);
    function.setArguments(args);

    try {
      ColorValueOptimizer.parseRgbArguments(function);
      fail("Too few arguments to rgb function; should have thrown.");
    } catch (NumberFormatException expected) {
      // Exception is expected.
    }
  }