Java Code Examples for cz.vutbr.web.css.CSSFactory#assignDOM()

The following examples show how to use cz.vutbr.web.css.CSSFactory#assignDOM() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void combinators() throws SAXException, IOException {  
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors3.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors3.html"),"screen", true);
    
    NodeData i1 = getStyleById(elements, decl, "i1");
    NodeData i2 = getStyleById(elements, decl, "i2");
    NodeData i3 = getStyleById(elements, decl, "i3");
    NodeData i4 = getStyleById(elements, decl, "i4");

    assertThat("Descendant combinator", i1.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
    assertThat("Child combinator", i2.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
    assertThat("Adjacent sibling combinator", i3.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
    assertThat("Generic sibling combinator", i4.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
}
 
Example 2
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void inherit() throws SAXException, IOException {  
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/inherit.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null,
    		getClass().getResource("/advanced/inherit.html"),"screen", true);
    
    NodeData data = decl.get(elements.getElementById("item1"));
    assertNotNull("Data for #item1 exist", data);
    assertThat(data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(1.0f, Unit.px)));
    assertThat(data.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 128, 0)));
    assertThat((CSSProperty.BorderStyle) data.getProperty("border-top-style"), is(CSSProperty.BorderStyle.SOLID));
    assertThat(data.getValue(TermLength.class, "margin-top"), is(tf.createLength(1.0f, Unit.em)));
    assertThat(data.getValue(TermLength.class, "margin-bottom"), is(tf.createLength(3.0f, Unit.em)));
    
    data = decl.get(elements.getElementById("item2"));
    assertNotNull("Data for #item2 exist", data);
    assertThat(data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(5.0f, Unit.px)));
    assertThat(data.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 128, 0)));
    assertThat((CSSProperty.BorderStyle) data.getProperty("border-top-style"), is(CSSProperty.BorderStyle.DOTTED));
    assertThat(data.getValue(TermLength.class, "margin-top"), is(tf.createLength(1.0f, Unit.em)));
    assertNull(data.getValue(TermLength.class, "margin-bottom"));
    
}
 
Example 3
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void initial() throws SAXException, IOException {  
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/initial.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null,
            getClass().getResource("/advanced/initial.html"),"screen", true);
    
    NodeData data = decl.get(elements.getElementById("item1"));
    assertNotNull("Data for #item1 exist", data);
    assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 0, 0)));
    assertThat(data.getSpecifiedValue(TermColor.class, "color"), is(tf.createColor(0, 0, 0)));
    
    data = decl.get(elements.getElementById("item4"));
    assertNotNull("Data for #item4 exist", data);
    assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(255, 0, 0)));
    assertThat(data.getSpecifiedValue(TermColor.class, "color"), is(tf.createColor(255, 0, 0)));
}
 
Example 4
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void defaulting() throws SAXException, IOException {  
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/initial.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null,
            getClass().getResource("/advanced/initial.html"),"screen", true);
    
    NodeData data = decl.get(elements.getElementById("content"));
    assertNotNull("Data for #content exist", data);
    //cascaded value
    assertNull(data.getProperty("border-top-color"));
    assertNull(data.getValue(TermColor.class, "border-top-color"));
    //specified value
    assertThat((CSSProperty.BorderColor) data.getSpecifiedProperty("border-top-color"), is(CSSProperty.BorderColor.color));
    assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(tf.createIdent("currentColor"))));
}
 
Example 5
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void invalidValues() throws SAXException, IOException {  
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/invval.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/invval.html"), "screen", true);
    
    NodeData data = decl.get(elements.getElementById("test"));
    assertNotNull("Data for #test exist", data);
    
    assertThat("Reference border width parsed", data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(3.0f, Unit.px)));
    assertThat("Negative zero treated as zero", data.getValue(TermLength.class, "border-right-width"), is(tf.createLength(0.0f, Unit.px)));
    assertThat("Reference padding parsed", data.getValue(TermLength.class, "padding-bottom"), is(tf.createLength(1.0f, Unit.em)));
    assertThat("Negative padding ignored", data.getValue(TermLength.class, "padding-top"), is(tf.createLength(1.0f, Unit.em)));
    assertThat("Reference margin parsed", data.getValue(TermLength.class, "margin-top"), is(tf.createLength(2.0f, Unit.em)));
    assertThat("Negative margin accepted", data.getValue(TermLength.class, "margin-bottom"), is(tf.createLength(-5.0f, Unit.em)));
}
 
