Search in sources :

Example 11 with Icon

use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderHTMLWithSSX.

@Test
public void renderHTMLWithSSX() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setSsx("ssx");
    iconSet.addIcon("test", new Icon("blabla"));
    // Test
    mocker.getComponentUnderTest().renderHTML("test", iconSet);
    // Verify
    verify(skinExtension).use("ssx");
    verify(linkExtension, never()).use(any());
    verify(jsExtension, never()).use(any());
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 12 with Icon

use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderWithCSS.

@Test
public void renderWithCSS() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setCss("css");
    iconSet.addIcon("test", new Icon("blabla"));
    when(velocityRenderer.render("css")).thenReturn("velocityParsedCSS");
    // Test
    mocker.getComponentUnderTest().render("test", iconSet);
    // Verify
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("rel", "stylesheet");
    verify(linkExtension).use(eq("velocityParsedCSS"), eq(parameters));
    verify(skinExtension, never()).use(any());
    verify(jsExtension, never()).use(any());
}
Also used : HashMap(java.util.HashMap) Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 13 with Icon

use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method render.

@Test
public void render() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setRenderWiki("image:$icon.png");
    iconSet.addIcon("test", new Icon("blabla"));
    when(velocityRenderer.render("#set($icon = \"blabla\")\nimage:$icon.png")).thenReturn("image:blabla.png");
    // Test
    String result = mocker.getComponentUnderTest().render("test", iconSet);
    // Verify
    assertEquals("image:blabla.png", result);
    verify(linkExtension, never()).use(any());
    verify(skinExtension, never()).use(any());
    verify(jsExtension, never()).use(any());
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 14 with Icon

use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderWithException.

@Test
public void renderWithException() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setRenderWiki("image:$icon.png");
    iconSet.addIcon("test", new Icon("blabla"));
    IconException exception = new IconException("exception", null);
    when(velocityRenderer.render(any())).thenThrow(exception);
    // Test
    IconException caughtException = null;
    try {
        mocker.getComponentUnderTest().render("test", iconSet);
    } catch (IconException e) {
        caughtException = e;
    }
    // Verify
    assertNotNull(caughtException);
    assertEquals(exception, caughtException);
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) IconException(org.xwiki.icon.IconException) Test(org.junit.Test)

Example 15 with Icon

use of org.xwiki.icon.Icon in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderWithJSX.

@Test
public void renderWithJSX() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setJsx("jsx");
    iconSet.addIcon("test", new Icon("blabla"));
    // Test
    mocker.getComponentUnderTest().render("test", iconSet);
    // Verify
    verify(jsExtension).use("jsx");
    verify(linkExtension, never()).use(any());
    verify(skinExtension, never()).use(any());
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Aggregations

Icon (org.xwiki.icon.Icon)15 IconSet (org.xwiki.icon.IconSet)14 Test (org.junit.Test)13 HashMap (java.util.HashMap)2 IconException (org.xwiki.icon.IconException)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Properties (java.util.Properties)1