Search in sources :

Example 16 with IconSet

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

the class DefaultIconSetManagerTest method getDefaultIconWhenInCache.

@Test
public void getDefaultIconWhenInCache() throws Exception {
    IconSet iconSet = new IconSet("default");
    when(iconSetCache.get("default")).thenReturn(iconSet);
    // Test
    IconSet result = mocker.getComponentUnderTest().getDefaultIconSet();
    // Verify
    assertEquals(iconSet, result);
    verify(iconSetLoader, never()).loadIconSet(any(InputStreamReader.class), any());
}
Also used : InputStreamReader(java.io.InputStreamReader) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 17 with IconSet

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

the class DefaultIconSetManagerTest method getCurrentIconSetWhenInCache.

@Test
public void getCurrentIconSetWhenInCache() throws Exception {
    String currentIconTheme = "IconThemes.SilkTheme";
    when(configurationSource.getProperty("iconTheme")).thenReturn(currentIconTheme);
    DocumentReference iconThemeRef = new DocumentReference("xwiki", "IconThemes", "SilkTheme");
    when(documentReferenceResolver.resolve(currentIconTheme)).thenReturn(iconThemeRef);
    when(documentAccessBridge.exists(iconThemeRef)).thenReturn(true);
    IconSet iconSet = new IconSet(currentIconTheme);
    when(iconSetCache.get(iconThemeRef)).thenReturn(iconSet);
    // Test
    IconSet result = mocker.getComponentUnderTest().getCurrentIconSet();
    // Verify
    assertEquals(iconSet, result);
    verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DocumentReference(org.xwiki.model.reference.DocumentReference) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 18 with IconSet

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

the class DefaultIconSetManagerTest method getCurrentIconSetWhenItDoesNotExist.

@Test
public void getCurrentIconSetWhenItDoesNotExist() throws Exception {
    String currentIconTheme = "xwiki:IconThemes.SilkTheme";
    when(configurationSource.getProperty("iconTheme")).thenReturn(currentIconTheme);
    DocumentReference iconThemeRef = new DocumentReference("xwiki", "IconThemes", "SilkTheme");
    when(documentReferenceResolver.resolve(currentIconTheme)).thenReturn(iconThemeRef);
    when(documentAccessBridge.exists(iconThemeRef)).thenReturn(false);
    when(iconSetCache.get(iconThemeRef)).thenReturn(null);
    // Test
    IconSet result = mocker.getComponentUnderTest().getCurrentIconSet();
    // Verify
    assertNull(result);
    verify(iconSetLoader, never()).loadIconSet(any(DocumentReference.class));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DocumentReference(org.xwiki.model.reference.DocumentReference) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 19 with IconSet

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

the class DefaultIconSetManagerTest method getDefaultIcon.

@Test
public void getDefaultIcon() throws Exception {
    InputStream is = getClass().getResourceAsStream("/test.iconset");
    when(xwiki.getResourceAsStream("/resources/icons/default.iconset")).thenReturn(is);
    IconSet iconSet = new IconSet("default");
    when(iconSetLoader.loadIconSet(any(InputStreamReader.class), eq("default"))).thenReturn(iconSet);
    // Test
    IconSet result = mocker.getComponentUnderTest().getDefaultIconSet();
    // Verify
    assertEquals(iconSet, result);
    verify(iconSetCache).put("default", iconSet);
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 20 with IconSet

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

the class IconSetTest method simpleTest.

@Test
public void simpleTest() throws Exception {
    IconSet iconSet = new IconSet("myIconSet");
    assertEquals("myIconSet", iconSet.getName());
    iconSet.setName("newName");
    assertEquals("newName", iconSet.getName());
}
Also used : 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