Search in sources :

Example 26 with IconSet

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

the class DefaultIconManagerTest method renderHTMLWithFallBack.

@Test
public void renderHTMLWithFallBack() throws Exception {
    IconSet iconSet = new IconSet("silk");
    when(iconSetManager.getCurrentIconSet()).thenReturn(iconSet);
    IconSet defaultIconSet = new IconSet("default");
    when(iconSetManager.getDefaultIconSet()).thenReturn(defaultIconSet);
    when(iconRenderer.renderHTML("test", defaultIconSet)).thenReturn("rendered icon");
    // Test
    String result = mocker.getComponentUnderTest().renderHTML("test");
    assertEquals("rendered icon", result);
}
Also used : IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 27 with IconSet

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

the class DefaultIconRendererTest method renderWithSSX.

@Test
public void renderWithSSX() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setSsx("ssx");
    iconSet.addIcon("test", new Icon("blabla"));
    // Test
    mocker.getComponentUnderTest().render("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 28 with IconSet

use of org.xwiki.icon.IconSet 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 29 with IconSet

use of org.xwiki.icon.IconSet 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 30 with IconSet

use of org.xwiki.icon.IconSet 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)

Aggregations

IconSet (org.xwiki.icon.IconSet)38 Test (org.junit.Test)33 Icon (org.xwiki.icon.Icon)14 DocumentReference (org.xwiki.model.reference.DocumentReference)9 InputStreamReader (java.io.InputStreamReader)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 IconException (org.xwiki.icon.IconException)4 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 Query (org.xwiki.query.Query)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)1