Example 6
Source File: ElementMatcherTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkDocument(String name, ElementMatcher matcher, TermColor[] expect, String msg) throws SAXException, IOException
{
    DOMSource ds = new DOMSource(getClass().getResourceAsStream(name));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    CSSFactory.registerElementMatcher(matcher);
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource(name),"screen", true);
    
    Element list = elements.getElementById("list");
    NodeList items = list.getElementsByTagName("li");
    for (int i = 0; i < items.getLength(); i++)
    {
        NodeData style = decl.get((Element) items.item(i));
        assertEquals(msg + " : line " + (i+1), expect[i], style.getValue(TermColor.class, "color"));
    }
}
 
Example 7
Source File: ProfilerEntryPointAnalyzer.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        final String src = "/profiling/slate.html";
        //final String src = "/profiling/lidovky2.html";
        
        Date start = new Date();
        DOMSource ds = new DOMSource(AnalyzerTest.class.getResourceAsStream(src));
        Document doc = ds.parse();
        
        Date analyze = new Date();
        StyleMap decl = CSSFactory.assignDOM(doc, null, ProfilerEntryPointAnalyzer.class.getResource(src), "screen", true);
        
        Date end = new Date();
        System.out.println("DOM parsing: " + (analyze.getTime() - start.getTime()) + " ms");
        System.out.println("CSS analysis: " + (end.getTime() - analyze.getTime()) + " ms");
        System.out.println("Obtained " + decl.size() + " node styles");
    }
 
Example 8
Source File: PseudoClassTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void pseudoClassMap() throws SAXException, IOException {  
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK);
    cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER);
    cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED);
    cond.addMatch(elements.getElementById("l3"), PseudoClassType.HOVER);
    cond.removeMatch(elements.getElementById("l3"), PseudoClassType.HOVER);
    CSSFactory.registerDefaultMatchCondition(cond);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, createBaseFromFilename("data/simple/pseudo.html"),"screen", true);
    
    NodeData l1 = getStyleById(elements, decl, "l1");
    NodeData l2 = getStyleById(elements, decl, "l2");
    NodeData l3 = getStyleById(elements, decl, "l3");
    
    assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0)));
    assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255)));
    assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170)));
}
 
Example 9
Source File: PseudoClassTest.java    From jStyleParser with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void pseudoClassMapNonStatic() throws SAXException, IOException {

    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);

    MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK);
    cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER);
    cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED);
    cond.addMatch(elements.getElementById("l3"), PseudoClassType.HOVER);
    cond.removeMatch(elements.getElementById("l3"), PseudoClassType.HOVER);

    StyleMap decl = CSSFactory.assignDOM(doc, null, createBaseFromFilename("data/simple/pseudo.html"),"screen", true, cond);

    NodeData l1 = getStyleById(elements, decl, "l1");
    NodeData l2 = getStyleById(elements, decl, "l2");
    NodeData l3 = getStyleById(elements, decl, "l3");

    assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0)));
    assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255)));
    assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170)));
}
 
Example 10
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void structureSelectors() throws SAXException, IOException {  
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors.html"),"screen", true);
    
    NodeData i1 = getStyleById(elements, decl, "i1");
    NodeData i2 = getStyleById(elements, decl, "i2");
    NodeData i5 = getStyleById(elements, decl, "i5");
    NodeData i6 = getStyleById(elements, decl, "i6");
    NodeData i8 = getStyleById(elements, decl, "i8");
    NodeData empty = getStyleById(elements, decl, "empty");
    NodeData only = getStyleById(elements, decl, "only");

    NodeData html = decl.get(doc.getDocumentElement());
    assertNotNull("Data for <html> exists", html);
    
    assertThat(i1.getValue(TermColor.class, "color"), is(tf.createColor(255,0,0)));
    assertNull(i2.getValue(TermColor.class, "color"));
    assertThat(i5.getValue(TermColor.class, "background-color"), is(tf.createColor(255,0,0)));
    assertThat(i6.getValue(TermColor.class, "background-color"), is(tf.createColor(0,128,0)));
    assertThat(i8.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,0,255)));
    assertThat(only.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,0,255)));
    assertThat(only.getValue(TermColor.class, "background-color"), is(tf.createColor(0,255,255)));
    assertThat(empty.getValue(TermColor.class, "border-top-color"), is(tf.createColor(255,0,0)));
    assertThat(html.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
    
}
 
Example 11
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void indexSelectors() throws SAXException, IOException {  
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors2.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors2.html"),"screen", true);
    
    NodeData i1 = getStyleById(elements, decl, "i1");
    NodeData i2 = getStyleById(elements, decl, "i2");
    NodeData i3 = getStyleById(elements, decl, "i3");
    NodeData i5 = getStyleById(elements, decl, "i5");
    NodeData i7 = getStyleById(elements, decl, "i7");
    NodeData i8 = getStyleById(elements, decl, "i8");
    NodeData i9 = getStyleById(elements, decl, "i9");

    NodeData html = decl.get(doc.getDocumentElement());
    assertNotNull("Data for <html> exists", html);
    
    assertNull(i1.getValue(TermColor.class, "color"));
    assertNull(i1.getValue(TermColor.class, "border-top-color"));
    assertNull(i1.getValue(TermColor.class, "background-color"));
    assertNull(i7.getValue(TermColor.class, "color"));
    assertNull(i7.getValue(TermColor.class, "border-top-color"));
    assertNull(i7.getValue(TermColor.class, "background-color"));
    
    assertThat(i2.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
    assertThat(i5.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
    assertThat(i8.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
    
    assertThat(i8.getValue(TermColor.class, "color"), is(tf.createColor(255,0,0)));
    
    assertThat(i3.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
    assertThat(i9.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
    assertThat(i5.getValue(TermColor.class, "background-color"), is(tf.createColor(170,170,255)));
    
}
 
Example 12
Source File: TestUtils.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void runTests(Iterable<TestData> tests, URL testedSource) {
    try {
        DOMSource ds = new DOMSource(testedSource.openStream());
        Document doc = ds.parse();
        StyleMap sm = CSSFactory.assignDOM(doc, null, testedSource, "screen", true);

        ElementMap elements = new ElementMap(doc);
        NodeData data;
        CSSProperty prop;
        Term<?> term;

        for (TestData test : tests) {
            System.out.print("Testing #" + test._id + " {" + test._propertyName + ": ");
            String id = test._id;
            data = sm.get(elements.getElementById(id));
            prop = data.getSpecifiedProperty(test._propertyName);
            
            Assert.assertEquals(test._expextedProperty, prop);
            if (test._expectedValue != null) {
                System.out.print(test._expectedValue);
                term = data.getSpecifiedValue(test._propertyName);
                if (!test._expectedValue.equals(term)) {
                    if (test._expectedValue instanceof TermList && term instanceof TermList) {
                        compareLists((TermList) test._expectedValue, (TermList) term);
                    }
                }
                Assert.assertEquals(test._expectedValue, term);
            } else {
                System.out.print(test._expextedProperty);
            }
            System.out.println("}");
        }
        
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
 
Example 13
Source File: DOMAssignMediaTest.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NodeData evaluateForMedia(MediaSpec spec) throws SAXException, IOException
{
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/media/media1.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/media/media1.html"), spec, true);
    NodeData data = decl.get(elements.getElementById("test"));
    
    return data;
}
 
Example 14
Source File: DecoderTest.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void boxShadow() throws SAXException, IOException {

    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/boxshadow.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);

    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/advanced/boxshadow.html"), "screen", true);

    Map<String, Integer> elementsToCheck = new LinkedHashMap<>();
    elementsToCheck.put("shadow1", 4);
    elementsToCheck.put("shadow2", 4);
    elementsToCheck.put("shadow3", 5);
    elementsToCheck.put("shadow4", 6);
    elementsToCheck.put("shadow5", 2);
    elementsToCheck.put("shadow_multi1", 8);
    elementsToCheck.put("shadow_multi2", 7);
    elementsToCheck.put("shadow_multi3", 12);

    for (Map.Entry<String, Integer> entry : elementsToCheck.entrySet()) {
        NodeData data = decl.get(elements.getElementById(entry.getKey()));
        assertNotNull("Data for #" + entry.getKey() + " exists", data);
        TermList value = data.getValue(TermList.class, "box-shadow");
        assertNotNull("TermList for #" + entry.getKey() + " exists", value);
        assertEquals("parsed all components of shadow for #" + entry.getKey(), (int)entry.getValue(), value.size());
    }
}
 
Example 15
Source File: DOMAssignTest.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void basic() throws SAXException, IOException {	
	
       DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/domassign.html"));
       Document doc = ds.parse();
       ElementMap elements = new ElementMap(doc);
       
	StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/advanced/domassign.html"), "screen", true);
	
	NodeData data = decl.get(elements.getElementById("bp"));
	assertNotNull("Data for #bp exist", data);
	
	assertThat(data.getValue(TermList.class, "background-position", 0).size(), is(2));
	
	assertThat(data.getValue(TermColor.class, "color"), is(tf.createColor(255, 255, 255)));
	
	data = decl.get(elements.getElementById("battlecruiser"));
	
	assertThat(tf.createColor(255, 255, 0), is(data.getValue(TermColor.class, "color")));
	
	data = decl.get(elements.getElementById("border"));
	assertNotNull("Data for #border exist", data);
	assertThat(data.getValue(TermColor.class, "border-bottom-color"),
			is(tf.createColor(255,255,255)));
	
}
 
Example 16
Source File: DecoderTest.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void backgrounds() throws SAXException, IOException {    
    
    DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/background.html"));
    Document doc = ds.parse();
    ElementMap elements = new ElementMap(doc);
    
    StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/advanced/background.html"), "screen", true);
    
    NodeData data = decl.get(elements.getElementById("bg1"));
    assertNotNull("Data for #bg1 exist", data);
    assertEquals(data.getValue(TermList.class, "background-position", 0).size(), 2);
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position", 0).get(0)), tf.createLength(25.0f, Unit.px));
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position", 0).get(1)), tf.createLength(25.0f, Unit.px));
    assertEquals(data.getValue(TermList.class, "background-size", 0).size(), 2);
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-size", 0).get(0)), tf.createLength(1.0f, Unit.px));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-size", 0).get(1)), tf.createPercent(10.0f));
    assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(0, 0, 255));
    
    data = decl.get(elements.getElementById("bg2"));
    assertNotNull("Data for #bg2 exist", data);
    assertEquals(data.getValue(TermList.class, "background-position", 0).size(), 2);
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 0).get(0)), tf.createPercent(100.0f));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 0).get(1)), tf.createPercent(100.0f));
    assertEquals(data.getProperty("background-size", 0), BackgroundSize.COVER); 
    assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(255, 255, 0));
    
    data = decl.get(elements.getElementById("bg3"));
    assertNotNull("Data for #bg3 exist", data);
    assertEquals(data.getValue(TermList.class, "background-position", 0).size(), 2);
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position", 0).get(0)), tf.createLength(10.0f, Unit.pt));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 0).get(1)), tf.createPercent(50.0f));
    assertEquals(data.getValue(TermList.class, "background-size", 0).size(), 2);
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-size", 0).get(0)), tf.createLength(20.0f, Unit.px));
    assertEquals(data.getValue(TermList.class, "background-size", 0).get(1), tf.createIdent("auto"));
    assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(0, 128, 0));
    
    data = decl.get(elements.getElementById("bg4"));
    assertNotNull("Data for #bg4 exist", data);
    assertEquals("background-image is a gradient", CSSProperty.BackgroundImage.gradient, data.getProperty("background-image", 0));
    TermFunction.Gradient fn = data.getValue(TermFunction.Gradient.class, "background-image", 0);
    assertEquals(LinearGradientImpl.class, fn.getClass());
    assertEquals("Angle", tf.createAngle("0.25", Unit.turn, 1), ((LinearGradientImpl) fn).getAngle());
    
    data = decl.get(elements.getElementById("bg5"));
    assertNotNull("Data for #bg5 exist", data);
    assertEquals("background-image is a gradient", CSSProperty.BackgroundImage.gradient, data.getProperty("background-image", 0));
    fn = data.getValue(TermFunction.Gradient.class, "background-image", 0);
    assertEquals(LinearGradientImpl.class, fn.getClass());
    assertEquals("Angle", tf.createAngle("0.25", Unit.turn, 1), ((LinearGradientImpl) fn).getAngle());
    
    data = decl.get(elements.getElementById("bgmulti1"));
    assertNotNull("Data for #bgmulti1 exist", data);
    assertEquals(data.getListSize("background-repeat", true), 3);
    assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(255, 0, 0));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 0).get(0)), tf.createPercent(100.0f));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 0).get(1)), tf.createPercent(100.0f));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 1).get(0)), tf.createPercent(50.0f));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 1).get(1)), tf.createPercent(50.0f));
    assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position", 2).get(0)), tf.createLength(10.0f, Unit.pt));
    assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position", 2).get(1)), tf.createPercent(50.0f));
    
    data = decl.get(elements.getElementById("bgmulti2"));
    assertNotNull("Data for #bgmulti2 exist", data);
    assertEquals(data.getListSize("background-repeat", true), 1);
    assertEquals(tf.createColor(0, 128, 0), data.getValue(TermColor.class, "background-color"));
    assertEquals(CSSProperty.BackgroundRepeat.REPEAT, data.getProperty("background-repeat", 0));
}